Thread: Edit Control

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    4

    Edit Control

    Hi, I have a error with my createwindow for the edit control:C2198 to few parameters.
    As far as I can see the parameters are correct or am I not seeing something stupid that I did. If I comment out the createwindow for the edit control all compiles ok.
    Code:
    #include <windows.h>
    
    #define IDC_EDIT WM_USER + 1000;
    
    LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
    
    HINSTANCE hInst;
    
    int WINAPI WinMain( HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode )
    {
    	WNDCLASSEX wc;
    	HWND hwnd;
    	HWND hEdit;
    	MSG msg;
    	
    	hInst = hThisInst;
    	
    	// register window class
    	wc.cbSize = sizeof( WNDCLASSEX );
    	wc.style = 0;
    	wc.lpfnWndProc = WndProc;
    	wc.cbClsExtra = 0;
    	wc.cbWndExtra = 0;
    	wc.hInstance = hInst;
    	wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    	wc.hIconSm = NULL;
    	wc.hCursor = LoadCursor( NULL, IDC_ARROW );
    	wc.hbrBackground = ( HBRUSH )GetStockObject( BLACK_BRUSH );
    	wc.lpszMenuName = NULL;
    	wc.lpszClassName = "EditBoxTest";
    	RegisterClassEx( &wc );
    	
    	// create main window
    	hwnd = CreateWindow( "EditBoxTest", 
    		                 "EditBox Test", 
    		                 WS_OVERLAPPEDWINDOW,
    		                 0, 0, 800, 600,
    		                 NULL, NULL, hInst, NULL );
    
    	// create edit box
    	hEdit = CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("Edit"),"",WS_CHILD|WS_VISIBLE,
                                 10,10,200,30,hwnd,
                                 (HMENU)IDC_EDIT,hInst,NULL);
    
    	
    	ShowWindow( hwnd, nWinMode );
    	UpdateWindow( hwnd );
    
    	while( GetMessage( &msg, NULL, 0, 0 ) )
    	{
    		TranslateMessage( &msg );
    		DispatchMessage( &msg );
    	}
    	
    	return msg.wParam;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch( message )
    	{
    		case WM_DESTROY: PostQuitMessage( 0 );
    		                 break;
    		default: return DefWindowProc( hwnd, message, wParam, lParam );
    			     break;
    	}
    	return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I get the error "missing ';' before ','" when compiling your code. The reason for that is you have an extraneous semicoloin at the end of your #define at the top.

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    4
    ugh I knew it would be something dumb, must have typed the ; without thinking. I never thought to check before winmain for the error, but i guess the error was in winmain as IDC_EDIT would have been replaced by a value with an ; on the end of it.
    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I send a text string to an edit control
    By marc74 in forum Windows Programming
    Replies: 5
    Last Post: 01-06-2005, 10:14 PM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  3. Restricting input to an edit control
    By bennyandthejets in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2003, 01:10 AM
  4. endless edit control
    By ZerOrDie in forum Windows Programming
    Replies: 3
    Last Post: 03-21-2003, 02:51 AM
  5. Keeping focus on an edit control ...
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 02-19-2002, 02:12 AM