]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/wince/hello.cpp
1 // -----------------------------------------------------------
2 // This hello program will test wxBase for WinCE
3 // -----------------------------------------------------------
5 // Include WinCE headers
10 // Include wxWindows headers
12 #include "wx/string.h"
14 // Do not undef DrawText, since we need it here
15 #include "wx/msw/private.h"
17 // -----------------------------------------------------------
19 // -----------------------------------------------------------
21 HINSTANCE hInst
= NULL
; // Local copy of hInstance
22 HWND hwndMain
= NULL
; // Handle to Main window returned from CreateWindow
24 TCHAR szAppName
[] = TEXT("Hello Pocket PC Application");
25 TCHAR szTitle
[] = TEXT("Hello Pocket PC");
27 LRESULT CALLBACK
WndProc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
29 LRESULT lResult
= TRUE
;
37 switch (GET_WM_COMMAND_ID(wp
,lp
))
40 SendMessage(hwnd
,WM_CLOSE
,0,0);
43 return DefWindowProc(hwnd
, msg
, wp
, lp
);
48 hdc
= BeginPaint (hwnd
, &ps
);
49 GetClientRect (hwnd
, &rect
);
52 wxString
test( wxT("Hello wxWindows!") );
53 DrawText (hdc
, test
.c_str(), -1, &rect
, DT_SINGLELINE
| DT_CENTER
| DT_VCENTER
);
68 lResult
= DefWindowProc(hwnd
, msg
, wp
, lp
);
75 BOOL
InitInstance (HINSTANCE hInstance
, int CmdShow
)
79 hwndMain
= CreateWindow(szAppName
,
86 NULL
, NULL
, hInstance
, NULL
);
92 ShowWindow(hwndMain
, CmdShow
);
93 UpdateWindow(hwndMain
);
97 BOOL
InitApplication ( HINSTANCE hInstance
)
102 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
103 wc
.lpfnWndProc
= (WNDPROC
)WndProc
;
107 wc
.hInstance
= hInstance
;
109 wc
.hbrBackground
= (HBRUSH
) GetStockObject( WHITE_BRUSH
);
110 wc
.lpszMenuName
= NULL
;
111 wc
.lpszClassName
= szAppName
;
113 f
= (RegisterClass(&wc
));
119 int WINAPI
WinMain(HINSTANCE hInstance
,
120 HINSTANCE hPrevInstance
,
125 // We use wxBase as a first test
129 HWND hHelloWnd
= NULL
;
130 HACCEL hAccel
= NULL
;
132 //Check if Hello.exe is running. If it's running then focus on the window
133 hHelloWnd
= FindWindow(szAppName
, szTitle
);
136 SetForegroundWindow (hHelloWnd
);
140 if ( !hPrevInstance
)
142 if ( !InitApplication ( hInstance
) )
148 if ( !InitInstance( hInstance
, CmdShow
) )
152 hAccel
= LoadAccelerators(hInstance
, MAKEINTRESOURCE(IDR_ACCELERATOR1
));
154 while ( GetMessage( &msg
, NULL
, 0,0 ) == TRUE
)
156 if (!TranslateAccelerator(hwndMain
,hAccel
, &msg
))
158 TranslateMessage (&msg
);
159 DispatchMessage(&msg
);