Results 1 to 9 of 9

Thread: Create a simple Window.....

  1. #1

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544

    Unhappy

    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
    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
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

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

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  5. #5

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    That is the correct way........
    Any other suggestions????
    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
    Dreamlax
    Guest
    theif someone elses code and see if that works, then compare the two.

  7. #7
    Addicted Member
    Join Date
    Nov 2001
    Posts
    163
    It works fine with my computer.May be U have changed some settings.
    Create a new win32 project and paste it, it will work.
    Purushottam

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  9. #9
    Dreamlax
    Guest
    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
  •  



Click Here to Expand Forum to Full Width