• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

Center Open/Save dialogs on the desktop?

Hi, I have made a DLL for calling in my Delphi application using Dev-CPP which contains the means of accessing the windows explorer style open/save dialogs.

They don't center themselves though, they end up in the top left hand corner...
0
HiImGlen
Asked:
HiImGlen
  • 3
  • 2
1 Solution
 
AmigoJackCommented:
uhm... and why dont you call it directly in delphi? you could hook the dialog and then set whatever once you got its handle. if you want i can give an example in delphi
0
 
HiImGlenAuthor Commented:
Because it takes up space and ram, I also noticed that even when free'd the dialog still used ram and it wasn't released, so I thought if I did it manually in c++ that wouldn't happen.

But the same behaviour remains, I find it a good idea to contain all the code in a dll though. Dynamically used of course.
0
 
AmigoJackCommented:
hmm... i suspect youre using something else than directly calling GetOpenFileName(). if you can say me how i can test if my pure api calls also take "space and ram" which are never released then i could test if my methods result in the same (propably it wont be enough to watch taskman when opening the dialog and when closing it, right?). in fact i never had memory problems with that.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
HiImGlenAuthor Commented:
Through Delphi as TOpenDialog/TSaveDialog or using API in Delphi and in C++ seems to have no difference, but only as the Task Manager shows, even if it isn't really there it's annoying that it displays it.

I do call a function in my c++ DLL that sets it up for two different opendialogs and executes the api or a save dialog and executes the api.

I know it never centers itself by default though, but I can't find any answers that don't pertain to MFC..........
0
 
AmigoJackCommented:
at least i know how to hook the selectfolder-dialog to resize it according to its calling window and i know the open/save dialogs also support a specific callback hook. i could try to do that in borland builder 5 to do so, or in delphi 5. both things will be pure api calls and will show you how to change the position of the dialog. if you want that - say yes :) otherwise i can spare the work
0
 
itsmeandnobodyelseCommented:
>>>> They don't center themselves though, they end up in the top left hand corner...

Did you pass the parent's window handle via the OPENFILENAME struct?

If yes, (or if passing the window's  handle doesn't help), you could provide an OFNHookProc hook procedure for an Explorer-style Open dialog box. To enable the hook procedure, set the OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the address of the hook procedure in the lpfnHook member.

The hook procedure has the following prototype:

UINT CALLBACK OFNHookProc(
  HWND hdlg,      // handle to child dialog window
  UINT uiMsg,     // message identifier
  WPARAM wParam,  // message parameter
  LPARAM lParam   // message parameter
);
 
If the procedure indicates the WM_INITDIALOG message you might get the parent window by GetParent() and the parent's window rect by GetWindowRect. Then you might move the file dialog's window by calling MoveWindow.

Regards, Alex

0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now