|
-
Dec 11th, 2000, 03:05 PM
#1
Thread Starter
Frenzied Member
How can I create a Window in a Win32 App using Borland C++??? (Doesn't have to be complex or anything... )
-
Dec 11th, 2000, 03:35 PM
#2
Frenzied Member
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;
}
-
Dec 11th, 2000, 03:42 PM
#3
Thread Starter
Frenzied Member
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]
-
Dec 11th, 2000, 04:39 PM
#4
Frenzied Member
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.
-
Dec 11th, 2000, 04:41 PM
#5
Thread Starter
Frenzied Member
Do you have a clue on what it might be???
Do you know where i can get VC++ (for free )
-
Dec 11th, 2000, 05:14 PM
#6
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...
-
Dec 12th, 2000, 03:40 AM
#7
Thread Starter
Frenzied Member
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!
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
|