CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2009
    Posts
    31

    [RESOLVED] Problems creating button (C2660)

    I receive the fallowing errors:

    1>.\EnterIFSEnt.cpp(56) : error C2143: syntax error : missing ')' before ';'
    1>.\EnterIFSEnt.cpp(56) : error C2660: 'CreateWindowExA' : function does not take 10 arguments
    1>.\EnterIFSEnt.cpp(56) : error C2143: syntax error : missing ';' before ','
    1>.\EnterIFSEnt.cpp(59) : error C2059: syntax error : ')'

    Obviously I have 12 arguments as described in docs. What's going on here? I works fine on my other form.

    Line 56 = "(HMENU)cmdOK,"
    Code:
    LRESULT CALLBACK WndProcess(HWND hwndex, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    	HWND hwndcmdOK;
    
    	switch(msg)
    	{
    		case WM_CLOSE:
    			DestroyWindow(hwndex);
    			break;
    		case WM_DESTROY:
    			PostQuitMessage(0);
    			break;
    		case WM_COMMAND:
    			break;
    		case WM_CREATE:
    			{	
    				RegisterGridClass(hInstee);//Registers the style class "BABYGRID"
    
    				//cmdOK
    
    				hwndcmdOK=CreateWindowEx(0,				/* 1 more or ''extended'' styles */
    					TEXT("BUTTON"),							/* 2 GUI ''class'' to create */
    					TEXT("OK"),								/* 3 GUI caption */
    					WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,	/* 4 control styles separated by | */
    					111,									/* 5 X POSITION (Position from left) */
    					279,									/* 6 Y POSITION  (Position from Top) */
    					75,										/* 7 WIDTH OF CONTROL */
    					23,										/* 8 HEIGHT OF CONTROL */
    					hwndee,									/* 9 Parent window handle */
    					(HMENU)cmdOK,							/* 10 control''s ID for WM_COMMAND */
    					NULL,									/* 11 application instance */
    					NULL									/* 12 LParam (not used)*/
    					);
    
    				////DataGrid Enter entity
    				//hwnddgEnterEnt=CreateWindowExA(WS_EX_CLIENTEDGE,"BABYGRID","",WS_VISIBLE|WS_CHILD,2,2,200,200,hwndee,(HMENU)dgEnterEnt,NULL,NULL);
    				//SendMessage(hwnddgEnterEnt,BGM_SETEDITABLE,TRUE,0);//Allows the grid to be editable
    				//SendMessage(hwnddgEnterEnt,BGM_SETCOLSNUMBERED,FALSE,0);
    				//SendMessage(hwnddgEnterEnt,BGM_SETGRIDDIM,0,1);
    				//SendMessage(hwnddgEnterEnt,BGM_SETCOLWIDTH,0,0);//hides the row numbers
    				//SendMessage(hwnddgEnterEnt,BGM_SETCOLWIDTH,1,253);//sets column width of column 1
    				//SendMessage(hwnddgEnterEnt,BGM_SETHEADINGFONT,(WPARAM)g_fmyfont,NULL);//set the column heading font
    				//SendMessage(hwnddgEnterEnt,BGM_SETALLOWCOLRESIZE,(WPARAM)TRUE,NULL);//Allows the columns to be resized
    				//SendMessage(hwnddgEnterEnt,BGM_AUTOROW,(WPARAM)TRUE,NULL);
    			}
    			break;
    		default:
    		return DefWindowProc(hwndex,msg,wParam,lParam);
    	 
    	}
    }
    Last edited by james2432; June 30th, 2009 at 01:38 PM.

  2. #2
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Problems creating button (C2660)

    Pass the correct number of parameters to CreateWindowEx.
    Which lines are causing other errors?
    You posted actual code, or commented the error lines here?
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  3. #3
    Join Date
    Jun 2009
    Posts
    31

    Re: Problems creating button (C2660)

    lines creating errors (the commented lines create the same errors):

    Code:
    hwndcmdOK=CreateWindowEx(0,				/* 1 more or ''extended'' styles */
    					TEXT("BUTTON"),							/* 2 GUI ''class'' to create */
    					TEXT("OK"),								/* 3 GUI caption */
    					WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,	/* 4 control styles separated by | */
    					111,									/* 5 X POSITION (Position from left) */
    					279,									/* 6 Y POSITION  (Position from Top) */
    					75,										/* 7 WIDTH OF CONTROL */
    					23,										/* 8 HEIGHT OF CONTROL */
    					hwndee,									/* 9 Parent window handle */
    					(HMENU)cmdOK,							/* 10 control''s ID for WM_COMMAND */
    					NULL,									/* 11 application instance */
    					NULL									/* 12 LParam (not used)*/
    					);

  4. #4
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Problems creating button (C2660)

    I declared the three variables required, and it compiles smoothly.
    Is it related to TEXT macro?
    Try removing it and re-compile.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  5. #5
    Join Date
    Jun 2009
    Posts
    31

    Re: Problems creating button (C2660)

    Same errors
    Code:
    CreateWindowEx(0,                 /*1 Extended styles*/
    					"BUTTON",							/* 2 GUI ''class'' to create */
    					"OK",..........................

  6. #6
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Problems creating button (C2660)

    Please try to solve your problem yourself. Your problem seems to be simple.
    And, you are not giving enough information to reproduce the error.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  7. #7
    Join Date
    Jun 2009
    Posts
    31

    Re: Problems creating button (C2660)

    I have cmdOK defined at the top (see code below)

    When I use cmdOK I get the error. When I use 203(directly) it compiles


    Code:
    #include <string.h>
    #include <cstring>
    #include <stdlib.h>
    #include "BabyGrid.h"
    #include "EnterIFSEnt.h"
    #include "datamanager.h"
    #include <vector>
    
    #define dgEnterEnt	202;
    #define cmdOK		203;
    
     const char g_seeClassName[] = "EnterIFSEntWC";
     int g_ieSizex,g_ieSizey;
     HINSTANCE hInstee;
     HFONT g_fmyfont;
     WNDCLASSEX wcx;
     HWND hwndee;
     HWND hwnddgEnterEnt;
     MSG eMsg;
     _BGCELL cellee;

    *EDIT*

    Even if I use 203 directly it doesn't register on the form.
    Last edited by james2432; June 30th, 2009 at 03:44 PM.

  8. #8
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Problems creating button (C2660)

    Code:
     
    #define dgEnterEnt 202;
    #define cmdOK 203;
    What is this? First remove the ; remove from these definitions. Second, the dgEnterEnt and cmdOK are supposed to be variables of respective type that CreateWindow takes/returns.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  9. #9
    Join Date
    Jun 2009
    Posts
    31

    Re: Problems creating button (C2660)

    I use them up there so that I can always reference the HMENU later to find the hwnd with FindDlgWindow() so I can change settings/read them so if I do have to change the number I don't have to modify the whole program...and wow I must have been tired to add a ; to a define

  10. #10
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: Problems creating button (C2660)

    I use them up there so that I can always reference the HMENU later to find the hwnd with FindDlgWindow() so I can change settings/read them so if I do have to change the number I don't have to modify the whole program...and wow I must have been tired to add a ; to a define
    Your sentence is vague! Add some punctuation marks to make it understandable.

    You cannot make a constant a variable.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  11. #11
    Join Date
    Jun 2009
    Posts
    31

    Re: Problems creating button (C2660)

    I found the problem why it wasn't adding to the form. In the CreateWindowEx() I was useing hwndee(which was in the process of being created) which is the global variable at the top. I had to take the hwnd parameter to the WndProc which actually had a address space reserved(the global was always 0x0000000).
    Last edited by james2432; July 2nd, 2009 at 07:40 AM.

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

Featured