HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

WM_SETTEXT is only temorary?

01-12-2007, 12:37 PM#1
SFilip
I've found a Delphi example on how to set a text inside a running process so I modified it a bit to work with the trigger editor.
Code:
function WriteEnumProc(wnd: HWND; Lines: TStrings): BOOL; stdcall;
var
  Caption: string;
  N: Integer;
begin
  Result := True;
  if GetDlgCtrlID(wnd) = 17 then begin
    for N := 0 to Lines.Count - 1 do Caption := Caption + Lines[N] + #13#10;
    SendMessage(wnd, WM_SETTEXT, Length(Caption) + 1, Integer(PChar(Caption)));
    Result := False;
  end;
end;

procedure SetTEText(Strings: TStrings);
var h: HWND;
begin
  h := FindWindow(nil, 'Trigger Editor');
  EnumChildWindows(h, @WriteEnumProc, Integer(Strings));
end;
It pretty much works fine - the text in the trigger editor indeed changes, but as soon as I select another trigger and go back to the one I injected in, the original script returns as if the program did nothing.
The only way to make the injected text inside I came up with was to manually type something after injecting - it seems that the trigger editor actually "saves" when the user types something inside the custom script box.

Well anyway my question is how to make it save the injected text without having to type something manually...is there something I'm doing wrong in the code above?

Thanks in Advance
01-12-2007, 01:00 PM#2
Vexorian
hmnn you should get the source of kattana's jasseditor since it does exactly what you want
01-12-2007, 09:07 PM#3
wyrmlord
Try forcing a key to be pressed with that window open. Like paste in all the text, make it selected by the user, and then force a key such as 'a' to be pressed and delete the last character entered (or first, I don't know). This would be my guess as to how it would work.
01-12-2007, 09:19 PM#4
Zoxc
Code:
  SendMessage(hTE, WM_SETTEXT, 0, Longint(pT));
  SendMessage(hTE, WM_CHAR, Ord(' '), 0);
  SendMessage(hTE, WM_CHAR, VK_BACK, 0);
  SetForegroundWindow(hTE);
  Windows.SetFocus(hTE);
01-13-2007, 12:08 AM#5
SFilip
I looked intro the JSP source soon after I posted this and found the part Zoxc posted.
Can't rep him or Vexorian (have to spread around), sorry...and thanks all three of you for helping.
10-06-2011, 03:16 PM#6
ioadong
A EN_CHANGE notification should be sent to the editor's parent window via WM_COMMAND after the WM_SETTEXT message.