|
-
Jan 8th, 2003, 10:55 PM
#1
Thread Starter
Member
Man This Stinks
Could ne one help me here? im now gettin into windows API, and I tried to manually debug it, but I cannot snatch the error. help ne one?
Here it is:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASS kWndClass;
kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
kWndClass.hInstance = hInstance;
kWndClass.lpfnWndProc = WndProc;
kWndClass.lpszClassName = "Alex's Window";
kWndClass.lpszMenuName = NULL;
kWndClass.cbClsExtra = NULL;
kWndClass.cbWndExtra = NULL;
kWndClass.style = NULL;
if (!RegisterClass (&kWndClass))
{
return -1;
}
HWND hWindow;
hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
MSG kMessage;
while (GetMessage (&kMessage, hWindow, 0, 0))
{
TranslateMessage (&kMessage);
DispatchMessage (&kMessage)
}
return 0;
}
LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAm lParam)
{
switch (iMessage)
{
case WM_CLOSE;
POSTQUITMESSAGE (0);
break;
default:
return DefWindowProc (hWindow, iMessage, wParam, lParam);
}
return 0;
}
I'd Appreciate any help! thanks ohh and here are the errors....
--------------------Configuration: Window - Win32 Debug--------------------
Compiling...
Window S.cpp
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(3) : error C2061: syntax error : identifier 'UNIT'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(14) : error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(37) : error C2143: syntax error : missing ';' before '}'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(42) : error C2061: syntax error : identifier 'UNIT'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(44) : error C2065: 'iMessage' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(46) : error C2143: syntax error : missing ':' before ';'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2065: 'wParam' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2065: 'lParam' : undeclared identifier
Error executing cl.exe.
Window.exe - 9 error(s), 0 warning(s)
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 12:24 AM
#2
Lively Member
instead of UNIT try UINT where you declare the WndProc procedure...
-
Jan 9th, 2003, 06:45 AM
#3
I could solve every error for you, but that would be of little use to you.
First I recommend you walk through your app and search for missing ; or places where you confused : and ;
I see two errors coming from that.
Then you should correct the error Arawn pointed out. UINT is an abbreviation for unsigned integer.
Next check case. C++ is case sensitive and names of the windows API follow a simple case scheme: types and constants are all capitals (1 error) and functions start with a capital and each word in them also starts with a capital (1 error).
The remaining errors (2) are follow-ups.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 9th, 2003, 07:09 AM
#4
Thread Starter
Member
Alright, thaks guys, I appreciate it
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 07:14 AM
#5
Frenzied Member
And please always place your code here between code tags:
[code] Your code here [/code]
It makes it easier to read since the code is posted exactely (formatting) as you wrote it, and it makes it easier to see in a glance what's code and what not.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jan 9th, 2003, 04:37 PM
#6
Thread Starter
Member
Ok thanks guys, im down to 1 error, and im guessing its the function begining not begining with a capital, but where?????
Code:
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(43) : error C2447: missing function header (old-style formal list?)
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 05:07 PM
#7
What are the lines around line 43? And 43 itself too of course.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 9th, 2003, 05:08 PM
#8
Could it be that you added a ; here?
Code:
}
LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAm lParam) <--
{
switch (iMessage)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 9th, 2003, 05:27 PM
#9
Thread Starter
Member
I erased it and still has one error of the header ****ing old style
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 05:36 PM
#10
Show me your new code.
And mark the line where the error occurs.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 9th, 2003, 06:12 PM
#11
Thread Starter
Member
alright here:
Code:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASS kWndClass;
kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
kWndClass.hInstance = hInstance;
kWndClass.lpfnWndProc = WndProc;
kWndClass.lpszClassName = "Alex's Window";
kWndClass.lpszMenuName = NULL;
kWndClass.cbClsExtra = NULL;
kWndClass.cbWndExtra = NULL;
kWndClass.style = NULL;
if (!RegisterClass (&kWndClass))
{
return -1;
}
HWND hWindow;
hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
MSG kMessage;
while (GetMessage (&kMessage, hWindow, 0, 0))
{
TranslateMessage (&kMessage);
DispatchMessage (&kMessage);
}
return 0;
}
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
{
switch (iMessage)
{
case WM_CLOSE;
POSTQUITMESSAGE (0);
break;
default:
return DefWindowProc (hWindow, iMessage, wParam, lParam)
}
return 0;
}
It dose not really tell me where but once I saw a bue arrow right here:
Code:
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
{
The bracket under the function.
So I dont know if this helped you help me....
Thanks ne way.
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 06:23 PM
#12
Hyperactive Member
Code:
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
{
Remove the ; like CornedBee has told you.
Code:
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
-
Jan 9th, 2003, 06:32 PM
#13
Thread Starter
Member
that generates 5 more errors and like 1 warning:
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(45) : warning C4060: switch statement contains no 'case' or 'default' labels
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2143: syntax error : missing ':' before ';'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2046: illegal case
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(48) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(49) : error C2143: syntax error : missing ';' before 'break'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(49) : error C2043: illegal break
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2047: illegal default
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(53) : error C2143: syntax error : missing ';' before '}'
Error executing cl.exe.
The Code:
#include <windows.h>
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASS kWndClass;
kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
kWndClass.hInstance = hInstance;
kWndClass.lpfnWndProc = WndProc;
kWndClass.lpszClassName = "Alex's Window";
kWndClass.lpszMenuName = NULL;
kWndClass.cbClsExtra = NULL;
kWndClass.cbWndExtra = NULL;
kWndClass.style = NULL;
if (!RegisterClass (&kWndClass))
{
return -1;
}
HWND hWindow;
hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
MSG kMessage;
while (GetMessage (&kMessage, hWindow, 0, 0))
{
TranslateMessage (&kMessage);
DispatchMessage (&kMessage);
}
return 0;
}
LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch (iMessage);
{
case WM_CLOSE;
POSTQUITMESSAGE (0)
break;
default:
return DefWindowProc (hWindow, iMessage, wParam, lParam)
}
return 0;
}
I cannot make ne thing of it lol
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 06:34 PM
#14
Thread Starter
Member
ok never mind, only creates 2 more errors, the other ones were my fault, here are the 2 more:
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2143: syntax error : missing ':' before ';'
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(48) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(53) : error C2143: syntax error : missing ';' before '}'
Error executing cl.exe.
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 07:18 PM
#15
Good Ol' Platypus
Look at the switch in WndProc.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Jan 9th, 2003, 07:21 PM
#16
Thread Starter
Member
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 9th, 2003, 07:30 PM
#17
Thread Starter
Member
ok this is really starting to piss me off..... Ok there are 0 errors in building it, but two errors in compieling it! *** god, I hate this compieler.................. and it hates me.. ok here they are:
--------------------Configuration: Window S - Win32 Debug--------------------
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Window S.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Window S.exe - 2 error(s), 0 warning(s)
Ok? some one help? dont tell me you need the code because I posted it only like 6 times above, please help! I need this crap to work!!!!!
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 11th, 2003, 12:11 AM
#18
Thread Starter
Member
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 11th, 2003, 12:33 AM
#19
Frenzied Member
Create a new project that is NOT a Win32 Console Application, but a Win32 Application. Console applications use main as the entry point, Win32 applications use WinMain.
Z.
-
Jan 11th, 2003, 01:20 AM
#20
Thread Starter
Member
Zaei, it is a win32 app. , not a console, thanks 4 trying tho
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
-
Jan 11th, 2003, 01:23 AM
#21
Thread Starter
Member
wait... hold on.... it works!!!!!!!!! YEAH THANKS FINALLY FOR THE SAKE OF GOD!!!!!!!! I thought I made sure it was a win 32 app.
damn....
A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.
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
|