Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding another VC++ Dialog causes the second one to have focus dotted rectangle around controls?
    primarykey
    data
    text
    <p>I made a Visual Studio 2012 (Professional) project that behaves unexpectedly. When I have just one dialog, no focus rectangles appear (dotted border) on controls when I use them, except after I first press TAB or ALT. When I tried to load another dialog prior to the primary one (as a splash screen), the focus dotted borders <strong>do</strong> appear on the main (second) dialog, they are already shown on the first item when the window loads. Why is this so and how do I prevent this from happening?</p> <p><img src="https://i.stack.imgur.com/fWfXm.png" alt="enter image description here"></p> <p>My only guess is that pressing ENTER or ESC causes the same kind of behavior as pressing TAB or ALT, and I always see the effects because the user has to press ENTER or ESC to close the splash screen. One would think there was a way to remove focus from a control, but that doesn't seem easy to do. I can easily set the focus to a control, but not just remove it in general.</p> <p>For those interested in sample code:</p> <hr> <p>I could show the my entire project's code but it'd be easier to test it yourself honestly. Create a new VC++ project > MFC Application, set as "Dialog based", Finish. In the Resource View, right click Dialog and "Insert Dialog". Make it something recognizably different than the main window and add least one control that can take focus. Finally, near the top of your primary .cpp file, you will find the text "// The one and only"... Under that is a line that declares the primary application object. Create a new dialog class beneath <em>that</em> line (for the "splash screen", you can see mine below*), and then within your primary application's <code>InitInstance()</code>, insert code to load the splash screen just above the part that looks something like this:</p> <pre><code>CDlg dlg; m_pMainWnd = &amp;dlg; INT_PTR nResponse = dlg.DoModal(); </code></pre> <p>The code I used to show the splash screen is:</p> <pre><code>CSplashDlg dlgSplash; dlgSplash.DoModal(); </code></pre> <p>*My code for the splash dialog:</p> <p><strong>Update:</strong> I changed my code to allow clicking the dialog first instead of pressing enter (in fact, I will at some point override pretranslatemsg() and catch ESC and ENTER. Here is my lastest code:</p> <pre><code>class CSplashDlg : public CDialogEx { public: CSplashDlg(); enum { IDD = IDD_SPLASH }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support protected: DECLARE_MESSAGE_MAP() public: afx_msg void OnLButtonUp(UINT nFlags, CPoint point); }; CSplashDlg::CSplashDlg() : CDialogEx(CSplashDlg::IDD) {} void CSplashDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CSplashDlg, CDialogEx) ON_WM_LBUTTONUP() END_MESSAGE_MAP() void CSplashDlg::OnLButtonUp(UINT nFlags, CPoint point) { EndDialog(1); CDialogEx::OnLButtonUp(nFlags, point); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload