c++ - Why does this dialog box close immediately after opening? -
my issue trying create opengl/win32 application , unable keep dialog box open. literally flashes if pressed cancel on right when opened. i've looked around google , found few others issue, none of solutions posted have helped me, turn stackoverflow community!
initially, wrote code dialog procedure...
lresult callback logindlgproc(hwnd hwnddlg, uint msg, wparam wparam, lparam lparam) { showwindow(hwnddlg, sw_show); // these added window show updatewindow(hwnddlg); // if chance small. switch(msg) { case wm_initdialog: return true; case wm_command: switch(wparam) { case idok: enddialog(hwnddlg, 0); return true; } break; } return false; }
i wrote actual code display box.
void displayloginbox() { logindlghwnd = null; logindlghwnd = (hwnd)dialogbox(getmodulehandle(null), makeintresource(login_dialog), app.gethandle(), reinterpret_cast<dlgproc>(logindlgproc) ); if(logindlghwnd == null) messagebox(null, null, null, mb_ok); }
app.gethandle() returns hwnd of main program. function works properly. , logindlghwnd global variable.
the actual dialog created , included well. have ideas? -celestialkey
- dialogbox not return hwnd, function not return until dialog closed, if want modeless dialog , handle, use createdialog
- the dlgproc dialogbox parameter should not require cast, change logindlgproc' lresult int_ptr
- messagebox(null, null, null, mb_ok); not display anything, needs text in 2nd parameter
it hard why dialog not stay open, should check return value of dialogbox, if 0, parent hwnd invalid, if -1, call getlasterror() more info. 1 thing try remove controls in login_dialog dialog template (if used common controls, did not call initcommoncontrols, dialog not work etc)
Comments
Post a Comment