Results 1 to 5 of 5

Thread: What is wrong with this code.....??

  1. #1

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

    Question

    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;
    }
    I get 5 errors....
    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
    What errors?
    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

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    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)
    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
    Guest
    Your code works fine for me. Using VC++ 6, I added it to a new Win32 project with 1 source file.

  5. #5

    Thread Starter
    Frenzied Member CyberCarsten's Avatar
    Join Date
    Sep 1999
    Location
    Aalborg Ø, Denmark
    Posts
    1,544
    I use Borland C++ 4.5, do you know why it doesn't work on mine????

    I create a new Win32 Project, with no resource file or .def file.

    I have also tried to use Borland's C++ Compiler 5.5.....no go!

    [Edited by CyberCarsten on 12-10-2000 at 12:56 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)

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