trouble with a windows 98 skeleton
I was trying to get the windows 98 skeleton from "windows 98 programming from the ground up" (pages19 to 21). I managed to get it down to 3 errors. heres the code:
// a minimal windows skeleton
#include
LRESULT CALLBACK WIndowFunc(HWND, UINT, WPARAM, LPARAM);
char szWinName[] = "MyWin"; //name of window class
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hprevInst,
LPSTR lpszArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
//define a window class
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hInstance = hThisInst; //handle to this instance
wcl.lpszClassName = szWinName; //window class name
wcl.lpfnWndProc = WindowFunc; //window function
wcl.style = 0; //default style
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION); //standard icon
wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO); //small icon
wcl.hCursor = LoadCursor(NULL, IDC_ARROW); //cursor style
wcl.lpszMenuName = NULL; //no menu
wcl.cbClsExtra = 0; //no extra info needed
wcl.cbWndExtra = 0; //no extra info needed
//make the background brush white
wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
//register the window class
if(!RegisterClassEx(&wcl)) return 0;
//now that a window class has been registered, a window can be created
hwnd = CreateWindow(
szWinName, //name of windows class
"Windows 98 Skeleton", //title
WS_OVERLAPPEDWINDOW, //window style: normal
CW_USEDEFAULT, //x coord- let windows decide
CW_USEDEFAULT, //y coord - let windows decide
CW_USEDEFAULT, //width - let windows decide
CW_USEDEFAULT, //height - let windows decide
HWND_DESKTOP, //no parent window
NULL, //no menu
hThisInst, //handle of this instance of the program
NULL, //no additional arguments
);
//display the window
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
//create the message loop
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg); //translate keyboard messages
DispatchMessage(&msg); //return control to windows 98
}
return msg.wParam;
}
//this function is called by windows 98 and is passed
//messages from the queue
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_DESTROY://terminate the program
PostQuitMessage(0);
break;
default:
//let windows 98 process any messages not specified in the preceeding switch statement
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
It gave me the following errors:
1.(21) : error C2065: ''WindowFunc'' : undeclared identifier
2.(21) : error C2440: ''='' : cannot convert from ''int'' to ''long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'', Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
3. (70) : error C2373: ''WindowFunc'' : redefinition; different type modifiers
can anyone here help me?
- Moe -
For starters try this:
LRESULT CALLBACK WIndowFunc(HWND, UINT, WPARAM, LPARAM);
changes to:
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
and also:
wcl.lpfnWndProc = WindowFunc; //window function
changes to:
wcl.lpfnWndProc = (WNDPROC)WindowFunc; //window function
Hope that helps
LRESULT CALLBACK WIndowFunc(HWND, UINT, WPARAM, LPARAM);
changes to:
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
and also:
wcl.lpfnWndProc = WindowFunc; //window function
changes to:
wcl.lpfnWndProc = (WNDPROC)WindowFunc; //window function
Hope that helps
~deadlinegrunt
Make sure you have the following in your source file
#include
...if it''s working properly you shouldn''t have to cast
(WNDPROC) at all it should be fine.
Watch your spelling/capitalization too...c/c++ is picky about it.
#include
...if it''s working properly you shouldn''t have to cast
(WNDPROC) at all it should be fine.
Watch your spelling/capitalization too...c/c++ is picky about it.
~ blackspy
Ok..I just realized, you probably do have windows.h included there, seems the board removes part of the command when you put it in the "< >" ....
~ blackspy
blackspy and anyone else who wants to include a "<" or ">" in your post for stuff like
#include <windows.h>
a "<"= "& l t ;"
a ">" = "& g t ;"
(As when I post I probably will find that I screwed up too)
Edited by - Nytegard on 4/1/00 1:54:18 PM
#include <windows.h>
a "<"= "& l t ;"
a ">" = "& g t ;"
(As when I post I probably will find that I screwed up too)
Edited by - Nytegard on 4/1/00 1:54:18 PM
Hehe. There are over 3000 people registered here, most of them computer interested, and this is the first time I see see someone do this correctly
Someone else might have done it before, though.
A polar bear is a rectangular bear after a coordinate transform.
Someone else might have done it before, though.
A polar bear is a rectangular bear after a coordinate transform.
A polar bear is a rectangular bear after a coordinate transform.
ok, this is really pissin' me of!!
what do you type so the little things (< >) don't clear the word they enclose?
do you put them in quotes?
that post by Nytegard wasn't very clear at all...
Edited by - Zipster on 4/1/00 4:44:13 PM
what do you type so the little things (< >) don't clear the word they enclose?
do you put them in quotes?
that post by Nytegard wasn't very clear at all...
Edited by - Zipster on 4/1/00 4:44:13 PM
Zipster, I''m sorry if my other post was unclear.
< = "& l t ;"
> = "& g t ;"
Take what I have in quotes, and take the spaces out.
I''m sorry, but I don''t know how to type an ampersand, followed by a l (or g), followed by a t, followed by a semicolon in one string. It stands for less than and greater than. If you are still confused, look at the source code.
< = "& l t ;"
> = "& g t ;"
Take what I have in quotes, and take the spaces out.
I''m sorry, but I don''t know how to type an ampersand, followed by a l (or g), followed by a t, followed by a semicolon in one string. It stands for less than and greater than. If you are still confused, look at the source code.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement