Changeset 724 for trunk/src/user32/new/win32wnd.cpp
- Timestamp:
- Aug 28, 1999, 4:09:58 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wnd.cpp
r715 r724 1 /* $Id: win32wnd.cpp,v 1.3 1 1999-08-27 17:50:56 dengertExp $ */1 /* $Id: win32wnd.cpp,v 1.32 1999-08-28 14:09:30 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Code for OS/2 … … 11 11 * Copyright 1993, 1994 Alexandre Julliard 12 12 * 13 * TODO: Not thread/process safe 13 14 * 14 15 * Project Odin Software License can be found in LICENSE.TXT … … 23 24 #include <misc.h> 24 25 #include <handlemanager.h> 26 #include <heapstring.h> 25 27 #include <win32wnd.h> 26 28 #include <spy.h> … … 71 73 fFirstShow = TRUE; 72 74 73 memset(windowNameA, 0, MAX_WINDOW_NAMELENGTH);74 memset(windowNameW, 0, MAX_WINDOW_NAMELENGTH*sizeof(WCHAR));75 windowNameA = NULL; 76 windowNameW = NULL; 75 77 wndNameLength = 0; 76 78 … … 125 127 if(userWindowLong) 126 128 free(userWindowLong); 129 if(windowNameA) { 130 free(windowNameA); 131 windowNameA = NULL; 132 } 133 if(windowNameW) { 134 free(windowNameW); 135 windowNameW = NULL; 136 } 127 137 } 128 138 //****************************************************************************** … … 249 259 nrUserWindowLong = windowClass->getExtraWndWords(); 250 260 if(nrUserWindowLong) { 251 userWindowLong = (ULONG *) malloc(nrUserWindowLong);261 userWindowLong = (ULONG *)_smalloc(nrUserWindowLong); 252 262 memset(userWindowLong, 0, nrUserWindowLong); 253 263 } … … 371 381 #endif 372 382 383 if(cs->lpszName) 384 SetWindowText((LPSTR)cs->lpszName); 385 373 386 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 374 dwOSWinStyle, dwOSFrameStyle, (char *) cs->lpszName,387 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA, 375 388 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 376 389 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, … … 985 998 { 986 999 if(isUnicode) { 987 SendInternalMessageW(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameW);1000 SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW); 988 1001 } 989 1002 else { 990 SendInternalMessageA(WM_GETTEXT, MAX_WINDOW_NAMELENGTH, (LPARAM)windowNameA);1003 SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA); 991 1004 } 992 1005 return windowNameA; … … 1656 1669 } 1657 1670 //****************************************************************************** 1658 //TODO: not complete nor correct (distinction between top-level, top-most & child windows) 1671 //TODO: 1672 //We assume (for now) that if hwndParent or hwndChildAfter are real window handles, that 1673 //the current process owns them. 1674 //****************************************************************************** 1675 HWND Win32Window::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow, 1676 BOOL fUnicode) 1677 { 1678 Win32Window *parent = GetWindowFromHandle(hwndParent); 1679 Win32Window *child = GetWindowFromHandle(hwndChildAfter); 1680 1681 if((hwndParent != OSLIB_HWND_DESKTOP && !parent) || 1682 (hwndChildAfter != 0 && !child) || 1683 (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0)) 1684 { 1685 dprintf(("Win32Window::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter)); 1686 SetLastError(ERROR_INVALID_WINDOW_HANDLE); 1687 return 0; 1688 } 1689 if(hwndParent != OSLIB_HWND_DESKTOP) 1690 {//if the current process owns the window, just do a quick search 1691 child = (Win32Window *)parent->GetFirstChild(); 1692 if(hwndChildAfter != 0) 1693 { 1694 while(child) 1695 { 1696 if(child->getWindowHandle() == hwndChildAfter) 1697 { 1698 child = (Win32Window *)child->GetNextChild(); 1699 break; 1700 } 1701 child = (Win32Window *)child->GetNextChild(); 1702 } 1703 } 1704 while(child) 1705 { 1706 if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) && 1707 (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode))) 1708 { 1709 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle())); 1710 return child->getWindowHandle(); 1711 } 1712 child = (Win32Window *)child->GetNextChild(); 1713 } 1714 } 1715 else { 1716 Win32Window *wnd; 1717 HWND henum, hwnd; 1718 1719 henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP); 1720 hwnd = OSLibWinGetNextWindow(henum); 1721 1722 while(hwnd) 1723 { 1724 HWND hwndClient; 1725 1726 wnd = GetWindowFromOS2Handle(hwnd); 1727 if(wnd == NULL) { 1728 hwndClient = OSLibWinQueryClientWindow(hwnd); 1729 if(hwndClient) wnd = GetWindowFromOS2Handle(hwndClient); 1730 } 1731 1732 if(wnd && wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) && 1733 (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode))) 1734 { 1735 OSLibWinEndEnumWindows(henum); 1736 dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle())); 1737 return wnd->getWindowHandle(); 1738 } 1739 hwnd = OSLibWinGetNextWindow(henum); 1740 } 1741 OSLibWinEndEnumWindows(henum); 1742 } 1743 SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct 1744 return 0; 1745 } 1746 //****************************************************************************** 1747 //TODO: not complete nor correct (distinction be tween top-level, top-most & child windows) 1659 1748 //****************************************************************************** 1660 1749 HWND Win32Window::GetWindow(UINT uCmd) … … 1770 1859 //****************************************************************************** 1771 1860 //****************************************************************************** 1861 BOOL Win32Window::hasWindowName(LPSTR wndname, BOOL fUnicode) 1862 { 1863 if(fUnicode) { 1864 return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0); 1865 } 1866 else return (strcmp(windowNameA, wndname) == 0); 1867 } 1868 //****************************************************************************** 1869 //****************************************************************************** 1772 1870 int Win32Window::GetWindowTextLengthA() 1773 1871 { … … 1782 1880 //****************************************************************************** 1783 1881 //****************************************************************************** 1784 BOOL Win32Window::SetWindowTextA(LPCSTR lpsz) 1785 { 1786 return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)lpsz); 1882 BOOL Win32Window::SetWindowText(LPSTR lpsz) 1883 { 1884 if(lpsz == NULL) 1885 return FALSE; 1886 1887 if(isUnicode == FALSE) { 1888 windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1); 1889 strcpy(windowNameA, lpsz); 1890 windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR)); 1891 lstrcpyAtoW(windowNameW, windowNameA); 1892 } 1893 else { 1894 windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR)); 1895 lstrcpyW(windowNameW, (LPWSTR)lpsz); 1896 windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1); 1897 lstrcpyWtoA(windowNameA, windowNameW); 1898 } 1899 wndNameLength = strlen(windowNameA)+1; //including 0 terminator 1900 1901 if(OS2Hwnd) 1902 return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA); 1903 1904 return TRUE; 1787 1905 } 1788 1906 //****************************************************************************** … … 1810 1928 return oldval; 1811 1929 case GWL_HWNDPARENT: 1812 return SetParent((HWND)value);1930 return SetParent((HWND)value); 1813 1931 1814 1932 case GWL_ID: … … 1895 2013 1896 2014 if(HIWORD(hwnd) != 0x6800) { 1897 return NULL;2015 return NULL; 1898 2016 } 1899 2017 1900 2018 if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) { 1901 return window;2019 return window; 1902 2020 } 1903 2021 else return NULL; … … 1914 2032 1915 2033 if(win32wnd && CheckMagicDword(magic)) { 1916 return win32wnd;2034 return win32wnd; 1917 2035 } 1918 2036 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.