handle for getdlgitemtext (Where is it)

This is a discussion on handle for getdlgitemtext (Where is it) within the Windows Programming forums, part of the Platform Specific Boards category; Were do get the handle for this function? GetDlgItemText( ???, // handle of dialog box IDC_EDIT1, // identifier of control ...

  1. #1
    Unregistered
    Guest

    handle for getdlgitemtext (Where is it)

    Were do get the handle for this function?

    GetDlgItemText(
    ???, // handle of dialog box
    IDC_EDIT1, // identifier of control
    newname, // address of buffer for text
    50 // maximum size of string
    );


    Thanks..

  2. #2
    Registered User (TNT)'s Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    339
    Hey,

    You should have a function for your dialog, you should also have a handle in there like this:

    Code:
    BOOL Dialog(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    case WM_COMMAND:
    	{
    switch(wParam)
    {
    case IDOK:
    	{
    	TCHAR szBuffer[60];
    
                    GetDlgItemText(hWnd, IDC_NUM1, szBuffer, strlen(buffer);
    
    	MessageBox(hWnd, buffer, "Num1 Edit", MB_ICONOK);
    	EndDialog(hWnd, 0);
    
    	}
    	return FALSE;
    }
    Somthing like that anyway, you should adapt it for your program, as you can see the HWND param to the Dlg proc is a handle to your dialog, if you dont have a prodecure then you have phraphs created it wrong. You should call your dialog and specify it to a spefic prodecure like this:

    Code:
    DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DLG), 
    		NULL, (DLGPROC)Dialog, 0);

    There may be another way of doing this but thats how i do it and it works

    Give it a go anyway,
    TNT
    Last edited by (TNT); 01-14-2002 at 02:05 PM.
    TNT
    You Can Stop Me, But You Cant Stop Us All

  3. #3
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    Erhmm...GetDlgItemText doesn't take a handle...it takes an ID. If you didn't use a resource script to make your dialog, use GetWindowText()

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    GetDlgItemText() does take a HANDLE (HWND) and an int resource ID.

    If created on the fly (as opposed to in the resource editor) the HMENU param is cast as the control / dialog ID.

    GetForegroundWindow() will return the HWND of the window / dialog that has focus (is being used).

    For more look up "Window Functions" in MSDN SDK.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with setting text into LTEXT using Window Handle
    By jasperleeabc in forum Windows Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  4. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 05:23 AM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM

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