1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <windows.h>
#include <shlwapi.h>//for the open file dialog
#include <commctrl.h>//MSDN documentation says that INITCOMMONCONTROLSEX is declared here
int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hprev,LPSTR cmdline,int cmdshow){
//variable declaration
WNDCLASSEX wndclass;
HWND hwnd;
MSG msg;
//register the class
wndclass.cbSize=sizeof(WNDCLASSEX);
wndclass.style=0;
wndclass.lpfnWndProc=piproc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hinst;
wndclass.hIcon=(HICON)LoadImage(hinst,MAKEINTRESOURCE(MAINICON),IMAGE_ICON,48,48,0);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
wndclass.lpszMenuName=MAKEINTRESOURCE(PIPAINT_MENU);
wndclass.lpszClassName="PiPaint";
wndclass.hIconSm=(HICON)LoadImage(hinst,MAKEINTRESOURCE(MAINICON),IMAGE_ICON,16,16,0);
if(!RegisterClassEx(&wndclass)){
MessageBox(0,"ERROR: Window registration failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 1;}
//create the window
if((hwnd=CreateWindow("PiPaint","PiPaint",WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,640,480,NULL,NULL,hinst,NULL))==NULL){
MessageBox(0,"ERROR: Window creation failed","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 2;}
ShowWindow(hwnd,cmdshow);
UpdateWindow(hwnd);
InvalidateRect(hwnd,NULL,true);
//inititialize common controls
//vvv This is apparently not declared, even though MSDN documentation says it is in commctrl.h
INITCOMMONCONTROLSEX icex;
icex.dwSize=sizeof(INITCOMMONCONTROLSEX);
icex.dwICC=ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
//main loop
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);}
return msg.wParam;}
|