shadeMe
shadeMe

Reputation: 716

Modifying a window's textbox control's text

Case in point : I've got a handle to a window (for instance, using the getForegroundWindow() API function). This window's got a textbox (possibly a richtext control). Would it be possible to modify the textbox's text through an Windows API call ? More specifically, I'd like to replace its text with some of my own.

Upvotes: 0

Views: 391

Answers (1)

sean e
sean e

Reputation: 11925

Once you have the handle to the parent window, you need to get the handle to the editcontrol.

If the editcontrol has a known, consistent identifier, use GetDlgItem to get its HWND. Otherwise you will need to resort to FindWindowEx.

Once you have the HWND of the editcontrol, you can use SendMessage to send a WM_SETTEXT message it. For rich text controls, use the EM_SETTEXTEX message.

Upvotes: 2

Related Questions