PRB: OnLButtonDblClk() Not Called in Windows CE (185281)



The information in this article applies to:

  • Microsoft Visual C++ for Windows CE 1.0
  • Microsoft Visual C++ for Windows CE 2.0

This article was previously published under Q185281

SYMPTOMS

Message handlers for the WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK and WM_MBUTTONDBLCLK messages are not called for a Microsoft Foundation Classes (MFC) application running in the Windows CE emulation environment or on a handheld PC (H/PC).

CAUSE

For a window to receive the WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK, or WM_MBUTTONDBLCLK messages, the class definition of the window must include the CS_DBLCLKS style. By default, MFC does not add the CS_DBLCLKS style to the class definition that it uses for single document interface (SDI) frame windows and views on the Windows CE platform.

RESOLUTION

To work around this problem, register a new class that includes the CS_DBLCLKS style and use this new class when you create the window. You can do this in the PreCreateWindow() method of the window that handles the double-click messages, as in the following code:

Sample Code

   BOOL CtestView::PreCreateWindow(CREATESTRUCT& cs)
   {
      if (CView::PreCreateWindow(cs))
      {
         WNDCLASS wc;
         // Get the class information for the default MFC view class.
         ::GetClassInfo(AfxGetInstanceHandle(),cs.lpszClass,&wc);

         // Register a new class using the attributes of the default
         // view class, and make it the new default class.
         cs.lpszClass = AfxRegisterWndClass(wc.style | CS_DBLCLKS,
            wc.hCursor,wc.hbrBackground,wc.hIcon);
         return TRUE;
      }
      return FALSE;
   }
				

STATUS

This behavior is by design.

Modification Type:MajorLast Reviewed:10/2/2003
Keywords:kbprb KB185281