How can I create a Window in a Win32 App using Borland C++??? (Doesn't have to be complex or anything...:) )
Printable View
How can I create a Window in a Win32 App using Borland C++??? (Doesn't have to be complex or anything...:) )
This will create a window:
Code:#include <windows.h>
LRESULT CALLBACK WindowFunc(HWND, UINT, WPARAM, LPARAM);
char szWinNamw[] = "MyWin";
int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
LPSTR kposzArgs, int nWinMode)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wcl;
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.hInstance = hThisInst;
wcl.lpszClassName = "My Window";
wcl.lpfnWndProc = WindowFunc;
wcl.style = 0;
wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcl.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.lpszMenuName = NULL;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
if(!RegisterClassEx(&wcl)) return 0;
hwnd = CreateWindow(
"My Window",
"Skeleton Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_DESKTOP,
NULL,
hThisInst,
NULL
);
ShowWindow(hwnd, nWinMode);
UpdateWindow(hwnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
switch(message) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
I get the following errors:
Line 11:Undefined symbol 'WNDCLASSEX' in function __stdcall WinMain(void*,void*,char^,int)
Line 11: Statement missing ; in function __stdcall WinMain(void*,void*,char^,int)
Line 12: Undefined symbol 'wcl' in function __stdcall WinMain(void*,void*,char^,int)
Line 12: Not an allowed type in function__stdcall WinMain(void*,void*,char^,int)
Line 18: Undefined symbol 'IDI_WINLOGO' in function __stdcall WinMain(void*,void*,char^,int)
Line 24: Call to undefined function 'RegisterClassEx' in function __stdcall WinMain(void*,void*,char^,int)
[Edited by CyberCarsten on 12-11-2000 at 03:47 PM]
It works fine in VC++ as for Borland C++ i never used it. But it is the same language the same API's. There must be some little catch in Borland.
Do you have a clue on what it might be???
Do you know where i can get VC++ (for free :) )
you're using borland turbo C++ 4.5, am I correct?
the default are borland EZWin
go to
Project -> New Project
and if it's not already selected, click "application(.exe)"
set your preferences, etc. click Ok...
No, I'm using Borland C++ 4.5.
But I discovered that the BC 4.5 compiler couldn't hande the Win32 API properly, so I downloaded the BC 5.5 compiler from borland's website, and it works fine now! :)
Thanks for all your help guys! :)