1 // Windows/Window.cpp
2
3 #include "StdAfx.h"
4
5 // For compilers that support precompilation, includes "wx/wx.h".
6 #include "wx/wxprec.h"
7
8 #ifdef __BORLANDC__
9 #pragma hdrstop
10 #endif
11
12 // for all others, include the necessary headers (this file is usually all you
13 // need because it includes almost all "standard" wxWidgets headers)
14 #ifndef WX_PRECOMP
15 #include "wx/wx.h"
16 #endif
17
18 #ifndef _UNICODE
19 #include "Common/StringConvert.h"
20 #endif
21 #include "Windows/Window.h"
22
23 class LockGUI
24 {
25 bool _IsMain;
26 public:
LockGUI()27 LockGUI() {
28 _IsMain = wxThread::IsMain();
29 if (!_IsMain) wxMutexGuiEnter();
30 }
~LockGUI()31 ~LockGUI() { if (!_IsMain) wxMutexGuiLeave(); }
32 };
33
34 namespace NWindows {
35
GetDlgItem(HWND dialogWindow,int ControlID)36 HWND GetDlgItem(HWND dialogWindow, int ControlID)
37 {
38 LockGUI lock;
39 if (dialogWindow) return dialogWindow->FindWindow(ControlID);
40 return 0;
41 }
42
MySetWindowText(HWND wnd,LPCWSTR s)43 void MySetWindowText(HWND wnd, LPCWSTR s)
44 {
45 if (wnd == 0) return;
46
47 LockGUI lock;
48
49 wxString str = s;
50 /*
51 int id = wnd->GetId();
52 if ( (id != wxID_OK) && (id != wxID_CANCEL) && (id != wxID_HELP) && (id != wxID_YES) && (id != wxID_NO))
53 */
54 {
55 wnd->SetLabel(str);
56 }
57 }
58
GetText(CSysString & s)59 bool CWindow::GetText(CSysString &s)
60 {
61 wxString str;
62 {
63 LockGUI lock;
64 str = _window->GetLabel();
65 }
66 s = str;
67 return true;
68 }
69
IsEnabled()70 bool CWindow::IsEnabled()
71 {
72 LockGUI lock;
73 return _window->IsEnabled();
74 }
75 }
76
77 ////////////////////////////////// Windows Compatibility
78 #include <sys/resource.h>
79
Sleep(unsigned millisec)80 void Sleep(unsigned millisec)
81 {
82 wxMilliSleep(millisec);
83 }
84
GetCurrentProcess(void)85 t_processID GetCurrentProcess(void) {
86 return getpid();
87 }
88
SetPriorityClass(t_processID pid,int priority)89 void SetPriorityClass(t_processID pid , int priority) {
90 setpriority(PRIO_PROCESS,pid,priority);
91 }
92
93