PDA

Click to See Complete Forum and Search --> : Create a simple Window.....


CyberCarsten
Dec 10th, 2000, 04:53 PM
I have tried to create a simple window by creating a new Win32 App and using the following 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

parksie
Dec 10th, 2000, 05:01 PM
Do you have up-to-date header files and libraries?

Dec 10th, 2000, 05:03 PM
It might be this statement.

#include <windows.h>

Look in the Borland help file and see if this is the proper method of including a file.

parksie
Dec 10th, 2000, 05:06 PM
I thought that was the way you always did it in C?

CyberCarsten
Dec 10th, 2000, 05:25 PM
That is the correct way........
Any other suggestions???? :)

Dreamlax
Jun 26th, 2002, 02:39 AM
theif someone elses code and see if that works, then compare the two.

purusingh
Jun 26th, 2002, 09:32 AM
It works fine with my computer.May be U have changed some settings.
Create a new win32 project and paste it, it will work.

parksie
Jun 26th, 2002, 05:24 PM
Umm...this thread is nearly 2 years old :p

Dreamlax
Jun 27th, 2002, 02:29 AM
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.