Actually the program is already a win32 application with the the proper windows functions. All it does is display a window and compiles and runs fine in VC++. The problem seems to be something else. Here's the code:
#include <windows.h>
static char pClassName[] = "TheClass";
static HINSTANCE ghInst = 0;
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case CM_CLOSEWIN: DestroyWindow(hwnd); break;
case WM_CLOSE: DestroyWindow(hwnd); break;
case WM_DESTROY: PostQuitMessage(0); break;
default: return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wce;
HWND hwnd;
MSG msg;
ghInst = hInstance;
wce.cbSize = sizeof(WNDCLASSEX);
wce.style = 0;
wce.lpfnWndProc = WndProc;
wce.cbClsExtra = 0;
wce.cbWndExtra = 0;
wce.hInstance = ghInst;
wce.hIcon = LoadIcon(0, IDI_WINLOGO);
wce.hCursor = LoadCursor(0, IDC_ARROW);
wce.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wce.lpszMenuName = 0;
wce.lpszClassName = pClassName;
wce.hIconSm = LoadIcon(0, IDI_WINLOGO);
if(!RegisterClassEx(&wce))return 0;
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, pClassName, "title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
800, 600, 0, 0, ghInst, 0);
if(hwnd == 0) return 0;
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}