0

This is a minor, but annoying issue, and I don't understand why MS have seemingly made it so complicated!

I've created a customised CFileDialog-derived class for opening image files using the 'new' IFileDialog, IFileDialogEvents and IFileDialogControlEvents interfaces. It is all working as intended with my custom controls added (though the lack of control re where these go is a secondary annoying issue!).

The problem is, the dialog will not display centred in my application window, no matter what I try to do. There is also no OnInitDone or OnInitDialog I can use to reposition it.

Firstly, why is it not centred in the window I specified as the parent / owner? Secondly, why is it so difficult / impossible to reposition it after the fact?

I don't know how relevant it is but this is how I set it up:

COpenImageFileDialog ifd(TRUE, JPG_EXT, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, IMAGE_FILTER, AfxGetMainWnd());
CString sTitle = RESSTR(IDS_IMPORT_IMAGE);
ifd.m_ofn.lpstrTitle = sTitle;
ifd.m_ofn.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
ifd.m_ofn.hInstance = AfxGetInstanceHandle();
if (ifd.DoModal() == IDOK)
{
273K
  • 29,503
  • 10
  • 41
  • 64
Kyudos
  • 625
  • 4
  • 18
  • [Does this answer your question?](https://stackoverflow.com/questions/13476169/possible-to-specify-the-start-position-of-an-ifiledialog) – PaulMcKenzie Jul 05 '23 at 00:01
  • @PaulMcKenzie I mean - yes it does, thank you - but it seems ridiculous that we're forced to resort to such hacky tricks. – Kyudos Jul 05 '23 at 00:21
  • Well, you could take the solution you used and create a class derived from `CFileDialog` (maybe call it `CFileDialogEx` or something), that allows the positioning of the dialog (nothing else added, just the position setting). Then derive `COpenImageFileDialog` from `CFileDialogEx` . – PaulMcKenzie Jul 05 '23 at 02:30
  • Yeah I could - but I shouldn't really have to. The new customisation functions for CFileDialog seem half-arsed at best. – Kyudos Jul 05 '23 at 02:44

0 Answers0