(How) Can FutureWindows be used with standard file open dialogs?

I'm trying to use the tomazy FutureWindows infrastructure (see his answer to the Delphi GUI Testing and Modal Forms or the tool house at https://github.com/tomazy/DelphiUtils ), but I would like to know how and how it can be used with standard dialog boxes open windows files? They don't seem to inherit from TControl, which seems to suggest FutureWindows infra (if I didn't understand it).

What I would like to do is basically just select a file in OpenFileDialog, which opens modally with the command in my testing, but still could not figure out how to do this.

+5
source share
2 answers

Use a tool like Spy ++ to find out what the window class name is. For example, on my Windows 7 machine, the window class name for opening the system file #32770 (Dialog).

+4
source

My current solution is below:

TFutureWindows.Expect(MESSAGE_BOX_WINDOW_CLASS)
  .ExecProc(
    procedure (const AWindow: IWindow)
    var
      DlgHandle: HWND;
      FileName: string;
    begin
      FileName := ExpandFileName('myFileToUse.txt');
      DlgHandle := AWindow.GetHandle;
      Windows.SetDlgItemText(DlgHandle, 1148, PChar(FileName));
    end
    )
  .ExecSendKey(VK_RETURN);

So basically sending a message using the Windows API. Ideas (and ID 1148) were found here: http://social.msdn.microsoft.com/forums/en-US/winforms/thread/62d5db14-5497-4ceb-8af0-d7f81732e937/

Perhaps the best solutions are welcome, but for me it seems reasonably affordable, at least for now. Thanks for the comments so far!

+3
source

All Articles