|
1
|
1 #include "shared.h"
|
|
|
2
|
|
|
3 static DWORD g_main_thread = GetCurrentThreadId();
|
|
|
4
|
|
|
5 static t_modal_dialog_entry g_status = {0,false};
|
|
|
6
|
|
|
7 static bool TestMainThread()
|
|
|
8 {
|
|
|
9 if (GetCurrentThreadId() == g_main_thread) return true;
|
|
|
10 OutputDebugString(TEXT("This function can be called only from main thread.\n"));
|
|
|
11 return false;
|
|
|
12 }
|
|
|
13
|
|
|
14 HWND SHARED_EXPORT FindOwningPopup(HWND p_wnd)
|
|
|
15 {
|
|
|
16 return pfc::findOwningPopup(p_wnd);
|
|
|
17 }
|
|
|
18
|
|
|
19 void SHARED_EXPORT PokeWindow(HWND p_wnd)
|
|
|
20 {
|
|
|
21 p_wnd = FindOwningPopup(p_wnd);
|
|
|
22 if (IsWindowEnabled(p_wnd))
|
|
|
23 {
|
|
|
24 // SetForegroundWindow(p_wnd);
|
|
|
25 SetActiveWindow(p_wnd);
|
|
|
26 FlashWindow(p_wnd,FALSE);
|
|
|
27 }
|
|
|
28 else
|
|
|
29 {
|
|
|
30 HWND child = GetWindow(p_wnd,GW_ENABLEDPOPUP);
|
|
|
31 if (child != 0)
|
|
|
32 {
|
|
|
33 // SetForegroundWindow(child);
|
|
|
34 SetActiveWindow(child);
|
|
|
35 FlashWindow(child,FALSE);
|
|
|
36 }
|
|
|
37 }
|
|
|
38 }
|
|
|
39
|
|
|
40 extern "C" {
|
|
|
41 void SHARED_EXPORT ModalDialog_Switch(t_modal_dialog_entry & p_entry)
|
|
|
42 {
|
|
|
43 if (TestMainThread())
|
|
|
44 pfc::swap_t(p_entry,g_status);
|
|
|
45 }
|
|
|
46
|
|
|
47 void SHARED_EXPORT ModalDialog_PokeExisting()
|
|
|
48 {
|
|
|
49 if (TestMainThread())
|
|
|
50 {
|
|
|
51 if (g_status.m_in_use && g_status.m_wnd_to_poke != 0)
|
|
|
52 {
|
|
|
53 PokeWindow(g_status.m_wnd_to_poke);
|
|
|
54 MessageBeep(0);
|
|
|
55 }
|
|
|
56 }
|
|
|
57 }
|
|
|
58
|
|
|
59 bool SHARED_EXPORT ModalDialog_CanCreateNew()
|
|
|
60 {
|
|
|
61 if (TestMainThread())
|
|
|
62 return !g_status.m_in_use;
|
|
|
63 else
|
|
|
64 return false;
|
|
|
65 }
|
|
|
66 } |