Writing Function

This is a discussion on Writing Function within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to create a window that writes something to the screen but i've got an unusual error Code: #include ...

  1. #1
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161

    Writing Function

    I'm trying to create a window that writes something to the screen but i've got an unusual error

    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc ( HWND, UINT, WPARAM, LPARAM );
    
    HINSTANCE hInstGlobal;
    
    int APIENTRY WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                           LPSTR lpCmdLine, int nCmdShow )
    {
          hInstGlobal = hInstance;
          
          WNDCLASS wc;
          wc.style               = 0;
          wc.cbClsExtra          = 0;
          wc.cbWndExtra          = 0;
          wc.lpfnWndProc         = WndProc;
          wc.hInstance           = hInstance;
          wc.hbrBackground       = (HBRUSH) (COLOR_WINDOW+1);
          wc.hCursor             = LoadCursor (NULL, IDC_ARROW);
          wc.hIcon               = LoadIcon (NULL, IDI_APPLICATION);
          wc.lpszMenuName        = 0;
          wc.lpszClassName       = "Dog Simulator 2";
          RegisterClass (&wc);
          
          HWND hWindow;
          hWindow = CreateWindow ( "Kazalio Studios", "Dog Simulator 2",
                                   WS_OVERLAPPEDWINDOW,
                                   0, 0, 600, 460, NULL, NULL,
                                   hInstance, NULL );
          ShowWindow(hWindow, nCmdShow);
          UpdateWindow(hWindow);
          
          MSG Message;
          while (GetMessage(&Message, NULL, 0, 0))
          {
                TranslateMessage (&Message);
                DispatchMessage (&Message);
                }
          return (Message.wParam);
    }
    
    void begin(HWND hWnd)
    {
             HDC         hDC;
        PAINTSTRUCT Ps;
        HFONT	    font;
         hDC = BeginPaint(hWnd, &Ps);
    		
             font = CreateFont(46, 28, 215, 0,
                               FW_NORMAL, FALSE, FALSE, FALSE,
                               ANSI_CHARSET, OUT_DEFAULT_PRECIS,
    		         CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
    		         DEFAULT_PITCH | FF_ROMAN,
    			"Times New Roman");
    
            SelectObject(hDC, font);
            TextOut(hDC, 20, 128, "Euzhan Palcy", 12);
            DeleteObject(font);
    
    	EndPaint(hWnd, &Ps);
    }
    
    LRESULT CALLBACK WndProc ( HWND hWnd, UINT uiMessage, 
                               WPARAM wParam, LPARAM lParam )
    {
          switch (uiMessage)
          {
                 case WM_CREATE:
                      HWND hBegin, hExit;
                      hBegin = CreateWindow ("BUTTON", "Continue",  //error
                                             WS_CHILD|WS_VISIBLE,
                                             BS_PUSHBUTTON,
                                             10, 340, 140, 20,
                                             hWnd, (HMENU) 1,
                                             hInstGlobal, NULL);
                      hExit = CreateWindow ("BUTTON", "Exit",
                                            WS_CHILD|WS_VISIBLE|
                                            BS_PUSHBUTTON,
                                            360, 340, 140, 20,
                                            hWnd, (HMENU), 2,
                                            hInstGlobal, NULL);
                      return 0;
                 case WM_COMMAND:
                      if (HIWORD(wParam) == BN_CLICKED)
                      {
                          if (LOWORD(wParam) == 1)
                          {
                               begin(HWND hWnd);
                               }
                          if (LOWORD(wParam) == 2)
                          {
                               SendMessage (GetParent((HWND) lParam),
                                           WM_DESTROY, 0, 0);
                                           }
                                           }
                               return 0;
                          case WM_DESTROY:
                               PostQuitMessage(0);
                               return 0;
                          default:
                                  return DefWindowProc (hWnd, uiMessage,
                                                        wParam, lParam);
                                                        }
    }
    It comes up with the error
    CreateWindowa passes 12 arguements but only takes 11
    [Build Error] [main.o]Error1
    I started out with nothing and I still have most of it left.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Code:
    hBegin = CreateWindow ("BUTTON", "Continue",  //error
                            WS_CHILD|WS_VISIBLE | /* <--'OR' styles - not comma*/
                            BS_PUSHBUTTON,
                            10, 340, 140, 20,
                            hWnd, (HMENU) 1,
                            hInstGlobal, NULL);
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    thanks one more problem on the bit where it says begin(HWND hWnd); which calls the write function it says primary expression before hWnd
    I started out with nothing and I still have most of it left.

  4. #4
    yes, I'm registered!!! algi's Avatar
    Join Date
    Nov 2004
    Location
    Ipswich
    Posts
    161
    sorry i've fixed that but when I compile it and try to run it, I can't see the window.
    I started out with nothing and I still have most of it left.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 07:54 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 07:44 PM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21