Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Add a WM_LBUTTONUP handler to your message map</p> <p>ie</p> <pre><code>BEGIN_MESSAGE_MAP(CYourDialog, CDialog) ON_WM_LBUTTONUP() END_MESSAGE_MAP() </code></pre> <p>It is easiest to do this by adding an event handler to the window. This is most easily done through the resource editor. Go to the properties page then go to the messages section. Then add a function for WM_LBUTTONUP.</p> <p>Finally you could fill in the function as follows.</p> <pre><code>void CYourDialog::OnLButtonUp(UINT nFlags, CPoint point) { // Grab the 3 (or more) edit control CEdit* pEdit1 = (CEdit*)GetDlgItem( ID_YOUR_EDIT_CONTROL1 ); CEdit* pEdit2 = (CEdit*)GetDlgItem( ID_YOUR_EDIT_CONTROL2 ); CEdit* pEdit3 = (CEdit*)GetDlgItem( ID_YOUR_EDIT_CONTROL3 ); // Grab the edit control window rects in screen coords. CRect edit1Rect; CRect edit2Rect; CRect edit3Rect; pEdit1-&gt;GetWindowRect( &amp;edit1Rect ); pEdit2-&gt;GetWindowRect( &amp;edit2Rect ); pEdit3-&gt;GetWindowRect( &amp;edit3Rect ); // Convert to client coordinates relative to their parent (ie this) window. ScreenToClient( edit1Rect ); ScreenToClient( edit2Rect ); ScreenToClient( edit3Rect ); // Test if the point passed in to this function is in the control's rectangle. const BOOL bEnable1 = edit1Rect.PtInRect( point ); const BOOL bEnable2 = edit2Rect.PtInRect( point ); const BOOL bEnable3 = edit3Rect.PtInRect( point ); // Enable the window that was clicked on and disable the others. pEdit1-&gt;EnableWindow( bEnable1 ); pEdit2-&gt;EnableWindow( bEnable2 ); pEdit3-&gt;EnableWindow( bEnable3 ); // Set keyboard focus to the relevant control if ( bEnable1 ) { pEdit1-&gt;SetFocus(); } else if ( bEnable1 ) { pEdit2-&gt;SetFocus(); } else if ( bEnable1 ) { pEdit3-&gt;SetFocus(); } CDialog::OnLButtonUp(nFlags, point); } </code></pre> <p>This will, essentially, hit test and if the hit test is in an edit window it will enable it, disable the others and give it keyboard focus.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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