User input edit box

This is a discussion on User input edit box within the Windows Programming forums, part of the Platform Specific Boards category; I don't understand the examples of dialogs I've seen using the search feature. Would one of you Guru's please explain ...

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    User input edit box

    I don't understand the examples of dialogs I've seen using the search feature.

    Would one of you Guru's please explain to me how to get floats or doubles from my hEditX and Y boxes to variables so that I can utilize them.

    I am beginning to think I'll never get this, or perhaps I need a different book.




    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
    
    HINSTANCE hInstGlobal;
    HWND hEdit;
    
    int APIENTRY WinMain(HINSTANCE hInstance,
    			  HINSTANCE hPrevInstance,
    			  LPSTR lpCmdLine,
    			  int nCmdShow)
    {
    	hInstGlobal = hInstance;
    
    	WNDCLASS WndClass;
    	WndClass.style = 0;
    	WndClass.cbClsExtra = 0;
    	WndClass.cbWndExtra = 0;
    	WndClass.lpfnWndProc = WndProc;
    	WndClass.hInstance = hInstance;
    	WndClass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
    	WndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
    	WndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    	WndClass.lpszMenuName = 0;
    	WndClass.lpszClassName = "WinProg";
    
    	RegisterClass(&WndClass);
    
    	HWND hWindow;
    	hWindow = CreateWindow("WinProg", "Edit Field",
    		WS_OVERLAPPEDWINDOW,
    		0,0,640,400,NULL,NULL,
    		hInstance, NULL);
    
    	ShowWindow (hWindow, nCmdShow);
    
    	UpdateWindow (hWindow);
    
    	MSG Message;
    	while (GetMessage(&Message, NULL, 0, 0))
    	{
    		DispatchMessage(&Message);
    	}
    
    	return (Message.wParam);
    }
    
    LRESULT CALLBACK WndProc (HWND hWnd, UINT uiMessage,
    						  WPARAM wParam, LPARAM lParam)
    {
    	switch(uiMessage)
    	{
    	case WM_CREATE:
    		HWND hEditX, hEditY, hButtonExit, hButtonGroupBox, hButtonXCoord, hButtonYCoord;
    
    		hButtonGroupBox = CreateWindow("BUTTON", "Center",
    			WS_CHILD | WS_VISIBLE | BS_GROUPBOX,
    			5,5,225,90,
    			hWnd, (HMENU) 6,
    			hInstGlobal, NULL);
    
    		hButtonXCoord = CreateWindow("BUTTON", "X Coord",
    			WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | ES_READONLY,		// Dont let user mess with this.
    			10,30,80, 20,
    			hWnd, (HMENU) 5,
    			hInstGlobal, NULL);
    
    		hButtonYCoord = CreateWindow("BUTTON", "Y Coord",
    			WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | ES_READONLY,		// Dont let user mess with this.
    			10,60,80, 20,
    			hWnd, (HMENU) 4,
    			hInstGlobal, NULL);
    
    		hButtonExit = CreateWindow("BUTTON","EXIT",
    			WS_CHILD | WS_VISIBLE |BS_PUSHBUTTON,
    			480,320,140,20,
    			hWnd, (HMENU) 3,
    			hInstGlobal, NULL);
    
    		hEditX = CreateWindow("EDIT","",
    			WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER | BS_DEFPUSHBUTTON,		// Only digits does this allow floats?
    			100,30,120,20,
    			hWnd, (HMENU) 2,
    			hInstGlobal, NULL);
    		hEditY = CreateWindow("EDIT","",
    			WS_CHILD | WS_VISIBLE | WS_BORDER | ES_NUMBER,
    			100,60,120,20,
    			hWnd, (HMENU) 1,
    			hInstGlobal, NULL);
    
    
    		return 0;
    
    	case WM_COMMAND:
    	if(HIWORD(wParam) == BN_CLICKED)		// BN = Button Notification.  BS_PUSHBUTTON returns BN_CLICKED
    		{
    			if(LOWORD(wParam) == 1)			// Store the Y coord. to variable.
    			{
    
    /*				char *string1;
    				string1 = new char[255];		// new float???
    				SendMessage (hEdit, WM_GETTEXT, 256,(LPARAM) string1);	*/
    												
    			}
    			if(LOWORD(wParam) == 2)			// Store the X coord. to variable.
    			{
    
    			}
    			if (LOWORD(wParam) == 3)
    			{
    				SendMessage (GetParent((HWND) lParam),	// hWnd is the handle of a window object to which the message is sent.
    					WM_DESTROY ,0 ,0);					// Msg is the value which identifies the message.
    			}											// wParam is the first parameter of the message.
    		}												// lParam is the second parameter of the message.
    		return 0;
    
    	case WM_DESTROY:
    		PostQuitMessage(0);
    		return 0;
    	default:
    	
    		return DefWindowProc (hWnd, uiMessage, wParam, lParam);
    	}
    }

  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Talking

    How about:

    GetDlgItemText(hWnd, IDC_A, buffer, sizeof(buffer) / sizeof(TCHAR));

    I found this at : http://sunlightd.virtualave.net/Windows/GUI/

    I think I shall throw away my book and just do the tutorial on this site.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  2. Storing values from Edit Box into an array
    By E_I_S in forum C++ Programming
    Replies: 10
    Last Post: 06-05-2008, 06:24 AM
  3. Creating an Edit Box (Subclassing)
    By csonx_p in forum Windows Programming
    Replies: 9
    Last Post: 05-05-2008, 06:36 AM
  4. Replies: 9
    Last Post: 02-13-2008, 01:59 PM
  5. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 06:15 PM

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