c++ - How To register a Windows Class and Find the Window using registered class -
i creating mfc application launched on click on explorer context (rightclick) menu.
but need launch single instance of application. have use findwindow , afxregisterclass
i tried register class in mfc app below:
bool cndsclientdlg::initinstance() { //register window updated on 16th nov 2010, @subhen // register our unique class name wish use wndclass wndcls; memset(&wndcls, 0, sizeof(wndclass)); //class name using findwindow later wndcls.lpszclassname = _t("ndsapp"); // register new class , exit if fails if(!afxregisterclass(&wndcls)) // [c] { return false; } }
and called method in constructor of mfc class. verified class being registered while starting application.
now in shell extension trying find class registered in mfc below:
cwnd *pwndprev = null; pwndprev = cwnd::findwindow(_t("ndsapp"),null); if(pwndprev != null) pwndprev->bringwindowtotop();
but not able cwnd window. not able figure out. please let me know if missing or doing wrong.
findwindow finds window instances not window classes. in app registers class need create window extension can find window.
(finding window class name fine; problem haven't created find.)
also, suspect if try create window based on window-class you've registered fail because you've left of wndclass structure null. see example linked better default values. (e.g. must provide wndproc , hinstance.)
Comments
Post a Comment