Win32 import interface library, which is the main interface
int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { CPaintManagerUI: : SetInstance (hInstance); CMainFrameWnd MainWnd; MainWnd. Create (NULL, _T (" "), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE); MainWnd. CenterWindow (); MainWnd. ShowModal (); } In the main interface creates a non-modal dialog
CTestFrame * pCmd=new CTestFrame (); PTest - & gt; Init (& amp; M_PaintManager); PTest - & gt; ShowWindow (); A modal dialog box to create whatever in pTest - & gt; Init () function sends setfocuse message, the newly created a modal dialog box is always can not get the keyboard focus, must the mouse click dialog box that can be input in the Edit control, with bosses encountered a similar situation?
CodePudding user response:
Showwindow (true)
CodePudding user response:
So I use, but the result did not achieve the ideal state;
Else if (MSG) sType==DUI_MSGTYPE_WINDOWINIT) { M_PaintManager. SetFocus (m_pNameEdit, true); if (NULL !=m_pNameEdit) { //m_pNameEdit - & gt; SetFocus (); M_pNameEdit - & gt; SetSelAll (); } } CodePudding user response:
refer to the second floor of simple reply: I is such, but the results did not reach the ideal state; Else if (MSG) sType==DUI_MSGTYPE_WINDOWINIT) { M_PaintManager. SetFocus (m_pNameEdit, true); if (NULL !=m_pNameEdit) { //m_pNameEdit - & gt; SetFocus (); M_pNameEdit - & gt; SetSelAll (); } } I tried, still no focal point, the cursor is to set a success, the news of the keyboard input if it's not the mouse click interface, default is issued to the parent window CodePudding user response:
reference 1st floor zjq9931 response: showwindow (true) I told the duilib showwindow code, the default is true Void ShowWindow (bool bShow=true, bool bTakeFocus=true). Void CWindowWnd: : ShowWindow (bool bShow=true *//* and bool bTakeFocus/* */=false) { ASSERT (: : IsWindow (m_hWnd)); if( ! : : IsWindow (m_hWnd)) return; : : ShowWindow (m_hWnd, bShow? (bTakeFocus? SW_SHOWNORMAL: SW_SHOWNOACTIVATE) : SW_HIDE); } CodePudding user response:
Yiyefangzhou24 reference 4 floor response: Quote: refer to 1st floor zjq9931 response: Showwindow (true) I told the duilib showwindow code, the default is true Void ShowWindow (bool bShow=true, bool bTakeFocus=true). Void CWindowWnd: : ShowWindow (bool bShow=true *//* and bool bTakeFocus/* */=false) { ASSERT (: : IsWindow (m_hWnd)); if( ! : : IsWindow (m_hWnd)) return; : : ShowWindow (m_hWnd, bShow? (bTakeFocus? SW_SHOWNORMAL: SW_SHOWNOACTIVATE) : SW_HIDE); } Create ~ WS_EX_NOACTIVE try, here I remember before to solve the problem, if not try after showwindow call setforegroundwindow CodePudding user response:
reference 5 floor zjq9931 reply: Quote: refer to 4th floor yiyefangzhou24 response: Quote: refer to 1st floor zjq9931 response: Showwindow (true) I told the duilib showwindow code, the default is true Void ShowWindow (bool bShow=true, bool bTakeFocus=true). Void CWindowWnd: : ShowWindow (bool bShow=true *//* and bool bTakeFocus/* */=false) { ASSERT (: : IsWindow (m_hWnd)); if( ! : : IsWindow (m_hWnd)) return; : : ShowWindow (m_hWnd, bShow? (bTakeFocus? SW_SHOWNORMAL: SW_SHOWNOACTIVATE) : SW_HIDE); } Create ~ WS_EX_NOACTIVE try, here I remember before to solve the problem, if not try after showwindow call setforegroundwindow are tried, useless, the new window has been on the front end on the feeling, the keyboard focus is not, keyboard input messages are sent to the parent window, MFC don't know if there is no this problem, a modal dialog box to create a modal dialog box, is the focus? CodePudding user response:
refer to 6th floor yiyefangzhou24 response: create ~ WS_EX_NOACTIVE try, here I remember before to solve the problem, if not try after showwindow call setforegroundwindow are tried, useless, the new window has been on the front end on the feeling, the keyboard focus is not, keyboard input messages are sent to the parent window, MFC don't know if there is no this problem, a modal dialog box to create a modal dialog box, is the focus? Keyboard message to the parent window? But not to the child window? You can't traverse to the child window message loop to leak? Because if the child window no news cycle will turn to the parent window, you can turn within the parent window is in the past, also can start the child Windows message loop, CodePudding user response:
refer to 7th floor zjq9931 response: Quote: refer to the sixth floor yiyefangzhou24 response: The create ~ WS_EX_NOACTIVE try, I remember before solve the problem here, if not try after showwindow call setforegroundwindow are tried, useless, the new window has been on the front end on the feeling, is the keyboard focus, keyboard input messages are sent to the parent window, MFC don't know if there is no this problem, a modal dialog box to create a modal dialog box, is the focus? Keyboard message to the parent window? But not to the child window? You can't traverse to the child window message loop to leak? Because if the child window no news cycle will turn to the parent window, you can turn within the parent window is in the past, also can start the child Windows message loop, According to you speak, I purposely went to see the duilib carefully the underlying source code, there is a message handler, if not, it is impossible to a new window click on the keyboard can be received after a click message LRESULT CALLBACK CWindowWnd: : __WndProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM LPARAM) { PThis CWindowWnd *=NULL; If (uMsg==WM_NCCREATE) { nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull