Skip to content

Commit

Permalink
[update] イベント処理を修正
Browse files Browse the repository at this point in the history
並びが変わってなかったので、データの受け渡し修正
  • Loading branch information
Cilda committed Aug 29, 2024
1 parent e220b71 commit 1b24d5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion UmaUmaChecker/src/Recognizer/Uma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ void Uma::MonitorThread()

image->GetHBITMAP(Gdiplus::Color(0, 0, 0), &hBmp);

UmaThreadData data = { event, hBmp };

wxThreadEvent event(wxEVT_THREAD);
event.SetId(1);
event.SetPayload(hBmp);
event.SetPayload(data);
wxQueueEvent(frame, event.Clone());
}
}
Expand Down
6 changes: 6 additions & 0 deletions UmaUmaChecker/src/Recognizer/Uma.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

class Uma
{
public:
struct UmaThreadData {
std::shared_ptr<EventSource> event;
HBITMAP hBitmap;
};

public:
Uma(wxFrame* frame);
~Uma();
Expand Down
12 changes: 6 additions & 6 deletions UmaUmaChecker/src/UI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,19 +411,19 @@ void MainFrame::OnSelectedUma(wxCommandEvent& event)
void MainFrame::OnUmaThreadEvent(wxThreadEvent& event)
{
if (event.GetId() == 1) {
HBITMAP hBmp = event.GetPayload<HBITMAP>();
Uma::UmaThreadData data = event.GetPayload<Uma::UmaThreadData>();

if (umaMgr->CurrentEvent) {
ChangeEventOptions(umaMgr->CurrentEvent);
if (data.event) {
ChangeEventOptions(data.event.get());

if (m_PreviewWindow) {
BITMAP bmp;

GetObject(hBmp, sizeof(BITMAP), &bmp);
m_PreviewWindow->SetImage(hBmp, bmp.bmWidth, bmp.bmHeight);
GetObject(data.hBitmap, sizeof(BITMAP), &bmp);
m_PreviewWindow->SetImage(data.hBitmap, bmp.bmWidth, bmp.bmHeight);
}
else {
DeleteObject(hBmp);
DeleteObject(data.hBitmap);
}
}
}
Expand Down

0 comments on commit 1b24d5d

Please sign in to comment.