Thread: GetDlgItemText

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    24

    GetDlgItemText

    Im using this functiuon here:

    UINT GetDlgItemText(HWND hDlg,
    int nIDDlgItem,
    LPTSTR lpString,
    int nMaxCount
    );

    I have all the parameters apart from 'int nIDDlgItem'
    I have no idea where or how to get this. I've looked at some example, I see alot of IDC_????
    I tried to look these up to no avail.

    Could someone tell how i woulg go about finding this value, or the function calls to use?

    Thanks.

  2. #2
    Banal internet user
    Join Date
    Aug 2002
    Posts
    1,380
    Use the MAKEINTRESOURCE macro... like
    Code:
    ::GetDlgItemText(hDlg, MAKEINTRESOURCE(IDC_SOMETHING), Str, StrLen);
    Where IDC_SOMETHING is the ID of the control you want to get text from

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    24
    ok i saw a post down the list, it said you can use the resourse editor, this edit box i am trying to recieve text from is an another application.
    so im not sure about how to do the equivilient, i used spy++ to see if i could see anything, i closest thing i found saw under cursor handle: IDC_SIZE which dosent work

  4. #4
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Maybe you can just use WM_GETTEXT? You don't have to specify an identifier for that.

    Also, you can retrieve the identifier using GetDlgCtrlID(). That should work.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    24
    ok, i eventually found it on MSDN, the function cant be called to retrieve text from other processes.

    the solution in case anyone has the need: is to simple copy to the the windows clipboard as all processes have access to this function

  6. #6
    Anal comment spacer DominicTrix's Avatar
    Join Date
    Apr 2002
    Posts
    120
    or, as bennyandthejets pointed out, you can use GETTEXT. If you can get the HWND of the edit box in question (p'haps using EnumWindows and EnumChildWindows) you can simply use:

    Code:
    LPCTSTR buff[MINSIZE]
    SendMessage(hEditWnd, WM_GETTEXT, MINSIZE, (LPARAM)buff);
    its true you cant use GetDlgItemText or GetWindowText accross processes, but you can use WM_GETTEXT. Its cos the former two functions have some sort of security built in - I think it was to avoid people hacking passwords in password edit boxes, which you can still do with WM_GETTEXT!!
    Last edited by DominicTrix; 09-10-2003 at 09:34 PM.
    "The most important thing about acting is honesty. If you can fake that you've got it made" - George Burns

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Characters With GetDlgItemText
    By execute in forum Windows Programming
    Replies: 4
    Last Post: 05-04-2006, 04:53 PM
  2. GetDlgItemText with a listbox
    By Brigs76 in forum C++ Programming
    Replies: 2
    Last Post: 06-09-2005, 11:22 PM
  3. Problem with GetDlgItemText()
    By face_master in forum Windows Programming
    Replies: 6
    Last Post: 05-17-2002, 12:23 AM
  4. Mad @ GetDlgItemText
    By _Unregistered_ in forum Windows Programming
    Replies: 2
    Last Post: 04-11-2002, 09:11 AM
  5. handle for getdlgitemtext (Where is it)
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 01-14-2002, 08:33 PM