I have this code (example)
const char g_sz_className[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UNIT msg,WPARAM wParam, LPARAM lPraram)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage;
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HISTANCE hIstance, HISTANCE hPrevIstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hIstance;
wc.hbrBackground = (HBRUSH) 13;
wc.lpfnWndProc = WndProc;
wc.lpszClassName = g_sz_className;
wc.lpszMenuName = NULL; //change
if(!RegisterClassEx)
{
MessageBox(NULL, "Err", "ERR", MB_OK | MB_EXCLAMATION);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_sz_className,
"My app",
WS_OVERLAPPEDWINDOW,
CW_USERDEFAULT,
CW_USERDEFAULT,
600,
650,
NULL,NULL, hIstance, NULL);
if(hwnd = NULL)
{
MessageBox(NULL,"ERROr", "HWND ERR", MB_OK | MB_ICONEXCLAMATION);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
But it looks like its not portable.
Now in Visual Studio I cannot compile that. There is a bit more complicated file with stdfax.cpp, stdfax.h, resouurce.h files. What should I do?
Where can I get a good tutorial which will teach me Win32 API as Visual Studio wants???
Thanks in advance,
Jan