|
-
Dec 10th, 2000, 05:53 PM
#1
Thread Starter
Frenzied Member
I have tried to create a simple window by creating a new Win32 App and using the following code:
Code:
#define STRICT
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg,
WPARAM wParam, LPARAM lParam)
{ switch (iMsg)
{ case WM_LBUTTONDOWN:
MessageBox(hWnd, "Left-mousebutton pressed", "Info", MB_OK);
return 0;
case WM_RBUTTONDOWN:
MessageBox(hWnd, "Right-mousebutton pressed", "Info", MB_OK);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, iMsg, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
const char *const szAppName = "tradwin";
WNDCLASSEX wndclass;
HWND hWnd;
MSG msg;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass);
hWnd = CreateWindow(szAppName, "Tradwin: Press a mousekey.",
WS_OVERLAPPEDWINDOW, 0, 0, 640, 480,
NULL, NULL, hInstance, NULL);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL,0,0))
{ TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
But I get the following errors:
NONAME.CPP 24: Undefined symbol 'WNDCLASSEX' in function pascal WinMain(const HINSTANCE__near*,const HINSTANCE__near*,char near*,int)
NONAME.CPP 24: Statement missing ; in function pascal WinMain(const HINSTANCE__near*,const HINSTANCE__near*,char near*,int)
NONAME.CPP 28: Undefined symbol 'wndclass' in function pascal WinMain(const HINSTANCE__near*,const HINSTANCE__near*,char near*,int)
NONAME.CPP 28: Not an allowed type in function pascal WinMain(const HINSTANCE__near*,const HINSTANCE__near*,char near*,int)
NONAME.CPP 41: Call to undefined function 'RegisterClassEx' in function pascal WinMain(const HINSTANCE__near*,const HINSTANCE__near*,char near*,int)
What is wrong....Megatron tried it in VC++6 and it worked fine....
I'm using Borland C++ 4.5
-
Dec 10th, 2000, 06:01 PM
#2
Monday Morning Lunatic
Do you have up-to-date header files and libraries?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 10th, 2000, 06:03 PM
#3
It might be this statement.
Code:
#include <windows.h>
Look in the Borland help file and see if this is the proper method of including a file.
-
Dec 10th, 2000, 06:06 PM
#4
Monday Morning Lunatic
I thought that was the way you always did it in C?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 10th, 2000, 06:25 PM
#5
Thread Starter
Frenzied Member
That is the correct way........
Any other suggestions????
-
Jun 26th, 2002, 02:39 AM
#6
theif someone elses code and see if that works, then compare the two.
-
Jun 26th, 2002, 09:32 AM
#7
Addicted Member
It works fine with my computer.May be U have changed some settings.
Create a new win32 project and paste it, it will work.
-
Jun 26th, 2002, 05:24 PM
#8
Monday Morning Lunatic
Umm...this thread is nearly 2 years old
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 27th, 2002, 02:29 AM
#9
Errr, that'll be my fault... Whenever I have a problem I always search for a solution first (hint hint), and forget that some of the threads are quite old and respond to them.
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
|