2 * Wordpad implementation
4 * Copyright 2004 by Krzysztof Foltman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN
22 #define _WIN32_IE 0x0400
37 static const WCHAR xszAppTitle
[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
38 static const WCHAR xszMainMenu
[] = {'M','A','I','N','M','E','N','U',0};
40 static const WCHAR wszRichEditClass
[] = {'R','I','C','H','E','D','I','T','2','0','W',0};
41 static const WCHAR wszMainWndClass
[] = {'W','O','R','D','P','A','D','T','O','P',0};
42 static const WCHAR wszAppTitle
[] = {'W','i','n','e',' ','W','o','r','d','p','a','d',0};
45 static HWND hEditorWnd
;
47 static void AddButton(HWND hwndToolBar
, int nImage
, int nCommand
)
51 ZeroMemory(&button
, sizeof(button
));
52 button
.iBitmap
= nImage
;
53 button
.idCommand
= nCommand
;
54 button
.fsState
= TBSTATE_ENABLED
;
55 button
.fsStyle
= TBSTYLE_BUTTON
;
58 SendMessage(hwndToolBar
, TB_ADDBUTTONS
, 1, (LPARAM
)&button
);
61 static void AddSeparator(HWND hwndToolBar
)
65 ZeroMemory(&button
, sizeof(button
));
69 button
.fsStyle
= TBSTYLE_SEP
;
72 SendMessage(hwndToolBar
, TB_ADDBUTTONS
, 1, (LPARAM
)&button
);
75 static LPSTR stream_buffer
;
76 static LONG stream_buffer_size
;
78 static DWORD CALLBACK
stream_in(DWORD_PTR cookie
, LPBYTE buffer
, LONG cb
, LONG
*pcb
)
80 LONG size
= min(stream_buffer_size
, cb
);
82 memcpy(buffer
, stream_buffer
, size
);
83 stream_buffer_size
-= size
;
84 stream_buffer
+= size
;
89 static void DoOpenFile(LPCWSTR szFileName
)
97 hFile
= CreateFileW(szFileName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
98 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
99 if (hFile
== INVALID_HANDLE_VALUE
)
102 size
= GetFileSize(hFile
, NULL
);
103 if (size
== INVALID_FILE_SIZE
)
110 pTemp
= HeapAlloc(GetProcessHeap(), 0, size
);
117 if (!ReadFile(hFile
, pTemp
, size
, &dwNumRead
, NULL
))
120 HeapFree(GetProcessHeap(), 0, pTemp
);
124 pTemp
[dwNumRead
] = 0;
126 memset(&es
, 0, sizeof(es
));
127 es
.pfnCallback
= stream_in
;
129 stream_buffer
= pTemp
;
130 stream_buffer_size
= size
;
132 SendMessage(hEditorWnd
, EM_STREAMIN
, SF_RTF
, (LPARAM
)&es
);
133 HeapFree(GetProcessHeap(), 0, pTemp
);
135 SetFocus(hEditorWnd
);
138 static void HandleCommandLine(LPWSTR cmdline
)
143 /* skip white space */
144 while (*cmdline
== ' ') cmdline
++;
146 /* skip executable name */
147 delimiter
= (*cmdline
== '"' ? '"' : ' ');
149 if (*cmdline
== delimiter
) cmdline
++;
150 while (*cmdline
&& *cmdline
!= delimiter
) cmdline
++;
151 if (*cmdline
== delimiter
) cmdline
++;
153 while (*cmdline
== ' ' || *cmdline
== '-' || *cmdline
== '/')
157 if (*cmdline
++ == ' ') continue;
160 if (option
) cmdline
++;
161 while (*cmdline
== ' ') cmdline
++;
174 /* file name is passed on the command line */
175 if (cmdline
[0] == '"')
178 cmdline
[lstrlenW(cmdline
) - 1] = 0;
181 InvalidateRect(hMainWnd
, NULL
, FALSE
);
185 MessageBox(hMainWnd
, "Printing not implemented", "WordPad", MB_OK
);
188 static LRESULT
OnCreate( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
190 HWND hToolBarWnd
, hReBarWnd
;
191 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtr(hWnd
, GWLP_HINSTANCE
);
198 CreateStatusWindow(CCS_NODIVIDER
|WS_CHILD
|WS_VISIBLE
, "RichEdit text", hWnd
, IDC_STATUSBAR
);
200 hReBarWnd
= CreateWindowEx(WS_EX_TOOLWINDOW
, REBARCLASSNAME
, NULL
,
201 CCS_NODIVIDER
|WS_CHILD
|WS_VISIBLE
|WS_CLIPSIBLINGS
|WS_CLIPCHILDREN
|RBS_VARHEIGHT
|CCS_TOP
,
202 CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, hWnd
, (HMENU
)IDC_REBAR
, hInstance
, NULL
);
204 rbi
.cbSize
= sizeof(rbi
);
207 if(!SendMessage(hReBarWnd
, RB_SETBARINFO
, 0, (LPARAM
)&rbi
))
210 hToolBarWnd
= CreateToolbarEx(hReBarWnd
, CCS_NOPARENTALIGN
|CCS_NODIVIDER
|CCS_NOMOVEY
|WS_VISIBLE
|WS_CHILD
|TBSTYLE_TOOLTIPS
|TBSTYLE_BUTTON
,
212 3, hInstance
, IDB_TOOLBAR
,
214 24, 24, 16, 16, sizeof(TBBUTTON
));
216 ab
.hInst
= HINST_COMMCTRL
;
217 ab
.nID
= IDB_STD_SMALL_COLOR
;
218 nStdBitmaps
= SendMessage(hToolBarWnd
, TB_ADDBITMAP
, 3, (LPARAM
)&ab
);
219 AddButton(hToolBarWnd
, nStdBitmaps
+STD_FILENEW
, ID_FILE_NEW
);
220 AddButton(hToolBarWnd
, nStdBitmaps
+STD_FILEOPEN
, ID_FILE_OPEN
);
221 AddButton(hToolBarWnd
, nStdBitmaps
+STD_FILESAVE
, ID_FILE_SAVE
);
222 AddSeparator(hToolBarWnd
);
223 AddButton(hToolBarWnd
, nStdBitmaps
+STD_PRINT
, ID_PRINT
);
224 AddButton(hToolBarWnd
, nStdBitmaps
+STD_PRINTPRE
, ID_PREVIEW
);
225 AddSeparator(hToolBarWnd
);
226 AddButton(hToolBarWnd
, nStdBitmaps
+STD_FIND
, ID_FIND
);
227 AddSeparator(hToolBarWnd
);
228 AddButton(hToolBarWnd
, nStdBitmaps
+STD_CUT
, ID_EDIT_CUT
);
229 AddButton(hToolBarWnd
, nStdBitmaps
+STD_COPY
, ID_EDIT_COPY
);
230 AddButton(hToolBarWnd
, nStdBitmaps
+STD_PASTE
, ID_EDIT_PASTE
);
231 AddButton(hToolBarWnd
, nStdBitmaps
+STD_UNDO
, ID_EDIT_UNDO
);
232 AddButton(hToolBarWnd
, nStdBitmaps
+STD_REDOW
, ID_EDIT_REDO
);
233 AddSeparator(hToolBarWnd
);
234 AddButton(hToolBarWnd
, 0, ID_FORMAT_BOLD
);
235 AddButton(hToolBarWnd
, 1, ID_FORMAT_ITALIC
);
236 AddButton(hToolBarWnd
, 2, ID_FORMAT_UNDERLINE
);
238 SendMessage(hToolBarWnd
, TB_ADDSTRING
, 0, (LPARAM
)"Exit\0");
239 SendMessage(hToolBarWnd
, TB_AUTOSIZE
, 0, 0);
241 rbb
.cbSize
= sizeof(rbb
);
242 rbb
.fMask
= RBBIM_SIZE
| RBBIM_CHILDSIZE
| RBBIM_CHILD
| RBBIM_STYLE
;
243 rbb
.fStyle
= RBBS_CHILDEDGE
;
245 rbb
.hwndChild
= hToolBarWnd
;
247 rbb
.cyChild
= rbb
.cyMinChild
= HIWORD(SendMessage(hToolBarWnd
, TB_GETBUTTONSIZE
, 0, 0));
249 SendMessage(hReBarWnd
, RB_INSERTBAND
, -1, (LPARAM
)&rbb
);
251 hDLL
= LoadLibrary("RICHED20.DLL");
254 hEditorWnd
= CreateWindowExW(WS_EX_CLIENTEDGE
, wszRichEditClass
, NULL
,
255 WS_CHILD
|WS_VISIBLE
|ES_MULTILINE
|ES_AUTOVSCROLL
|ES_WANTRETURN
|WS_VSCROLL
,
256 0, 0, 1000, 100, hWnd
, (HMENU
)IDC_EDITOR
, hInstance
, NULL
);
259 fprintf(stderr
, "Error code %u\n", GetLastError());
264 SetFocus(hEditorWnd
);
265 SendMessage(hEditorWnd
, EM_SETEVENTMASK
, 0, ENM_SELCHANGE
);
269 static LRESULT
OnUser( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
271 HWND hwndEditor
= GetDlgItem(hWnd
, IDC_EDITOR
);
272 HWND hwndReBar
= GetDlgItem(hWnd
, IDC_REBAR
);
273 HWND hwndToolBar
= GetDlgItem(hwndReBar
, IDC_TOOLBAR
);
277 ZeroMemory(&fmt
, sizeof(fmt
));
278 fmt
.cbSize
= sizeof(fmt
);
280 SendMessage(hwndEditor
, EM_GETCHARFORMAT
, TRUE
, (LPARAM
)&fmt
);
282 SendMessage(hwndEditor
, EM_GETSEL
, (WPARAM
)&from
, (LPARAM
)&to
);
283 SendMessage(hwndToolBar
, TB_ENABLEBUTTON
, ID_EDIT_UNDO
,
284 SendMessage(hwndEditor
, EM_CANUNDO
, 0, 0));
285 SendMessage(hwndToolBar
, TB_ENABLEBUTTON
, ID_EDIT_REDO
,
286 SendMessage(hwndEditor
, EM_CANREDO
, 0, 0));
287 SendMessage(hwndToolBar
, TB_ENABLEBUTTON
, ID_EDIT_CUT
, from
== to
? 0 : 1);
288 SendMessage(hwndToolBar
, TB_ENABLEBUTTON
, ID_EDIT_COPY
, from
== to
? 0 : 1);
289 SendMessage(hwndToolBar
, TB_CHECKBUTTON
, ID_FORMAT_BOLD
, (fmt
.dwMask
& CFM_BOLD
) && (fmt
.dwEffects
& CFE_BOLD
));
290 SendMessage(hwndToolBar
, TB_INDETERMINATE
, ID_FORMAT_BOLD
, !(fmt
.dwMask
& CFM_BOLD
));
291 SendMessage(hwndToolBar
, TB_CHECKBUTTON
, ID_FORMAT_ITALIC
, (fmt
.dwMask
& CFM_ITALIC
) && (fmt
.dwEffects
& CFE_ITALIC
));
292 SendMessage(hwndToolBar
, TB_INDETERMINATE
, ID_FORMAT_ITALIC
, !(fmt
.dwMask
& CFM_ITALIC
));
293 SendMessage(hwndToolBar
, TB_CHECKBUTTON
, ID_FORMAT_UNDERLINE
, (fmt
.dwMask
& CFM_UNDERLINE
) && (fmt
.dwEffects
& CFE_UNDERLINE
));
294 SendMessage(hwndToolBar
, TB_INDETERMINATE
, ID_FORMAT_UNDERLINE
, !(fmt
.dwMask
& CFM_UNDERLINE
));
298 static LRESULT
OnNotify( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
300 HWND hwndEditor
= GetDlgItem(hWnd
, IDC_EDITOR
);
301 NMHDR
*pHdr
= (NMHDR
*)lParam
;
303 if (pHdr
->hwndFrom
!= hwndEditor
)
306 if (pHdr
->code
== EN_SELCHANGE
)
308 SELCHANGE
*pSC
= (SELCHANGE
*)lParam
;
311 sprintf( buf
,"selection = %d..%d, line count=%ld\n",
312 pSC
->chrg
.cpMin
, pSC
->chrg
.cpMax
,
313 SendMessage(hwndEditor
, EM_GETLINECOUNT
, 0, 0));
314 SetWindowText(GetDlgItem(hWnd
, IDC_STATUSBAR
), buf
);
315 SendMessage(hWnd
, WM_USER
, 0, 0);
321 static LRESULT
OnCommand( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
323 HWND hwndEditor
= GetDlgItem(hWnd
, IDC_EDITOR
);
325 if ((HWND
)lParam
== hwndEditor
)
328 switch(LOWORD(wParam
))
331 PostMessage(hWnd
, WM_CLOSE
, 0, 0);
335 SetWindowTextA(hwndEditor
, "");
336 /* FIXME: set default format too */
344 MessageBox(hWnd
, "Not implemented", "WordPad", MB_OK
);
348 case ID_FORMAT_ITALIC
:
349 case ID_FORMAT_UNDERLINE
:
353 if (LOWORD(wParam
) == ID_FORMAT_ITALIC
) mask
= CFM_ITALIC
;
354 if (LOWORD(wParam
) == ID_FORMAT_UNDERLINE
) mask
= CFM_UNDERLINE
;
356 ZeroMemory(&fmt
, sizeof(fmt
));
357 fmt
.cbSize
= sizeof(fmt
);
358 SendMessage(hwndEditor
, EM_GETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&fmt
);
359 if (!(fmt
.dwMask
&mask
))
360 fmt
.dwEffects
|= mask
;
362 fmt
.dwEffects
^= mask
;
364 SendMessage(hwndEditor
, EM_SETCHARFORMAT
, SCF_SELECTION
, (LPARAM
)&fmt
);
369 PostMessage(hwndEditor
, WM_CUT
, 0, 0);
373 PostMessage(hwndEditor
, WM_COPY
, 0, 0);
377 PostMessage(hwndEditor
, WM_PASTE
, 0, 0);
380 case ID_EDIT_SELECTALL
:
382 CHARRANGE range
= {0, -1};
383 SendMessage(hwndEditor
, EM_EXSETSEL
, 0, (LPARAM
)&range
);
384 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
388 case ID_EDIT_GETTEXT
:
390 int nLen
= GetWindowTextLengthW(hwndEditor
);
391 LPWSTR data
= HeapAlloc( GetProcessHeap(), 0, (nLen
+1)*sizeof(WCHAR
) );
394 GetWindowTextW(hwndEditor
, data
, nLen
+1);
395 MessageBoxW(NULL
, data
, xszAppTitle
, MB_OK
);
397 HeapFree( GetProcessHeap(), 0, data
);
398 data
= HeapAlloc(GetProcessHeap(), 0, (nLen
+1)*sizeof(WCHAR
));
400 tr
.chrg
.cpMax
= nLen
;
402 SendMessage (hwndEditor
, EM_GETTEXTRANGE
, 0, (LPARAM
)&tr
);
403 MessageBoxW(NULL
, data
, xszAppTitle
, MB_OK
);
404 HeapFree( GetProcessHeap(), 0, data
);
406 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
410 case ID_EDIT_CHARFORMAT
:
411 case ID_EDIT_DEFCHARFORMAT
:
415 ZeroMemory(&cf
, sizeof(cf
));
416 cf
.cbSize
= sizeof(cf
);
418 i
= SendMessage(hwndEditor
, EM_GETCHARFORMAT
,
419 LOWORD(wParam
) == ID_EDIT_CHARFORMAT
, (LPARAM
)&cf
);
423 case ID_EDIT_PARAFORMAT
:
426 ZeroMemory(&pf
, sizeof(pf
));
427 pf
.cbSize
= sizeof(pf
);
428 SendMessage(hwndEditor
, EM_GETPARAFORMAT
, 0, (LPARAM
)&pf
);
432 case ID_EDIT_SELECTIONINFO
:
434 CHARRANGE range
= {0, -1};
438 SendMessage(hwndEditor
, EM_EXGETSEL
, 0, (LPARAM
)&range
);
439 data
= HeapAlloc(GetProcessHeap(), 0, sizeof(*data
) * (range
.cpMax
-range
.cpMin
+1));
440 SendMessage(hwndEditor
, EM_GETSELTEXT
, 0, (LPARAM
)data
);
441 sprintf(buf
, "Start = %d, End = %d", range
.cpMin
, range
.cpMax
);
442 MessageBoxA(hWnd
, buf
, "Editor", MB_OK
);
443 MessageBoxW(hWnd
, data
, xszAppTitle
, MB_OK
);
444 HeapFree( GetProcessHeap(), 0, data
);
445 /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
449 case ID_EDIT_READONLY
:
451 long nStyle
= GetWindowLong(hwndEditor
, GWL_STYLE
);
452 if (nStyle
& ES_READONLY
)
453 SendMessage(hwndEditor
, EM_SETREADONLY
, 0, 0);
455 SendMessage(hwndEditor
, EM_SETREADONLY
, 1, 0);
459 case ID_EDIT_MODIFIED
:
460 if (SendMessage(hwndEditor
, EM_GETMODIFY
, 0, 0))
461 SendMessage(hwndEditor
, EM_SETMODIFY
, 0, 0);
463 SendMessage(hwndEditor
, EM_SETMODIFY
, 1, 0);
467 SendMessage(hwndEditor
, EM_UNDO
, 0, 0);
471 SendMessage(hwndEditor
, EM_REDO
, 0, 0);
475 case ID_ALIGN_CENTER
:
480 pf
.cbSize
= sizeof(pf
);
481 pf
.dwMask
= PFM_ALIGNMENT
;
482 switch(LOWORD(wParam
)) {
483 case ID_ALIGN_LEFT
: pf
.wAlignment
= PFA_LEFT
; break;
484 case ID_ALIGN_CENTER
: pf
.wAlignment
= PFA_CENTER
; break;
485 case ID_ALIGN_RIGHT
: pf
.wAlignment
= PFA_RIGHT
; break;
487 SendMessage(hwndEditor
, EM_SETPARAFORMAT
, 0, (LPARAM
)&pf
);
492 SendMessage(hwndEditor
, EM_SETBKGNDCOLOR
, 1, 0);
496 SendMessage(hwndEditor
, EM_SETBKGNDCOLOR
, 0, RGB(255,255,192));
500 SendMessage(hwndEditor
, WM_COMMAND
, wParam
, lParam
);
506 static LRESULT
OnInitPopupMenu( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
508 HMENU hMenu
= (HMENU
)wParam
;
509 HWND hwndEditor
= GetDlgItem(hWnd
, IDC_EDITOR
);
513 pf
.cbSize
= sizeof(PARAFORMAT
);
514 SendMessage(hwndEditor
, EM_GETPARAFORMAT
, 0, (LPARAM
)&pf
);
515 CheckMenuItem(hMenu
, ID_EDIT_READONLY
,
516 MF_BYCOMMAND
|(GetWindowLong(hwndEditor
, GWL_STYLE
)&ES_READONLY
? MF_CHECKED
: MF_UNCHECKED
));
517 CheckMenuItem(hMenu
, ID_EDIT_MODIFIED
,
518 MF_BYCOMMAND
|(SendMessage(hwndEditor
, EM_GETMODIFY
, 0, 0) ? MF_CHECKED
: MF_UNCHECKED
));
519 if (pf
.dwMask
& PFM_ALIGNMENT
)
520 nAlignment
= pf
.wAlignment
;
521 CheckMenuItem(hMenu
, ID_ALIGN_LEFT
, MF_BYCOMMAND
|(nAlignment
== PFA_LEFT
) ? MF_CHECKED
: MF_UNCHECKED
);
522 CheckMenuItem(hMenu
, ID_ALIGN_CENTER
, MF_BYCOMMAND
|(nAlignment
== PFA_CENTER
) ? MF_CHECKED
: MF_UNCHECKED
);
523 CheckMenuItem(hMenu
, ID_ALIGN_RIGHT
, MF_BYCOMMAND
|(nAlignment
== PFA_RIGHT
) ? MF_CHECKED
: MF_UNCHECKED
);
524 EnableMenuItem(hMenu
, ID_EDIT_UNDO
, MF_BYCOMMAND
|(SendMessage(hwndEditor
, EM_CANUNDO
, 0, 0)) ? MF_ENABLED
: MF_GRAYED
);
525 EnableMenuItem(hMenu
, ID_EDIT_REDO
, MF_BYCOMMAND
|(SendMessage(hwndEditor
, EM_CANREDO
, 0, 0)) ? MF_ENABLED
: MF_GRAYED
);
529 static LRESULT
OnSize( HWND hWnd
, WPARAM wParam
, LPARAM lParam
)
531 int nStatusSize
= 0, nTBSize
= 0;
533 HWND hwndEditor
= GetDlgItem(hWnd
, IDC_EDITOR
);
534 HWND hwndStatusBar
= GetDlgItem(hWnd
, IDC_STATUSBAR
);
535 HWND hwndReBar
= GetDlgItem(hWnd
, IDC_REBAR
);
536 HWND hwndToolBar
= GetDlgItem(hwndReBar
, IDC_TOOLBAR
);
540 SendMessage(hwndStatusBar
, WM_SIZE
, 0, 0);
541 GetClientRect(hwndStatusBar
, &rc
);
542 nStatusSize
= rc
.bottom
- rc
.top
;
546 rc
.left
= rc
.top
= 0;
547 rc
.right
= LOWORD(lParam
);
548 rc
.bottom
= HIWORD(lParam
);
549 SendMessage(hwndToolBar
, TB_AUTOSIZE
, 0, 0);
550 SendMessage(hwndReBar
, RB_SIZETORECT
, 0, (LPARAM
)&rc
);
551 nTBSize
= SendMessage(hwndReBar
, RB_GETBARHEIGHT
, 0, 0);
552 GetClientRect(hwndReBar
, &rc
);
553 MoveWindow(hwndReBar
, 0, 0, LOWORD(lParam
), rc
.right
, FALSE
);
557 GetClientRect(hWnd
, &rc
);
558 MoveWindow(hwndEditor
, 0, nTBSize
, rc
.right
, rc
.bottom
-nStatusSize
-nTBSize
, TRUE
);
561 return DefWindowProcW(hWnd
, WM_SIZE
, wParam
, lParam
);
564 static LRESULT CALLBACK
WndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
569 return OnCreate( hWnd
, wParam
, lParam
);
572 return OnUser( hWnd
, wParam
, lParam
);
575 return OnNotify( hWnd
, wParam
, lParam
);
578 return OnCommand( hWnd
, wParam
, lParam
);
586 SetFocus(GetDlgItem(hWnd
, IDC_EDITOR
));
589 case WM_INITMENUPOPUP
:
590 return OnInitPopupMenu( hWnd
, wParam
, lParam
);
593 return OnSize( hWnd
, wParam
, lParam
);
596 return DefWindowProcW(hWnd
, msg
, wParam
, lParam
);
602 int CALLBACK
WinMain(HINSTANCE hInstance
, HINSTANCE hOldInstance
, LPSTR szCmdParagraph
, int res
)
604 INITCOMMONCONTROLSEX classes
= {8, ICC_BAR_CLASSES
|ICC_COOL_CLASSES
};
609 InitCommonControlsEx(&classes
);
611 hAccel
= LoadAccelerators(hInstance
, "MAINACCELTABLE");
613 wc
.style
= CS_HREDRAW
| CS_VREDRAW
;
614 wc
.lpfnWndProc
= WndProc
;
617 wc
.hInstance
= hInstance
;
619 wc
.hCursor
= LoadCursor(NULL
, IDC_IBEAM
);
620 wc
.hbrBackground
= GetSysColorBrush(COLOR_WINDOW
);
621 wc
.lpszMenuName
= xszMainMenu
;
622 wc
.lpszClassName
= wszMainWndClass
;
625 hMainWnd
= CreateWindowExW(0, wszMainWndClass
, wszAppTitle
, WS_OVERLAPPEDWINDOW
,
626 CW_USEDEFAULT
, CW_USEDEFAULT
, 680, 260, NULL
, NULL
, hInstance
, NULL
);
627 ShowWindow(hMainWnd
, SW_SHOWDEFAULT
);
629 HandleCommandLine(GetCommandLineW());
631 while(GetMessage(&msg
,0,0,0))
633 if (TranslateAccelerator(hMainWnd
, hAccel
, &msg
))
635 TranslateMessage(&msg
);
636 DispatchMessage(&msg
);
637 if (!PeekMessage(&msg
, 0, 0, 0, PM_NOREMOVE
))
638 SendMessage(hMainWnd
, WM_USER
, 0, 0);