Changeset 5496 for trunk/src/user32/win32wbase.cpp
- Timestamp:
- Apr 12, 2001, 4:04:54 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wbase.cpp
r5440 r5496 1 /* $Id: win32wbase.cpp,v 1.2 49 2001-04-02 17:30:58sandervl Exp $ */1 /* $Id: win32wbase.cpp,v 1.250 2001-04-12 14:04:32 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 109 109 windowNameA = NULL; 110 110 windowNameW = NULL; 111 wndNameLength = 0;112 111 113 112 userWindowBytes = NULL;; … … 545 544 if (!isUnicode) 546 545 { 547 wndNameLength = strlen(cs->lpszName);546 int wndNameLength = strlen(cs->lpszName); 548 547 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 549 548 strcpy(windowNameA,cs->lpszName); … … 555 554 else 556 555 { 557 wndNameLength = lstrlenW((LPWSTR)cs->lpszName); 558 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 559 lstrcpyWtoA(windowNameA,(LPWSTR)cs->lpszName); 556 // Wide 557 int wndNameLength = lstrlenW((LPWSTR)cs->lpszName); 560 558 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); 561 559 lstrcpyW(windowNameW,(LPWSTR)cs->lpszName); 562 windowNameA[wndNameLength] = 0; 563 windowNameW[wndNameLength] = 0; 560 windowNameW[lstrlenW((LPWSTR)cs->lpszName)] = 0; // need ? 561 // Ascii 562 LPSTR tmp = HEAP_strdupWtoA(GetProcessHeap(), 0, (LPWSTR)cs->lpszName); 563 if(tmp) { 564 long tmpLength = strlen( tmp ); 565 windowNameA = (LPSTR)_smalloc(tmpLength+1); 566 strcpy(windowNameA,tmp); 567 windowNameA[tmpLength] = 0; // need ? 568 HEAP_free(tmp); 569 } else { 570 windowNameA = (LPSTR)_smalloc(1); 571 windowNameA[0] = 0; 572 } 564 573 } 565 574 } … … 1380 1389 1381 1390 case WM_GETTEXTLENGTH: 1382 return wndNameLength; 1391 if(windowNameA) { 1392 return strlen(windowNameA); 1393 } 1394 else { 1395 return 0; 1396 } 1383 1397 1384 1398 case WM_GETTEXT: … … 1386 1400 if (!windowNameA) ((LPSTR)lParam)[0] = 0; 1387 1401 else lstrcpynA((LPSTR)lParam, windowNameA, wParam); 1388 return min( wndNameLength, wParam);1402 return min((windowNameA ? strlen(windowNameA) : 0), wParam); 1389 1403 1390 1404 case WM_SETTEXT: … … 1396 1410 if (lParam) 1397 1411 { 1398 wndNameLength = strlen(lpsz);1412 int wndNameLength = strlen(lpsz); 1399 1413 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 1400 1414 strcpy(windowNameA, lpsz); … … 1406 1420 windowNameA = NULL; 1407 1421 windowNameW = NULL; 1408 wndNameLength = 0;1409 1422 } 1410 1423 dprintf(("WM_SETTEXT of %x to %s\n", Win32Hwnd, lParam)); … … 1689 1702 sibling = GetWindow (GW_HWNDFIRST); 1690 1703 while (sibling != 0) { 1691 siblingWindow = GetWindowFromHandle (sibling); 1692 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40); 1693 1694 // find the siblings mnemonic 1695 mnemonic = '\0'; 1696 for (int i=0 ; i<nameLength ; i++) { 1697 if (nameBuffer [i] == '&') { 1698 mnemonic = nameBuffer [i+1]; 1699 if ((mnemonic >= 'a') && (mnemonic <= 'z')) 1700 mnemonic -= 32; // make it uppercase 1701 break; // stop searching 1704 siblingWindow = GetWindowFromHandle (sibling); 1705 nameLength = siblingWindow->GetWindowTextA (nameBuffer, 40); 1706 1707 // find the siblings mnemonic 1708 mnemonic = '\0'; 1709 for (int i=0 ; i<nameLength ; i++) { 1710 if (IsDBCSLeadByte(nameBuffer[i])) { 1711 // Skip DBCS 1712 continue; 1713 } 1714 if (nameBuffer [i] == '&') { 1715 mnemonic = nameBuffer [i+1]; 1716 if ((mnemonic >= 'a') && (mnemonic <= 'z')) 1717 mnemonic -= 32; // make it uppercase 1718 break; // stop searching 1719 } 1702 1720 } 1703 } 1704 1705 // key matches siblings mnemonic, send mouseclick 1706 if (mnemonic == (char) wParam) { 1707 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0); 1708 } 1709 1710 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT); 1721 1722 // key matches siblings mnemonic, send mouseclick 1723 if (mnemonic == (char) wParam) { 1724 siblingWindow->SendInternalMessageA (BM_CLICK, 0, 0); 1725 } 1726 1727 sibling = siblingWindow->GetNextWindow (GW_HWNDNEXT); 1711 1728 } 1712 1729 … … 1845 1862 { 1846 1863 case WM_GETTEXTLENGTH: 1847 return wndNameLength; 1864 if(windowNameW) { 1865 return lstrlenW(windowNameW); 1866 } 1867 else return 0; 1848 1868 1849 1869 case WM_GETTEXT: … … 1851 1871 if (!windowNameW) ((LPWSTR)lParam)[0] = 0; 1852 1872 else lstrcpynW((LPWSTR)lParam,windowNameW,wParam); 1853 return min( wndNameLength,wParam);1873 return min((windowNameW ? lstrlenW(windowNameW) : 0),wParam); 1854 1874 1855 1875 case WM_SETTEXT: … … 1861 1881 if (lParam) 1862 1882 { 1863 wndNameLength = lstrlenW(lpsz); 1864 windowNameA = (LPSTR)_smalloc(wndNameLength+1); 1865 lstrcpyWtoA(windowNameA,lpsz); 1866 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); 1867 lstrcpyW(windowNameW,lpsz); 1883 // Wide 1884 int wndNameLength = lstrlenW(lpsz); 1885 windowNameW = (LPWSTR)_smalloc((wndNameLength+1)*sizeof(WCHAR)); 1886 lstrcpyW(windowNameW,lpsz); 1887 // Ascii 1888 LPSTR tmp = HEAP_strdupWtoA(GetProcessHeap(), 0, lpsz); 1889 if(tmp) { 1890 long tmpLength = strlen( tmp ); 1891 windowNameA = (LPSTR)_smalloc(tmpLength+1); 1892 strcpy(windowNameA,tmp); 1893 windowNameA[tmpLength] = 0; // need ? 1894 HEAP_free(tmp); 1895 } 1896 else { 1897 windowNameA = (LPSTR)_smalloc(1); 1898 windowNameA[0] = 0; 1899 } 1868 1900 } 1869 1901 else 1870 1902 { 1871 windowNameA = NULL; 1872 windowNameW = NULL; 1873 wndNameLength = 0; 1903 windowNameA = NULL; 1904 windowNameW = NULL; 1874 1905 } 1875 1906 dprintf(("WM_SETTEXT of %x\n",Win32Hwnd)); … … 2298 2329 //testestest 2299 2330 //temporary workaround for file dialogs with template dialog child 2300 //they don't redraw when switching directories 2331 //they don't redraw when switching directories 2301 2332 //For some reason the new child's (syslistview32) update rectangle stays 2302 2333 //empty after its parent is made visible with ShowWindow … … 3238 3269 BOOL Win32BaseWindow::hasWindowName(LPSTR wndname, BOOL fUnicode) 3239 3270 { 3240 INT len = GetWindowTextLength( );3271 INT len = GetWindowTextLength(fUnicode); 3241 3272 BOOL res; 3242 3273 3243 3274 if (wndname == NULL) 3244 return (len == 0);3275 return (len == 0); 3245 3276 3246 3277 len++; 3247 3278 if (fUnicode) 3248 3279 { 3249 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR)); 3250 3251 GetWindowTextW(text,len); 3252 res = (lstrcmpW(text,(LPWSTR)wndname) == 0); 3253 free(text); 3254 } else 3255 { 3256 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR)); 3257 3258 GetWindowTextA(text,len); 3259 res = (strcmp(text,wndname) == 0); 3260 free(text); 3280 WCHAR *text = (WCHAR*)malloc(len*sizeof(WCHAR)); 3281 3282 GetWindowTextW(text,len); 3283 res = (lstrcmpW(text,(LPWSTR)wndname) == 0); 3284 free(text); 3285 } 3286 else 3287 { 3288 CHAR *text = (CHAR*)malloc(len*sizeof(CHAR)); 3289 3290 GetWindowTextA(text,len); 3291 res = (strcmp(text,wndname) == 0); 3292 free(text); 3261 3293 } 3262 3294 … … 3267 3299 CHAR *Win32BaseWindow::getWindowNamePtrA() 3268 3300 { 3269 INT len = GetWindowTextLength( );3301 INT len = GetWindowTextLength(FALSE); 3270 3302 CHAR *text; 3271 3303 … … 3281 3313 WCHAR *Win32BaseWindow::getWindowNamePtrW() 3282 3314 { 3283 INT len = GetWindowTextLength( );3315 INT len = GetWindowTextLength(TRUE); 3284 3316 WCHAR *text; 3285 3317 … … 3301 3333 //does NOT send WM_GETTEXTLENGTH. 3302 3334 //****************************************************************************** 3303 int Win32BaseWindow::GetWindowTextLength( )3335 int Win32BaseWindow::GetWindowTextLength(BOOL fUnicode) 3304 3336 { 3305 3337 //if the destination window is created by this process, send message 3306 3338 if(dwProcessId == currentProcessId) { 3307 return SendInternalMessageA(WM_GETTEXTLENGTH,0,0); 3339 if(fUnicode) { 3340 return SendInternalMessageW(WM_GETTEXTLENGTH,0,0); 3341 } 3342 else return SendInternalMessageA(WM_GETTEXTLENGTH,0,0); 3308 3343 } 3309 3344 //else get data directory from window structure 3310 return wndNameLength; 3345 //TODO: must lock window structure.... (TODO) 3346 if(fUnicode) { 3347 if(windowNameW) { 3348 return strlenW(windowNameW); 3349 } 3350 else return 0; 3351 } 3352 else { 3353 if(windowNameA) { 3354 return strlen(windowNameA); 3355 } 3356 else return 0; 3357 } 3311 3358 } 3312 3359 //****************************************************************************** … … 3324 3371 if (!windowNameA) lpsz[0] = 0; 3325 3372 else lstrcpynA(lpsz, windowNameA, cch); 3326 return min( wndNameLength, cch);3373 return min((windowNameA ? strlen(windowNameA) : 0), cch); 3327 3374 } 3328 3375 //****************************************************************************** … … 3340 3387 if (!windowNameW) lpsz[0] = 0; 3341 3388 else lstrcpynW(lpsz, windowNameW, cch); 3342 return min( wndNameLength, cch);3389 return min((windowNameW ? strlenW(windowNameW) : 0), cch); 3343 3390 } 3344 3391 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.