How to center a dialog in front of parent window

  • Thread starter Thread starter Farmer777
  • Start date Start date
F

Farmer777

Guest
Hello,

I have an open file dialog that currently shows in the top left corner of the parent window. How can I make it appear in the center of the parent window? Here is my code to create the dialog;

HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED|COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hr))
{
// Create the FileOpenDialog object.
IFileOpenDialog *pFileOpen;
hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL,
IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));

//...

if (SUCCEEDED(hr)) {
hr = pFileOpen->Show(GetForegroundWindow());
}
}


Thank You

Continue reading...
 
Back
Top