Windows Skeleton- Sex, drugs and a run-time error
I''m having trouble with this windows skeleton that I made.. it compiles without any errors or warnings, but when I ry to run it, it simply doesn''t show up. Can anyone help a poor white fool like myself?
// a windows skeleton
#include ''windows.h''
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
char szWinName[] = "MyWin"; // name of window class
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
WNDCLASSEX wcl;
MSG msg;
// define the window class
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.lpszClassName = szWinName;
wcl.lpfnWndProc = WinProc;
wcl.style = 0;
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcl.hIconSm = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.lpszMenuName = NULL; // no menu
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
// make the background of the window black
wcl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
// register the window class
if(!RegisterClassEx(&wcl)) return 0; // if the class doesn''t register, break it
// the window has been defined and registered,
// but now it''s time to create it
hwnd = CreateWindow(szWinName, // name of window class
"Windows Skeleton", //title
WS_OVERLAPPEDWINDOW, //style
CW_USEDEFAULT, // x
CW_USEDEFAULT, // y
CW_USEDEFAULT, // width
CW_USEDEFAULT, // height
NULL, // no parent window
NULL, // no menu
hThisInstance, //instance handle
NULL // no additional arguments
);
// diplay the window
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
// create a message loop
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
// the message handler
LRESULT CALLBACK WinProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch(message){
case WM_DESTROY: // terminate the program
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
GO LEAFS GO!
3D Math- The type of mathematics that'll put hair on your chest!
April 21, 2000 07:52 PM
I''m not an expert in Windows-programming, but I think you forgot to set the instance-handle:
wcl.hInstance = hThisInstance;
Hope this helps.
wcl.hInstance = hThisInstance;
Hope this helps.
In the CreateWindow function, the fourth argument(the style argument) must be: WS_OVERLAPPEDWINDOW / WS_VISIBLE
Also setting wcl.hInstance = hThisInstance is correct.
That should do it, good luck!
Edited by - isolier on 4/21/00 8:28:19 PM
Also setting wcl.hInstance = hThisInstance is correct.
That should do it, good luck!
Edited by - isolier on 4/21/00 8:28:19 PM
You don''t have to explicitly specify WS_VISIBLE, as you''re calling ShowWindow(). It might even be implicit, but I couldn''t say for sure.
-------------------
Revolver, aka Brian Smith
MIS Programmer Analyst
brian.smith@realpage.com
RealPage >> www.realpage.com
My views aren't even mine, much less my employers. =)
-------------------
Revolver, aka Brian Smith
MIS Programmer Analyst
brian.smith@realpage.com
RealPage >> www.realpage.com
My views aren't even mine, much less my employers. =)
Creativity is a bloody nuisance and an evil curse that will see to it that you die from stress and alcohol abuse at a very early age, that you piss off all your friends, break appointments, show up late, and have this strange bohemian urge (you know that decadent laid-back pimp-style way of life). The truly creative people I know all live lousy lives, never have time to see you, don't take care of themselves properly, have weird tastes in women and behave badly. They don't wash and they eat disgusting stuff, they are mentally unstable and are absolutely brilliant. (k10k)
quote: Original post by Isolier
In the CreateWindow function, the fourth argument(the style argument) must be: WS_OVERLAPPEDWINDOW / WS_VISIBLE
Also setting wcl.hInstance = hThisInstance is correct.
That should do it, good luck!
I thought that WS_VISIBLE was unnessary when you call
ShowWindow(hwnd, nCmdShow), because in ShowWindow(..) your are telling the window how to show in the nCmdShow-parameter.
But perhaps I got all this wrong, who knows...
<<>> The Big ? <<>>
Yay! Thanks, I got it.. I''m new to windows programming, so I have no idea why I would even include that in the class definition, but thanks for the people who helped! I got it running with:
wcl.hInstance = hThisInstance;
GO LEAFS GO!
wcl.hInstance = hThisInstance;
GO LEAFS GO!
3D Math- The type of mathematics that'll put hair on your chest!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement