Results 1 to 7 of 7

Thread: How can I create a Window

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    How can I create a Window in a Win32 App using Borland C++??? (Doesn't have to be complex or anything... )
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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 am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    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]
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    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.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    Do you have a clue on what it might be???
    Do you know where i can get VC++ (for free )
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

  6. #6
    Guest
    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...

  7. #7

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    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!
    razor
    Software Engineer Student, Aalborg University, Denmark
    http://www.cs.auc.dk

    My email at AUC: will get a new email soon
    My website: http://www.razorsoftware.net


    Windows XP Pro/ Gentoo Linux (Laptop)
    Windows XP Pro (Home PC)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width