c++ - How to change position of an OPENFILENAME dialog in Windows? -


this attempt using hook function dialog window handle. both setwindowpos() , getlasterror() return correct values, dialog window unaffected , shown @ position 0,0.

#include <windows.h> #include <iostream>  static uint_ptr callback ofnhookproc (hwnd hdlg, uint uimsg, wparam wparam, lparam lparam) {   using namespace std;   switch (uimsg) {     case wm_initdialog: {       // setwindowpos returns 1       cout << setwindowpos(hdlg, hwnd_topmost, 200, 200, 0, 0, swp_nosize ) << endl;       // getlasterror returns 0       cout << getlasterror() << endl;       break;     }   }   return 0; }  int main() {   openfilenamew ofn;   zeromemory(&ofn, sizeof(ofn));   ofn.lstructsize = sizeof(openfilenamew);   ofn.nmaxfile = max_path;   ofn.flags = ofn_explorer | ofn_filemustexist | ofn_enablehook;   ofn.lpfnhook = ofnhookproc;   getopenfilenamew(&ofn);   return 0; } 

when using ofn_explorer, have move hdlg's parent window, hwnd passed callback not actual dialog window. stated in documentation:

ofnhookproc callback function

hdlg [in]
handle child dialog box of open or save dialog box. use getparent function handle open or save dialog box.

also, should wait callback receive cdn_initdone notification, instead of wm_initdialog message.

try this:

static uint_ptr callback ofnhookproc (hwnd hdlg, uint uimsg, wparam wparam, lparam lparam) {   if ((uimsg == wm_notify) &&       (reinterpret_cast<ofnotify*>(lparam)->hdr.code == cdn_initdone))   {     setwindowpos(getparent(hdlg), hwnd_topmost, 200, 200, 0, 0, swp_nosize);   }   return 0; } 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -