Automatically enter text in a dialog box

This is a discussion on Automatically enter text in a dialog box within the Windows Programming forums, part of the Platform Specific Boards category; Hi all, Is there any API that will enable me to enter a string in the text area of a ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    39

    Automatically enter text in a dialog box

    Hi all,

    Is there any API that will enable me to enter a string in the text area of a dialog box?
    As shown in the attached figure, I would like to enter the text c:\temp.ps in the text area as and when the dialog appears. I heard it is possible using SetText() but it doesn't seem very clear in MSDN if it really is possible that way. Is anybody aware of any possible method?

    Also, after the text is entered, I would like to enter the OK button in a similar manner

    Thanks
    Attached Images Attached Images  

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    SetDlgItemText or get a handle to the edit control and send WM_SETTEXT.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    39
    Quote Originally Posted by Quantum1024
    SetDlgItemText or get a handle to the edit control and send WM_SETTEXT.
    The window is not created by me, so I don't have the handle to the edit control (only the handle to window). Can I still use SetDlgItemText?

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    If you have the control ID of the edit box then you should still be able to use SendDlgItemText. You could aslo use FindWindowEx to get the edit control handle.

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    39
    Quote Originally Posted by Quantum1024
    If you have the control ID of the edit box then you should still be able to use SendDlgItemText. You could aslo use FindWindowEx to get the edit control handle.
    I used the FindWindowEx to get the handle of the edit text box, but what I actually need to enter a text in it is its ID which is of type int. How do I find this ID then?

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    If you have the handle of the edit control then you can use SendMessage to send the WM_SETTEXT message. I don't know which function returns an ID from a handle value.

  7. #7
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Quote Originally Posted by leojose
    I used the FindWindowEx to get the handle of the edit text box, but what I actually need to enter a text in it is its ID which is of type int. How do I find this ID then?
    GetDlgCtrlID.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 10:06 AM
  2. Display text in a Dialog Box
    By Dark_Phoenix in forum Windows Programming
    Replies: 9
    Last Post: 01-02-2009, 05:30 AM
  3. Set Printer Prior To Loading Print Dialog Box
    By Beaner in forum Windows Programming
    Replies: 3
    Last Post: 10-10-2008, 01:02 PM
  4. struct question
    By caduardo21 in forum Windows Programming
    Replies: 5
    Last Post: 01-31-2005, 03:49 PM
  5. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 07:00 PM

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