Hot Key Control: Fixes and Status Update

Robert Shearman rob at codeweavers.com
Tue Sep 21 04:14:20 CDT 2004


Changelog:
- Status update.
- Should create HOTKEY_INFO storage in WM_NCCREATE rather than in 
WM_CREATE so that we can also add the WS_EX_CLIENTEDGE style.
- Remove code that draws the client edge; it is already drawn by 
DefWindowProc.
-------------- next part --------------
Index: wine/dlls/comctl32/hotkey.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/hotkey.c,v
retrieving revision 1.29
diff -u -p -r1.29 hotkey.c
--- wine/dlls/comctl32/hotkey.c	25 Aug 2004 17:33:01 -0000	1.29
+++ wine/dlls/comctl32/hotkey.c	21 Sep 2004 09:07:27 -0000
@@ -18,8 +18,21 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * This code was audited for completeness against the documented features
+ * of Comctl32.dll version 6.0 on Sep. 21, 2004, by Robert Shearman.
+ * 
+ * Unless otherwise noted, we believe this code to be complete, as per
+ * the specification mentioned above.
+ * If you discover missing features or bugs please note them below.
+ *
  * TODO:
- *   - What are we meant to do with the WM_CHAR message?
+ *   Messages:
+ *     WM_CHAR
+ *     WM_SYSCHAR
+ *   Styles:
+ *     WS_DISABLED
+ *   Notifications:
+ *     EN_CHANGED
  */
 
 #include <stdarg.h>
@@ -99,8 +112,6 @@ HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, 
     DrawTextW(hdc, KeyName, NameLen, rc, DT_LEFT | DT_VCENTER);
     rc->left -= 2;
     rc->top--;
-    if(dwExStyle & WS_EX_CLIENTEDGE)
-	DrawEdge(hdc, rc, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
 
     /* Get the text size and position the caret accordingly */
     GetTextExtentPoint32W (hdc, KeyName, NameLen, &TextSize);
@@ -209,28 +220,18 @@ HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WP
 /* << HOTKEY_Char >> */
 
 static LRESULT
-HOTKEY_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
+HOTKEY_Create (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
 {
-    HOTKEY_INFO *infoPtr;
     TEXTMETRICW tm;
     HDC hdc;
 
-    /* allocate memory for info structure */
-    infoPtr = (HOTKEY_INFO *)Alloc (sizeof(HOTKEY_INFO));
-    SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
-
-    /* initialize info structure */
-    infoPtr->HotKey = infoPtr->InvComb = infoPtr->InvMod = infoPtr->CurrMod = 0;
-    infoPtr->CaretPos = 2;
-    infoPtr->hwndSelf = hwnd;
     infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent;
-    LoadStringW(COMCTL32_hModule, HKY_NONE, infoPtr->strNone, 15);
 
     /* get default font height */
-    hdc = GetDC (hwnd);
+    hdc = GetDC (infoPtr->hwndSelf);
     GetTextMetricsW (hdc, &tm);
     infoPtr->nHeight = tm.tmHeight;
-    ReleaseDC (hwnd, hdc);
+    ReleaseDC (infoPtr->hwndSelf, hdc);
 
     return 0;
 }
@@ -358,11 +359,24 @@ HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr
 
 
 inline static LRESULT
-HOTKEY_NCCreate (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
+HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
 {
-    DWORD dwExStyle = GetWindowLongW (infoPtr->hwndSelf, GWL_EXSTYLE);
-    SetWindowLongW (infoPtr->hwndSelf, GWL_EXSTYLE, 
+    HOTKEY_INFO *infoPtr;
+    DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
+    SetWindowLongW (hwnd, GWL_EXSTYLE, 
                     dwExStyle | WS_EX_CLIENTEDGE);
+
+    /* allocate memory for info structure */
+    infoPtr = (HOTKEY_INFO *)Alloc (sizeof(HOTKEY_INFO));
+    SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
+
+    /* initialize info structure */
+    infoPtr->HotKey = infoPtr->InvComb = infoPtr->InvMod = infoPtr->CurrMod = 0;
+    infoPtr->CaretPos = 2;
+    infoPtr->hwndSelf = hwnd;
+    LoadStringW(COMCTL32_hModule, HKY_NONE, infoPtr->strNone, 15);
+
+
     return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, wParam, lParam);
 }
 
@@ -414,7 +428,7 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg,
 {
     HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
     TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam);
-    if (!infoPtr && (uMsg != WM_CREATE))
+    if (!infoPtr && (uMsg != WM_NCCREATE))
         return DefWindowProcW (hwnd, uMsg, wParam, lParam);
     switch (uMsg)
     {
@@ -430,7 +444,7 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg,
 /*	case WM_CHAR: */
 
 	case WM_CREATE:
-	    return HOTKEY_Create (hwnd, wParam, lParam);
+	    return HOTKEY_Create (infoPtr, wParam, lParam);
 
 	case WM_DESTROY:
 	    return HOTKEY_Destroy (infoPtr, wParam, lParam);
@@ -459,7 +473,7 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg,
 	    return HOTKEY_LButtonDown (infoPtr, wParam, lParam);
 
 	case WM_NCCREATE:
-	    return HOTKEY_NCCreate (infoPtr, wParam, lParam);
+	    return HOTKEY_NCCreate (hwnd, wParam, lParam);
 
 	case WM_PAINT:
 	    HOTKEY_Paint(infoPtr, (HDC)wParam);


More information about the wine-patches mailing list