At 07:54 26/07/99 +1200, you wrote:
>Ok, well, With a bit of digging around, I found a solution which worked, BUT
>now when the dialog box appears, (from doing CTRL+S (save)) I cant seem to
>be able to send keys to the dialog box to enter a filename.
>The Filename Textbox has the focus by defualt but nothing happens.
>
>Anyone had tis experiance ??
>

I think you are send key to wrong window handle.  Here is a piece of my
code to simulate key presses, and it works fine.
Hope it helps.

(KeyDef : TList of TKey)
(Key    : TKey - a simple TObject with KeyFlag and KeyCode)
for i := 0 to KeyDef.Count - 1 do
  begin
  Key := KeyDef.Items[i];
  case Key.KeyFlag of
    Key_Char :
      begin
      PostMessage( Screen.ActiveControl.Handle, WM_Char, Key.KeyCode, 1 );
      if i < (KeyDef.Count-1) then
        ProcessMessages;
      end;
    Key_KeyDown :
      begin
      PostMessage( Screen.ActiveControl.Handle, WM_KEYDOWN, Key.KeyCode, 1 );
      PostMessage( Screen.ActiveControl.Handle, WM_KEYUP, Key.KeyCode,
Integer($C0000001) );
      if i < (KeyDef.Count-1) then
        ProcessMessages;
      end;
    Key_SysChar :
      begin
      PostMessage( Screen.ActiveControl.Handle, WM_SysChar, Key.KeyCode,
$20000001 );
      end;
    Key_SysKeyDown :
      begin
      PostMessage( Screen.ActiveControl.Handle, WM_SYSKEYDOWN, Key.KeyCode,
$20000001 );
      end;
    end;
  end;


--------------------------------------------------------------
Edward Tianjun Huang                    Today Software Limited
                                        97 Great South Road
Email: [EMAIL PROTECTED] (Company)     Remuera
       [EMAIL PROTECTED] (Private)    Auckland
--------------------------------------------------------------

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to