@@ -1299,6 +1299,7 @@ static void test_edit_control_5(void)
1299
1299
len = SendMessageA (hWnd , WM_GETTEXTLENGTH , 0 , 0 );
1300
1300
ok (lstrlenA (str ) == len , "text shouldn't have been truncated\n" );
1301
1301
DestroyWindow (hWnd );
1302
+ DestroyWindow (parentWnd );
1302
1303
}
1303
1304
1304
1305
/* Test WM_GETTEXT processing
@@ -1423,6 +1424,8 @@ static void test_margins(void)
1423
1424
RECT old_rect , new_rect ;
1424
1425
INT old_right_margin ;
1425
1426
DWORD old_margins , new_margins ;
1427
+ LOGFONTA lf ;
1428
+ HFONT hfont ;
1426
1429
1427
1430
hwEdit = create_editcontrol (WS_BORDER | ES_AUTOHSCROLL | ES_AUTOVSCROLL , 0 );
1428
1431
@@ -1470,6 +1473,46 @@ static void test_margins(void)
1470
1473
ok (new_rect .bottom == old_rect .bottom , "The bottom border of the rectangle has changed\n" );
1471
1474
1472
1475
DestroyWindow (hwEdit );
1476
+
1477
+ memset (& lf , 0 , sizeof (lf ));
1478
+ lf .lfHeight = -11 ;
1479
+ lf .lfWeight = FW_NORMAL ;
1480
+ lf .lfCharSet = DEFAULT_CHARSET ;
1481
+ strcpy (lf .lfFaceName , "Tahoma" );
1482
+
1483
+ hfont = CreateFontIndirectA (& lf );
1484
+ ok (hfont != NULL , "got %p\n" , hfont );
1485
+
1486
+ /* Empty window rectangle */
1487
+ hwEdit = CreateWindowExA (0 , "Edit" , "A" , WS_POPUP , 0 , 0 , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , NULL , NULL );
1488
+ ok (hwEdit != NULL , "got %p\n" , hwEdit );
1489
+ GetClientRect (hwEdit , & old_rect );
1490
+ ok (IsRectEmpty (& old_rect ), "got rect %d,%d-%d,%d\n" , old_rect .left , old_rect .top , old_rect .right , old_rect .bottom );
1491
+
1492
+ old_margins = SendMessageA (hwEdit , EM_GETMARGINS , 0 , 0 );
1493
+ ok (old_margins == 0 , "got %x\n" , old_margins );
1494
+
1495
+ SendMessageA (hwEdit , WM_SETFONT , (WPARAM )hfont , MAKELPARAM (TRUE, 0 ));
1496
+ old_margins = SendMessageA (hwEdit , EM_GETMARGINS , 0 , 0 );
1497
+ ok (HIWORD (old_margins ) > 0 && LOWORD (old_margins ) > 0 , "got %d, %d\n" , HIWORD (old_margins ), LOWORD (old_margins ));
1498
+
1499
+ DestroyWindow (hwEdit );
1500
+
1501
+ /* Size is not enough to display a text, but not empty */
1502
+ hwEdit = CreateWindowExA (0 , "Edit" , "A" , WS_POPUP , 0 , 0 , 2 , 2 , NULL , NULL , NULL , NULL );
1503
+ ok (hwEdit != NULL , "got %p\n" , hwEdit );
1504
+ GetClientRect (hwEdit , & old_rect );
1505
+ ok (!IsRectEmpty (& old_rect ), "got rect %d,%d-%d,%d\n" , old_rect .left , old_rect .top , old_rect .right , old_rect .bottom );
1506
+
1507
+ old_margins = SendMessageA (hwEdit , EM_GETMARGINS , 0 , 0 );
1508
+ ok (old_margins == 0 , "got %x\n" , old_margins );
1509
+
1510
+ SendMessageA (hwEdit , WM_SETFONT , (WPARAM )hfont , MAKELPARAM (TRUE, 0 ));
1511
+ old_margins = SendMessageA (hwEdit , EM_GETMARGINS , 0 , 0 );
1512
+ ok (old_margins == 0 , "got %d, %d\n" , HIWORD (old_margins ), LOWORD (old_margins ));
1513
+
1514
+ DeleteObject (hfont );
1515
+ DestroyWindow (hwEdit );
1473
1516
}
1474
1517
1475
1518
static INT CALLBACK find_font_proc (const LOGFONTA * elf , const TEXTMETRICA * ntm , DWORD type , LPARAM lParam )
@@ -2132,8 +2175,8 @@ static void test_child_edit_wmkeydown(void)
2132
2175
destroy_child_editcontrol (hwEdit );
2133
2176
}
2134
2177
2135
- static int got_en_setfocus = 0 ;
2136
- static int got_wm_capturechanged = 0 ;
2178
+ static BOOL got_en_setfocus = FALSE ;
2179
+ static BOOL got_wm_capturechanged = FALSE ;
2137
2180
static LRESULT (CALLBACK * p_edit_proc )(HWND , UINT , WPARAM , LPARAM );
2138
2181
2139
2182
static LRESULT CALLBACK edit4_wnd_procA (HWND hWnd , UINT msg , WPARAM wParam , LPARAM lParam )
@@ -2142,14 +2185,14 @@ static LRESULT CALLBACK edit4_wnd_procA(HWND hWnd, UINT msg, WPARAM wParam, LPAR
2142
2185
case WM_COMMAND :
2143
2186
switch (HIWORD (wParam )) {
2144
2187
case EN_SETFOCUS :
2145
- got_en_setfocus = 1 ;
2188
+ got_en_setfocus = TRUE ;
2146
2189
break ;
2147
2190
}
2148
2191
break ;
2149
2192
case WM_CAPTURECHANGED :
2150
2193
if (hWnd != (HWND )lParam )
2151
2194
{
2152
- got_wm_capturechanged = 1 ;
2195
+ got_wm_capturechanged = TRUE ;
2153
2196
pEndMenu ();
2154
2197
}
2155
2198
break ;
@@ -2200,9 +2243,49 @@ static LRESULT CALLBACK edit_proc_proxy(HWND hWnd, UINT msg, WPARAM wParam, LPAR
2200
2243
return p_edit_proc (hWnd , msg , wParam , lParam );
2201
2244
}
2202
2245
2246
+ struct context_menu_messages
2247
+ {
2248
+ unsigned int wm_command , em_setsel ;
2249
+ };
2250
+
2251
+ static struct context_menu_messages menu_messages ;
2252
+
2253
+ static LRESULT CALLBACK child_edit_menu_proc (HWND hwnd , UINT msg , WPARAM wParam , LPARAM lParam )
2254
+ {
2255
+ switch (msg ) {
2256
+ case WM_ENTERIDLE :
2257
+ if (wParam == MSGF_MENU ) {
2258
+ HWND hwndMenu = (HWND )lParam ;
2259
+ MENUBARINFO mbi = { sizeof (MENUBARINFO ) };
2260
+ if (pGetMenuBarInfo (hwndMenu , OBJID_CLIENT , 0 , & mbi )) {
2261
+ MENUITEMINFOA mii = { sizeof (MENUITEMINFOA ), MIIM_STATE };
2262
+ if (GetMenuItemInfoA (mbi .hMenu , EM_SETSEL , FALSE, & mii )) {
2263
+ if (mii .fState & MFS_HILITE ) {
2264
+ PostMessageA (hwnd , WM_KEYDOWN , VK_RETURN , 0x1c0001 );
2265
+ PostMessageA (hwnd , WM_KEYUP , VK_RETURN , 0x1c0001 );
2266
+ }
2267
+ else {
2268
+ PostMessageA (hwnd , WM_KEYDOWN , VK_DOWN , 0x500001 );
2269
+ PostMessageA (hwnd , WM_KEYUP , VK_DOWN , 0x500001 );
2270
+ }
2271
+ }
2272
+ }
2273
+ }
2274
+ break ;
2275
+ case WM_COMMAND :
2276
+ menu_messages .wm_command ++ ;
2277
+ break ;
2278
+ case EM_SETSEL :
2279
+ menu_messages .em_setsel ++ ;
2280
+ break ;
2281
+ }
2282
+ return CallWindowProcA (p_edit_proc , hwnd , msg , wParam , lParam );
2283
+ }
2284
+
2203
2285
static void test_contextmenu (void )
2204
2286
{
2205
2287
HWND hwndMain , hwndEdit ;
2288
+ MSG msg ;
2206
2289
2207
2290
hwndMain = CreateWindowA (szEditTest4Class , "ET4" , WS_OVERLAPPEDWINDOW |WS_VISIBLE ,
2208
2291
0 , 0 , 200 , 200 , NULL , NULL , hinst , NULL );
@@ -2226,6 +2309,25 @@ static void test_contextmenu(void)
2226
2309
SendMessageA (hwndEdit , WM_CONTEXTMENU , (WPARAM )hwndEdit , MAKEWORD (10 , 10 ));
2227
2310
}
2228
2311
2312
+ DestroyWindow (hwndEdit );
2313
+
2314
+ hwndEdit = CreateWindowA ("EDIT" , "Test Text" ,
2315
+ WS_CHILD | WS_BORDER | WS_VISIBLE ,
2316
+ 0 , 0 , 100 , 100 ,
2317
+ hwndMain , NULL , hinst , NULL );
2318
+ memset (& menu_messages , 0 , sizeof (menu_messages ));
2319
+ p_edit_proc = (void * )SetWindowLongPtrA (hwndEdit , GWLP_WNDPROC ,
2320
+ (ULONG_PTR )child_edit_menu_proc );
2321
+
2322
+ SetFocus (hwndEdit );
2323
+ SendMessageA (hwndEdit , WM_SETTEXT , 0 , (LPARAM )"foo" );
2324
+ SendMessageA (hwndEdit , WM_CONTEXTMENU , (WPARAM )hwndEdit , MAKEWORD (-1 , -1 ));
2325
+ while (PeekMessageA (& msg , hwndEdit , 0 , 0 , PM_REMOVE )) DispatchMessageA (& msg );
2326
+ ok (menu_messages .wm_command == 0 ,
2327
+ "Expected no WM_COMMAND messages, got %d\n" , menu_messages .wm_command );
2328
+ ok (menu_messages .em_setsel == 1 ,
2329
+ "Expected 1 EM_SETSEL message, got %d\n" , menu_messages .em_setsel );
2330
+
2229
2331
DestroyWindow (hwndEdit );
2230
2332
DestroyWindow (hwndMain );
2231
2333
}
0 commit comments