January 25th, 2013 10:05 PM
#1
[RESOLVED] starter app not responding
The following code results in simple window which stops responding as soon as it is executed.
i really have no idea what is happening, i am just starting visual c++
#include<windows.h>
#include<stdio.h>
#ifndef UNICODE
#define UNICODE
#endif
LRESULT CALLBACK windowprocess (HWND hwindow, UINT uMsg, WPARAM wParam, LPARAM lParm);
int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
WNDCLASSEX wc ={};
wc.lpfnWndProc = windowprocess;
static LPCSTR CLASS_NAME = "Starter Window Class";
wc.lpszClassName = CLASS_NAME;
wc.hInstance = hInstance;
wc.cbSize = sizeof(WNDCLASSEX);
RegisterClassEx (&wc) ;
HWND hWnd;
hWnd = CreateWindowEx ( 0, // Optional window styles.
CLASS_NAME, // Window class
"Starter App", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
hInstance, // Instance handle
NULL // Additional application data
);
// printf("Window created");
if(!hWnd)
{return 0;}
// printf("window verified");
ShowWindow(hWnd, nCmdShow);
LPMSG Msg;
while(GetMessage(Msg, hWnd, 0, 0))
{
TranslateMessage(Msg);
DispatchMessage(Msg);
}
return 0;
}
LRESULT CALLBACK windowprocess (HWND hwindow, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwindow, &ps);
FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));
EndPaint(hwindow, &ps);
}
break;
default:
return DefWindowProc(hwindow, uMsg, wParam, lParam);
}
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks