diff --git a/ANNOUNCE b/ANNOUNCE index e9201d24167..6485e586263 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,13 +1,12 @@ -This is release 960314 of Wine the MS Windows emulator. This is still a +This is release 960324 of Wine the MS Windows emulator. This is still a developer's only release. There are many bugs and many unimplemented API features. Most applications still do not work. Patches should be submitted to "julliard@lrc.epfl.ch". Please don't forget to include a ChangeLog entry. -WHAT'S NEW with Wine-960314: (see ChangeLog for details) - - Many combo and listbox fixes. - - Win32 exception handling. +WHAT'S NEW with Wine-960324: (see ChangeLog for details) + - Many Win32 and Winelib improvements. - Lots of bug fixes. See the README file in the distribution for installation instructions. @@ -16,10 +15,10 @@ Because of lags created by using mirror, this message may reach you before the release is available at the ftp sites. The sources will be available from the following locations: - sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960314.tar.gz - tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960314.tar.gz - ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960314.tar.gz - aris.com:/pub/linux/ALPHA/Wine/development/Wine-960314.tar.gz + sunsite.unc.edu:/pub/Linux/ALPHA/wine/development/Wine-960324.tar.gz + tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-960324.tar.gz + ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-960324.tar.gz + aris.com:/pub/linux/ALPHA/Wine/development/Wine-960324.tar.gz It should also be available from any site that mirrors tsx-11 or sunsite. diff --git a/ChangeLog b/ChangeLog index 93749833c24..687c40231dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,89 @@ +---------------------------------------------------------------------- +Sun Mar 24 13:13:11 1996 Alexandre Julliard + + * [include/win.h] [windows/*.c] + Replaced next, parent, child and owner handles by pointers in WND + structure. This should improve performance, and should be + reasonably safe since Microsoft did the same in Win95. + + * [include/wintypes.h] [*/*] + Redefined HANDLE to be UINT instead of a pointer for Winelib. This + allows removing a lot of unnecessary casts and NPFMTs. + + * [windows/caret.c] + Create the caret brush upon CreateCaret(); use the bitmap + dimensions for the caret. + Fixed CARET_DisplayCaret() to use PatBlt(). + +Fri Mar 22 16:00:00 1996 Anand Kumria + + * [misc/winsocket.c] + More sanity checks, fixup some erroneous return codes. + + * [documentation/winsock] + Description of how compatible the winsock is currently. + +Fri Mar 22 13:05:34 1996 Ulrich Schmid + + * [library/winmain.c] + Set `lpszCmdParam' by concatenating arguments. + + * [loader/module.c] + WinExec: accept Unix commands, use Wine emulator. + +Mon Mar 18 12:16:27 1996 Martin von Loewis + + * [if1632/kernel32.spec][win32/thread.c][include/kernel32.h] + DeleteCriticalSection, EnterCriticalSection, + InitializeCriticalSection, LeaveCriticalSection, TlsAlloc, + TlsFree, TlsGetValue, TlsSetValue: new functions. + CRITICAL_SECTION: new structure. + + * [if1632/kernel32.spec][win32/code_page.c] + WideCharToMultiByte: new function. + + * [if1632/kernel32.spec][win32/file.c] + GetFileAttributesA: new function. + + * [if1632/kernel32.spec][misc/main.c] + GetEnvironmentStringsW, FreeEnvironmentStringsA, + FreeEnvironmentStringsW: new functions. + + * [if1632/user.spec][win32/cursoricon32.c][win32/Makefile.in] + cursoricon32.c: new file. + LoadCursorA, LoadCursorW: modified implementation from LoadCursor + to WIN32_*. + LoadIconA, LoadIconW: modified implementation from LoadIconA32 + to WIN32_*. + + * [include/struct32.h] + pragma pack inserted. + CURSORICON32 structures added. + + * [include/winnls.h] + Constants CP_* and WC_* added. + + * [loader/pe_image.c] + PE_LoadModule: call PE_InitDLL with hModule rather than wpnt. + +Sun Mar 17 16:59:12 1996 Albrecht Kleine + + * [misc/commdlg.c] + Introduced hook function handling in file dialog. + Removed an unnecessary ShowWindow call in FILEDLG_WMCommand(). + +Thu Mar 14 10:50:00 1996 Thomas Sandford + + * [if1632/gdi32.spec] + Added GetNearestColor. + + * [if1632/kernel32.spec] + Added GlobalAddAtomA. + + * [win32/param32.c] + Added stackframe.h to includes. + WIN32_GlobalAddAtomA() - new function. + ---------------------------------------------------------------------- Wed Mar 13 19:46:50 1996 Alexandre Julliard diff --git a/configure b/configure index 4e497a1c4cf..361565bf7f7 100755 --- a/configure +++ b/configure @@ -2,8 +2,8 @@ # From configure.in configure.in 1.00 # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.8 -# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# Generated automatically using autoconf version 2.9 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. @@ -341,7 +341,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.8" + echo "configure generated by autoconf version 2.9" exit 0 ;; -with-* | --with-*) @@ -1089,13 +1089,15 @@ LIBS="-lICE $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1101: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1131,15 +1133,17 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1157,7 +1161,7 @@ else echo "$ac_t""no" 1>&6 fi - if test $ac_cv_lib_dnet = no; then + if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for -ldnet_stub""... $ac_c" 1>&6 ac_lib_var=`echo dnet_stub_dnet_ntoa | tr '.-/+' '___p'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then @@ -1166,15 +1170,17 @@ else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1206,15 +1212,17 @@ else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1245,15 +1253,17 @@ else ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1350,15 +1360,17 @@ else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1374: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1473,15 +1485,17 @@ else ac_save_LIBS="$LIBS" LIBS="-li386 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1513,11 +1527,11 @@ else ac_cv_c_cross=yes else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then ac_cv_c_cross=no else @@ -1538,7 +1552,7 @@ else ac_cv_c_gcc_strength_bug="yes" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then ac_cv_c_gcc_strength_bug="no" else @@ -1574,7 +1588,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; }; then +if { (eval echo configure:1614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1626,12 +1640,12 @@ if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1635: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1649: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1660,7 +1674,7 @@ if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1715,7 +1729,7 @@ if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1783: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1789,7 +1803,7 @@ if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1797,7 +1811,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1801: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1815: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1812,7 +1826,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1830,7 +1844,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1851,7 +1865,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1862,7 +1876,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -{ (eval echo configure:1866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } +{ (eval echo configure:1880: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } if test -s conftest && (./conftest; exit) 2>/dev/null; then : else @@ -1886,7 +1900,7 @@ if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -2005,7 +2019,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.8" + echo "$CONFIG_STATUS generated by autoconf version 2.9" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; diff --git a/controls/button.c b/controls/button.c index 9310643e656..80bd0f40a2d 100644 --- a/controls/button.c +++ b/controls/button.c @@ -161,8 +161,7 @@ LRESULT ButtonWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } #ifdef WINELIB32 SendMessage( GetParent(hWnd), WM_COMMAND, - MAKEWPARAM(wndPtr->wIDmenu,BN_CLICKED), - (LPARAM) hWnd ); + MAKEWPARAM(wndPtr->wIDmenu,BN_CLICKED), hWnd); #else SendMessage( GetParent(hWnd), WM_COMMAND, wndPtr->wIDmenu, MAKELPARAM(hWnd,BN_CLICKED)); @@ -199,7 +198,7 @@ LRESULT ButtonWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_GETFONT: - return (LONG) infoPtr->hFont; + return infoPtr->hFont; case WM_SETFOCUS: infoPtr->state |= BUTTON_HASFOCUS; @@ -281,8 +280,7 @@ static void PB_Paint( HWND hButton, HDC hDC, WORD action ) /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */ if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); #ifdef WINELIB32 - SendMessage( GetParent(hButton), WM_CTLCOLORBTN, - (WPARAM)hDC, (LPARAM)hButton ); + SendMessage( GetParent(hButton), WM_CTLCOLORBTN, hDC, hButton ); #else SendMessage( GetParent(hButton), WM_CTLCOLOR, (WORD)hDC, MAKELPARAM(hButton, CTLCOLOR_BTN) ); @@ -340,8 +338,8 @@ static void PB_Paint( HWND hButton, HDC hDC, WORD action ) } } - SelectObject(hDC, (HANDLE)hOldPen); - SelectObject(hDC, (HANDLE)hOldBrush); + SelectObject( hDC, hOldPen ); + SelectObject( hDC, hOldBrush ); } @@ -364,10 +362,9 @@ static void CB_Paint( HWND hWnd, HDC hDC, WORD action ) if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); #ifdef WINELIB32 /* JBP: Different in Win32 */ - hBrush = (HBRUSH) SendMessage(GetParent(hWnd), WM_CTLCOLORBTN, (WPARAM)hDC, - (LPARAM)hWnd); + hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd); #else - hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC, + hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, hDC, MAKELPARAM(hWnd, CTLCOLOR_BTN)); #endif if (action == ODA_DRAWENTIRE) FillRect(hDC, &rc, hBrush); @@ -444,9 +441,9 @@ static void GB_Paint( HWND hWnd, HDC hDC, WORD action ) if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); #ifdef WINELIB32 - SendMessage( GetParent(hWnd), WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hWnd ); + SendMessage( GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd ); #else - SendMessage( GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC, + SendMessage( GetParent(hWnd), WM_CTLCOLOR, hDC, MAKELPARAM(hWnd, CTLCOLOR_BTN)); #endif SelectObject( hDC, sysColorObjects.hpenWindowFrame ); @@ -487,8 +484,7 @@ static void UB_Paint( HWND hWnd, HDC hDC, WORD action ) if (infoPtr->hFont) SelectObject( hDC, infoPtr->hFont ); #ifdef WINELIB32 - hBrush = (HBRUSH) SendMessage(GetParent(hWnd), WM_CTLCOLORBTN, (WPARAM)hDC, - (LPARAM)hWnd); + hBrush = SendMessage( GetParent(hWnd), WM_CTLCOLORBTN, hDC, hWnd ); #else hBrush = SendMessage(GetParent(hWnd), WM_CTLCOLOR, (WORD)hDC, MAKELPARAM(hWnd, CTLCOLOR_BTN)); diff --git a/controls/combo.c b/controls/combo.c index 338c0c8887c..f637b0fe6b6 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -175,7 +175,7 @@ static LRESULT CBCreate(HWND hwnd, WPARAM wParam, LPARAM lParam) 0, 0, WIN_GetWindowInstance(hwnd), (SEGPTR)hwnd ); ShowWindow(lphc->hWndLBox, SW_HIDE); - dprintf_combo(stddeb,"Combo Creation LBox="NPFMT"!\n", lphc->hWndLBox); + dprintf_combo(stddeb,"Combo Creation LBox=%04x\n", lphc->hWndLBox); return 0; } @@ -226,8 +226,7 @@ static LRESULT CBPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) hOldFont = SelectObject(hdc, lphl->hFont); #ifdef WINELIB32 - hBrush = (HBRUSH) SendMessage(lphl->hParent, WM_CTLCOLORLISTBOX, (WPARAM)hdc, - (LPARAM)hwnd); + hBrush = SendMessage(lphl->hParent, WM_CTLCOLORLISTBOX, hdc, hwnd); #else hBrush = SendMessage(lphl->hParent, WM_CTLCOLOR, hdc, MAKELONG(hwnd, CTLCOLOR_LISTBOX)); @@ -473,7 +472,7 @@ static LRESULT CBSetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) wRet = ListBoxSetCurSel(lphl, wParam); - dprintf_combo(stddeb,"CBSetCurSel: hwnd "NPFMT" wp %x lp %lx wRet %d\n", + dprintf_combo(stddeb,"CBSetCurSel: hwnd %04x wp %x lp %lx wRet %d\n", hwnd,wParam,lParam,wRet); /* SetScrollPos(hwnd, SB_VERT, lphl->FirstVisible, TRUE);*/ InvalidateRect(hwnd, NULL, TRUE); @@ -756,8 +755,7 @@ static LRESULT CBLPaint( HWND hwnd, WPARAM wParam, LPARAM lParam ) hOldFont = SelectObject(hdc, lphl->hFont); #ifdef WINELIB32 - hBrush = (HBRUSH) SendMessage(lphl->hParent, WM_CTLCOLORLISTBOX, (WPARAM)hdc, - (LPARAM)hwnd); + hBrush = SendMessage(lphl->hParent, WM_CTLCOLORLISTBOX, hdc, hwnd); #else hBrush = SendMessage(lphl->hParent, WM_CTLCOLOR, hdc, MAKELONG(hwnd, CTLCOLOR_LISTBOX)); @@ -783,7 +781,8 @@ static LRESULT CBLPaint( HWND hwnd, WPARAM wParam, LPARAM lParam ) lpls->itemRect.left = rect.left; lpls->itemRect.right = rect.right; - dprintf_listbox(stddeb,"drawing item: %ld %d %ld %d %d\n",(LONG)rect.left,top,(LONG)rect.right,top+height,lpls->itemState); + dprintf_listbox(stddeb,"drawing item: %d %d %d %d %d\n", + rect.left,top,rect.right,top+height,lpls->itemState); if (lphl->OwnerDrawn) { ListBoxDrawItem (combohwnd, lphl, hdc, lpls, &lpls->itemRect, ODA_DRAWENTIRE, 0); if (lpls->itemState) @@ -891,7 +890,7 @@ static LRESULT CBLMouseMove( HWND hwnd, WPARAM wParam, LPARAM lParam ) ListBoxGetItemRect(lphl, wRet, &rectsel); GetClientRect(hwnd, &rect); - dprintf_combo(stddeb,"CBLMouseMove: hwnd "NPFMT" wp %x lp %lx y %d if %d wret %d %d,%d-%d,%d\n", + dprintf_combo(stddeb,"CBLMouseMove: hwnd %04x wp %x lp %lx y %d if %d wret %d %d,%d-%d,%d\n", hwnd,wParam,lParam,y,lphl->ItemFocused,wRet,rectsel.left,rectsel.top,rectsel.right,rectsel.bottom); if ((wParam & MK_LBUTTON) != 0) { @@ -997,7 +996,7 @@ LRESULT ComboLBoxWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) */ BOOL DlgDirSelectComboBox(HWND hDlg, LPSTR lpStr, INT nIDLBox) { - fprintf(stdnimp,"DlgDirSelectComboBox("NPFMT", '%s', %d) \n", + fprintf(stdnimp,"DlgDirSelectComboBox(%04x, '%s', %d) \n", hDlg, lpStr, nIDLBox); return TRUE; } @@ -1011,7 +1010,7 @@ INT DlgDirListComboBox( HWND hDlg, SEGPTR path, INT idCBox, { INT ret = 0; - dprintf_combo( stddeb,"DlgDirListComboBox("NPFMT",%08lx,%d,%d,%04X) \n", + dprintf_combo( stddeb,"DlgDirListComboBox(%04x,%08lx,%d,%d,%04X) \n", hDlg, (DWORD)path, idCBox, idStatic, wType ); if (idCBox) diff --git a/controls/edit.c b/controls/edit.c index 9eeb811de9e..4537c02acaa 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -743,14 +743,14 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) /* make sure rectangle is within window */ if (rc.left >= es->ClientWidth - 1) { - dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.left (%ld) is greater than right edge\n", - (LONG)rc.left); + dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.left (%d) is greater than right edge\n", + rc.left); return; } if (rc.right <= 0) { - dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.right (%ld) is less than left edge\n", - (LONG)rc.right); + dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.right (%d) is less than left edge\n", + rc.right); return; } if (y - es->wtop < (rc.top / es->txtht) || @@ -2008,8 +2008,8 @@ static void EDIT_SetHandleMsg(HWND hwnd, WPARAM wParam) es->textwidth = 0; es->SelBegLine = es->SelBegCol = 0; es->SelEndLine = es->SelEndCol = 0; - dprintf_edit(stddeb, "EDIT_SetHandleMsg: handle %04lx, textlen=%d\n", - (DWORD)wParam, es->textlen); + dprintf_edit(stddeb, "EDIT_SetHandleMsg: handle %04x, textlen=%d\n", + wParam, es->textlen); EDIT_BuildTextPointers(hwnd); es->PaintBkgd = TRUE; @@ -2353,8 +2353,8 @@ static void EDIT_WM_Paint(HWND hwnd) GetClientRect(hwnd, &rc); IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom); - dprintf_edit(stddeb,"WM_PAINT: rc=(%ld,%ld), (%ld,%ld)\n", (LONG)rc.left, - (LONG)rc.top, (LONG)rc.right, (LONG)rc.bottom); + dprintf_edit(stddeb,"WM_PAINT: rc=(%d,%d), (%d,%d)\n", + rc.left, rc.top, rc.right, rc.bottom); if (es->PaintBkgd) FillWindow(GetParent(hwnd), hwnd, hdc, (HBRUSH)CTLCOLOR_EDIT); diff --git a/controls/listbox.c b/controls/listbox.c index e255cbd0365..6bba90f1935 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -1253,7 +1253,7 @@ static LONG LBSetRedraw(HWND hwnd, WORD wParam, LONG lParam) { LPHEADLIST lphl = ListBoxGetStorageHeader(hwnd); - dprintf_listbox(stddeb,"ListBox WM_SETREDRAW hWnd="NPFMT" w=%04X !\n", + dprintf_listbox(stddeb,"ListBox WM_SETREDRAW hWnd=%04x w=%04x !\n", hwnd, wParam); lphl->bRedrawFlag = wParam; @@ -1365,8 +1365,8 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam) if( IntersectRect(&scratchRect,&paintRect,&lpls->itemRect) ) { - dprintf_listbox(stddeb,"LBPaint: drawing item: %ld %d %ld %d %d\n",(LONG)rect.left,top, - (LONG)rect.right,top+height,lpls->itemState); + dprintf_listbox(stddeb,"LBPaint: drawing item: %d %d %d %d %d\n", + rect.left,top,rect.right,top+height,lpls->itemState); if (lphl->OwnerDrawn && (lphl->ItemFocused == i) && GetFocus() == hwnd) { @@ -1401,7 +1401,7 @@ static LONG LBSetFocus(HWND hwnd, WORD wParam, LONG lParam) { LPHEADLIST lphl = ListBoxGetStorageHeader(hwnd); - dprintf_listbox(stddeb,"ListBox WM_SETFOCUS for "NPFMT"\n",hwnd); + dprintf_listbox(stddeb,"ListBox WM_SETFOCUS for %04x\n",hwnd); if(!(lphl->dwStyle & LBS_MULTIPLESEL) ) if( lphl->ItemsCount && lphl->ItemFocused != -1) { @@ -1429,7 +1429,7 @@ static LONG LBKillFocus(HWND hwnd, WORD wParam, LONG lParam) { LPHEADLIST lphl = ListBoxGetStorageHeader(hwnd); - dprintf_listbox(stddeb,"ListBox WM_KILLFOCUS for "NPFMT"\n",hwnd); + dprintf_listbox(stddeb,"ListBox WM_KILLFOCUS for %04x\n",hwnd); if (!(lphl->dwStyle & LBS_MULTIPLESEL)) { if( lphl->ItemsCount ) @@ -1780,7 +1780,7 @@ static LONG LBSetCaretIndex(HWND hwnd, WORD wParam, LONG lParam) if (!(lphl->dwStyle & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL) )) return 0; - dprintf_listbox(stddeb,"LBSetCaretIndex: hwnd "NPFMT" n=%i\n",hwnd,wParam); + dprintf_listbox(stddeb,"LBSetCaretIndex: hwnd %04x n=%i\n",hwnd,wParam); if (wParam >= lphl->ItemsCount) return LB_ERR; @@ -1946,9 +1946,9 @@ static LRESULT LBPassToParent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa WND* ptrWnd = WIN_FindWndPtr(hwnd); if( ptrWnd ) - if( /* !(ptrWnd->dwExStyle & WS_EX_NOPARENTNOTIFY) && */ - ptrWnd->hwndParent ) - return SendMessage(ptrWnd->hwndParent,message,wParam,lParam); + if( /* !(ptrWnd->dwExStyle & WS_EX_NOPARENTNOTIFY) && */ + ptrWnd->parent ) + return SendMessage(ptrWnd->parent->hwndSelf,message,wParam,lParam); return 0; } @@ -2044,8 +2044,7 @@ BOOL DlgDirSelect( HWND hDlg, LPSTR lpStr, INT id ) char buffer[20]; INT i; - dprintf_listbox( stddeb, "DlgDirSelect: "NPFMT" '%s' %d\n", - hDlg, lpStr, id ); + dprintf_listbox( stddeb, "DlgDirSelect: %04x '%s' %d\n", hDlg, lpStr, id ); if ((i = SendDlgItemMessage( hDlg, id, LB_GETCURSEL, 0, 0 )) == LB_ERR) return FALSE; SendDlgItemMessage( hDlg, id, LB_GETTEXT, i, MAKE_SEGPTR(buffer) ); @@ -2083,7 +2082,7 @@ INT DlgDirList( HWND hDlg, SEGPTR spec, INT idLBox, INT idStatic, UINT attrib ) ((attrib & DDL_POSTMSGS) ? PostMessage( hwnd, msg, wparam, lparam ) \ : SendMessage( hwnd, msg, wparam, lparam )) - dprintf_listbox( stddeb, "DlgDirList: "NPFMT" '%s' %d %d %04x\n", + dprintf_listbox( stddeb, "DlgDirList: %04x '%s' %d %d %04x\n", hDlg, filespec ? filespec : "NULL", idLBox, idStatic, attrib ); diff --git a/controls/menu.c b/controls/menu.c index 00c21290d5d..0457c11fba0 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -126,7 +126,7 @@ static HMENU MENU_CopySysMenu(void) } menu = (POPUPMENU*) USER_HEAP_LIN_ADDR(hMenu); menu->wFlags |= MF_SYSMENU | MF_POPUP; - dprintf_menu(stddeb,"CopySysMenu hMenu="NPFMT" !\n", hMenu); + dprintf_menu(stddeb,"CopySysMenu hMenu=%04x !\n", hMenu); return hMenu; } @@ -252,7 +252,7 @@ static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, UINT key ) } #ifdef WINELIB32 menuchar = SendMessage( hwndOwner, WM_MENUCHAR, - MAKEWPARAM(key,menu->wFlags), (LPARAM)hmenu ); + MAKEWPARAM(key,menu->wFlags), hmenu ); #else menuchar = SendMessage( hwndOwner, WM_MENUCHAR, key, MAKELONG( menu->wFlags, hmenu ) ); @@ -413,8 +413,8 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, LPPOPUPMENU lppop, if ((lprect == NULL) || (lppop == NULL)) return; if (lppop->nItems == 0) return; - dprintf_menu(stddeb,"MENU_MenuBarCalcSize left=%ld top=%ld right=%ld bottom=%ld !\n", - (LONG)lprect->left, (LONG)lprect->top, (LONG)lprect->right, (LONG)lprect->bottom); + dprintf_menu(stddeb,"MENU_MenuBarCalcSize left=%d top=%d right=%d bottom=%d\n", + lprect->left, lprect->top, lprect->right, lprect->bottom); items = (MENUITEM *)USER_HEAP_LIN_ADDR( lppop->hItems ); lppop->Width = lprect->right - lprect->left; lppop->Height = 0; @@ -495,7 +495,7 @@ static void MENU_DrawMenuItem( HWND hwnd, HDC hdc, LPMENUITEM lpitem, dis.hwndItem = hwnd; dis.hDC = hdc; dis.rcItem = lpitem->rect; - SendMessage( hwnd, WM_DRAWITEM, 0, MAKE_SEGPTR(&dis) ); + SendMessage( hwnd, WM_DRAWITEM, 0, (LPARAM)MAKE_SEGPTR(&dis) ); return; } @@ -655,7 +655,7 @@ UINT MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw) lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR( (HMENU)wndPtr->wIDmenu ); if (lppop == NULL || lprect == NULL) return SYSMETRICS_CYMENU; - dprintf_menu(stddeb,"MENU_DrawMenuBar("NPFMT", %p, %p); !\n", + dprintf_menu(stddeb,"MENU_DrawMenuBar(%04x, %p, %p); !\n", hDC, lprect, lppop); if (lppop->Height == 0) MENU_MenuBarCalcSize(hDC, lprect, lppop, hwnd); lprect->bottom = lprect->top + lppop->Height; @@ -794,7 +794,7 @@ static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, UINT wIndex ) /* FIX: Lost Info */ else SendMessage( hwndOwner, WM_MENUSELECT, MAKEWPARAM( (DWORD)hmenu, lppop->wFlags | MF_MOUSESELECT), - (LPARAM)hmenu ); + hmenu ); #else else SendMessage( hwndOwner, WM_MENUSELECT, hmenu, MAKELONG( lppop->wFlags | MF_MOUSESELECT, hmenu ) ); @@ -920,7 +920,7 @@ static BOOL MENU_SetItemData( MENUITEM *item, UINT flags, UINT id, SEGPTR data) strcpy( (char *)USER_HEAP_LIN_ADDR( hText ), str ); } } - else if (flags & MF_BITMAP) item->hText = (HANDLE)(DWORD)data; + else if (flags & MF_BITMAP) item->hText = (HANDLE)data; else if (flags & MF_OWNERDRAW) SET_OWNERDRAW_DATA( item, data ); else item->hText = 0; @@ -945,7 +945,7 @@ static MENUITEM *MENU_InsertItem( HMENU hMenu, UINT pos, UINT flags ) if (!(menu = (POPUPMENU *)USER_HEAP_LIN_ADDR(hMenu))) { - dprintf_menu( stddeb, "MENU_InsertItem: "NPFMT" not a menu handle\n", + dprintf_menu( stddeb, "MENU_InsertItem: %04x not a menu handle\n", hMenu ); return NULL; } @@ -969,7 +969,7 @@ static MENUITEM *MENU_InsertItem( HMENU hMenu, UINT pos, UINT flags ) } if (!(menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) { - dprintf_menu(stddeb,"MENU_InsertItem: "NPFMT" not a menu handle\n", + dprintf_menu(stddeb,"MENU_InsertItem: %04x not a menu handle\n", hMenu); return NULL; } @@ -1670,7 +1670,7 @@ LRESULT PopupMenuWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) CREATESTRUCT *createStruct = (CREATESTRUCT*)PTR_SEG_TO_LIN(lParam); #ifdef WINELIB32 HMENU hmenu = (HMENU) (createStruct->lpCreateParams); - SetWindowLong( hwnd, 0, (LONG)hmenu ); + SetWindowLong( hwnd, 0, hmenu ); #else HMENU hmenu = (HMENU) ((int)createStruct->lpCreateParams & 0xffff); SetWindowWord( hwnd, 0, hmenu ); @@ -1731,8 +1731,8 @@ UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, int orgX, int orgY ) */ BOOL ChangeMenu( HMENU hMenu, UINT pos, SEGPTR data, UINT id, UINT flags ) { - dprintf_menu( stddeb,"ChangeMenu: menu="NPFMT" pos=%d data=%08lx id=%04x flags=%04x\n", - hMenu, pos, data, id, flags ); + dprintf_menu( stddeb,"ChangeMenu: menu=%04x pos=%d data=%08lx id=%04x flags=%04x\n", + hMenu, pos, (DWORD)data, id, flags ); if (flags & MF_APPEND) { return AppendMenu( hMenu, flags & ~MF_APPEND, id, data ); @@ -1766,8 +1766,7 @@ INT CheckMenuItem( HMENU hMenu, UINT id, UINT flags ) MENUITEM *item; INT ret; - dprintf_menu( stddeb,"CheckMenuItem: "NPFMT" %04x %04x\n", - hMenu, id, flags ); + dprintf_menu( stddeb,"CheckMenuItem: %04x %04x %04x\n", hMenu, id, flags ); if (!(item = MENU_FindItem( &hMenu, &id, flags ))) return -1; ret = item->item_flags & MF_CHECKED; if (flags & MF_CHECKED) item->item_flags |= MF_CHECKED; @@ -1782,7 +1781,7 @@ INT CheckMenuItem( HMENU hMenu, UINT id, UINT flags ) BOOL EnableMenuItem(HMENU hMenu, UINT wItemID, UINT wFlags) { LPMENUITEM lpitem; - dprintf_menu(stddeb,"EnableMenuItem ("NPFMT", %04X, %04X) !\n", + dprintf_menu(stddeb,"EnableMenuItem (%04x, %04X, %04X) !\n", hMenu, wItemID, wFlags); if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return FALSE; @@ -1811,7 +1810,7 @@ int GetMenuString( HMENU hMenu, UINT wItemID, { LPMENUITEM lpitem; - dprintf_menu( stddeb, "GetMenuString: menu="NPFMT" item=%04x ptr=%p len=%d flags=%04x\n", + dprintf_menu( stddeb, "GetMenuString: menu=%04x item=%04x ptr=%p len=%d flags=%04x\n", hMenu, wItemID, str, nMaxSiz, wFlags ); if (!str || !nMaxSiz) return 0; str[0] = '\0'; @@ -1830,8 +1829,8 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, UINT wItemID, UINT wHilite) { LPPOPUPMENU menu; LPMENUITEM lpitem; - dprintf_menu(stddeb,"HiliteMenuItem("NPFMT", "NPFMT", %04X, %04X);\n", - hWnd, hMenu, wItemID, wHilite); + dprintf_menu(stddeb,"HiliteMenuItem(%04x, %04x, %04x, %04x);\n", + hWnd, hMenu, wItemID, wHilite); if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wHilite ))) return FALSE; if (!(menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return FALSE; if (menu->FocusedItem == wItemID) return TRUE; @@ -1847,7 +1846,7 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, UINT wItemID, UINT wHilite) UINT GetMenuState(HMENU hMenu, UINT wItemID, UINT wFlags) { LPMENUITEM lpitem; - dprintf_menu(stddeb,"GetMenuState("NPFMT", %04X, %04X);\n", + dprintf_menu(stddeb,"GetMenuState(%04x, %04x, %04x);\n", hMenu, wItemID, wFlags); if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return -1; if (lpitem->item_flags & MF_POPUP) @@ -1866,10 +1865,10 @@ UINT GetMenuState(HMENU hMenu, UINT wItemID, UINT wFlags) INT GetMenuItemCount(HMENU hMenu) { LPPOPUPMENU menu; - dprintf_menu(stddeb,"GetMenuItemCount("NPFMT");\n", hMenu); + dprintf_menu(stddeb,"GetMenuItemCount(%04x);\n", hMenu); menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu); if (menu == NULL) return (UINT)-1; - dprintf_menu(stddeb,"GetMenuItemCount("NPFMT") return %d \n", + dprintf_menu(stddeb,"GetMenuItemCount(%04x) return %d \n", hMenu, menu->nItems); return menu->nItems; } @@ -1883,7 +1882,7 @@ UINT GetMenuItemID(HMENU hMenu, int nPos) LPPOPUPMENU menu; MENUITEM *item; - dprintf_menu(stddeb,"GetMenuItemID("NPFMT", %d);\n", hMenu, nPos); + dprintf_menu(stddeb,"GetMenuItemID(%04x, %d);\n", hMenu, nPos); if (!(menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return -1; if ((nPos < 0) || (nPos >= menu->nItems)) return -1; item = (MENUITEM *) USER_HEAP_LIN_ADDR( menu->hItems ); @@ -1900,9 +1899,9 @@ BOOL InsertMenu( HMENU hMenu, UINT pos, UINT flags, UINT id, SEGPTR data ) MENUITEM *item; if (IS_STRING_ITEM(flags) && data) - dprintf_menu( stddeb, "InsertMenu: "NPFMT" %d %04x %04x '%s'\n", + dprintf_menu( stddeb, "InsertMenu: %04x %d %04x %04x '%s'\n", hMenu, pos, flags, id, (char *)PTR_SEG_TO_LIN(data) ); - else dprintf_menu( stddeb, "InsertMenu: "NPFMT" %d %04x %04x %08lx\n", + else dprintf_menu( stddeb, "InsertMenu: %04x %d %04x %04x %08lx\n", hMenu, pos, flags, id, (DWORD)data ); if (!(item = MENU_InsertItem( hMenu, pos, flags ))) return FALSE; @@ -1938,7 +1937,7 @@ BOOL RemoveMenu(HMENU hMenu, UINT nPos, UINT wFlags) { LPPOPUPMENU menu; LPMENUITEM lpitem; - dprintf_menu(stddeb,"RemoveMenu ("NPFMT", %04X, %04X) !\n", + dprintf_menu(stddeb,"RemoveMenu (%04x, %04x, %04x) !\n", hMenu, nPos, wFlags); if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE; if (!(menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return FALSE; @@ -1990,13 +1989,13 @@ BOOL ModifyMenu( HMENU hMenu, UINT pos, UINT flags, UINT id, SEGPTR data ) if (IS_STRING_ITEM(flags)) { - dprintf_menu( stddeb, "ModifyMenu: "NPFMT" %d %04x %04x '%s'\n", + dprintf_menu( stddeb, "ModifyMenu: %04x %d %04x %04x '%s'\n", hMenu, pos, flags, id, data ? (char *)PTR_SEG_TO_LIN(data) : "#NULL#"); if (!data) return FALSE; } else - dprintf_menu( stddeb, "ModifyMenu: "NPFMT" %d %04x %04x %08lx\n", + dprintf_menu( stddeb, "ModifyMenu: %04x %d %04x %04x %08lx\n", hMenu, pos, flags, id, (DWORD)data ); if (!(item = MENU_FindItem( &hMenu, &pos, flags ))) return FALSE; @@ -2032,11 +2031,11 @@ DWORD GetMenuCheckMarkDimensions() * SetMenuItemBitmaps [USER.418] */ BOOL SetMenuItemBitmaps(HMENU hMenu, UINT nPos, UINT wFlags, - HBITMAP hNewUnCheck, HBITMAP hNewCheck) + HBITMAP hNewUnCheck, HBITMAP hNewCheck) { LPMENUITEM lpitem; - dprintf_menu(stddeb,"SetMenuItemBitmaps ("NPFMT", %04X, %04X, "NPFMT", %08lX) !\n", - hMenu, nPos, wFlags, hNewCheck, (DWORD)hNewUnCheck); + dprintf_menu(stddeb,"SetMenuItemBitmaps(%04x, %04x, %04x, %04x, %04x)\n", + hMenu, nPos, wFlags, hNewCheck, hNewUnCheck); if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE; if (!hNewCheck && !hNewUnCheck) @@ -2077,7 +2076,7 @@ HMENU CreateMenu() menu->hWnd = 0; menu->hItems = 0; menu->FocusedItem = NO_SELECTED_ITEM; - dprintf_menu(stddeb,"CreateMenu // return "NPFMT"\n", hMenu); + dprintf_menu(stddeb,"CreateMenu // return %04x\n", hMenu); return hMenu; } @@ -2088,7 +2087,7 @@ HMENU CreateMenu() BOOL DestroyMenu(HMENU hMenu) { LPPOPUPMENU lppop; - dprintf_menu(stddeb,"DestroyMenu ("NPFMT") !\n", hMenu); + dprintf_menu(stddeb,"DestroyMenu (%04x) !\n", hMenu); if (hMenu == 0) return FALSE; lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu); if (!lppop || (lppop->wMagic != MENU_MAGIC)) return FALSE; @@ -2110,7 +2109,7 @@ BOOL DestroyMenu(HMENU hMenu) USER_HEAP_FREE( lppop->hItems ); } USER_HEAP_FREE( hMenu ); - dprintf_menu(stddeb,"DestroyMenu ("NPFMT") // End !\n", hMenu); + dprintf_menu(stddeb,"DestroyMenu (%04x) // End !\n", hMenu); return TRUE; } @@ -2162,18 +2161,18 @@ BOOL SetMenu(HWND hWnd, HMENU hMenu) LPPOPUPMENU lpmenu; WND * wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { - fprintf(stderr,"SetMenu("NPFMT", "NPFMT") // Bad window handle !\n", + fprintf(stderr,"SetMenu(%04x, %04x) // Bad window handle !\n", hWnd, hMenu); return FALSE; } - dprintf_menu(stddeb,"SetMenu("NPFMT", "NPFMT");\n", hWnd, hMenu); + dprintf_menu(stddeb,"SetMenu(%04x, %04x);\n", hWnd, hMenu); if (GetCapture() == hWnd) ReleaseCapture(); wndPtr->wIDmenu = (UINT)hMenu; if (hMenu != 0) { lpmenu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu); if (lpmenu == NULL) { - fprintf(stderr,"SetMenu("NPFMT", "NPFMT") // Bad menu handle !\n", + fprintf(stderr,"SetMenu(%04x, %04x) // Bad menu handle !\n", hWnd, hMenu); return FALSE; } @@ -2195,7 +2194,7 @@ HMENU GetSubMenu(HMENU hMenu, short nPos) { LPPOPUPMENU lppop; LPMENUITEM lpitem; - dprintf_menu(stddeb,"GetSubMenu ("NPFMT", %04X) !\n", hMenu, nPos); + dprintf_menu(stddeb,"GetSubMenu (%04x, %04X) !\n", hMenu, nPos); if (!(lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return 0; if ((UINT)nPos >= lppop->nItems) return 0; lpitem = (MENUITEM *) USER_HEAP_LIN_ADDR( lppop->hItems ); @@ -2211,7 +2210,7 @@ void DrawMenuBar(HWND hWnd) { WND *wndPtr; LPPOPUPMENU lppop; - dprintf_menu(stddeb,"DrawMenuBar ("NPFMT")\n", hWnd); + dprintf_menu(stddeb,"DrawMenuBar (%04x)\n", hWnd); wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr != NULL && (wndPtr->dwStyle & WS_CHILD) == 0 && wndPtr->wIDmenu != 0) { @@ -2259,11 +2258,11 @@ HMENU LoadMenu( HINSTANCE instance, SEGPTR name ) if (HIWORD(name)) { char *str = (char *)PTR_SEG_TO_LIN( name ); - dprintf_menu( stddeb, "LoadMenu("NPFMT",'%s')\n", instance, str ); + dprintf_menu( stddeb, "LoadMenu(%04x,'%s')\n", instance, str ); if (str[0] == '#') name = (SEGPTR)atoi( str + 1 ); } else - dprintf_resource(stddeb,"LoadMenu("NPFMT",%04x)\n",instance,LOWORD(name)); + dprintf_resource(stddeb,"LoadMenu(%04x,%04x)\n",instance,LOWORD(name)); if (!name) return 0; diff --git a/controls/scroll.c b/controls/scroll.c index 8f67f09e8bc..9824b3b672d 100644 --- a/controls/scroll.c +++ b/controls/scroll.c @@ -358,9 +358,8 @@ static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, int nBar, RECT *rect, if (nBar == SB_CTL) /* Only scrollbar controls send WM_CTLCOLOR */ { #ifdef WINELIB32 - HBRUSH hbrush = (HBRUSH)SendMessage( GetParent(hwnd), - WM_CTLCOLORSCROLLBAR, - (WPARAM)hdc, (LPARAM)hwnd ); + HBRUSH hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLORSCROLLBAR, + hdc, hwnd ); #else HBRUSH hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLOR, hdc, MAKELONG(hwnd, CTLCOLOR_SCROLLBAR) ); @@ -505,7 +504,7 @@ static void SCROLL_RefreshScrollBar( HWND hwnd, int nBar ) static void SCROLL_HandleKbdEvent( HWND hwnd, WORD wParam ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); - WORD msg; + WPARAM msg; switch(wParam) { @@ -521,7 +520,7 @@ static void SCROLL_HandleKbdEvent( HWND hwnd, WORD wParam ) #ifdef WINELIB32 SendMessage( GetParent(hwnd), (wndPtr->dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)msg, (LPARAM)hwnd ); + msg, hwnd ); #else SendMessage( GetParent(hwnd), (wndPtr->dwStyle & SBS_VERT) ? WM_VSCROLL : WM_HSCROLL, @@ -598,8 +597,8 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) return; /* Should never happen */ } - dprintf_scroll( stddeb, "ScrollBar Event: hwnd="NPFMT" bar=%d msg=%x pt=%ld,%ld hit=%d\n", - hwnd, nBar, msg, (LONG)pt.x, (LONG)pt.y, hittest ); + dprintf_scroll( stddeb, "ScrollBar Event: hwnd=%04x bar=%d msg=%x pt=%d,%d hit=%d\n", + hwnd, nBar, msg, pt.x, pt.y, hittest ); switch(trackHitTest) { @@ -615,7 +614,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) { #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)SB_LINEUP, (LPARAM)hwndCtl ); + SB_LINEUP, hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_LINEUP, MAKELONG( 0, hwndCtl )); @@ -638,7 +637,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) { #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)SB_PAGEUP, (LPARAM)hwndCtl ); + SB_PAGEUP, hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_PAGEUP, MAKELONG( 0, hwndCtl )); @@ -682,7 +681,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) uTrackingPos = trackThumbPos + pos - lastClickPos; #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - MAKEWPARAM(SB_THUMBTRACK,val), (LPARAM)hwndCtl ); + MAKEWPARAM(SB_THUMBTRACK,val), hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_THUMBTRACK, MAKELONG( val, hwndCtl )); @@ -703,7 +702,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) { #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)SB_PAGEDOWN, (LPARAM)hwndCtl ); + SB_PAGEDOWN, hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_PAGEDOWN, MAKELONG( 0, hwndCtl )); @@ -725,7 +724,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) { #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)SB_LINEDOWN, (LPARAM)hwndCtl ); + SB_LINEDOWN, hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_LINEDOWN, MAKELONG( 0, hwndCtl )); @@ -747,7 +746,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) trackThumbPos + lastMousePos - lastClickPos ); #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - MAKEWPARAM(SB_THUMBPOSITION,val), (LPARAM)hwndCtl ); + MAKEWPARAM(SB_THUMBPOSITION,val), hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_THUMBPOSITION, MAKELONG( val, hwndCtl ) ); @@ -756,7 +755,7 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) else #ifdef WINELIB32 SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, - (WPARAM)SB_ENDSCROLL, (LPARAM)hwndCtl ); + SB_ENDSCROLL, hwndCtl ); #else SendMessage( hwndOwner, vertical ? WM_VSCROLL : WM_HSCROLL, SB_ENDSCROLL, MAKELONG( 0, hwndCtl ) ); @@ -812,7 +811,7 @@ LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) } } if (!hUpArrow) SCROLL_LoadBitmaps(); - dprintf_scroll( stddeb, "ScrollBar creation, hwnd="NPFMT"\n", hwnd ); + dprintf_scroll( stddeb, "ScrollBar creation, hwnd=%04x\n", hwnd ); return 0; case WM_LBUTTONDOWN: @@ -898,7 +897,7 @@ void SetScrollRange(HWND hwnd, int nBar, int MinVal, int MaxVal, BOOL bRedraw) if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return; - dprintf_scroll( stddeb,"SetScrollRange hwnd="NPFMT" bar=%d min=%d max=%d\n", + dprintf_scroll( stddeb,"SetScrollRange hwnd=%04x bar=%d min=%d max=%d\n", hwnd, nBar, MinVal, MaxVal ); /* Invalid range -> range is set to (0,0) */ @@ -936,7 +935,7 @@ void ShowScrollBar( HWND hwnd, WORD wBar, BOOL fShow ) WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr) return; - dprintf_scroll( stddeb, "ShowScrollBar: hwnd="NPFMT" bar=%d on=%d\n", hwnd, wBar, fShow ); + dprintf_scroll( stddeb, "ShowScrollBar: hwnd=%04x bar=%d on=%d\n", hwnd, wBar, fShow ); switch(wBar) { @@ -1002,7 +1001,7 @@ BOOL EnableScrollBar( HWND hwnd, UINT nBar, UINT flags ) HDC hdc; if (!(infoPtr = SCROLL_GetScrollInfo( hwnd, nBar ))) return FALSE; - dprintf_scroll( stddeb, "EnableScrollBar: "NPFMT" %d %d\n", hwnd, nBar, flags ); + dprintf_scroll( stddeb, "EnableScrollBar: %04x %d %d\n", hwnd, nBar, flags ); flags &= ESB_DISABLE_BOTH; if (infoPtr->flags == flags) return FALSE; infoPtr->flags = flags; diff --git a/controls/static.c b/controls/static.c index 11adb0dfb9f..eb5196139b9 100644 --- a/controls/static.c +++ b/controls/static.c @@ -91,9 +91,9 @@ LONG StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (createStruct->lpszName) { HICON hicon = LoadIcon( createStruct->hInstance, - (SEGPTR)createStruct->lpszName ); + createStruct->lpszName ); if (!hicon) /* Try OEM icon (FIXME: is this right?) */ - hicon = LoadIcon( 0, (SEGPTR)createStruct->lpszName ); + hicon = LoadIcon( 0, createStruct->lpszName ); STATIC_SetIcon( hWnd, hicon ); } return 1; @@ -159,7 +159,7 @@ LONG StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) break; case WM_GETFONT: - return (LONG)infoPtr->hFont; + return infoPtr->hFont; case WM_NCHITTEST: return HTTRANSPARENT; @@ -168,10 +168,10 @@ LONG StaticWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DLGC_STATIC; case STM_GETICON: - return (LONG)infoPtr->hIcon; + return infoPtr->hIcon; case STM_SETICON: - lResult = (LONG)STATIC_SetIcon( hWnd, (HICON)wParam ); + lResult = STATIC_SetIcon( hWnd, (HICON)wParam ); InvalidateRect( hWnd, NULL, FALSE ); UpdateWindow( hWnd ); break; @@ -230,16 +230,14 @@ static void PaintTextfn( HWND hwnd, HDC hdc ) if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont ); #ifdef WINELIB32 - hBrush = (HBRUSH)SendMessage( wndPtr->hwndParent, WM_CTLCOLORSTATIC, - (WPARAM)hdc, (LPARAM)hwnd ); + hBrush = SendMessage( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); #else - hBrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, (WORD)hdc, + hBrush = SendMessage( GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc, MAKELONG(hwnd, CTLCOLOR_STATIC)); #endif - if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH); + if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH); FillRect(hdc, &rc, hBrush); - if (text) - DrawText(hdc, text, -1, &rc, wFormat); + if (text) DrawText( hdc, text, -1, &rc, wFormat ); } static void PaintRectfn( HWND hwnd, HDC hdc ) @@ -293,10 +291,9 @@ static void PaintIconfn( HWND hwnd, HDC hdc ) GetClientRect(hwnd, &rc); #ifdef WINELIB32 - hbrush = (HBRUSH)SendMessage( wndPtr->hwndParent, WM_CTLCOLORSTATIC, - (WPARAM)hdc, (LPARAM)hwnd ); + hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLORSTATIC, hdc, hwnd ); #else - hbrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, hdc, + hbrush = SendMessage( GetParent(hwnd), WM_CTLCOLOR, hdc, MAKELONG(hwnd, CTLCOLOR_STATIC)); #endif FillRect( hdc, &rc, hbrush ); diff --git a/documentation/winsock b/documentation/winsock new file mode 100644 index 00000000000..d8c497eb68b --- /dev/null +++ b/documentation/winsock @@ -0,0 +1,65 @@ +Winsock + +Platform 1. +Windows NT 3.51, build 1057, Service Pack 2 + +Platform 2. +Windows 3.1 with Trumpet Sockets (2.1f) + +Testing +------- + Testing was done using the Windows Sockets API Tester (WSAT), available +from rhino.microsoft.com/wsat/wsat594.exe. I found a number of tests that +would not run under Wine, some that failed under Trumpet, and others under +NT. So, I decided to use tests that at least succeeded IN FULL on all the +test platforms. + +These are only the local tests. + +Any program which makes use of the WSAAsync* calls, pretty much won't +work. Other program which work correctly will work ... mostly. Programs +which are incorrect, will probably crash and burn fairly quickly. + +I have tried to make WINESockets as close as possible to Trumpet's. + +The numbers in brackets next to each platform indicate how many tests failed, +the numbers listed on the variations line are the test that failed. + +Investigated +============ + +BINDT.TST NT (00) Trumpet (10) Wine (10) +BINDU.TST NT (00) Trumpet (10) Wine (10) +HOST.TST NT (01) Trumpet (06) Wine (38)*3 +HOSTHOST.TST NT (01)*1 Trumpet (01)*1 Wine (00) +HOSTNAME.TST NT (01) Trumpet (00) Wine (00)*2 +INET.TST NT (01) Trumpet (24)*1 Wine (01) +IOCTLT.TST NT (00) Trumpet (00) Wine (06) +IOCTLU.TST NT (00) Trumpet (00) Wine (04) +PROTO.TST NT (00) Trumpet (00) Wine (41)*3 +SERV.TST NT (00) Trumpet (00) Wine (50)*3 +SOCKETT.TST NT (01) Trumpet (00) Wine (00) +SOCKETU.TST NT (03) Trumpet (00) Wine (00) +START.TST NT (00) Trumpet (00) Wine (08)*3 +STARTL.TST NT (00)*4 Trumpet (00) Wine (00) + +STARTH.TST Wine crashed with two messages (from the program, methinks) + indicating "FREE - HEAPBADNODE - bad node in head." + +Unchecked +========= +ENOBUFST.TST ENOBUFSU.TST +GETOPTT.TST GETOPTU.TST +SETOPTT.TST SETOPTU.TST +All the client/server tests + +*1 errors in the NT and/or Trumpet were caused + by a mistake I made while configuring this test. + +*2 Wine passes these tests, because they aren't done + correctly not because it does everything correctly. + +*3 Wine crashed part way through the testing process, + hence the large value of tests failed. + +*4 NT actually supports Winsock 1.0 as well. diff --git a/files/file.c b/files/file.c index a16f929c33b..758aa64d929 100644 --- a/files/file.c +++ b/files/file.c @@ -1048,8 +1048,8 @@ WORD SetHandleCount( WORD count ) { memcpy( pdb->fileHandles, files, 20 ); #ifdef WINELIB - GlobalFree( pdb->fileHandlesPtr ); - pdb->fileHandlesPtr = pdb->fileHandles; + GlobalFree( (HGLOBAL)pdb->fileHandlesPtr ); + pdb->fileHandlesPtr = (SEGPTR)pdb->fileHandles; #else GlobalFree( GlobalHandle( SELECTOROF(pdb->fileHandlesPtr) )); pdb->fileHandlesPtr = (SEGPTR)MAKELONG( 0x18, @@ -1075,7 +1075,7 @@ WORD SetHandleCount( WORD count ) } else memcpy( newfiles, files, count ); #ifdef WINELIB - if (pdb->nbFiles > 20) GlobalFree( pdb->fileHandlesPtr ); + if (pdb->nbFiles > 20) GlobalFree( (HGLOBAL)pdb->fileHandlesPtr ); #else if (pdb->nbFiles > 20) GlobalFree( GlobalHandle( SELECTOROF(pdb->fileHandlesPtr) )); diff --git a/if1632/gdi32.spec b/if1632/gdi32.spec index 5b6d3c0ed7a..299f8333a00 100644 --- a/if1632/gdi32.spec +++ b/if1632/gdi32.spec @@ -203,7 +203,7 @@ base 1 0199 stub GetMetaFileW 0200 stub GetMetaRgn 0201 stub GetMiterLimit -0202 stub GetNearestColor +0202 stdcall GetNearestColor(long long) GetNearestColor 0203 stub GetNearestPaletteIndex 0204 stdcall GetObjectA(long long ptr) WIN32_GetObject 0205 stub GetObjectType diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec index 20f485a9c75..3388430dc68 100644 --- a/if1632/kernel32.spec +++ b/if1632/kernel32.spec @@ -71,7 +71,7 @@ base 1 0067 stub DefineDosDeviceA 0068 stub DefineDosDeviceW 0069 stub DeleteAtom -0070 stub DeleteCriticalSection +0070 stdcall DeleteCriticalSection(ptr) DeleteCriticalSection 0071 stub DeleteFileA 0072 stub DeleteFileW 0073 stub DeviceIoControl @@ -82,7 +82,7 @@ base 1 0078 stdcall DuplicateHandle(long long long ptr long long long) DuplicateHandle 0079 stub EndUpdateResourceA 0080 stub EndUpdateResourceW -0081 stub EnterCriticalSection +0081 stdcall EnterCriticalSection(ptr) EnterCriticalSection 0082 stub EnumCalendarInfoA 0083 stub EnumCalendarInfoW 0084 stub EnumDateFormatsA @@ -142,8 +142,8 @@ base 1 0138 stub FormatMessageA 0139 stub FormatMessageW 0140 stub FreeConsole -0141 stub FreeEnvironmentStringsA -0142 stub FreeEnvironmentStringsW +0141 stdcall FreeEnvironmentStringsA(ptr) FreeEnvironmentStringsA +0142 stdcall FreeEnvironmentStringsW(ptr) FreeEnvironmentStringsW 0143 stub FreeLibrary 0144 stub FreeLibraryAndExitThread 0145 stdcall FreeResource(long) FreeResource32 @@ -213,12 +213,12 @@ base 1 0209 stub GetDriveTypeW 0210 stdcall GetEnvironmentStrings() GetEnvironmentStrings 0211 stub GetEnvironmentStringsA -0212 stub GetEnvironmentStringsW +0212 stdcall GetEnvironmentStringsW() GetEnvironmentStringsW 0213 stdcall GetEnvironmentVariableA(ptr ptr long) GetEnvironmentVariableA 0214 stub GetEnvironmentVariableW 0215 stub GetExitCodeProcess 0216 stub GetExitCodeThread -0217 stub GetFileAttributesA +0217 stdcall GetFileAttributesA(ptr) GetFileAttributesA 0218 stub GetFileAttributesW 0219 stdcall GetFileInformationByHandle(long ptr) GetFileInformationByHandle 0220 stub GetFileSize @@ -315,7 +315,7 @@ base 1 0310 stub GetVolumeInformationW 0311 stub GetWindowsDirectoryA 0312 stub GetWindowsDirectoryW -0313 stub GlobalAddAtomA +0313 stdcall GlobalAddAtomA(long) WIN32_GlobalAddAtomA 0314 stub GlobalAddAtomW 0315 stdcall GlobalAlloc(long long) GlobalAlloc32 0316 stub GlobalCompact @@ -348,7 +348,7 @@ base 1 0343 stub HeapValidate 0344 stub HeapWalk 0345 stub InitAtomTable -0346 stub InitializeCriticalSection +0346 stdcall InitializeCriticalSection(ptr) InitializeCriticalSection 0347 stub InterlockedDecrement 0348 stub InterlockedExchange 0349 stub InterlockedIncrement @@ -366,7 +366,7 @@ base 1 0361 stub IsValidLocale 0362 stub LCMapStringA 0363 stub LCMapStringW -0364 stub LeaveCriticalSection +0364 stdcall LeaveCriticalSection(ptr) LeaveCriticalSection 0365 stdcall LoadLibraryA(long) LoadLibraryA 0366 stub LoadLibraryExA 0367 stub LoadLibraryExW @@ -532,10 +532,10 @@ base 1 0527 stub SystemTimeToTzSpecificLocalTime 0528 stub TerminateProcess 0529 stub TerminateThread -0530 stub TlsAlloc -0531 stub TlsFree -0532 stub TlsGetValue -0533 stub TlsSetValue +0530 stdcall TlsAlloc() TlsAlloc +0531 stdcall TlsFree(long) TlsFree +0532 stdcall TlsGetValue(long) TlsGetValue +0533 stdcall TlsSetValue(long ptr) TlsSetValue 0534 stub TransactNamedPipe 0535 stub TransmitCommChar 0536 stub TrimVirtualBuffer @@ -567,7 +567,7 @@ base 1 0562 stub WaitForSingleObjectEx 0563 stub WaitNamedPipeA 0564 stub WaitNamedPipeW -0565 stub WideCharToMultiByte +0565 stdcall WideCharToMultiByte(long long ptr long ptr long ptr ptr) WideCharToMultiByte 0566 stub WinExec 0567 stub WriteConsoleA 0568 stub WriteConsoleInputA diff --git a/if1632/user32.spec b/if1632/user32.spec index 763352f38d3..9934c77d708 100644 --- a/if1632/user32.spec +++ b/if1632/user32.spec @@ -366,13 +366,12 @@ base 1 0355 stdcall LoadAcceleratorsW(long ptr) WIN32_LoadAcceleratorsW 0356 stdcall LoadBitmapA(long ptr) WIN32_LoadBitmapA 0357 stdcall LoadBitmapW(long ptr) WIN32_LoadBitmapW -0357 stub LoadBitmapW -0358 stdcall LoadCursorA(long ptr) LoadCursor +0358 stdcall LoadCursorA(long ptr) WIN32_LoadCursorA 0359 stub LoadCursorFromFileA 0360 stub LoadCursorFromFileW -0361 stub LoadCursorW -0362 stdcall LoadIconA(long ptr) LoadIconA32 -0363 stdcall LoadIconW(long ptr) LoadIconW32 +0361 stdcall LoadCursorW(long ptr) WIN32_LoadCursorW +0362 stdcall LoadIconA(long ptr) WIN32_LoadIconA +0363 stdcall LoadIconW(long ptr) WIN32_LoadIconW 0364 stub LoadImageA 0365 stub LoadImageW 0366 stub LoadKeyboardLayoutA diff --git a/include/callback.h b/include/callback.h index 4f8b6ddb980..2a33b6fca56 100644 --- a/include/callback.h +++ b/include/callback.h @@ -81,7 +81,7 @@ extern WORD CallTo16_regs_( FARPROC func, WORD ds, WORD es, WORD bp, WORD ax, #define CallEnumObjectsProc( func, lpobj, lParam ) \ (*func)( lpobj, lParam ) #define CallEnumPropProc( func, hwnd, lpstr, data ) \ - (*func)( hwnd, lpstr, data ) + (*func)( hwnd, (LPCTSTR)(lpstr), data ) #define CallEnumTaskWndProc( func, hwnd, lParam ) \ (*func)( hwnd, lParam ) #define CallEnumWindowsProc( func, hwnd, lParam ) \ diff --git a/include/kernel32.h b/include/kernel32.h index 53e28b65a70..1b0febc14e2 100644 --- a/include/kernel32.h +++ b/include/kernel32.h @@ -133,4 +133,14 @@ typedef struct #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x0200 #define FILE_ATTRIBUTE_XACTION_WRITE 0x0400 +/* Could this type be considered opaque? */ +typedef struct { + LPVOID DebugInfo; + LONG LockCount; + LONG RecursionCount; + HANDLE OwningThread; + HANDLE LockSemaphore; + DWORD Reserved; +}CRITICAL_SECTION; + #endif /* __WINE_KERNEL32_H */ diff --git a/include/struct32.h b/include/struct32.h index 1e1de489986..ff53d2472e4 100644 --- a/include/struct32.h +++ b/include/struct32.h @@ -3,6 +3,10 @@ #define _STRUCT32_H #include "handle32.h" +#ifndef WINELIB +#pragma pack(1) +#endif + typedef struct tagRECT32 { LONG left; @@ -45,21 +49,21 @@ void STRUCT32_MINMAXINFO16to32(const MINMAXINFO*,MINMAXINFO32*); typedef struct { DWORD style; DWORD dwExtendedStyle; - WORD noOfItems; - short x; - short y; - WORD cx; - WORD cy; + WORD noOfItems WINE_PACKED; + short x WINE_PACKED; + short y WINE_PACKED; + WORD cx WINE_PACKED; + WORD cy WINE_PACKED; } DLGTEMPLATE32; typedef struct { DWORD style; DWORD dwExtendedStyle; - short x; - short y; - short cx; - short cy; - WORD id; + short x WINE_PACKED; + short y WINE_PACKED; + short cx WINE_PACKED; + short cy WINE_PACKED; + WORD id WINE_PACKED; } DLGITEMTEMPLATE32; #define CW_USEDEFAULT32 0x80000000 @@ -132,4 +136,45 @@ typedef CREATESTRUCT32 CREATESTRUCTA; void STRUCT32_CREATESTRUCT32to16(const CREATESTRUCT32*,CREATESTRUCT*); void STRUCT32_CREATESTRUCT16to32(const CREATESTRUCT*,CREATESTRUCT32*); +typedef struct { + BYTE bWidth; + BYTE bHeight; + BYTE bColorCount; + BYTE bReserved; + WORD wPlanes; + WORD wBitCount; + DWORD dwBytesInRes; + WORD wResId WINE_PACKED; + /*WORD padding; Spec is wrong, no padding here*/ +} ICONDIRENTRY32; + +typedef struct { + WORD wWidth; + WORD wHeight; + WORD wPlanes; + WORD wBitCount; + DWORD dwBytesInRes; + WORD wResId WINE_PACKED; + /*WORD padding;*/ +} CURSORDIRENTRY32; + +typedef union{ + ICONDIRENTRY32 icon; + CURSORDIRENTRY32 cursor; +} CURSORICONDIRENTRY32; + +typedef struct { + WORD idReserved; + WORD idType; + WORD idCount; + /*WORD padding;*/ + CURSORICONDIRENTRY32 idEntries[1]; +} CURSORICONDIR32; + + + +#ifndef WINELIB +#pragma pack(4) +#endif + #endif diff --git a/include/user.h b/include/user.h index dc5c68acae3..5e18d8f6ab7 100644 --- a/include/user.h +++ b/include/user.h @@ -20,7 +20,8 @@ extern BOOL USER_HeapInit(void); #define USER_HEAP_LIN_ADDR(handle) LocalLock (handle) #define USER_HEAP_SEG_ADDR(handle) LocalLock (handle) #define USER_HEAP_FREE(handle) LocalFree (handle) -#else + +#else /* WINELIB */ extern LPSTR USER_Heap; extern WORD USER_HeapSel; diff --git a/include/win.h b/include/win.h index f3b49b1326a..43b3fa6e2df 100644 --- a/include/win.h +++ b/include/win.h @@ -29,11 +29,12 @@ typedef struct tagWND { - HWND hwndNext; /* Next sibling */ - HWND hwndChild; /* First child */ + struct tagWND *next; /* Next sibling */ + struct tagWND *child; /* First child */ + struct tagWND *parent; /* Window parent (from CreateWindow) */ + struct tagWND *owner; /* Window owner */ DWORD dwMagic; /* Magic number (must be WND_MAGIC) */ - HWND hwndParent; /* Window parent (from CreateWindow) */ - HWND hwndOwner; /* Window owner */ + HWND hwndSelf; /* Handle of this window */ HCLASS hClass; /* Window class */ HANDLE hInstance; /* Window hInstance (from CreateWindow) */ RECT rectClient; /* Client area rel. to parent client area */ @@ -75,6 +76,7 @@ typedef struct tagWND /* Window functions */ extern WND *WIN_FindWndPtr( HWND hwnd ); +extern WND *WIN_GetDesktop(void); extern void WIN_DumpWindow( HWND hwnd ); extern void WIN_WalkWindows( HWND hwnd, int indent ); extern Window WIN_GetXWindow( HWND hwnd ); diff --git a/include/windows.h b/include/windows.h index 53be8c89296..fa91818c726 100644 --- a/include/windows.h +++ b/include/windows.h @@ -9,10 +9,7 @@ #pragma pack(1) #endif -#ifdef WINELIB32 -typedef struct { SHORT x,y; } POINTS; -#define MAKEPOINTS(l) (*((POINTS *)&(l))) -#else +#ifndef WINELIB32 #define MAKEPOINT(l) (*((POINT *)&(l))) #endif typedef struct { INT cx,cy; } SIZE, *LPSIZE; @@ -541,11 +538,7 @@ typedef struct tagLOGBRUSH { WORD lbStyle; COLORREF lbColor WINE_PACKED; -#ifdef WINELIB32 - LONG lbHatch; -#else - INT lbHatch; -#endif + INT lbHatch; } LOGBRUSH, *PLOGBRUSH, *NPLOGBRUSH, *LPLOGBRUSH; /* Brush styles */ @@ -2801,7 +2794,7 @@ BOOL ExtFloodFill(HDC,INT,INT,COLORREF,WORD); BOOL ExtTextOut(HDC,short,short,WORD,LPRECT,LPSTR,WORD,LPINT); HICON ExtractIcon(HINSTANCE,LPCSTR,UINT); WORD FarGetOwner(HANDLE); -void FarSetOwner(HANDLE,WORD); +void FarSetOwner(HANDLE,HANDLE); void FatalAppExit(UINT,LPCSTR); void FatalExit(int); int FillRect(HDC,LPRECT,HBRUSH); diff --git a/include/winnls.h b/include/winnls.h index 003ad2f73da..6791fd300b4 100644 --- a/include/winnls.h +++ b/include/winnls.h @@ -106,4 +106,13 @@ #define NORM_IGNORESYMBOLS 4 #define NORM_STRINGSORT 0x1000 +#define CP_ACP 0 +#define CP_OEMCP 1 + +#define WC_DEFAULTCHECK 0x00000100 +#define WC_COMPOSITECHECK 0x00000200 +#define WC_DISCARDNS 0x00000010 +#define WC_SEPCHARS 0x00000020 +#define WC_DEFAULTCHAR 0x00000040 + #endif /* __WINE_WINNLS_H */ diff --git a/include/winpos.h b/include/winpos.h index 33ee4bbc4a8..455cce8d556 100644 --- a/include/winpos.h +++ b/include/winpos.h @@ -4,8 +4,10 @@ * Copyright 1994 Alexandre Julliard */ -#ifndef WINPOS_H -#define WINPOS_H +#ifndef __WINE_WINPOS_H +#define __WINE_WINPOS_H + +#include "win.h" #define DWP_MAGIC 0x5057 /* 'WP' */ @@ -34,6 +36,6 @@ extern LONG WINPOS_SendNCCalcSize( HWND hwnd, BOOL calcValidRect, RECT *oldClientRect, WINDOWPOS *winpos, RECT *newClientRect ); extern LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ); -extern INT WINPOS_WindowFromPoint( POINT pt, HWND *phwnd ); +extern INT WINPOS_WindowFromPoint( POINT pt, WND **ppWnd ); -#endif /* WINPOS_H */ +#endif /* __WINE_WINPOS_H */ diff --git a/include/wintypes.h b/include/wintypes.h index 01df224faa6..52e054886b5 100644 --- a/include/wintypes.h +++ b/include/wintypes.h @@ -31,31 +31,19 @@ typedef unsigned short WCHAR; #ifdef WINELIB32 typedef int INT; typedef unsigned int UINT; -typedef short SHORT; -typedef LONG WPARAM; -typedef void* HANDLE; +typedef char TCHAR; /* Should probably eventually be unsigned short */ typedef void* NPVOID; typedef void* SEGPTR; -#define UIFMT "%u" -#define NPFMT "%p" -#define SPFMT "%p" - -/* Should probably eventually be unsigned short, but not now */ -typedef char TCHAR; -#else +#else /* WINELIB32 */ typedef short INT; typedef unsigned short UINT; -typedef UINT WPARAM; -typedef WORD HANDLE; +typedef char TCHAR; /* TCHAR is just char in Win16 */ typedef WORD NPVOID; typedef DWORD SEGPTR; -#define UIFMT "%hu" -#define NPFMT "%04x" -#define SPFMT "%08lx" +#endif /* WINELIB32 */ -/* TCHAR is just char in Win16 */ -typedef char TCHAR; -#endif +typedef UINT HANDLE; +typedef UINT WPARAM; typedef LONG LPARAM; typedef LONG LRESULT; typedef INT HFILE; diff --git a/ipc/dde_proc.c b/ipc/dde_proc.c index c72f37103b4..660dfd6d81a 100644 --- a/ipc/dde_proc.c +++ b/ipc/dde_proc.c @@ -386,8 +386,7 @@ int DDE_GetRemoteMessage() struct msg_dat msg_dat; BOOL was_sent; /* sent/received */ BOOL passed; - HWND hwnd; - WND *window; + WND *wndPtr; if (curr_proc_idx==-1) /* do we have DDE initialized ? */ return 0; @@ -476,16 +475,17 @@ int DDE_GetRemoteMessage() } /* iterate through all the windows */ - for (hwnd = GetTopWindow(GetDesktopWindow()); - hwnd && (window = WIN_FindWndPtr(hwnd))!=NULL ; - hwnd = window->hwndNext) { - if (window->dwStyle & WS_POPUP || window->dwStyle & WS_CAPTION) { + for (wndPtr = WIN_FindWndPtr(GetTopWindow(GetDesktopWindow())); + wndPtr != NULL; + wndPtr = wndPtr->next) + { + if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) { if (was_sent) - SendMessage( hwnd, remote_message->message, + SendMessage( wndPtr->hwndSelf, remote_message->message, remote_message->wParam, remote_message->lParam ); else - PostMessage( hwnd, remote_message->message, - remote_message->wParam, remote_message->lParam ); + PostMessage( wndPtr->hwndSelf, remote_message->message, + remote_message->wParam, remote_message->lParam ); } /* if */ } /* for */ diff --git a/ipc/wine_test_stub.c b/ipc/wine_test_stub.c index dd9499cea92..76cc9525ccb 100644 --- a/ipc/wine_test_stub.c +++ b/ipc/wine_test_stub.c @@ -97,7 +97,7 @@ WND *WIN_FindWndPtr(HWND hwnd) printf("WIN_FindWndPtr(%d)\n",hwnd); if (hwnd==0) return NULL; - win.hwndNext=0; + win.next=NULL; win.dwStyle=WS_POPUP; return &win; diff --git a/library/heap.c b/library/heap.c index c27389b4351..d942902f618 100644 --- a/library/heap.c +++ b/library/heap.c @@ -222,7 +222,7 @@ HANDLE HEAP_Alloc (WORD flags, DWORD bytes) if (flags & LMEM_ZEROINIT) memset( m, 0, bytes ); } m->Size=bytes-sizeof(HeapData); - return m+1; + return (HANDLE)(m+1); } HANDLE HEAP_Free (HANDLE hMem) @@ -253,7 +253,7 @@ HANDLE HEAP_ReAlloc(HANDLE hMem,DWORD bytes,UINT flags) if(flags & LMEM_ZEROINIT && bytes > m->Size) memset( (char*)m+sizeof(HeapData)+m->Size, 0, bytes-m->Size ); m->Size=bytes; - return m+1; + return (HANDLE)(m+1); } HANDLE LocalAlloc (WORD flags, WORD bytes) @@ -278,7 +278,7 @@ BOOL LocalInit (HANDLE segment, WORD start, WORD end) LPVOID LocalLock (HANDLE hMem) { - return hMem; + return (LPVOID)hMem; } HANDLE LocalReAlloc (HANDLE hMem, WORD new_size, WORD flags) @@ -311,7 +311,7 @@ HANDLE GlobalFree (HANDLE hMem) LPVOID GlobalLock (HGLOBAL hMem) { - return hMem; + return (LPVOID)hMem; } BOOL GlobalUnlock (HANDLE hMem) diff --git a/library/libres.c b/library/libres.c index 15a34342067..f3c4e5abec2 100644 --- a/library/libres.c +++ b/library/libres.c @@ -92,7 +92,7 @@ HGLOBAL LIBRES_LoadResource( HINSTANCE hModule, HRSRC hRsrc ) */ LPVOID LIBRES_LockResource( HGLOBAL handle ) { - return handle; + return (LPVOID)handle; } diff --git a/library/miscstubs.c b/library/miscstubs.c index 1354de1fb24..b06c6a6fb44 100644 --- a/library/miscstubs.c +++ b/library/miscstubs.c @@ -64,7 +64,7 @@ BOOL LOCAL_Unlock( WORD ds, HLOCAL handle ) WORD LOCAL_Size( WORD ds, HLOCAL handle ) { return LocalSize(handle); } -void FarSetOwner(HANDLE a, WORD b) +void FarSetOwner(HANDLE a, HANDLE b) { WINELIB_UNIMP("FarSetOwner()"); } diff --git a/library/winmain.c b/library/winmain.c index b94554eadb2..d1c0ac0dde4 100644 --- a/library/winmain.c +++ b/library/winmain.c @@ -3,6 +3,7 @@ #include #include "windows.h" #include "wine.h" +#include "xmalloc.h" extern int MAIN_Init(void); extern BOOL WIDGETS_Init(void); @@ -15,6 +16,16 @@ extern int USER_InitApp(HINSTANCE); int _WinMain (int argc, char *argv []) { HINSTANCE hInstance; + LPSTR lpszCmdParam; + int i, len = 0; + + /* Alloc szCmdParam */ + for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1; + lpszCmdParam = (LPSTR) xmalloc(len + 1); + /* Concatenate arguments */ + if (argc > 1) strcpy(lpszCmdParam, argv[1]); + else lpszCmdParam[0] = '\0'; + for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]); if(!MAIN_Init()) return 0; /* JBP: Needed for DosDrives[] structure, etc. */ hInstance = WinExec( *argv, SW_SHOWNORMAL ); @@ -29,7 +40,7 @@ int _WinMain (int argc, char *argv []) #else return WinMain (hInstance, /* hInstance */ 0, /* hPrevInstance */ - "", /* lpszCmdParam */ + lpszCmdParam, /* lpszCmdParam */ SW_NORMAL); /* nCmdShow */ #endif } diff --git a/loader/module.c b/loader/module.c index a18f1da4e45..7cece765d79 100644 --- a/loader/module.c +++ b/loader/module.c @@ -134,7 +134,7 @@ void MODULE_PrintModule( HMODULE hmodule ) /* Dump the module info */ - printf( "Module "NPFMT":\n", hmodule ); + printf( "Module %04x:\n", hmodule ); printf( "count=%d flags=%04x heap=%d stack=%d\n", pModule->count, pModule->flags, pModule->heap_size, pModule->stack_size ); @@ -154,7 +154,7 @@ void MODULE_PrintModule( HMODULE hmodule ) printf( "\nSegment table:\n" ); pSeg = NE_SEG_TABLE( pModule ); for (i = 0; i < pModule->seg_count; i++, pSeg++) - printf( "%02x: pos=%d size=%d flags=%04x minsize=%d sel="NPFMT"\n", + printf( "%02x: pos=%d size=%d flags=%04x minsize=%d sel=%04x\n", i + 1, pSeg->filepos, pSeg->size, pSeg->flags, pSeg->minsize, pSeg->selector ); @@ -264,7 +264,7 @@ int MODULE_OpenFile( HMODULE hModule ) static int cachedfd = -1; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_module( stddeb, "MODULE_OpenFile("NPFMT") cache: mod="NPFMT" fd=%d\n", + dprintf_module( stddeb, "MODULE_OpenFile(%04x) cache: mod=%04x fd=%d\n", hModule, hCachedModule, cachedfd ); if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return -1; if (hCachedModule == hModule) return cachedfd; @@ -273,7 +273,7 @@ int MODULE_OpenFile( HMODULE hModule ) name = NE_MODULE_NAME( pModule ); if (!(unixName = DOSFS_GetUnixFileName( name, TRUE )) || (cachedfd = open( unixName, O_RDONLY )) == -1) - fprintf( stderr, "MODULE_OpenFile: can't open file '%s' for module "NPFMT"\n", + fprintf( stderr, "MODULE_OpenFile: can't open file '%s' for module %04x\n", name, hModule ); dprintf_module( stddeb, "MODULE_OpenFile: opened '%s' -> %d\n", name, cachedfd ); @@ -461,7 +461,7 @@ HMODULE MODULE_LoadExeHeader( HFILE hFile, OFSTRUCT *ofs ) hModule = GlobalAlloc( GMEM_MOVEABLE | GMEM_ZEROINIT, size ); if (!hModule) return (HMODULE)11; /* invalid exe */ - FarSetOwner( hModule, (WORD)(DWORD)hModule ); + FarSetOwner( hModule, hModule ); pModule = (NE_MODULE *)GlobalLock( hModule ); memcpy( pModule, &ne_header, sizeof(NE_MODULE) ); pModule->count = 0; @@ -609,7 +609,7 @@ WORD MODULE_GetOrdinal( HMODULE hModule, char *name ) if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0; - dprintf_module( stddeb, "MODULE_GetOrdinal("NPFMT",'%s')\n", + dprintf_module( stddeb, "MODULE_GetOrdinal(%04x,'%s')\n", hModule, name ); /* First handle names of the form '#xxxx' */ @@ -1162,11 +1162,7 @@ BOOL FreeModule( HANDLE hModule ) */ HMODULE WIN16_GetModuleHandle( SEGPTR name ) { -#ifdef WINELIB32 - if (HIWORD(name) == 0) return GetExePtr( name ); -#else - if (HIWORD(name) == 0) return GetExePtr( LOWORD(name) ); -#endif + if (HIWORD(name) == 0) return GetExePtr( (HANDLE)name ); return MODULE_FindModule( PTR_SEG_TO_LIN(name) ); } @@ -1185,7 +1181,7 @@ int GetModuleUsage( HANDLE hModule ) hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return 0; - dprintf_module( stddeb, "GetModuleUsage("NPFMT"): returning %d\n", + dprintf_module( stddeb, "GetModuleUsage(%04x): returning %d\n", hModule, pModule->count ); return pModule->count; } @@ -1243,7 +1239,7 @@ HANDLE LoadLibrary( LPCSTR libname ) */ void FreeLibrary( HANDLE handle ) { - dprintf_module( stddeb,"FreeLibrary: "NPFMT"\n", handle ); + dprintf_module( stddeb,"FreeLibrary: %04x\n", handle ); FreeModule( handle ); } @@ -1258,6 +1254,7 @@ HANDLE WinExec( LPSTR lpCmdLine, WORD nCmdShow ) HANDLE handle; WORD *cmdShowPtr; char *p, *cmdline, filename[256]; + static int use_load_module = 1; if (!(cmdShowHandle = GlobalAlloc( 0, 2 * sizeof(WORD) ))) return 0; if (!(cmdLineHandle = GlobalAlloc( 0, 256 ))) return 0; @@ -1271,36 +1268,97 @@ HANDLE WinExec( LPSTR lpCmdLine, WORD nCmdShow ) /* Build the filename and command-line */ cmdline = (char *)GlobalLock( cmdLineHandle ); - strncpy( filename, lpCmdLine, 256 ); - filename[255] = '\0'; + lstrcpyn( filename, lpCmdLine, sizeof(filename) - 4 /* for extension */ ); for (p = filename; *p && (*p != ' ') && (*p != '\t'); p++); - if (*p) - { - strncpy( cmdline, p + 1, 128 ); - cmdline[127] = '\0'; - } + if (*p) lstrcpyn( cmdline, p + 1, 128 ); else cmdline[0] = '\0'; *p = '\0'; /* Now load the executable file */ -#ifdef WINELIB32 - params.hEnvironment = (HANDLE)GetDOSEnvironment(); -#else - params.hEnvironment = (HANDLE)SELECTOROF( GetDOSEnvironment() ); -#endif - params.cmdLine = (SEGPTR)WIN16_GlobalLock( cmdLineHandle ); - params.showCmd = (SEGPTR)WIN16_GlobalLock( cmdShowHandle ); - params.reserved = 0; - handle = LoadModule( filename, ¶ms ); - if (handle == (HANDLE)2) /* file not found */ + if (use_load_module) { - /* Check that the original file name did not have a suffix */ - p = strrchr(filename, '.'); - if (p && !(strchr(p, '/') || strchr(p, '\\'))) - return handle; /* filename already includes a suffix! */ - strcat( filename, ".exe" ); - handle = LoadModule( filename, ¶ms ); +#ifdef WINELIB + /* WINELIB: Use LoadModule() only for the program itself */ + use_load_module = 0; + params.hEnvironment = (HANDLE)GetDOSEnvironment(); +#else + params.hEnvironment = (HANDLE)SELECTOROF( GetDOSEnvironment() ); +#endif /* WINELIB */ + params.cmdLine = (SEGPTR)WIN16_GlobalLock( cmdLineHandle ); + params.showCmd = (SEGPTR)WIN16_GlobalLock( cmdShowHandle ); + params.reserved = 0; + handle = LoadModule( filename, ¶ms ); + if (handle == 2) /* file not found */ + { + /* Check that the original file name did not have a suffix */ + p = strrchr(filename, '.'); + if (!p || (strchr(p, '/') && strchr(p, '\\'))) + { + p = filename + strlen(filename); + strcpy( p, ".exe" ); + handle = LoadModule( filename, ¶ms ); + *p = '\0'; /* Remove extension */ + } + } + } + else handle = 2; + + if (handle < 32) + { + /* Try to start it as a unix program */ + if (!fork()) + { + /* Child process */ + const char *unixfilename; + const char *argv[256], **argptr; + int iconic = (nCmdShow == SW_SHOWMINIMIZED || + nCmdShow == SW_SHOWMINNOACTIVE); + + /* get unixfilename */ + if (strchr(filename, '/') || + strchr(filename, ':') || + strchr(filename, '\\')) + unixfilename = DOSFS_GetUnixFileName(filename, 1); + else unixfilename = filename; + + if (unixfilename) + { + /* build argv */ + argptr = argv; + if (iconic) *argptr++ = "-iconic"; + *argptr++ = unixfilename; + p = cmdline; + while (1) + { + while (*p && (*p == ' ' || *p == '\t')) *p++ = '\0'; + if (!*p) break; + *argptr++ = p; + while (*p && *p != ' ' && *p != '\t') p++; + } + *argptr++ = 0; + + /* Execute */ + execvp(argv[0], (char**)argv); + } + + /* Failed ! */ +#ifdef WINELIB + /* build argv */ + argptr = argv; + *argptr++ = "wine"; + if (iconic) *argptr++ = "-iconic"; + *argptr++ = lpCmdLine; + *argptr++ = 0; + + /* Execute */ + execvp(argv[0] , (char**)argv); + + /* Failed ! */ + fprintf(stderr, "WinExec: can't exec 'wine %s'\n", lpCmdLine); +#endif + exit(1); + } } GlobalFree( cmdShowHandle ); @@ -1335,20 +1393,20 @@ FARPROC GetProcAddress( HANDLE hModule, SEGPTR name ) if (HIWORD(name) != 0) { ordinal = MODULE_GetOrdinal( hModule, (LPSTR)PTR_SEG_TO_LIN(name) ); - dprintf_module( stddeb, "GetProcAddress: "NPFMT" '%s'\n", + dprintf_module( stddeb, "GetProcAddress: %04x '%s'\n", hModule, (LPSTR)PTR_SEG_TO_LIN(name) ); } else { ordinal = LOWORD(name); - dprintf_module( stddeb, "GetProcAddress: "NPFMT" %04x\n", + dprintf_module( stddeb, "GetProcAddress: %04x %04x\n", hModule, ordinal ); } if (!ordinal) return (FARPROC)0; ret = MODULE_GetEntryPoint( hModule, ordinal ); - dprintf_module( stddeb, "GetProcAddress: returning "SPFMT"\n", ret ); + dprintf_module( stddeb, "GetProcAddress: returning %08lx\n", (DWORD)ret ); return (FARPROC)ret; } diff --git a/loader/ne_image.c b/loader/ne_image.c index a2785c6b3a5..1b8c0a64ff2 100644 --- a/loader/ne_image.c +++ b/loader/ne_image.c @@ -57,7 +57,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) if (!pSeg->filepos) return TRUE; /* No file image, just return */ fd = MODULE_OpenFile( hModule ); - dprintf_module( stddeb, "Loading segment %d, selector="NPFMT"\n", + dprintf_module( stddeb, "Loading segment %d, selector=%04x\n", segnum, pSeg->selector ); lseek( fd, pSeg->filepos << pModule->alignment, SEEK_SET ); size = pSeg->size ? pSeg->size : 0x10000; @@ -134,7 +134,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) read( fd, &count, sizeof(count) ); if (!count) return TRUE; - dprintf_fixup( stddeb, "Fixups for %*.*s, segment %d, selector "NPFMT"\n", + dprintf_fixup( stddeb, "Fixups for %*.*s, segment %d, selector %04x\n", *((BYTE *)pModule + pModule->name_table), *((BYTE *)pModule + pModule->name_table), (char *)pModule + pModule->name_table + 1, @@ -173,7 +173,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) { NE_MODULE *pTarget = (NE_MODULE *)GlobalLock( module ); if (!pTarget) - fprintf( stderr, "Module not found: "NPFMT", reference %d of module %*.*s\n", + fprintf( stderr, "Module not found: %04x, reference %d of module %*.*s\n", module, rep->target1, *((BYTE *)pModule + pModule->name_table), *((BYTE *)pModule + pModule->name_table), @@ -274,7 +274,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) case NE_RADDR_LOWBYTE: do { sp = PTR_SEG_OFF_TO_LIN( pSeg->selector, offset ); - dprintf_fixup(stddeb," "NPFMT":%04x:%04x BYTE%s\n", + dprintf_fixup(stddeb," %04x:%04x:%04x BYTE%s\n", pSeg->selector, offset, *sp, additive ? " additive":""); offset = *sp; if(additive) @@ -288,7 +288,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) case NE_RADDR_OFFSET16: do { sp = PTR_SEG_OFF_TO_LIN( pSeg->selector, offset ); - dprintf_fixup(stddeb," "NPFMT":%04x:%04x OFFSET16%s\n", + dprintf_fixup(stddeb," %04x:%04x:%04x OFFSET16%s\n", pSeg->selector, offset, *sp, additive ? " additive" : "" ); offset = *sp; *sp = LOWORD(address); @@ -300,7 +300,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) case NE_RADDR_POINTER32: do { sp = PTR_SEG_OFF_TO_LIN( pSeg->selector, offset ); - dprintf_fixup(stddeb," "NPFMT":%04x:%04x POINTER32%s\n", + dprintf_fixup(stddeb," %04x:%04x:%04x POINTER32%s\n", pSeg->selector, offset, *sp, additive ? " additive" : "" ); offset = *sp; *sp = LOWORD(address); @@ -313,7 +313,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) case NE_RADDR_SELECTOR: do { sp = PTR_SEG_OFF_TO_LIN( pSeg->selector, offset ); - dprintf_fixup(stddeb," "NPFMT":%04x:%04x SELECTOR%s\n", + dprintf_fixup(stddeb," %04x:%04x:%04x SELECTOR%s\n", pSeg->selector, offset, *sp, additive ? " additive" : "" ); offset = *sp; *sp = HIWORD(address); diff --git a/loader/ne_resource.c b/loader/ne_resource.c index add76cf0eb3..e7e1a6e2136 100644 --- a/loader/ne_resource.c +++ b/loader/ne_resource.c @@ -355,7 +355,7 @@ BOOL NE_FreeResource( HMODULE hModule, HGLOBAL handle ) } pTypeInfo = (NE_TYPEINFO *)pNameInfo; } - fprintf( stderr, "FreeResource: "NPFMT" "NPFMT" not found!\n", hModule, handle ); + fprintf( stderr, "FreeResource: %04x %04x not found!\n", hModule, handle ); return FALSE; } #endif /* WINELIB */ diff --git a/loader/pe_image.c b/loader/pe_image.c index 9d68504b786..e95ade2bfe1 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -207,7 +207,7 @@ void fixup_imports(struct w_files* wpnt) while(*import_list) { - pe_name = (struct pe_import_name *) ((int) load_addr + *import_list); + pe_name = (struct pe_import_name *) ((int) load_addr + ((unsigned)*import_list & ~0x80000000)); if((unsigned)*import_list & 0x80000000) { int ordinal=*import_list & (0x80000000-1); @@ -652,7 +652,7 @@ HINSTANCE PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params ) /* FIXME: Is this really the correct place to initialise the DLL? */ if ((wpnt->pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL)) { - PE_InitDLL(wpnt); + PE_InitDLL(hModule); } else { TASK_CreateTask(hModule,hInstance,0, params->hEnvironment,(LPSTR)PTR_SEG_TO_LIN(params->cmdLine), diff --git a/loader/resource.c b/loader/resource.c index 4ded63636f9..dee9027f443 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -40,7 +40,7 @@ HRSRC FindResource( HMODULE hModule, SEGPTR name, SEGPTR type ) WORD *pModule; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "FindResource: module="NPFMT" type=", hModule ); + dprintf_resource(stddeb, "FindResource: module=%04x type=", hModule ); PrintId( type ); if (HIWORD(name)) /* Check for '#xxx' name */ { @@ -77,7 +77,7 @@ HGLOBAL LoadResource( HMODULE hModule, HRSRC hRsrc ) WORD *pModule; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "LoadResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n", hModule, hRsrc ); if (!hRsrc) return 0; if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -107,7 +107,7 @@ SEGPTR WIN16_LockResource( HGLOBAL handle ) HMODULE hModule; WORD *pModule; - dprintf_resource(stddeb, "LockResource: handle="NPFMT"\n", handle ); + dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle ); if (!handle) return (SEGPTR)0; hModule = GetExePtr( handle ); if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -132,7 +132,7 @@ LPVOID LockResource( HGLOBAL handle ) HMODULE hModule; WORD *pModule; - dprintf_resource(stddeb, "LockResource: handle="NPFMT"\n", handle ); + dprintf_resource(stddeb, "LockResource: handle=%04x\n", handle ); if (!handle) return NULL; hModule = GetExePtr( handle ); if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -160,7 +160,7 @@ BOOL FreeResource( HGLOBAL handle ) HMODULE hModule; WORD *pModule; - dprintf_resource(stddeb, "FreeResource: handle="NPFMT"\n", handle ); + dprintf_resource(stddeb, "FreeResource: handle=%04x\n", handle ); if (!handle) return FALSE; hModule = GetExePtr( handle ); if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -187,7 +187,7 @@ INT AccessResource( HINSTANCE hModule, HRSRC hRsrc ) WORD *pModule; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "AccessResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n", hModule, hRsrc ); if (!hRsrc) return 0; if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -215,7 +215,7 @@ DWORD SizeofResource( HMODULE hModule, HRSRC hRsrc ) WORD *pModule; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "SizeofResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "SizeofResource: module=%04x res=%04x\n", hModule, hRsrc ); if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; #ifndef WINELIB @@ -242,7 +242,7 @@ HGLOBAL AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size ) WORD *pModule; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "AllocResource: module="NPFMT" res="NPFMT" size=%ld\n", + dprintf_resource(stddeb, "AllocResource: module=%04x res=%04x size=%ld\n", hModule, hRsrc, size ); if (!hRsrc) return 0; if (!(pModule = (WORD *)GlobalLock( hModule ))) return 0; @@ -268,7 +268,8 @@ HGLOBAL AllocResource( HMODULE hModule, HRSRC hRsrc, DWORD size ) */ HANDLE DirectResAlloc(HANDLE hInstance, WORD wType, WORD wSize) { - dprintf_resource(stddeb,"DirectResAlloc("NPFMT",%x,%x)\n",hInstance,wType,wSize); + dprintf_resource(stddeb,"DirectResAlloc(%04x,%04x,%04x)\n", + hInstance, wType, wSize ); hInstance = GetExePtr(hInstance); if(!hInstance)return 0; if(wType != 0x10) /* 0x10 is the only observed value, passed from @@ -291,10 +292,10 @@ HANDLE LoadAccelerators(HANDLE instance, SEGPTR lpTableName) int i, n; if (HIWORD(lpTableName)) - dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" '%s'\n", + dprintf_accel( stddeb, "LoadAccelerators: %04x '%s'\n", instance, (char *)PTR_SEG_TO_LIN( lpTableName ) ); else - dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" %04x\n", + dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n", instance, LOWORD(lpTableName) ); if (!(hRsrc = FindResource( instance, lpTableName, RT_ACCELERATOR ))) @@ -340,7 +341,7 @@ int TranslateAccelerator(HWND hWnd, HANDLE hAccel, LPMSG msg) msg->message != WM_SYSKEYUP && msg->message != WM_CHAR) return 0; - dprintf_accel(stddeb, "TranslateAccelerators hAccel="NPFMT" !\n", hAccel); + dprintf_accel(stddeb, "TranslateAccelerators hAccel=%04x !\n", hAccel); lpAccelTbl = (LPACCELHEADER)GlobalLock(hAccel); for (i = 0; i < lpAccelTbl->wCount; i++) { @@ -387,8 +388,8 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen) int string_num; int i; - dprintf_resource(stddeb, "LoadString: instance = "NPFMT", id = %04x, buffer = %08x, " - "length = %d\n", instance, resource_id, (int) buffer, buflen); + dprintf_resource(stddeb,"LoadString: inst=%04x id=%04x buff=%08x len=%d\n", + instance, resource_id, (int) buffer, buflen); hrsrc = FindResource( instance, (SEGPTR)((resource_id>>4)+1), RT_STRING ); if (!hrsrc) return 0; diff --git a/loader/signal.c b/loader/signal.c index 3bd175f7247..995741b4b66 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -107,6 +107,8 @@ static void SIGNAL_SetHandler( int sig, void (*func)() ) #endif /* linux */ #if defined(__NetBSD__) || defined(__FreeBSD__) + sigset_t sig_mask; + sigemptyset(&sig_mask); sig_act.sa_handler = func; sig_act.sa_flags = SA_ONSTACK; sig_act.sa_mask = sig_mask; @@ -114,6 +116,8 @@ static void SIGNAL_SetHandler( int sig, void (*func)() ) #endif /* __FreeBSD__ || __NetBSD__ */ #if defined (__svr4__) + sigset_t sig_mask; + sigemptyset(&sig_mask); sig_act.sa_handler = func; sig_act.sa_flags = SA_ONSTACK | SA_SIGINFO; sig_act.sa_mask = sig_mask; @@ -136,7 +140,6 @@ void init_wine_signals(void) extern void stop_wait(int a); #if defined(__NetBSD__) || defined(__FreeBSD__) - sigset_t sig_mask; struct sigaltstack ss; #if !defined (__FreeBSD__) @@ -154,11 +157,9 @@ void init_wine_signals(void) perror("sigstack"); exit(1); } - sigemptyset(&sig_mask); #endif /* __FreeBSD__ || __NetBSD__ */ #if defined (__svr4__) - sigset_t sig_mask; struct sigaltstack ss; if ((ss.ss_sp = malloc(SIGSTKSZ) ) == NULL) { @@ -172,7 +173,6 @@ void init_wine_signals(void) perror("sigstack"); exit(1); } - sigemptyset(&sig_mask); #endif /* __svr4__ */ SIGNAL_SetHandler( SIGSEGV, (void (*)())win_fault ); diff --git a/loader/task.c b/loader/task.c index d8a0830dc08..1b6c55747b7 100644 --- a/loader/task.c +++ b/loader/task.c @@ -555,7 +555,7 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance, TASK_LinkTask( hTask ); - dprintf_task( stddeb, "CreateTask: module='%s' cmdline='%s' task="NPFMT"\n", + dprintf_task( stddeb, "CreateTask: module='%s' cmdline='%s' task=%04x\n", name, cmdLine, hTask ); return hTask; @@ -699,7 +699,7 @@ void TASK_Reschedule(void) if (!hTask) return; /* Do nothing */ pNewTask = (TDB *)GlobalLock( hTask ); - dprintf_task( stddeb, "Switching to task "NPFMT" (%.8s)\n", + dprintf_task( stddeb, "Switching to task %04x (%.8s)\n", hTask, pNewTask->module_name ); /* Save the stacks of the previous task (if any) */ @@ -939,8 +939,8 @@ FARPROC MakeProcInstance( FARPROC func, HANDLE hInstance ) if (!thunkaddr) return (FARPROC)0; thunk = PTR_SEG_TO_LIN( thunkaddr ); - dprintf_task( stddeb, "MakeProcInstance("SPFMT","NPFMT"): got thunk "SPFMT"\n", - (SEGPTR)func, hInstance, (SEGPTR)thunkaddr ); + dprintf_task( stddeb, "MakeProcInstance(%08lx,%04x): got thunk %08lx\n", + (DWORD)func, hInstance, (DWORD)thunkaddr ); *thunk++ = 0xb8; /* movw instance, %ax */ *thunk++ = (BYTE)(hInstance & 0xff); @@ -958,7 +958,7 @@ FARPROC MakeProcInstance( FARPROC func, HANDLE hInstance ) void FreeProcInstance( FARPROC func ) { #ifndef WINELIB32 - dprintf_task( stddeb, "FreeProcInstance("SPFMT")\n", (SEGPTR)func ); + dprintf_task( stddeb, "FreeProcInstance(%08lx)\n", (DWORD)func ); TASK_FreeThunk( hCurrentTask, (SEGPTR)func ); #endif } @@ -969,6 +969,7 @@ void FreeProcInstance( FARPROC func ) */ HANDLE GetCodeHandle( FARPROC proc ) { +#ifndef WINELIB32 HANDLE handle; BYTE *thunk = (BYTE *)PTR_SEG_TO_LIN( proc ); @@ -982,6 +983,9 @@ HANDLE GetCodeHandle( FARPROC proc ) handle = GlobalHandle( HIWORD(proc) ); return handle; +#else + return (HANDLE)proc; +#endif } @@ -1201,7 +1205,7 @@ BOOL TaskNext( TASKENTRY *lpte ) TDB *pTask; INSTANCEDATA *pInstData; - dprintf_toolhelp( stddeb, "TaskNext(%p): task="NPFMT"\n", lpte, lpte->hNext ); + dprintf_toolhelp( stddeb, "TaskNext(%p): task=%04x\n", lpte, lpte->hNext ); if (!lpte->hNext) return FALSE; pTask = (TDB *)GlobalLock( lpte->hNext ); if (!pTask || pTask->magic != TDB_MAGIC) return FALSE; diff --git a/memory/global.c b/memory/global.c index 3f06b43745a..78e0081d97f 100644 --- a/memory/global.c +++ b/memory/global.c @@ -649,7 +649,7 @@ void GlobalUnfix( HGLOBAL handle ) /*********************************************************************** * FarSetOwner (KERNEL.403) */ -void FarSetOwner( HANDLE handle, WORD hOwner ) +void FarSetOwner( HANDLE handle, HANDLE hOwner ) { GET_ARENA_PTR(handle)->hOwner = hOwner; } diff --git a/misc/clipboard.c b/misc/clipboard.c index 847e8918a79..31049baf812 100644 --- a/misc/clipboard.c +++ b/misc/clipboard.c @@ -59,7 +59,7 @@ BOOL OpenClipboard(HWND hWnd) { if (hWndClipboardOwner != 0) return FALSE; hWndClipboardOwner = hWnd; - dprintf_clipboard(stddeb,"OpenClipboard("NPFMT"); !\n", hWnd); + dprintf_clipboard(stddeb,"OpenClipboard(%04x); !\n", hWnd); return TRUE; } @@ -107,7 +107,7 @@ BOOL EmptyClipboard() HWND GetClipboardOwner() { dprintf_clipboard(stddeb, - "GetClipboardOwner() = "NPFMT" !\n", hWndClipboardOwner); + "GetClipboardOwner() = %04x !\n", hWndClipboardOwner); return hWndClipboardOwner; } @@ -119,7 +119,7 @@ HANDLE SetClipboardData(WORD wFormat, HANDLE hData) { LPCLIPFORMAT lpFormat = ClipFormats; dprintf_clipboard(stddeb, - "SetClipboardDate(%04X, "NPFMT") !\n", wFormat, hData); + "SetClipboardDate(%04X, %04x) !\n", wFormat, hData); while(TRUE) { if (lpFormat == NULL) return 0; if (lpFormat->wFormatID == wFormat) break; @@ -173,7 +173,7 @@ INT CountClipboardFormats() if (lpFormat == NULL) break; if (lpFormat->hData != 0) { dprintf_clipboard(stddeb, - "CountClipboardFormats // Find Not Empty ("NPFMT") !\n", + "CountClipboardFormats // Find Not Empty (%04x) !\n", lpFormat->hData); FormatCount++; } @@ -211,7 +211,7 @@ UINT EnumClipboardFormats(UINT wFormat) lpFormat = lpFormat->NextFormat; } dprintf_clipboard(stddeb, - "EnumClipboardFormats // Find Not Empty Id=%04X hData="NPFMT" !\n", + "EnumClipboardFormats // Find Not Empty Id=%04X hData=%04x !\n", lpFormat->wFormatID, lpFormat->hData); return lpFormat->wFormatID; } @@ -279,7 +279,7 @@ int GetClipboardFormatName(WORD wFormat, LPSTR retStr, short maxlen) HWND SetClipboardViewer(HWND hWnd) { HWND hwndPrev = hWndViewer; - dprintf_clipboard(stddeb,"SetClipboardViewer("NPFMT") !\n", hWnd); + dprintf_clipboard(stddeb,"SetClipboardViewer(%04x) !\n", hWnd); hWndViewer = hWnd; return hwndPrev; } @@ -290,7 +290,7 @@ HWND SetClipboardViewer(HWND hWnd) */ HWND GetClipboardViewer() { - dprintf_clipboard(stddeb,"GetClipboardFormat() = "NPFMT" !\n", hWndViewer); + dprintf_clipboard(stddeb,"GetClipboardFormat() = %04x !\n", hWndViewer); return hWndViewer; } @@ -301,7 +301,7 @@ HWND GetClipboardViewer() BOOL ChangeClipboardChain(HWND hWnd, HWND hWndNext) { dprintf_clipboard(stdnimp, - "ChangeClipboardChain("NPFMT", "NPFMT") !\n", hWnd, hWndNext); + "ChangeClipboardChain(%04x, %04x) !\n", hWnd, hWndNext); return 0; } @@ -331,7 +331,7 @@ BOOL IsClipboardFormatAvailable(WORD wFormat) HWND GetOpenClipboardWindow() { dprintf_clipboard(stddeb, - "GetOpenClipboardWindow() = "NPFMT" !\n", hWndClipboardOwner); + "GetOpenClipboardWindow() = %04x !\n", hWndClipboardOwner); return hWndClipboardOwner; } @@ -377,7 +377,7 @@ void CLIPBOARD_ReadSelection(Window w,Atom prop) hText=0; } else { dprintf_clipboard(stddeb,"Selection is %s\n",val); - hText=GlobalAlloc(GMEM_MOVEABLE, nitems); + hText=GlobalAlloc(GMEM_MOVEABLE, nitems+1); memcpy(GlobalLock(hText),val,nitems+1); GlobalUnlock(hText); } diff --git a/misc/commdlg.c b/misc/commdlg.c index 9e76ac0bf3f..3d242f799e7 100644 --- a/misc/commdlg.c +++ b/misc/commdlg.c @@ -294,6 +294,18 @@ static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) return TRUE; } +/*********************************************************************** + * FILEDLG_HookCallChk [internal] + */ +static int FILEDLG_HookCallChk(LPOPENFILENAME lpofn) +{ + if (lpofn) + if (lpofn->Flags & OFN_ENABLEHOOK) + if (lpofn->lpfnHook) + return 1; + return 0; +} + /*********************************************************************** * FILEDLG_WMInitDialog [internal] */ @@ -372,7 +384,11 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE); if (lpofn->Flags & OFN_HIDEREADONLY) ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE); - return TRUE; + if (FILEDLG_HookCallChk(lpofn)) + return (BOOL)CallWindowProc(lpofn->lpfnHook, + hWnd, WM_INITDIALOG, wParam,(LPARAM)MAKE_SEGPTR(lpofn)); + else + return TRUE; } /*********************************************************************** @@ -382,6 +398,7 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { LONG lRet; LPOPENFILENAME lpofn; + OPENFILENAME ofn2; char tmpstr[512], tmpstr2[512]; LPSTR pstr, pstr2; UINT control,notification; @@ -407,6 +424,12 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet, (LPARAM)MAKE_SEGPTR(tmpstr)); SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr)); + + if (FILEDLG_HookCallChk(lpofn)) + CallWindowProc (lpofn->lpfnHook, hWnd, + RegisterWindowMessage(MAKE_SEGPTR(LBSELCHSTRING)), + control, MAKELONG(lRet,CD_LBSELCHANGE)); + /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */ return TRUE; case lst2: /* directory list */ FILEDLG_StripEditControl(hWnd); @@ -454,6 +477,7 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) return TRUE; case IDOK: almost_ok: + ofn2=*lpofn; /* for later restoring */ SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, (LPARAM)MAKE_SEGPTR(tmpstr)); pstr = strrchr(tmpstr, '\\'); if (pstr == NULL) @@ -507,7 +531,9 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) } else SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, (LPARAM)MAKE_SEGPTR(tmpstr)); - ShowWindow(hWnd, SW_HIDE); +#if 0 + ShowWindow(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */ +#endif { int drive = DRIVE_GetCurrentDrive(); tmpstr2[0] = 'A'+ drive; @@ -535,6 +561,20 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) dprintf_commdlg(stddeb,"strcpy'ing '%s'\n",tmpstr); fflush(stdout); strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFileTitle), tmpstr); } + if (FILEDLG_HookCallChk(lpofn)) + { + lRet= (BOOL)CallWindowProc (lpofn->lpfnHook, + hWnd, RegisterWindowMessage(MAKE_SEGPTR(FILEOKSTRING)), + 0, (LPARAM)MAKE_SEGPTR(lpofn)); + if (lRet) + { + *lpofn=ofn2; /* restore old state */ +#if 0 + ShowWindow(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */ +#endif + break; + } + } EndDialog(hWnd, TRUE); return TRUE; case IDCANCEL: @@ -550,6 +590,15 @@ static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) */ LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { + LPOPENFILENAME lpofn = (LPOPENFILENAME)GetWindowLong(hWnd, DWL_USER); + + if (wMsg!=WM_INITDIALOG) + if (FILEDLG_HookCallChk(lpofn)) + { + LRESULT lRet=(BOOL)CallWindowProc(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam); + if (lRet) + return lRet; /* else continue message processing */ + } switch (wMsg) { case WM_INITDIALOG: @@ -584,6 +633,15 @@ LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) */ LRESULT FileSaveDlgProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) { + LPOPENFILENAME lpofn = (LPOPENFILENAME)GetWindowLong(hWnd, DWL_USER); + + if (wMsg!=WM_INITDIALOG) + if (FILEDLG_HookCallChk(lpofn)) + { + LRESULT lRet=(BOOL)CallWindowProc(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam); + if (lRet) + return lRet; /* else continue message processing */ + } switch (wMsg) { case WM_INITDIALOG: return FILEDLG_WMInitDialog(hWnd, wParam, lParam); diff --git a/misc/driver.c b/misc/driver.c index 7da499089b4..30567fadaad 100644 --- a/misc/driver.c +++ b/misc/driver.c @@ -33,7 +33,7 @@ void LoadStartupDrivers(void) dprintf_driver(stddeb,"LoadStartupDrivers // str='%s'\n", ptr); hDrv = OpenDriver(ptr, "drivers", 0L); dprintf_driver(stddeb, - "LoadStartupDrivers // hDrv="NPFMT"\n", hDrv); + "LoadStartupDrivers // hDrv=%04x\n", hDrv); ptr += strlen(ptr) + 1; } dprintf_driver(stddeb,"LoadStartupDrivers // end of list !\n"); @@ -44,7 +44,7 @@ void LoadStartupDrivers(void) */ LRESULT WINAPI SendDriverMessage(HDRVR hDriver, WORD msg, LPARAM lParam1, LPARAM lParam2) { - dprintf_driver(stdnimp,"SendDriverMessage("NPFMT", %04X, %08lX, %08lX);\n", + dprintf_driver(stdnimp,"SendDriverMessage(%04x, %04X, %08lX, %08lX);\n", hDriver, msg, lParam1, lParam2); return 0; } @@ -93,7 +93,7 @@ HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam) lpnewdrv->lpPrevItem = lpdrv; } lpnewdrv->lpDrvProc = NULL; - dprintf_driver(stddeb,"OpenDriver // hDrvr="NPFMT" loaded !\n", hDrvr); + dprintf_driver(stddeb,"OpenDriver // hDrvr=%04x loaded !\n", hDrvr); return hDrvr; } @@ -104,7 +104,7 @@ LRESULT CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) { LPDRIVERITEM lpdrv; dprintf_driver(stddeb, - "CloseDriver("NPFMT", %08lX, %08lX);\n", hDrvr, lParam1, lParam2); + "CloseDriver(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2); lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr); if (lpdrv != NULL && lpdrv->dis.hDriver == hDrvr) { if (lpdrv->lpPrevItem) @@ -113,7 +113,7 @@ LRESULT CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) ((LPDRIVERITEM)lpdrv->lpNextItem)->lpPrevItem = lpdrv->lpPrevItem; GlobalUnlock(hDrvr); GlobalFree(hDrvr); - dprintf_driver(stddeb,"CloseDriver // hDrvr="NPFMT" closed !\n", hDrvr); + dprintf_driver(stddeb,"CloseDriver // hDrvr=%04x closed !\n", hDrvr); return TRUE; } return FALSE; @@ -126,7 +126,7 @@ HANDLE GetDriverModuleHandle(HDRVR hDrvr) { LPDRIVERITEM lpdrv; HANDLE hModule = 0; - dprintf_driver(stddeb,"GetDriverModuleHandle("NPFMT");\n", hDrvr); + dprintf_driver(stddeb,"GetDriverModuleHandle(%04x);\n", hDrvr); lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr); if (lpdrv != NULL) { hModule = lpdrv->dis.hModule; @@ -175,7 +175,7 @@ LRESULT DefDriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, BOOL GetDriverInfo(HDRVR hDrvr, LPDRIVERINFOSTRUCT lpDrvInfo) { LPDRIVERITEM lpdrv; - dprintf_driver(stddeb,"GetDriverInfo("NPFMT", %p);\n", hDrvr, lpDrvInfo); + dprintf_driver(stddeb,"GetDriverInfo(%04x, %p);\n", hDrvr, lpDrvInfo); if (lpDrvInfo == NULL) return FALSE; lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr); if (lpdrv == NULL) return FALSE; @@ -191,7 +191,7 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags) { LPDRIVERITEM lpdrv; HDRVR hRetDrv = 0; - dprintf_driver(stddeb,"GetNextDriver("NPFMT", %08lX);\n", hDrvr, dwFlags); + dprintf_driver(stddeb,"GetNextDriver(%04x, %08lX);\n", hDrvr, dwFlags); if (hDrvr == 0) { if (lpDrvItemList == NULL) { dprintf_driver(stddeb, @@ -199,7 +199,7 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags) LoadStartupDrivers(); if (lpDrvItemList == NULL) return 0; } - dprintf_driver(stddeb,"GetNextDriver // return first "NPFMT" !\n", + dprintf_driver(stddeb,"GetNextDriver // return first %04x !\n", lpDrvItemList->dis.hDriver); return lpDrvItemList->dis.hDriver; } @@ -215,7 +215,7 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags) } GlobalUnlock(hDrvr); } - dprintf_driver(stddeb,"GetNextDriver // return "NPFMT" !\n", hRetDrv); + dprintf_driver(stddeb,"GetNextDriver // return %04x !\n", hRetDrv); return hRetDrv; } diff --git a/misc/exec.c b/misc/exec.c index fc0131b8d94..e66f09fd36a 100644 --- a/misc/exec.c +++ b/misc/exec.c @@ -55,7 +55,7 @@ void EXEC_ExitWindows( int retCode ) */ BOOL ExitWindows( DWORD dwReturnCode, WORD wReserved ) { - HWND hwnd, hwndDesktop; + HWND hwndDesktop; WND *wndPtr; HWND *list, *pWnd; int count, i; @@ -70,22 +70,16 @@ BOOL ExitWindows( DWORD dwReturnCode, WORD wReserved ) hwndDesktop = GetDesktopWindow(); count = 0; - for (hwnd = GetTopWindow(hwndDesktop); hwnd != 0; hwnd = wndPtr->hwndNext) - { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; + for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) count++; - } if (!count) /* No windows, we can exit at once */ EXEC_ExitWindows( LOWORD(dwReturnCode) ); /* Now build the list of all windows */ - if (!(list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; - for (hwnd = GetTopWindow(hwndDesktop), pWnd = list; hwnd != 0; hwnd = wndPtr->hwndNext) - { - wndPtr = WIN_FindWndPtr( hwnd ); - *pWnd++ = hwnd; - } + if (!(pWnd = list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; + for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) + *pWnd++ = wndPtr->hwndSelf; /* Now send a WM_QUERYENDSESSION message to every window */ diff --git a/misc/lzexpand.c b/misc/lzexpand.c index 57e5c8cd0d8..4b4b500590a 100644 --- a/misc/lzexpand.c +++ b/misc/lzexpand.c @@ -263,7 +263,7 @@ LZRead(HFILE fd,SEGPTR segbuf,WORD toread) { BYTE *buf; struct lzstate *lzs; - dprintf_file(stddeb,"LZRead(%d,%08lx,%d)\n",fd,segbuf,toread); + dprintf_file(stddeb,"LZRead(%d,%08lx,%d)\n",fd,(DWORD)segbuf,toread); howmuch=toread; for (i=0;iName != NULL) + { + count += strlen(lpEnv->Name) + 1; + count += strlen(lpEnv->Value) + 1; + } + lpEnv = lpEnv->Next; + } + + len=count; + envtable = malloc(count); + if(envtable) + { + lpEnv = lpEnvList; + envptr = envtable; + + while(lpEnv != NULL) + { + if(lpEnv->Name != NULL) + { + count = sprintf(envptr, "%s=%s", lpEnv->Name, lpEnv->Value); + envptr += count + 1; + } + lpEnv = lpEnv->Next; + } + *envptr = '\0'; + } + + wenvtable = malloc(2*len); + for(count=0;count", lpFile ? lpFile:"", lpParameters ? lpParameters : "", lpDirectory ? lpDirectory : "", iShowCmd); @@ -719,7 +721,7 @@ HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex) { HICON hIcon = 0; HINSTANCE hInst2 = hInst; - dprintf_reg(stddeb, "ExtractIcon("NPFMT", '%s', %d\n", + dprintf_reg(stddeb, "ExtractIcon(%04x, '%s', %d\n", hInst, lpszExeFileName, nIconIndex); return 0; if (lpszExeFileName != NULL) { diff --git a/misc/spy.c b/misc/spy.c index 065387c5300..f42791d1fa7 100644 --- a/misc/spy.c +++ b/misc/spy.c @@ -432,7 +432,7 @@ void SPY_EnterMessage( int iFlag, HWND hWnd, UINT msg, switch(iFlag) { case SPY_DISPATCHMESSAGE: - dprintf_message(stddeb,"("NPFMT") message [%04x] %s dispatched wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"(%04x) message [%04x] %s dispatched wp=%04x lp=%08lx\n", hWnd, msg, SPY_GetMsgName( msg ), wParam, lParam); break; @@ -443,10 +443,10 @@ void SPY_EnterMessage( int iFlag, HWND hWnd, UINT msg, HTASK hTask = GetWindowTask(hWnd); if (hTask == GetCurrentTask()) strcpy( taskName, "self" ); else if (!hTask) strcpy( taskName, "Wine" ); - else sprintf( taskName, "task "NPFMT" %s", + else sprintf( taskName, "task %04x %s", hTask, MODULE_GetModuleName( GetExePtr(hTask) ) ); - dprintf_message(stddeb,"%*s("NPFMT") message [%04x] %s sent from %s wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"%*s(%04x) message [%04x] %s sent from %s wp=%04x lp=%08lx\n", SPY_IndentLevel, "", hWnd, msg, SPY_GetMsgName( msg ), taskName, wParam, lParam ); SPY_IndentLevel += SPY_INDENT_UNIT; @@ -454,7 +454,7 @@ void SPY_EnterMessage( int iFlag, HWND hWnd, UINT msg, break; case SPY_DEFWNDPROC: - dprintf_message(stddeb, "%*s("NPFMT") DefWindowProc: %s [%04x] wp=%04x lp=%08lx\n", + dprintf_message(stddeb, "%*s(%04x) DefWindowProc: %s [%04x] wp=%04x lp=%08lx\n", SPY_IndentLevel, "", hWnd, SPY_GetMsgName( msg ), msg, wParam, lParam ); break; @@ -473,12 +473,12 @@ void SPY_ExitMessage( int iFlag, HWND hWnd, UINT msg, LRESULT lReturn ) switch(iFlag) { case SPY_RESULT_INVALIDHWND: - dprintf_message(stddeb,"%*s("NPFMT") message [%04x] %s HAS INVALID HWND\n", + dprintf_message(stddeb,"%*s(%04x) message [%04x] %s HAS INVALID HWND\n", SPY_IndentLevel, "", hWnd, msg, SPY_GetMsgName( msg ) ); break; case SPY_RESULT_OK: - dprintf_message(stddeb,"%*s("NPFMT") message [%04x] %s returned %08lx\n", + dprintf_message(stddeb,"%*s(%04x) message [%04x] %s returned %08lx\n", SPY_IndentLevel, "", hWnd, msg, SPY_GetMsgName( msg ), lReturn ); break; diff --git a/misc/winsocket.c b/misc/winsocket.c index 05e1ecfc516..cd69bc0f34b 100644 --- a/misc/winsocket.c +++ b/misc/winsocket.c @@ -49,7 +49,13 @@ struct ipc_packet { #pragma pack(1) #endif -#define IPC_PACKET_SIZE (sizeof(struct ipc_packet) - sizeof(long)) +#define WINSOCK_MAX_SOCKETS 256 +#define WINSOCK_MAX_UDPDG 1024 + +/* we are out by two with the following, is it due to byte alignment? + * #define IPC_PACKET_SIZE (sizeof(struct ipc_packet) - sizeof(long)) + */ +#define IPC_PACKET_SIZE (sizeof(struct ipc_packet) - sizeof(long) - 2) /*#define MTYPE 0xb0b0eb05*/ #define MTYPE 0x30b0eb05 @@ -152,8 +158,7 @@ static WORD wsaerrno(void) fprintf(stderr, "winsock: errno %d, (%s).\n", errno, sys_errlist[errno]); #else - fprintf(stderr, "winsock: errno %d, (%s).\n", - errno, strerror(errno)); + fprintf(stderr, "winsock: errno %d\n", errno); #endif #else fprintf(stderr, "winsock: errno %d\n", errno); @@ -242,8 +247,8 @@ static WORD wsaherrno(void) switch(h_errno) { - case TRY_AGAIN: return WSATRY_AGAIN; case HOST_NOT_FOUND: return WSAHOST_NOT_FOUND; + case TRY_AGAIN: return WSATRY_AGAIN; case NO_RECOVERY: return WSANO_RECOVERY; case NO_DATA: return WSANO_DATA; /* just in case we ever get here and there are no problems */ @@ -380,6 +385,11 @@ SOCKET WINSOCK_accept(SOCKET s, struct sockaddr *addr, INT *addrlen) dprintf_winsock(stddeb, "WSA_accept: socket %d, ptr %8x, length %d\n", s, (int) addr, *addrlen); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return INVALID_SOCKET; + } + if ((sock = accept(s, addr, (int *) addrlen)) < 0) { errno_to_wsaerrno(); return INVALID_SOCKET; @@ -389,11 +399,38 @@ SOCKET WINSOCK_accept(SOCKET s, struct sockaddr *addr, INT *addrlen) INT WINSOCK_bind(SOCKET s, struct sockaddr *name, INT namelen) { + dprintf_winsock(stddeb, "WSA_bind: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); dump_sockaddr(name); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + + if (namelen < sizeof(*name)) { + WSASetLastError(WSAEFAULT); + return SOCKET_ERROR; + } + + /* check the socket family */ + if ( ((struct sockaddr_in *)name)->sin_family != AF_INET ) { + WSASetLastError(WSAEAFNOSUPPORT); + return SOCKET_ERROR; + } + if (bind(s, name, namelen) < 0) { - errno_to_wsaerrno(); + switch(errno) { + case EBADF: + WSASetLastError(WSAENOTSOCK); + break; + case EADDRNOTAVAIL: + WSASetLastError(WSAEINVAL); + break; + default: + errno_to_wsaerrno(); + break; + } return SOCKET_ERROR; } return 0; @@ -403,10 +440,18 @@ INT WINSOCK_closesocket(SOCKET s) { dprintf_winsock(stddeb, "WSA_closesocket: socket %d\n", s); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + FD_CLR(s, &fd_in_use); if (close(s) < 0) { - errno_to_wsaerrno(); + if (errno == EBADF) + WSASetLastError(WSAENOTSOCK); + else + errno_to_wsaerrno(); return SOCKET_ERROR; } return 0; @@ -417,6 +462,11 @@ INT WINSOCK_connect(SOCKET s, struct sockaddr *name, INT namelen) dprintf_winsock(stddeb, "WSA_connect: socket %d, ptr %8x, length %d\n", s, (int) name, namelen); dump_sockaddr(name); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (connect(s, name, namelen) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -429,6 +479,11 @@ INT WINSOCK_getpeername(SOCKET s, struct sockaddr *name, INT *namelen) dprintf_winsock(stddeb, "WSA_getpeername: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, *namelen); dump_sockaddr(name); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (getpeername(s, name, (int *) namelen) < 0) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -443,6 +498,12 @@ INT WINSOCK_getpeername(SOCKET s, struct sockaddr *name, INT *namelen) INT WINSOCK_getsockname(SOCKET s, struct sockaddr *name, INT *namelen) { dprintf_winsock(stddeb, "WSA_getsockname: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, (int) *namelen); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (getsockname(s, name, (int *) namelen) < 0) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -458,10 +519,19 @@ INT WINSOCK_getsockopt(SOCKET s, INT level, INT optname, char *optval, INT *optlen) { dprintf_winsock(stddeb, "WSA_getsockopt: socket: %d, opt %d, ptr %8x, ptr %8x\n", s, level, (int) optval, (int) *optlen); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + convert_sockopt(&level, &optname); if (getsockopt(s, (int) level, optname, optval, (int *) optlen) < 0) { - errno_to_wsaerrno(); + if (errno == EBADF) + WSASetLastError(WSAENOTSOCK); + else + errno_to_wsaerrno(); return SOCKET_ERROR; } return 0; @@ -505,6 +575,11 @@ INT WINSOCK_ioctlsocket(SOCKET s, u_long cmd, u_long *argp) char *ctlname; dprintf_winsock(stddeb, "WSA_ioctl: socket %d, cmd %lX, ptr %8x\n", s, cmd, (int) argp); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + /* Why can't they all use the same ioctl numbers */ newcmd=cmd; newargp=argp; @@ -532,7 +607,10 @@ INT WINSOCK_ioctlsocket(SOCKET s, u_long cmd, u_long *argp) if (ioctl(s, newcmd, newargp) < 0) { - errno_to_wsaerrno(); + if (errno == EBADF) + WSASetLastError(WSAENOTSOCK); + else + errno_to_wsaerrno(); return SOCKET_ERROR; } return 0; @@ -542,6 +620,11 @@ INT WINSOCK_listen(SOCKET s, INT backlog) { dprintf_winsock(stddeb, "WSA_listen: socket %d, backlog %d\n", s, backlog); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (listen(s, backlog) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -565,6 +648,11 @@ INT WINSOCK_recv(SOCKET s, char *buf, INT len, INT flags) dprintf_winsock(stddeb, "WSA_recv: socket %d, ptr %8x, length %d, flags %d\n", s, (int) buf, len, flags); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if ((length = recv(s, buf, len, flags)) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -579,6 +667,11 @@ INT WINSOCK_recvfrom(SOCKET s, char *buf, INT len, INT flags, dprintf_winsock(stddeb, "WSA_recvfrom: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long)buf, len, flags); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if ((length = recvfrom(s, buf, len, flags, from, fromlen)) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -591,6 +684,11 @@ INT WINSOCK_select(INT nfds, fd_set *readfds, fd_set *writefds, { dprintf_winsock(stddeb, "WSA_select: fd # %d, ptr %8lx, ptr %8lx, ptr %8lX\n", nfds, (unsigned long) readfds, (unsigned long) writefds, (unsigned long) exceptfds); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } +/* FIXME */ return(select(nfds, readfds, writefds, exceptfds, timeout)); } @@ -600,6 +698,11 @@ INT WINSOCK_send(SOCKET s, char *buf, INT len, INT flags) dprintf_winsock(stddeb, "WSA_send: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long) buf, len, flags); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if ((length = send(s, buf, len, flags)) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -614,6 +717,11 @@ INT WINSOCK_sendto(SOCKET s, char *buf, INT len, INT flags, dprintf_winsock(stddeb, "WSA_sendto: socket %d, ptr %8lx, length %d, flags %d\n", s, (unsigned long) buf, len, flags); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if ((length = sendto(s, buf, len, flags, to, tolen)) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -627,6 +735,11 @@ INT WINSOCK_setsockopt(SOCKET s, INT level, INT optname, const char *optval, dprintf_winsock(stddeb, "WSA_setsockopt: socket %d, level %d, opt %d, ptr %8x, len %d\n", s, level, optname, (int) optval, optlen); convert_sockopt(&level, &optname); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (setsockopt(s, level, optname, optval, optlen) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -638,6 +751,11 @@ INT WINSOCK_shutdown(SOCKET s, INT how) { dprintf_winsock(stddeb, "WSA_shutdown: socket s %d, how %d\n", s, how); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (shutdown(s, how) < 0) { errno_to_wsaerrno(); return SOCKET_ERROR; @@ -651,24 +769,73 @@ SOCKET WINSOCK_socket(INT af, INT type, INT protocol) dprintf_winsock(stddeb, "WSA_socket: af=%d type=%d protocol=%d\n", af, type, protocol); - if ((sock = socket(af, type, protocol)) < 0) { - if (errno != EPERM) { - errno_to_wsaerrno(); - } else { - /* NOTE: EPERM does not always map to WSAESOCKTNOSUPPORT - * so this is done as a special case - */ - /* non super-user wants a raw socket */ - dprintf_winsock(stderr, "WSA_socket: not enough privileges\n"); - WSASetLastError(WSAESOCKTNOSUPPORT); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return INVALID_SOCKET; + } + + /* check the socket family */ + switch(af) { + case AF_INET: + case AF_UNSPEC: + break; + default: + WSASetLastError(WSAEAFNOSUPPORT); + return INVALID_SOCKET; + break; + } + + /* check the socket type */ + switch(type) { + case SOCK_STREAM: + case SOCK_DGRAM: + case SOCK_RAW: + break; + default: + WSASetLastError(WSAESOCKTNOSUPPORT); + return INVALID_SOCKET; + break; + } + + /* check the protocol type */ + if ( protocol < 0 ) { /* don't support negative values */ + WSASetLastError(WSAEPROTONOSUPPORT); + return INVALID_SOCKET; + } + + if ( af == AF_UNSPEC) { /* did they not specify the address family? */ + switch(protocol) { + case IPPROTO_TCP: + if (type == SOCK_STREAM) { + af = AF_INET; + break; + } + case IPPROTO_UDP: + if (type == SOCK_DGRAM) { + af = AF_INET; + break; + } + default: + WSASetLastError(WSAEPROTOTYPE); + return INVALID_SOCKET; + break; } - dprintf_winsock(stddeb, "WSA_socket: failed !\n"); - return INVALID_SOCKET; + } + + if ((sock = socket(af, type, protocol)) < 0) { + if (errno == EPERM) { + /* non super-user wants a raw socket */ + fprintf(stderr, "WSA_socket: not enough privileges\n"); + WSASetLastError(WSAESOCKTNOSUPPORT); + } else + errno_to_wsaerrno(); + dprintf_winsock(stddeb, "WSA_socket: failed !\n"); + return INVALID_SOCKET; } - if (sock > 0xffff) { - /* we only support socket numbers up to 0xffff. The return - * value indicates there are no more descriptors available + if (sock > WINSOCK_MAX_SOCKETS) { + /* we only support socket numbers up to WINSOCK_MAX_SOCKETS. + * The return value indicates no more descriptors are available */ WSASetLastError(WSAEMFILE); return INVALID_SOCKET; @@ -689,6 +856,11 @@ SEGPTR WINSOCK_gethostbyaddr(const char *addr, INT len, INT type) dprintf_winsock(stddeb, "WSA_gethostbyaddr: ptr %8x, len %d, type %d\n", (int) addr, len, type); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((host = gethostbyaddr(addr, len, type)) == NULL) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -711,6 +883,11 @@ SEGPTR WINSOCK_gethostbyname(const char *name) dprintf_winsock(stddeb, "WSA_gethostbyname: %s\n", name); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((host = gethostbyname(name)) == NULL) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -728,12 +905,16 @@ INT WINSOCK_gethostname(char *name, INT namelen) { dprintf_winsock(stddeb, "WSA_gethostname: name %s, len %d\n", name, namelen); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + if (gethostname(name, namelen) < 0) { - if (h_errno < 0) { - errno_to_wsaerrno(); - } else { - herrno_to_wsaerrno(); - } + if (errno == EINVAL) + WSASetLastError(WSAEFAULT); + else + errno_to_wsaerrno(); return SOCKET_ERROR; } return 0; @@ -748,6 +929,11 @@ SEGPTR WINSOCK_getprotobyname(char *name) dprintf_winsock(stddeb, "WSA_getprotobyname: name %s\n", name); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((proto = getprotobyname(name)) == NULL) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -770,12 +956,20 @@ SEGPTR WINSOCK_getprotobynumber(INT number) dprintf_winsock(stddeb, "WSA_getprotobynumber: num %d\n", number); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((proto = getprotobynumber(number)) == NULL) { +#if 0 if (h_errno < 0) { errno_to_wsaerrno(); } else { herrno_to_wsaerrno(); } +#endif + WSASetLastError(WSANO_DATA); return NULL; } CONVERT_PROTOENT(&Heap->protoent_number, proto); @@ -795,6 +989,11 @@ SEGPTR WINSOCK_getservbyname(const char *name, const char *proto) dprintf_winsock(stddeb, "WSA_getservbyname: name %s, proto %s\n", name, proto); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((service = getservbyname(name, proto)) == NULL) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -817,6 +1016,11 @@ SEGPTR WINSOCK_getservbyport(INT port, const char *proto) dprintf_winsock(stddeb, "WSA_getservbyport: port %d, name %s\n", port, proto); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + if ((service = getservbyport(port, proto)) == NULL) { if (h_errno < 0) { errno_to_wsaerrno(); @@ -833,7 +1037,7 @@ SEGPTR WINSOCK_getservbyport(INT port, const char *proto) /******************** winsock specific functions ************************ * */ -static HANDLE new_handle = 0; +static HANDLE new_handle = 1; static HANDLE AllocWSAHandle(void) { @@ -843,15 +1047,17 @@ static HANDLE AllocWSAHandle(void) static void recv_message(int sig) { static struct ipc_packet message; - static int message_is_valid = 0; + int message_is_valid = 0; BOOL result; + message.mtype = MTYPE; + signal(SIGUSR1, recv_message); while (1) { if (!message_is_valid) { if (msgrcv(wine_key, (struct msgbuf*)&(message), - IPC_PACKET_SIZE, MTYPE, IPC_NOWAIT) == -1) { + IPC_PACKET_SIZE, 0 /*MTYPE*/, IPC_NOWAIT) == -1) { perror("wine: winsock: msgrcv"); break; } @@ -859,7 +1065,7 @@ static void recv_message(int sig) result = PostMessage(message.hWnd, message.wMsg, (WPARAM)message.handle, message.lParam); - if (result == FALSE) { + if (result != FALSE) { message_is_valid = 1; break; } @@ -868,6 +1074,8 @@ static void recv_message(int sig) } + if ((wine_key = msgget(IPC_PRIVATE, 0600)) == -1) + perror("wine: winsock: msgget"); } @@ -884,7 +1092,7 @@ static void send_message( HWND hWnd, u_int wMsg, HANDLE handle, long lParam) if (msgsnd(wine_key, (struct msgbuf*)&(message), IPC_PACKET_SIZE, 0/*IPC_NOWAIT*/) == -1) perror("wine: winsock: msgsnd"); - + kill(getppid(), SIGUSR1); } @@ -894,10 +1102,18 @@ HANDLE WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char *addr, { HANDLE handle; struct hostent *host; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((host = gethostbyaddr(addr, len, type)) == NULL) { @@ -921,10 +1137,18 @@ HANDLE WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char *name, { HANDLE handle; struct hostent *host; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((host = gethostbyname(name)) == NULL) { @@ -948,10 +1172,18 @@ HANDLE WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char *name, { HANDLE handle; struct protoent *proto; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((proto = getprotobyname(name)) == NULL) { @@ -975,10 +1207,18 @@ HANDLE WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, INT number, { HANDLE handle; struct protoent *proto; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((proto = getprotobynumber(number)) == NULL) { @@ -1002,10 +1242,18 @@ HANDLE WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char *name, { HANDLE handle; struct servent *service; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((service = getservbyname(name, proto)) == NULL) { @@ -1029,10 +1277,18 @@ HANDLE WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, INT port, const char { HANDLE handle; struct servent *service; + int newpid; + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return 0; + } handle = AllocWSAHandle(); - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return handle; } else { if ((service = getservbyport(port, proto)) == NULL) { @@ -1055,8 +1311,14 @@ INT WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent) long event; fd_set read_fds, write_fds, except_fds; int errors = 0; + int newpid; - dprintf_winsock(stddeb, "WSA_AsyncSelect: socket %d, HWND "NPFMT", wMsg %d, event %ld\n", s, hWnd, wMsg, lEvent); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + + dprintf_winsock(stddeb, "WSA_AsyncSelect: socket %d, HWND %04x, wMsg %d, event %ld\n", s, hWnd, wMsg, lEvent); /* remove outstanding asyncselect() processes */ /* kill */ @@ -1064,7 +1326,9 @@ INT WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent) if (wMsg == 0 && lEvent == 0) return 0; - if (fork()) { + newpid = fork(); + if (newpid) { + dprintf_winsock(stddeb, "forked, child is (%d)\n",newpid); return 0; } else { while (1) { @@ -1099,7 +1363,12 @@ INT WSAFDIsSet(INT fd, fd_set *set) INT WSACancelAsyncRequest(HANDLE hAsyncTaskHandle) { - dprintf_winsock(stddeb, "WSA_AsyncRequest: handle "NPFMT"\n", hAsyncTaskHandle); + dprintf_winsock(stddeb, "WSA_AsyncRequest: handle %04x\n", hAsyncTaskHandle); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } return 0; } @@ -1107,6 +1376,12 @@ INT WSACancelAsyncRequest(HANDLE hAsyncTaskHandle) INT WSACancelBlockingCall(void) { dprintf_winsock(stddeb, "WSA_CancelBlockCall\n"); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } + return 0; } @@ -1114,14 +1389,24 @@ INT WSAGetLastError(void) { dprintf_winsock(stddeb, "WSA_GetLastError = %x\n", wsa_errno); - return wsa_errno; + return wsa_errno; } void WSASetLastError(INT iError) { dprintf_winsock(stddeb, "WSA_SetLastErorr %d\n", iError); - wsa_errno = iError; + /* technically, we should make sure that WINESockets + * has been started up correctly. But since this function + * is also used internally, it makes no sense. + * + *if (!wsa_initted) { + * WSASetLastError(WSANOTINITIALISED); + * return SOCKET_ERROR; + *} + */ + + wsa_errno = iError; } BOOL WSAIsBlocking(void) @@ -1134,6 +1419,12 @@ BOOL WSAIsBlocking(void) FARPROC WSASetBlockingHook(FARPROC lpBlockFunc) { dprintf_winsock(stddeb, "WSA_SetBlockHook %8lx, STUB!\n", (unsigned long) lpBlockFunc); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + BlockFunction = lpBlockFunc; return (FARPROC) lpBlockFunc; @@ -1142,11 +1433,18 @@ FARPROC WSASetBlockingHook(FARPROC lpBlockFunc) INT WSAUnhookBlockingHook(void) { dprintf_winsock(stddeb, "WSA_UnhookBlockingHook\n"); + + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return NULL; + } + BlockFunction = NULL; return 0; } +#ifdef 0 WSADATA WINSOCK_data = { 0x0101, 0x0101, @@ -1162,14 +1460,35 @@ WSADATA WINSOCK_data = { #else "Unknown", #endif - 128, - 1024, + WINSOCK_MAX_SOCKETS, + WINSOCK_MAX_UDPDG, NULL }; +#endif INT WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) { + WSADATA WINSOCK_data = { + 0x0101, + 0x0101, + "WINE Sockets", + #ifdef linux + "Linux/i386", + #elif defined(__NetBSD__) + "NetBSD/i386", + #elif defined(sunos) + "SunOS", + #elif defined(__FreeBSD__) + "FreeBSD", + #else + "Unknown", + #endif + WINSOCK_MAX_SOCKETS, + WINSOCK_MAX_UDPDG, + NULL + }; + dprintf_winsock(stddeb, "WSAStartup: verReq=%x\n", wVersionRequested); if (LOBYTE(wVersionRequested) < 1 || @@ -1186,7 +1505,9 @@ INT WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) return WSASYSNOTREADY; Heap = (struct WinSockHeap *) GlobalLock(HeapHandle); - memcpy(lpWSAData, &WINSOCK_data, sizeof(WINSOCK_data)); + + /* return winsock information */ + memcpy(lpWSAData, &WINSOCK_data, sizeof(WINSOCK_data)); /* ipc stuff */ @@ -1199,7 +1520,9 @@ INT WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) FD_ZERO(&fd_in_use); - wsa_initted = 1; + /* increment our usage count */ + wsa_initted++; + dprintf_winsock(stddeb, "WSAStartup: succeeded\n"); return(0); } @@ -1207,14 +1530,25 @@ INT WSACleanup(void) { int fd; - if (wine_key) - if (msgctl(wine_key, IPC_RMID, NULL) == -1) - perror("wine: winsock: shmctl"); + dprintf_winsock(stddeb, "WSACleanup (%d)\n",getpid()); - for (fd = 0; fd != FD_SETSIZE; fd++) - if (FD_ISSET(fd, &fd_in_use)) - close(fd); + if (!wsa_initted) { + WSASetLastError(WSANOTINITIALISED); + return SOCKET_ERROR; + } - wsa_initted = 0; + /* decrement usage count */ + wsa_initted--; + + if (wsa_initted == 0) { + if (wine_key) + if (msgctl(wine_key, IPC_RMID, NULL) == -1) + perror("wine: winsock: msgctl"); + + for (fd = 0; fd != FD_SETSIZE; fd++) + if (FD_ISSET(fd, &fd_in_use)) + close(fd); + + } return 0; } diff --git a/miscemu/interrupts.c b/miscemu/interrupts.c index 97a94908fcc..8e492c72728 100644 --- a/miscemu/interrupts.c +++ b/miscemu/interrupts.c @@ -4,6 +4,8 @@ * Copyright 1995 Alexandre Julliard */ +#include + #include "windows.h" #include "drive.h" #include "miscemu.h" diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c index c8960709645..de0fb0efd07 100644 --- a/multimedia/mcistring.c +++ b/multimedia/mcistring.c @@ -24,6 +24,12 @@ #include "debug.h" #include "xmalloc.h" +#ifdef WINELIB32 +#define UIFMT "%u" +#else +#define UIFMT "%hu" +#endif + extern MCI_OPEN_DRIVER_PARMS mciDrv[MAXMCIDRIVERS]; /* FIXME: I need to remember the aliasname of a spec. driver. diff --git a/objects/bitblt.c b/objects/bitblt.c index 73159f3a88d..b9b2b786019 100644 --- a/objects/bitblt.c +++ b/objects/bitblt.c @@ -1066,11 +1066,11 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst, dcSrc, xSrc, ySrc, widthSrc, heightSrc, &visRectSrc, &visRectDst )) return TRUE; - dprintf_bitblt( stddeb, " vissrc=%ld,%ld-%ld,%ld visdst=%ld,%ld-%ld,%ld\n", - (LONG)visRectSrc.left, (LONG)visRectSrc.top, - (LONG)visRectSrc.right, (LONG)visRectSrc.bottom, - (LONG)visRectDst.left, (LONG)visRectDst.top, - (LONG)visRectDst.right, (LONG)visRectDst.bottom ); + dprintf_bitblt( stddeb, " vissrc=%d,%d-%d,%d visdst=%d,%d-%d,%d\n", + visRectSrc.left, visRectSrc.top, + visRectSrc.right, visRectSrc.bottom, + visRectDst.left, visRectDst.top, + visRectDst.right, visRectDst.bottom ); } else { @@ -1078,9 +1078,9 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst, if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst, NULL, 0, 0, 0, 0, NULL, &visRectDst )) return TRUE; - dprintf_bitblt( stddeb, " vissrc=none visdst=%ld,%ld-%ld,%ld\n", - (LONG)visRectDst.left, (LONG)visRectDst.top, - (LONG)visRectDst.right, (LONG)visRectDst.bottom ); + dprintf_bitblt( stddeb, " vissrc=none visdst=%d,%d-%d,%d\n", + visRectDst.left, visRectDst.top, + visRectDst.right, visRectDst.bottom ); } width = visRectDst.right - visRectDst.left; @@ -1239,8 +1239,8 @@ BOOL PatBlt( HDC hdc, short left, short top, return TRUE; } - dprintf_bitblt(stddeb, "PatBlt: "NPFMT" %d,%d %dx%d %06lx\n", - hdc, left, top, width, height, rop ); + dprintf_bitblt(stddeb, "PatBlt: %04x %d,%d %dx%d %06lx\n", + hdc, left, top, width, height, rop ); return CallTo32_LargeStack( (int(*)())BITBLT_InternalStretchBlt, 11, dc, left, top, width, height, @@ -1266,7 +1266,7 @@ BOOL BitBlt( HDC hdcDst, INT xDst, INT yDst, INT width, INT height, dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC ); dprintf_bitblt(stddeb, - "BitBlt: "NPFMT" %d,%d %d bpp -> "NPFMT" %d,%d %dx%dx%d rop=%06lx\n", + "BitBlt: %04x %d,%d %d bpp -> %04x %d,%d %dx%dx%d rop=%06lx\n", hdcSrc, xSrc, ySrc, dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst, width, height, dcDst->w.bitsPerPixel, rop); @@ -1296,7 +1296,7 @@ BOOL StretchBlt( HDC hdcDst, short xDst, short yDst, dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC ); dprintf_bitblt(stddeb, - "StretchBlt: "NPFMT" %d,%d %dx%dx%d -> "NPFMT" %d,%d %dx%dx%d rop=%06lx\n", + "StretchBlt: %04x %d,%d %dx%dx%d -> %04x %d,%d %dx%dx%d rop=%06lx\n", hdcSrc, xSrc, ySrc, widthSrc, heightSrc, dcSrc ? dcSrc->w.bitsPerPixel : 0, hdcDst, xDst, yDst, widthDst, heightDst, dcDst->w.bitsPerPixel, rop ); diff --git a/objects/bitmap.c b/objects/bitmap.c index d534d5d7b66..b9921241eb7 100644 --- a/objects/bitmap.c +++ b/objects/bitmap.c @@ -123,7 +123,7 @@ HBITMAP CreateBitmap( INT width, INT height, UINT planes, UINT bpp, LPVOID bits HBITMAP CreateCompatibleBitmap( HDC hdc, INT width, INT height ) { DC * dc; - dprintf_gdi(stddeb, "CreateCompatibleBitmap: "NPFMT" %dx%d\n", + dprintf_gdi(stddeb, "CreateCompatibleBitmap: %04x %dx%d\n", hdc, width, height ); if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; return CreateBitmap( width, height, 1, dc->w.bitsPerPixel, NULL ); @@ -225,11 +225,11 @@ HBITMAP LoadBitmap( HANDLE instance, SEGPTR name ) if (HIWORD(name)) { char *str = (char *)PTR_SEG_TO_LIN( name ); - dprintf_bitmap( stddeb, "LoadBitmap("NPFMT",'%s')\n", instance, str ); + dprintf_bitmap( stddeb, "LoadBitmap(%04x,'%s')\n", instance, str ); if (str[0] == '#') name = (SEGPTR)(DWORD)(WORD)atoi( str + 1 ); } else - dprintf_bitmap( stddeb, "LoadBitmap("NPFMT",%04x)\n", + dprintf_bitmap( stddeb, "LoadBitmap(%04x,%04x)\n", instance, LOWORD(name) ); if (!instance) /* OEM bitmap */ @@ -311,7 +311,7 @@ HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap, */ HBITMAP CreateDiscardableBitmap(HDC hdc, INT width, INT height) { - dprintf_bitmap(stddeb,"CreateDiscardableBitmap("NPFMT", %d, %d); " + dprintf_bitmap(stddeb,"CreateDiscardableBitmap(%04x, %d, %d); " "// call CreateCompatibleBitmap() for now!\n", hdc, width, height); return CreateCompatibleBitmap(hdc, width, height); diff --git a/objects/brush.c b/objects/brush.c index 0bca76df60e..cd55bd35396 100644 --- a/objects/brush.c +++ b/objects/brush.c @@ -172,17 +172,13 @@ HBRUSH CreatePatternBrush( HBITMAP hbitmap ) LOGBRUSH logbrush = { BS_PATTERN, 0, 0 }; BITMAPOBJ *bmp, *newbmp; - dprintf_gdi(stddeb, "CreatePatternBrush: "NPFMT"\n", hbitmap ); + dprintf_gdi(stddeb, "CreatePatternBrush: %04x\n", hbitmap ); /* Make a copy of the bitmap */ if (!(bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC ))) return 0; -#ifdef WINELIB32 - logbrush.lbHatch = (LONG)CreateBitmapIndirect( &bmp->bitmap ); -#else logbrush.lbHatch = (INT)CreateBitmapIndirect( &bmp->bitmap ); -#endif newbmp = (BITMAPOBJ *) GDI_GetObjPtr( (HANDLE)logbrush.lbHatch, BITMAP_MAGIC ); if (!newbmp) return 0; XCopyArea( display, bmp->pixmap, newbmp->pixmap, BITMAP_GC(bmp), @@ -200,7 +196,7 @@ HBRUSH CreateDIBPatternBrush( HGLOBAL hbitmap, UINT coloruse ) BITMAPINFO *info, *newInfo; int size; - dprintf_gdi(stddeb, "CreateDIBPatternBrush: "NPFMT"\n", hbitmap ); + dprintf_gdi(stddeb, "CreateDIBPatternBrush: %04x\n", hbitmap ); /* Make a copy of the bitmap */ @@ -212,11 +208,7 @@ HBRUSH CreateDIBPatternBrush( HGLOBAL hbitmap, UINT coloruse ) * 8 * info->bmiHeader.biHeight; size += DIB_BitmapInfoSize( info, coloruse ); -#ifdef WINELIB32 - if (!(logbrush.lbHatch = (LONG)GlobalAlloc( GMEM_MOVEABLE, size ))) -#else if (!(logbrush.lbHatch = (INT)GlobalAlloc( GMEM_MOVEABLE, size ))) -#endif { GlobalUnlock( hbitmap ); return 0; @@ -348,8 +340,8 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) BITMAPINFO * bmpInfo; HBRUSH prevHandle = dc->w.hBrush; - dprintf_gdi(stddeb, "Brush_SelectObject hdc="NPFMT" hbrush="NPFMT"\n", - hdc,hbrush); + dprintf_gdi(stddeb, "Brush_SelectObject: hdc=%04x hbrush=%04x\n", + hdc,hbrush); if (dc->header.wMagic == METAFILE_DC_MAGIC) { switch (brush->logbrush.lbStyle) diff --git a/objects/clipping.c b/objects/clipping.c index 08e65d71f5e..fc96017042d 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -67,7 +67,7 @@ int SelectClipRgn( HDC hdc, HRGN hrgn ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "SelectClipRgn: "NPFMT" "NPFMT"\n", hdc, hrgn ); + dprintf_clipping(stddeb, "SelectClipRgn: %04x %04x\n", hdc, hrgn ); if (hrgn) { @@ -94,7 +94,7 @@ int SelectVisRgn( HDC hdc, HRGN hrgn ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc || !hrgn) return ERROR; - dprintf_clipping(stddeb, "SelectVisRgn: "NPFMT" "NPFMT"\n", hdc, hrgn ); + dprintf_clipping(stddeb, "SelectVisRgn: %04x %04x\n", hdc, hrgn ); retval = CombineRgn( dc->w.hVisRgn, hrgn, 0, RGN_COPY ); CLIPPING_UpdateGCRegion( dc ); @@ -116,7 +116,7 @@ int OffsetClipRgn( HDC hdc, short x, short y ) return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "OffsetClipRgn: "NPFMT" %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "OffsetClipRgn: %04x %d,%d\n", hdc, x, y ); if (dc->w.hClipRgn) { @@ -136,7 +136,7 @@ int OffsetVisRgn( HDC hdc, short x, short y ) int retval; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "OffsetVisRgn: "NPFMT" %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "OffsetVisRgn: %04x %d,%d\n", hdc, x, y ); retval = OffsetRgn( dc->w.hVisRgn, x, y ); CLIPPING_UpdateGCRegion( dc ); return retval; @@ -195,7 +195,7 @@ int ExcludeClipRect( HDC hdc, short left, short top, return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "ExcludeClipRect: "NPFMT" %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "ExcludeClipRect: %04x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, TRUE ); } @@ -216,7 +216,7 @@ int IntersectClipRect( HDC hdc, short left, short top, return NULLREGION; /* ?? */ } - dprintf_clipping(stddeb, "IntersectClipRect: "NPFMT" %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "IntersectClipRect: %04x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectClipRect( dc, left, top, right, bottom, FALSE ); } @@ -269,7 +269,7 @@ int ExcludeVisRect( HDC hdc, short left, short top, short right, short bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "ExcludeVisRect: "NPFMT" %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "ExcludeVisRect: %04x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, TRUE ); } @@ -283,7 +283,7 @@ int IntersectVisRect( HDC hdc, short left, short top, { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "IntersectVisRect: "NPFMT" %dx%d,%dx%d\n", + dprintf_clipping(stddeb, "IntersectVisRect: %04x %dx%d,%dx%d\n", hdc, left, top, right, bottom ); return CLIPPING_IntersectVisRect( dc, left, top, right, bottom, FALSE ); } @@ -297,7 +297,7 @@ BOOL PtVisible( HDC hdc, short x, short y ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "PtVisible: "NPFMT" %d,%d\n", hdc, x, y ); + dprintf_clipping(stddeb, "PtVisible: %04x %d,%d\n", hdc, x, y ); if (!dc->w.hGCClipRgn) return FALSE; return PtInRegion( dc->w.hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) ); } @@ -311,9 +311,8 @@ BOOL RectVisible( HDC hdc, LPRECT rect ) RECT tmpRect; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return FALSE; - dprintf_clipping(stddeb,"RectVisible: "NPFMT" %ld,%ldx%ld,%ld\n", - hdc, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, - (LONG)rect->bottom ); + dprintf_clipping(stddeb,"RectVisible: %04x %d,%dx%d,%d\n", + hdc, rect->left, rect->top, rect->right, rect->bottom ); if (!dc->w.hGCClipRgn) return FALSE; /* copy rectangle to avoid overwriting by LPtoDP */ tmpRect = *rect; @@ -330,7 +329,7 @@ int GetClipBox( HDC hdc, LPRECT rect ) int ret; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return ERROR; - dprintf_clipping(stddeb, "GetClipBox: "NPFMT" %p\n", hdc, rect ); + dprintf_clipping(stddeb, "GetClipBox: %04x %p\n", hdc, rect ); ret = GetRgnBox( dc->w.hGCClipRgn, rect ); DPtoLP( hdc, (LPPOINT)rect, 2 ); return ret; @@ -346,7 +345,7 @@ HRGN SaveVisRgn( HDC hdc ) RGNOBJ *obj, *copyObj; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return 0; - dprintf_clipping(stddeb, "SaveVisRgn: "NPFMT"\n", hdc ); + dprintf_clipping(stddeb, "SaveVisRgn: %04x\n", hdc ); if (!dc->w.hVisRgn) { fprintf( stderr, "SaveVisRgn: hVisRgn is zero. Please report this.\n" ); @@ -373,7 +372,7 @@ int RestoreVisRgn( HDC hdc ) RGNOBJ *obj, *savedObj; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc || !dc->w.hVisRgn) return ERROR; - dprintf_clipping(stddeb, "RestoreVisRgn: "NPFMT"\n", hdc ); + dprintf_clipping(stddeb, "RestoreVisRgn: %04x\n", hdc ); if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC ))) return ERROR; if (!(saved = obj->header.hNext)) return ERROR; diff --git a/objects/cursoricon.c b/objects/cursoricon.c index 763f53c91fe..870f0ef00c3 100644 --- a/objects/cursoricon.c +++ b/objects/cursoricon.c @@ -340,7 +340,7 @@ static HANDLE CURSORICON_LoadHandler( HANDLE handle, HINSTANCE hInstance, } /* Make it owned by the module */ - if (hInstance) FarSetOwner( handle, (WORD)(DWORD)GetExePtr(hInstance) ); + if (hInstance) FarSetOwner( handle, GetExePtr(hInstance) ); info = (CURSORICONINFO *)GlobalLock( handle ); info->ptHotSpot.x = hotspot.x; @@ -417,7 +417,7 @@ static HANDLE CURSORICON_Copy( HANDLE hInstance, HANDLE handle ) if (!(hInstance = GetExePtr( hInstance ))) return 0; size = GlobalSize( handle ); hNew = GlobalAlloc( GMEM_MOVEABLE, size ); - FarSetOwner( hNew, (WORD)(DWORD)hInstance ); + FarSetOwner( hNew, hInstance ); ptrNew = (char *)GlobalLock( hNew ); memcpy( ptrNew, ptrOld, size ); GlobalUnlock( handle ); @@ -466,10 +466,10 @@ HCURSOR CURSORICON_IconToCursor(HICON hIcon) HCURSOR LoadCursor( HANDLE hInstance, SEGPTR name ) { if (HIWORD(name)) - dprintf_cursor( stddeb, "LoadCursor: "NPFMT" '%s'\n", + dprintf_cursor( stddeb, "LoadCursor: %04x '%s'\n", hInstance, (char *)PTR_SEG_TO_LIN( name ) ); else - dprintf_cursor( stddeb, "LoadCursor: "NPFMT" %04x\n", + dprintf_cursor( stddeb, "LoadCursor: %04x %04x\n", hInstance, LOWORD(name) ); return CURSORICON_Load( hInstance, name, @@ -483,10 +483,10 @@ HCURSOR LoadCursor( HANDLE hInstance, SEGPTR name ) HICON LoadIcon( HANDLE hInstance, SEGPTR name ) { if (HIWORD(name)) - dprintf_icon( stddeb, "LoadIcon: "NPFMT" '%s'\n", + dprintf_icon( stddeb, "LoadIcon: %04x '%s'\n", hInstance, (char *)PTR_SEG_TO_LIN( name ) ); else - dprintf_icon( stddeb, "LoadIcon: "NPFMT" %04x\n", + dprintf_icon( stddeb, "LoadIcon: %04x %04x\n", hInstance, LOWORD(name) ); return CURSORICON_Load( hInstance, name, @@ -554,16 +554,16 @@ HANDLE CreateCursorIconIndirect( HANDLE hInstance, CURSORICONINFO *info, /*********************************************************************** * CopyIcon (USER.368) */ -#ifdef WINELIB32 +#ifdef WINELIB HICON CopyIcon( HICON hIcon ) { - dprintf_icon( stddeb, "CopyIcon: "NPFMT"\n", hIcon ); + dprintf_icon( stddeb, "CopyIcon: %04x\n", hIcon ); return CURSORICON_Copy( 0, hIcon ); } #else HICON CopyIcon( HANDLE hInstance, HICON hIcon ) { - dprintf_icon( stddeb, "CopyIcon: "NPFMT" "NPFMT"\n", hInstance, hIcon ); + dprintf_icon( stddeb, "CopyIcon: %04x %04x\n", hInstance, hIcon ); return CURSORICON_Copy( hInstance, hIcon ); } #endif @@ -572,16 +572,16 @@ HICON CopyIcon( HANDLE hInstance, HICON hIcon ) /*********************************************************************** * CopyCursor (USER.369) */ -#ifdef WINELIB32 +#ifdef WINELIB HCURSOR CopyCursor( HCURSOR hCursor ) { - dprintf_cursor( stddeb, "CopyCursor: "NPFMT"\n", hCursor ); + dprintf_cursor( stddeb, "CopyCursor: %04x\n", hCursor ); return CURSORICON_Copy( 0, hCursor ); } #else HCURSOR CopyCursor( HANDLE hInstance, HCURSOR hCursor ) { - dprintf_cursor( stddeb, "CopyCursor: "NPFMT" "NPFMT"\n", hInstance, hCursor ); + dprintf_cursor( stddeb, "CopyCursor: %04x %04x\n", hInstance, hCursor ); return CURSORICON_Copy( hInstance, hCursor ); } #endif @@ -592,7 +592,7 @@ HCURSOR CopyCursor( HANDLE hInstance, HCURSOR hCursor ) */ BOOL DestroyIcon( HICON hIcon ) { - dprintf_icon( stddeb, "DestroyIcon: "NPFMT"\n", hIcon ); + dprintf_icon( stddeb, "DestroyIcon: %04x\n", hIcon ); /* FIXME: should check for OEM icon here */ return (GlobalFree( hIcon ) != 0); } @@ -603,7 +603,7 @@ BOOL DestroyIcon( HICON hIcon ) */ BOOL DestroyCursor( HCURSOR hCursor ) { - dprintf_cursor( stddeb, "DestroyCursor: "NPFMT"\n", hCursor ); + dprintf_cursor( stddeb, "DestroyCursor: %04x\n", hCursor ); /* FIXME: should check for OEM cursor here */ return (GlobalFree( hCursor ) != 0); } @@ -697,7 +697,7 @@ static BOOL CURSORICON_SetCursor( HCURSOR hCursor ) if (!(ptr = (CURSORICONINFO*)GlobalLock( hCursor ))) return FALSE; if (ptr->bPlanes * ptr->bBitsPerPixel != 1) { - fprintf( stderr, "Cursor "NPFMT" has more than 1 bpp!\n", hCursor ); + fprintf( stderr, "Cursor %04x has more than 1 bpp!\n", hCursor ); return FALSE; } @@ -813,7 +813,7 @@ HCURSOR SetCursor( HCURSOR hCursor ) HCURSOR hOldCursor; if (hCursor == hActiveCursor) return hActiveCursor; /* No change */ - dprintf_cursor( stddeb, "SetCursor: "NPFMT"\n", hCursor ); + dprintf_cursor( stddeb, "SetCursor: %04x\n", hCursor ); hOldCursor = hActiveCursor; hActiveCursor = hCursor; /* Change the cursor shape only if it is visible */ @@ -892,8 +892,7 @@ void GetCursorPos( POINT *pt ) pt->x = rootX + desktopX; pt->y = rootY + desktopY; } - dprintf_cursor(stddeb, "GetCursorPos: ret=%ld,%ld\n", (LONG)pt->x, - (LONG)pt->y ); + dprintf_cursor(stddeb, "GetCursorPos: ret=%d,%d\n", pt->x, pt->y ); } @@ -920,7 +919,7 @@ WORD GetIconID( HANDLE hResource, DWORD resType ) return 0; } - dprintf_cursor( stddeb, "GetIconID: hRes="NPFMT", entries=%i\n", + dprintf_cursor( stddeb, "GetIconID: hRes=%04x, entries=%i\n", hResource, lpDir->idCount ); switch(resType) @@ -949,7 +948,7 @@ WORD GetIconID( HANDLE hResource, DWORD resType ) */ HICON LoadIconHandler( HANDLE hResource, BOOL bNew ) { - dprintf_cursor(stddeb,"LoadIconHandler: hRes="NPFMT"\n",hResource); + dprintf_cursor(stddeb,"LoadIconHandler: hRes=%04x\n",hResource); if( !bNew ) { diff --git a/objects/dc.c b/objects/dc.c index 029534c0d8a..6c7a5dcc31d 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -333,7 +333,7 @@ HDC GetDCState( HDC hdc ) if (!(handle = GDI_AllocObject( sizeof(DC), DC_MAGIC ))) return 0; newdc = (DC *) GDI_HEAP_LIN_ADDR( handle ); - dprintf_dc(stddeb, "GetDCState("NPFMT"): returning "NPFMT"\n", hdc, handle ); + dprintf_dc(stddeb, "GetDCState(%04x): returning %04x\n", hdc, handle ); memset( &newdc->u.x, 0, sizeof(newdc->u.x) ); memcpy( &newdc->w, &dc->w, sizeof(dc->w) ); @@ -366,7 +366,7 @@ void SetDCState( HDC hdc, HDC hdcs ) if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return; if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) return; if (!dcs->w.flags & DC_SAVED) return; - dprintf_dc(stddeb, "SetDCState: "NPFMT" "NPFMT"\n", hdc, hdcs ); + dprintf_dc(stddeb, "SetDCState: %04x %04x\n", hdc, hdcs ); /* Save the regions before overwriting everything */ hVisRgn = dc->w.hVisRgn; @@ -410,7 +410,7 @@ int SaveDC( HDC hdc ) dcs = (DC *) GDI_HEAP_LIN_ADDR( hdcs ); dcs->header.hNext = dc->header.hNext; dc->header.hNext = hdcs; - dprintf_dc(stddeb, "SaveDC("NPFMT"): returning %d\n", hdc, dc->saveLevel+1 ); + dprintf_dc(stddeb, "SaveDC(%04x): returning %d\n", hdc, dc->saveLevel+1 ); return ++dc->saveLevel; } @@ -422,7 +422,7 @@ BOOL RestoreDC( HDC hdc, short level ) { DC * dc, * dcs; - dprintf_dc(stddeb, "RestoreDC: "NPFMT" %d\n", hdc, level ); + dprintf_dc(stddeb, "RestoreDC: %04x %d\n", hdc, level ); dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) { @@ -459,7 +459,7 @@ HDC CreateDC( LPCTSTR driver, LPCTSTR device, LPCTSTR output, const DEVMODE* ini if (!handle) return 0; dc = (DC *) GDI_HEAP_LIN_ADDR( handle ); - dprintf_dc(stddeb, "CreateDC(%s %s %s): returning "NPFMT"\n", + dprintf_dc(stddeb, "CreateDC(%s %s %s): returning %04x\n", driver, device, output, handle ); if (!displayDevCaps) @@ -515,7 +515,7 @@ HDC CreateCompatibleDC( HDC hdc ) if (!handle) return 0; dc = (DC *) GDI_HEAP_LIN_ADDR( handle ); - dprintf_dc(stddeb, "CreateCompatibleDC("NPFMT"): returning "NPFMT"\n", hdc, handle ); + dprintf_dc(stddeb, "CreateCompatibleDC(%04x): returning %04x\n", hdc, handle ); /* Create default bitmap */ if (!(hbitmap = CreateBitmap( 1, 1, 1, 1, NULL ))) @@ -559,7 +559,7 @@ BOOL DeleteDC( HDC hdc ) DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return FALSE; - dprintf_dc(stddeb, "DeleteDC: "NPFMT"\n", hdc ); + dprintf_dc(stddeb, "DeleteDC: %04x\n", hdc ); while (dc->saveLevel) { @@ -608,7 +608,7 @@ int GetDeviceCaps( HDC hdc, WORD cap ) if (cap > sizeof(DeviceCaps)-sizeof(WORD)) return 0; - dprintf_dc(stddeb, "GetDeviceCaps("NPFMT",%d): returning %d\n", + dprintf_dc(stddeb, "GetDeviceCaps(%04x,%d): returning %d\n", hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) ); return *(WORD *)(((char *)dc->w.devCaps) + cap); } diff --git a/objects/font.c b/objects/font.c index bbef8f65786..114c8eaaea5 100644 --- a/objects/font.c +++ b/objects/font.c @@ -283,7 +283,7 @@ void FONT_GetMetrics( LOGFONT * logfont, XFontStruct * xfont, DWORD GetGlyphOutLine(HDC hdc, UINT uChar, UINT fuFormat, LPGLYPHMETRICS lpgm, DWORD cbBuffer, LPSTR lpBuffer, LPMAT2 lpmat2) { - fprintf( stdnimp,"GetGlyphOutLine("NPFMT", '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n", + fprintf( stdnimp,"GetGlyphOutLine(%04x, '%c', %04x, %p, %ld, %p, %p) // - empty stub!\n", hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer, lpmat2 ); return (DWORD)-1; /* failure */ } @@ -323,7 +323,7 @@ HFONT CreateFontIndirect( const LOGFONT * font ) fontPtr = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hfont ); memcpy( &fontPtr->logfont, font, sizeof(LOGFONT) ); AnsiLower( fontPtr->logfont.lfFaceName ); - dprintf_font(stddeb,"CreateFontIndirect(%p (%d,%d)); return "NPFMT"\n", + dprintf_font(stddeb,"CreateFontIndirect(%p (%d,%d)); return %04x\n", font, font->lfHeight, font->lfWidth, hfont); return hfont; } @@ -370,8 +370,7 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font ) X_PHYSFONT * stockPtr; HFONT prevHandle = dc->w.hFont; XFontStruct * fontStruct; - dprintf_font(stddeb,"FONT_SelectObject(%p, "NPFMT", %p)\n", - dc, hfont, font); + dprintf_font(stddeb,"FONT_SelectObject(%p, %04x, %p)\n", dc, hfont, font); #if 0 /* From the code in SelectObject, this can not happen */ /* Load font if necessary */ @@ -392,9 +391,8 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font ) else return 0; - /* Must be DWORD for WINELIB32 support */ if ((hfont >= FIRST_STOCK_FONT) && (hfont <= LAST_STOCK_FONT)) - stockPtr = &stockFonts[(DWORD)hfont - (DWORD)FIRST_STOCK_FONT]; + stockPtr = &stockFonts[hfont - FIRST_STOCK_FONT]; else stockPtr = NULL; @@ -405,7 +403,7 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font ) /* If it is not a stock font, we can simply return 0 */ if (!stockPtr) return 0; /* Otherwise we must try to find a substitute */ - dprintf_font(stddeb,"Loading font 'fixed' for "NPFMT"\n", hfont ); + dprintf_font(stddeb,"Loading font 'fixed' for %04x\n", hfont ); font->logfont.lfPitchAndFamily &= ~VARIABLE_PITCH; font->logfont.lfPitchAndFamily |= FIXED_PITCH; fontStruct = XLoadQueryFont( display, "fixed" ); @@ -420,7 +418,7 @@ HFONT FONT_SelectObject( DC * dc, HFONT hfont, FONTOBJ * font ) { fontStruct = stockPtr->fstruct; dprintf_font(stddeb, - "FONT_SelectObject: Loaded font from cache "NPFMT" %p\n", + "FONT_SelectObject: Loaded font from cache %04x %p\n", hfont, fontStruct ); } @@ -550,9 +548,8 @@ BOOL GetTextExtentPoint( HDC hdc, LPCSTR str, short count, LPSIZE size ) size->cy = abs((dc->u.x.font.fstruct->ascent+dc->u.x.font.fstruct->descent) * dc->w.WndExtY / dc->w.VportExtY); - dprintf_font(stddeb,"GetTextExtentPoint("NPFMT" '%*.*s' %d %p): returning %ld,%ld\n", - hdc, count, count, str, count, size, (LONG)size->cx, - (LONG)size->cy ); + dprintf_font(stddeb,"GetTextExtentPoint(%04x '%*.*s' %d %p): returning %d,%d\n", + hdc, count, count, str, count, size, size->cx, size->cy ); return TRUE; } @@ -588,7 +585,7 @@ BOOL GetTextMetrics( HDC hdc, LPTEXTMETRIC metrics ) */ DWORD SetMapperFlags(HDC hDC, DWORD dwFlag) { - dprintf_font(stdnimp,"SetmapperFlags("NPFMT", %08lX) // Empty Stub !\n", + dprintf_font(stdnimp,"SetmapperFlags(%04x, %08lX) // Empty Stub !\n", hDC, dwFlag); return 0L; } @@ -664,10 +661,6 @@ BOOL RemoveFontResource( LPSTR str ) int ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz) { int i; -#if 0 - dprintf_font(stddeb,"ParseFontParms('%s', %d, %p, %d);\n", - lpFont, wParmsNo, lpRetStr, wMaxSiz); -#endif if (lpFont == NULL) return 0; if (lpRetStr == NULL) return 0; for (i = 0; (*lpFont != '\0' && i != wParmsNo); ) { @@ -680,9 +673,6 @@ int ParseFontParms(LPSTR lpFont, WORD wParmsNo, LPSTR lpRetStr, WORD wMaxSiz) for (i = 0; (*lpFont != '\0' && *lpFont != '-' && i < wMaxSiz); i++) *(lpRetStr + i) = *lpFont++; *(lpRetStr + i) = '\0'; -#if 0 - dprintf_font(stddeb,"ParseFontParms // '%s'\n", lpRetStr); -#endif return i; } else @@ -789,7 +779,7 @@ INT EnumFonts(HDC hDC, LPCTSTR lpFaceName, FONTENUMPROC lpEnumFunc, LPARAM lpDat int nRet = 0; int i; - dprintf_font(stddeb,"EnumFonts("NPFMT", %p='%s', %08lx, %08lx)\n", + dprintf_font(stddeb,"EnumFonts(%04x, %p='%s', %08lx, %08lx)\n", hDC, lpFaceName, lpFaceName, (LONG)lpEnumFunc, lpData); if (lpEnumFunc == 0) return 0; hLog = GDI_HEAP_ALLOC( sizeof(LOGFONT) + LF_FACESIZE ); @@ -859,7 +849,7 @@ INT EnumFontFamilies(HDC hDC, LPCTSTR lpszFamily, FONTENUMPROC lpEnumFunc, LPARA int nRet = 0; int i; - dprintf_font(stddeb,"EnumFontFamilies("NPFMT", %p, %08lx, %08lx)\n", + dprintf_font(stddeb,"EnumFontFamilies(%04x, %p, %08lx, %08lx)\n", hDC, lpszFamily, (DWORD)lpEnumFunc, lpData); if (lpEnumFunc == 0) return 0; hLog = GDI_HEAP_ALLOC( sizeof(ENUMLOGFONT) ); diff --git a/objects/gdiobj.c b/objects/gdiobj.c index d840c1efd93..ad3ef50926b 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -174,7 +174,7 @@ BOOL GDI_Init(void) /* Create default palette */ if (!(hpalette = COLOR_Init())) return FALSE; - StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( hpalette ); + StockObjects[DEFAULT_PALETTE] = (GDIOBJHDR *)GDI_HEAP_LIN_ADDR( hpalette ); /* Create default bitmap */ @@ -217,8 +217,8 @@ BOOL GDI_FreeObject( HANDLE handle ) GDIOBJHDR * object; /* Can't free stock objects */ - if ((DWORD)handle >= FIRST_STOCK_HANDLE && - (DWORD)handle <= LAST_STOCK_HANDLE ) return TRUE; + if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE)) + return TRUE; object = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); if (!object) return FALSE; @@ -240,9 +240,8 @@ GDIOBJHDR * GDI_GetObjPtr( HANDLE handle, WORD magic ) { GDIOBJHDR * ptr = NULL; - if ((DWORD)handle >= FIRST_STOCK_HANDLE && - (DWORD)handle <= LAST_STOCK_HANDLE ) - ptr = StockObjects[(DWORD)handle - FIRST_STOCK_HANDLE]; + if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE)) + ptr = StockObjects[handle - FIRST_STOCK_HANDLE]; else ptr = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); if (!ptr) return NULL; @@ -261,7 +260,7 @@ BOOL DeleteObject( HGDIOBJ obj ) GDIOBJHDR * header = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( obj ); if (!header) return FALSE; - dprintf_gdi(stddeb, "DeleteObject: "NPFMT"\n", obj ); + dprintf_gdi(stddeb, "DeleteObject: %04x\n", obj ); /* Delete object */ @@ -285,9 +284,9 @@ HANDLE GetStockObject( int obj ) { if ((obj < 0) || (obj >= NB_STOCK_OBJECTS)) return 0; if (!StockObjects[obj]) return 0; - dprintf_gdi(stddeb, "GetStockObject: returning %ld\n", - (DWORD)FIRST_STOCK_HANDLE + obj ); - return (HANDLE)((DWORD)FIRST_STOCK_HANDLE + obj); + dprintf_gdi(stddeb, "GetStockObject: returning %d\n", + FIRST_STOCK_HANDLE + obj ); + return (HANDLE)(FIRST_STOCK_HANDLE + obj); } @@ -297,12 +296,11 @@ HANDLE GetStockObject( int obj ) int GetObject( HANDLE handle, int count, LPSTR buffer ) { GDIOBJHDR * ptr = NULL; - dprintf_gdi(stddeb, "GetObject: "NPFMT" %d %p\n", handle, count, buffer ); + dprintf_gdi(stddeb, "GetObject: %04x %d %p\n", handle, count, buffer ); if (!count) return 0; - if ((DWORD)handle >= FIRST_STOCK_HANDLE && - (DWORD)handle <= LAST_STOCK_HANDLE ) - ptr = StockObjects[(DWORD)handle - FIRST_STOCK_HANDLE]; + if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE)) + ptr = StockObjects[handle - FIRST_STOCK_HANDLE]; else ptr = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); if (!ptr) return 0; @@ -332,10 +330,9 @@ HANDLE SelectObject( HDC hdc, HANDLE handle ) GDIOBJHDR * ptr = NULL; DC * dc; - dprintf_gdi(stddeb, "SelectObject: "NPFMT" "NPFMT"\n", hdc, handle ); - if ((DWORD)handle >= FIRST_STOCK_HANDLE && - (DWORD)handle <= LAST_STOCK_HANDLE ) - ptr = StockObjects[(DWORD)handle - FIRST_STOCK_HANDLE]; + dprintf_gdi(stddeb, "SelectObject: %04x %04x\n", hdc, handle ); + if ((handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE)) + ptr = StockObjects[handle - FIRST_STOCK_HANDLE]; else ptr = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); if (!ptr) return 0; @@ -369,7 +366,7 @@ HANDLE SelectObject( HDC hdc, HANDLE handle ) */ BOOL UnrealizeObject( HANDLE handle ) { - dprintf_gdi(stdnimp, "UnrealizeObject: "NPFMT"\n", handle ); + dprintf_gdi(stdnimp, "UnrealizeObject: %04x\n", handle ); return TRUE; } @@ -393,7 +390,7 @@ INT EnumObjects( HDC hdc, INT nObjType, GOBJENUMPROC lpEnumFunc, LPARAM lParam ) int i, retval = 0; - dprintf_gdi( stddeb, "EnumObjects: "NPFMT" %d %08lx %08lx\n", + dprintf_gdi( stddeb, "EnumObjects: %04x %d %08lx %08lx\n", hdc, nObjType, (DWORD)lpEnumFunc, lParam ); switch(nObjType) { @@ -440,122 +437,17 @@ INT EnumObjects( HDC hdc, INT nObjType, GOBJENUMPROC lpEnumFunc, LPARAM lParam ) break; } return retval; -#if 0 - - /* HANDLE handle; - DC *dc;*/ - HANDLE *lphObj; - GDIOBJHDR *header; - WORD wMagic; - LPSTR lpLog; /* Point to a LOGBRUSH or LOGPEN struct */ - HANDLE hLog; - int nRet = 0; - - if (lpEnumFunc == 0) { - fprintf(stderr,"EnumObjects // Bad EnumProc callback address !\n"); - return 0; - } - switch (nObjType) { - case OBJ_PEN: - wMagic = PEN_MAGIC; - dprintf_gdi(stddeb,"EnumObjects("NPFMT", OBJ_PEN, %08lx, %p);\n", - hDC, (LONG)lpEnumFunc, lpData); - hLog = GDI_HEAP_ALLOC( sizeof(LOGPEN) ); - lpLog = (LPSTR) GDI_HEAP_LIN_ADDR(hLog); - if (lpLog == NULL) { - fprintf(stderr,"EnumObjects // Unable to alloc LOGPEN struct !\n"); - return 0; - } - break; - case OBJ_BRUSH: - wMagic = BRUSH_MAGIC; - dprintf_gdi(stddeb,"EnumObjects("NPFMT", OBJ_BRUSH, %08lx, %p);\n", - hDC, (LONG)lpEnumFunc, lpData); - hLog = GDI_HEAP_ALLOC( sizeof(LOGBRUSH) ); - lpLog = (LPSTR) GDI_HEAP_LIN_ADDR(hLog); - if (lpLog == NULL) { - fprintf(stderr,"EnumObjects // Unable to alloc LOGBRUSH struct !\n"); - return 0; - } - break; - default: - fprintf(stderr,"EnumObjects("NPFMT", %04X, %08lx, %p); // Unknown OBJ type !\n", - hDC, nObjType, (LONG)lpEnumFunc, lpData); - return 0; - } -#ifdef notdef /* FIXME: stock object ptr won't work in callback */ - dprintf_gdi(stddeb,"EnumObjects // Stock Objects first !\n"); - for (i = 0; i < NB_STOCK_OBJECTS; i++) { - header = StockObjects[i]; - if (header->wMagic == wMagic) { - PEN_GetObject( (PENOBJ *)header, sizeof(LOGPEN), lpLog); - BRUSH_GetObject( (BRUSHOBJ *)header, sizeof(LOGBRUSH),lpLog); - dprintf_gdi(stddeb,"EnumObjects // StockObj lpLog=%p lpData=%p\n", lpLog, lpData); - if (header->wMagic == BRUSH_MAGIC) { - dprintf_gdi(stddeb,"EnumObjects // StockBrush lbStyle=%04X\n", ((LPLOGBRUSH)lpLog)->lbStyle); - dprintf_gdi(stddeb,"EnumObjects // StockBrush lbColor=%08lX\n", ((LPLOGBRUSH)lpLog)->lbColor); - dprintf_gdi(stddeb,"EnumObjects // StockBrush lbHatch=%04X\n", ((LPLOGBRUSH)lpLog)->lbHatch); - } - if (header->wMagic == PEN_MAGIC) { - dprintf_gdi(stddeb,"EnumObjects // StockPen lopnStyle=%04X\n", ((LPLOGPEN)lpLog)->lopnStyle); - dprintf_gdi(stddeb,"EnumObjects // StockPen lopnWidth=%d\n", ((LPLOGPEN)lpLog)->lopnWidth.x); - dprintf_gdi(stddeb,"EnumObjects // StockPen lopnColor=%08lX\n", ((LPLOGPEN)lpLog)->lopnColor); - } - nRet = CallEnumObjectsProc( lpEnumFunc, - GDI_HEAP_SEG_ADDR(hLog), - (int)lpData ); - dprintf_gdi(stddeb,"EnumObjects // after Callback!\n"); - if (nRet == 0) { - GDI_HEAP_FREE(hLog); - dprintf_gdi(stddeb,"EnumObjects // EnumEnd requested by application !\n"); - return 0; - } - } - } - dprintf_gdi(stddeb,"EnumObjects // Now DC owned objects %p !\n", header); -#endif /* notdef */ - - if (lpPenBrushList == NULL) return 0; - for (lphObj = lpPenBrushList; *lphObj != 0; ) { - dprintf_gdi(stddeb,"EnumObjects // *lphObj="NPFMT"\n", *lphObj); - header = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR(*lphObj++); - if (header->wMagic == wMagic) { - dprintf_gdi(stddeb,"EnumObjects // DC_Obj lpLog=%p lpData=%p\n", lpLog, lpData); - if (header->wMagic == BRUSH_MAGIC) { - BRUSH_GetObject( (BRUSHOBJ *)header, sizeof(LOGBRUSH), lpLog); - dprintf_gdi(stddeb,"EnumObjects // DC_Brush lbStyle=%04X\n", ((LPLOGBRUSH)lpLog)->lbStyle); - dprintf_gdi(stddeb,"EnumObjects // DC_Brush lbColor=%08lX\n", ((LPLOGBRUSH)lpLog)->lbColor); - dprintf_gdi(stddeb,"EnumObjects // DC_Brush lbHatch=%04lX\n", (LONG)((LPLOGBRUSH)lpLog)->lbHatch); - } - if (header->wMagic == PEN_MAGIC) { - PEN_GetObject( (PENOBJ *)header, sizeof(LOGPEN), lpLog); - dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnStyle=%04X\n", ((LPLOGPEN)lpLog)->lopnStyle); - dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnWidth=%ld\n", (LONG)((LPLOGPEN)lpLog)->lopnWidth.x); - dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnColor=%08lX\n", ((LPLOGPEN)lpLog)->lopnColor); - } - nRet = CallEnumObjectsProc(lpEnumFunc, GDI_HEAP_SEG_ADDR(hLog), - (LONG)lpData); - if (nRet == 0) - break; - } - } - GDI_HEAP_FREE(hLog); - dprintf_gdi(stddeb,"EnumObjects // End of enumeration !\n"); - return nRet; -#endif } /*********************************************************************** - * IsGDIObject(GDI.462) + * IsGDIObject (GDI.462) */ BOOL IsGDIObject(HANDLE handle) { - GDIOBJHDR *object; + GDIOBJHDR *object; - object = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); - if (object) - return TRUE; - else - return FALSE; + object = (GDIOBJHDR *) GDI_HEAP_LIN_ADDR( handle ); + /* FIXME: should check magic here */ + return (object != NULL); } diff --git a/objects/linedda.c b/objects/linedda.c index d53e1336e02..a6b1296b0b7 100644 --- a/objects/linedda.c +++ b/objects/linedda.c @@ -3,8 +3,7 @@ * * Copyright 1993 Bob Amstadt * -static char Copyright[] = "Copyright Bob Amstadt, 1993"; -*/ + */ #include #include "windows.h" diff --git a/objects/metafile.c b/objects/metafile.c index e93c1a72f12..f66465cec6f 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -3,8 +3,7 @@ * * Copyright David W. Metcalfe, 1994 * -static char Copyright[] = "Copyright David W. Metcalfe, 1994"; -*/ + */ #include #include @@ -573,7 +572,7 @@ HANDLE GetMetaFileBits(HMETAFILE hmf) HANDLE hMem = mf->hMetaHdr; METAHEADER *mh = (METAHEADER *)GlobalLock(hMem); - dprintf_metafile(stddeb,"GetMetaFileBits: hmf in: "NPFMT"\n", hmf); + dprintf_metafile(stddeb,"GetMetaFileBits: hmf in: %04x\n", hmf); /* can't get bits of disk based metafile */ /* FIXME: should the disk file be loaded in this case? */ @@ -589,7 +588,7 @@ HANDLE GetMetaFileBits(HMETAFILE hmf) GlobalUnlock(hMem); GlobalFree(hmf); - dprintf_metafile(stddeb,"GetMetaFileBits: hMem out: "NPFMT"\n", hMem); + dprintf_metafile(stddeb,"GetMetaFileBits: hMem out: %04x\n", hMem); return hMem; } @@ -605,7 +604,7 @@ HMETAFILE SetMetaFileBits(HANDLE hMem) METAFILE *mf; METAHEADER *mh = (METAHEADER *)GlobalLock(hMem); - dprintf_metafile(stddeb,"SetMetaFileBits: hMem in: "NPFMT"\n", hMem); + dprintf_metafile(stddeb,"SetMetaFileBits: hMem in: %04x\n", hMem); if (!mh) return FALSE; @@ -629,7 +628,7 @@ HMETAFILE SetMetaFileBits(HANDLE hMem) GlobalUnlock(hMem); GlobalUnlock(hmf); - dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: "NPFMT"\n", hmf); + dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: %04x\n", hmf); return hmf; } diff --git a/objects/oembitmap.c b/objects/oembitmap.c index 0b2d9a5f983..63204cf997a 100644 --- a/objects/oembitmap.c +++ b/objects/oembitmap.c @@ -17,7 +17,7 @@ #include "cursoricon.h" #include "stddebug.h" #include "debug.h" - +#include "xmalloc.h" /* Include OEM pixmaps */ #include "bitmaps/obm_cdrom" @@ -327,28 +327,34 @@ static BOOL OBM_CreateBitmaps( char **data, BOOL color, HBITMAP *hBitmap, HBITMAP *hBitmapMask, POINT *hotspot ) { Pixmap pixmap, pixmask; - XpmAttributes attrs; + XpmAttributes *attrs; int err; - attrs.valuemask = XpmColormap | XpmDepth | XpmColorSymbols | XpmHotspot; - attrs.colormap = COLOR_WinColormap; - attrs.depth = color ? screenDepth : 1; - attrs.colorsymbols = (attrs.depth > 1) ? OBM_Colors : OBM_BlackAndWhite; - attrs.numsymbols = (attrs.depth > 1) ? NB_COLOR_SYMBOLS : 2; + attrs = (XpmAttributes *)xmalloc( XpmAttributesSize() ); + attrs->valuemask = XpmColormap | XpmDepth | XpmColorSymbols |XpmHotspot; + attrs->colormap = COLOR_WinColormap; + attrs->depth = color ? screenDepth : 1; + attrs->colorsymbols = (attrs->depth > 1) ? OBM_Colors : OBM_BlackAndWhite; + attrs->numsymbols = (attrs->depth > 1) ? NB_COLOR_SYMBOLS : 2; err = XpmCreatePixmapFromData( display, rootWindow, data, - &pixmap, &pixmask, &attrs ); + &pixmap, &pixmask, attrs ); - if (err != XpmSuccess) return FALSE; + if (err != XpmSuccess) + { + free( attrs ); + return FALSE; + } if (hotspot) { - hotspot->x = attrs.x_hotspot; - hotspot->y = attrs.y_hotspot; + hotspot->x = attrs->x_hotspot; + hotspot->y = attrs->y_hotspot; } - *hBitmap = OBM_MakeBitmap( attrs.width, attrs.height, - attrs.depth, pixmap ); - if (hBitmapMask) *hBitmapMask = OBM_MakeBitmap( attrs.width, attrs.height, - 1, pixmask ); + *hBitmap = OBM_MakeBitmap( attrs->width, attrs->height, + attrs->depth, pixmap ); + if (hBitmapMask) *hBitmapMask = OBM_MakeBitmap(attrs->width, attrs->height, + 1, pixmask ); + free( attrs ); if (!*hBitmap) { if (pixmap) XFreePixmap( display, pixmap ); diff --git a/objects/palette.c b/objects/palette.c index a637d5af47e..25001e16962 100644 --- a/objects/palette.c +++ b/objects/palette.c @@ -3,18 +3,11 @@ * * Copyright 1993,1994 Alexandre Julliard * -static char Copyright[] = "Copyright Alexandre Julliard, 1993,1994"; -*/ + */ #include #include -#include - -#if !defined (MAXINT) -#include -#define MAXINT INT_MAX -#endif - #include + #include "color.h" #include "palette.h" #include "stddebug.h" @@ -51,7 +44,7 @@ static WORD PALETTE_GetNearestIndexAndColor(HPALETTE hpalette, COLORREF *color) b = GetBValue(*color); entry = palPtr->logpalette.palPalEntry; - for (i = 0, minDist = MAXINT; minDist !=0 && + for (i = 0, minDist = 0xffffff; minDist !=0 && i < palPtr->logpalette.palNumEntries ; i++) { if (entry->peFlags != 0xff) @@ -158,7 +151,7 @@ BOOL AnimatePalette(HPALETTE hPal, UINT StartIndex, UINT NumEntries, WORD SetSystemPaletteUse( HDC hdc, WORD use) { WORD old=SystemPaletteUse; - printf("SetSystemPaletteUse("NPFMT",%04X) // empty stub !!!\n", hdc, use); + printf("SetSystemPaletteUse(%04x,%04x) // empty stub !!!\n", hdc, use); SystemPaletteUse=use; return old; } @@ -168,7 +161,7 @@ WORD SetSystemPaletteUse( HDC hdc, WORD use) */ WORD GetSystemPaletteUse( HDC hdc ) { - printf("GetSystemPaletteUse("NPFMT") // empty stub !!!\n", hdc); + printf("GetSystemPaletteUse(%04x) // empty stub !!!\n", hdc); return SystemPaletteUse; } @@ -206,7 +199,7 @@ WORD GetSystemPaletteEntries( HDC hdc, WORD start, WORD count, WORD GetNearestPaletteIndex( HPALETTE hpalette, COLORREF color ) { WORD index = PALETTE_GetNearestIndexAndColor( hpalette, &color ); - dprintf_palette(stddeb,"GetNearestPaletteIndex("NPFMT",%06lx): returning %d\n", + dprintf_palette(stddeb,"GetNearestPaletteIndex(%04x,%06lx): returning %d\n", hpalette, color, index ); return index; } @@ -247,7 +240,7 @@ HPALETTE GDISelectPalette( HDC hdc, HPALETTE hpal ) HPALETTE prev; DC *dc; - dprintf_palette(stddeb, "GDISelectPalette: "NPFMT" "NPFMT"\n", hdc, hpal ); + dprintf_palette(stddeb, "GDISelectPalette: %04x %04x\n", hdc, hpal ); if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; prev = dc->w.hPalette; dc->w.hPalette = hpal; @@ -262,7 +255,7 @@ HPALETTE GDISelectPalette( HDC hdc, HPALETTE hpal ) */ UINT GDIRealizePalette( HDC hdc ) { - dprintf_palette(stdnimp, "GDIRealizePalette: "NPFMT"\n", hdc ); + dprintf_palette(stdnimp, "GDIRealizePalette: %04x\n", hdc ); return 0; } diff --git a/objects/region.c b/objects/region.c index 7e7e2907592..f994a91d8e3 100644 --- a/objects/region.c +++ b/objects/region.c @@ -19,7 +19,7 @@ */ BOOL REGION_DeleteObject( HRGN hrgn, RGNOBJ * obj ) { - dprintf_region(stddeb, "DeleteRegion: "NPFMT"\n", hrgn ); + dprintf_region(stddeb, "DeleteRegion: %04x\n", hrgn ); if (obj->xrgn) XDestroyRegion( obj->xrgn ); return GDI_FreeObject( hrgn ); } @@ -32,7 +32,7 @@ int OffsetRgn( HRGN hrgn, short x, short y ) { RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ); if (!obj) return ERROR; - dprintf_region(stddeb, "OffsetRgn: "NPFMT" %d,%d\n", hrgn, x, y ); + dprintf_region(stddeb, "OffsetRgn: %04x %d,%d\n", hrgn, x, y ); if (!obj->xrgn) return NULLREGION; XOffsetRegion( obj->xrgn, x, y ); return COMPLEXREGION; @@ -46,7 +46,7 @@ int GetRgnBox( HRGN hrgn, LPRECT rect ) { RGNOBJ * obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ); if (!obj) return ERROR; - dprintf_region(stddeb, "GetRgnBox: "NPFMT"\n", hrgn ); + dprintf_region(stddeb, "GetRgnBox: %04x\n", hrgn ); if (!obj->xrgn) { SetRectEmpty( rect ); @@ -84,7 +84,7 @@ HRGN CreateRectRgn( INT left, INT top, INT right, INT bottom ) XUnionRectWithRegion( &rect, obj->xrgn, obj->xrgn ); } else obj->xrgn = 0; - dprintf_region( stddeb, "CreateRectRgn(%d,%d-%d,%d): returning "NPFMT"\n", + dprintf_region( stddeb, "CreateRectRgn(%d,%d-%d,%d): returning %04x\n", left, top, right, bottom, hrgn ); return hrgn; } @@ -106,7 +106,7 @@ void SetRectRgn( HRGN hrgn, short left, short top, short right, short bottom ) { RGNOBJ * obj; - dprintf_region(stddeb, "SetRectRgn: "NPFMT" %d,%d-%d,%d\n", + dprintf_region(stddeb, "SetRectRgn: %04x %d,%d-%d,%d\n", hrgn, left, top, right, bottom ); if (!(obj = (RGNOBJ *) GDI_GetObjPtr( hrgn, REGION_MAGIC ))) return; @@ -143,7 +143,7 @@ HRGN CreateRoundRectRgn( INT left, INT top, INT right, INT bottom, if (!(hrgn = GDI_AllocObject( sizeof(RGNOBJ), REGION_MAGIC ))) return 0; obj = (RGNOBJ *) GDI_HEAP_LIN_ADDR( hrgn ); obj->xrgn = XCreateRegion(); - dprintf_region(stddeb,"CreateRoundRectRgn(%d,%d-%d,%d %dx%d): return="NPFMT"\n", + dprintf_region(stddeb,"CreateRoundRectRgn(%d,%d-%d,%d %dx%d): return=%04x\n", left, top, right, bottom, ellipse_width, ellipse_height, hrgn ); /* Check parameters */ @@ -276,7 +276,7 @@ HRGN CreatePolyPolygonRgn( const POINT * points, const INT * count, } obj = (RGNOBJ *) GDI_HEAP_LIN_ADDR( hrgn ); obj->xrgn = 0; - dprintf_region(stddeb, "CreatePolyPolygonRgn: %d polygons, returning "NPFMT"\n", + dprintf_region(stddeb, "CreatePolyPolygonRgn: %d polygons, returning %04x\n", nbpolygons, hrgn ); /* Create X region */ @@ -411,7 +411,7 @@ INT CombineRgn( HRGN hDest, HRGN hSrc1, HRGN hSrc2, INT mode ) RGNOBJ *destObj, *src1Obj, *src2Obj; Region destrgn; - dprintf_region(stddeb, "CombineRgn: "NPFMT","NPFMT" -> "NPFMT" mode=%x\n", + dprintf_region(stddeb, "CombineRgn: %04x,%04x -> %04x mode=%x\n", hSrc1, hSrc2, hDest, mode ); if (!(destObj = (RGNOBJ *) GDI_GetObjPtr( hDest, REGION_MAGIC ))) diff --git a/objects/text.c b/objects/text.c index ad96f0eeefb..2929a01dd12 100644 --- a/objects/text.c +++ b/objects/text.c @@ -197,9 +197,8 @@ INT DrawText( HDC hdc, LPCTSTR str, INT i_count, LPRECT rect, UINT flags ) int width = rect->right - rect->left; int max_width = 0; - dprintf_text(stddeb,"DrawText: '%s', %d , [(%ld,%ld),(%ld,%ld)]\n", str, - count, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, - (LONG)rect->bottom); + dprintf_text(stddeb,"DrawText: '%s', %d , [(%d,%d),(%d,%d)]\n", str, + count, rect->left, rect->top, rect->right, rect->bottom); if (count == -1) count = strlen(str); strPtr = str; @@ -308,11 +307,9 @@ BOOL ExtTextOut( HDC hdc, short x, short y, WORD flags, LPRECT lprect, dprintf_text(stddeb,"ExtTextOut: %d,%d '%*.*s', %d flags=%d\n", x, y, count, count, str, count, flags); - if (lprect != NULL) { - dprintf_text(stddeb, "rect %ld %ld %ld %ld\n", (LONG)lprect->left, - (LONG)lprect->top, (LONG)lprect->right, - (LONG)lprect->bottom ); - } + if (lprect != NULL) dprintf_text(stddeb, "rect %d %d %d %d\n", + lprect->left, lprect->top, + lprect->right, lprect->bottom ); /* Setup coordinates */ @@ -574,7 +571,7 @@ LONG TEXT_TabbedTextOut( HDC hdc, int x, int y, LPSTR lpstr, int count, LONG TabbedTextOut( HDC hdc, short x, short y, LPSTR lpstr, short count, short cTabStops, LPINT lpTabPos, short nTabOrg ) { - dprintf_text( stddeb, "TabbedTextOut: "NPFMT" %d,%d '%*.*s' %d\n", + dprintf_text( stddeb, "TabbedTextOut: %04x %d,%d '%*.*s' %d\n", hdc, x, y, count, count, lpstr, count ); return TEXT_TabbedTextOut( hdc, x, y, lpstr, count, cTabStops, lpTabPos, nTabOrg, TRUE ); @@ -587,7 +584,7 @@ LONG TabbedTextOut( HDC hdc, short x, short y, LPSTR lpstr, short count, DWORD GetTabbedTextExtent( HDC hdc, LPSTR lpstr, int count, int cTabStops, LPINT lpTabPos ) { - dprintf_text( stddeb, "GetTabbedTextExtent: "NPFMT" '%*.*s' %d\n", + dprintf_text( stddeb, "GetTabbedTextExtent: %04x '%*.*s' %d\n", hdc, count, count, lpstr, count ); return TEXT_TabbedTextOut( hdc, 0, 0, lpstr, count, cTabStops, lpTabPos, 0, FALSE ); diff --git a/programs/progman/ChangeLog b/programs/progman/ChangeLog index 7a14e2dc007..c5a23497783 100644 --- a/programs/progman/ChangeLog +++ b/programs/progman/ChangeLog @@ -1,3 +1,14 @@ +Fri Mar 15 20:56:31 1996 Ulrich Schmid + + * [main.c] + `Arrange icons' in group windows + + * [program.c] + No sysmenu for program windows + + * [string.c] + Update sysmenu after language change + Wed Feb 28 19:21:55 1996 Ulrich Schmid * [progman.h] [main.c] [group.c] [program.c] [dialog.c] diff --git a/programs/progman/Makefile.in b/programs/progman/Makefile.in index 32f4a449c46..241c566b408 100644 --- a/programs/progman/Makefile.in +++ b/programs/progman/Makefile.in @@ -12,8 +12,7 @@ MOSTOBJS = \ grpfile.o \ license.o \ main.o \ - program.o \ - winexec.o + program.o STRINGOBJS = \ accel.o \ @@ -29,7 +28,7 @@ all: check_winerc $(PROGRAMS) @MAKE_RULES@ # Some strings need addresses >= 0x10000 -progman: $(MOSTOBJS) $(STRINGOBJS) +progman: $(MOSTOBJS) $(STRINGOBJS) $(WINELIB) $(CC) -o progman $(MOSTOBJS) $(LDOPTIONS) $(ALL_LIBS) $(STRINGOBJS) clean:: diff --git a/programs/progman/main.c b/programs/progman/main.c index 677512191c0..4d3cd13af28 100644 --- a/programs/progman/main.c +++ b/programs/progman/main.c @@ -320,7 +320,10 @@ static VOID MAIN_MenuCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) /* Menu Windows */ case PM_ARRANGE: - SendMessage(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0); + if (hActiveGroupWnd && !IsIconic(hActiveGroupWnd)) + ArrangeIconicWindows(hActiveGroupWnd); + else + SendMessage(Globals.hMDIWnd, WM_MDIICONARRANGE, 0, 0); break; /* Menu Language */ diff --git a/programs/progman/progman.h b/programs/progman/progman.h index 5d72ed9e760..875598bb121 100644 --- a/programs/progman/progman.h +++ b/programs/progman/progman.h @@ -11,14 +11,6 @@ #include "windows.h" -/* FIXME should use WinExec from -lwine */ -#ifdef WINELIB -#define WinExec ProgmanWinExec -#define WinHelp ProgmanWinHelp -HANDLE ProgmanWinExec(LPSTR,WORD); -BOOL ProgmanWinHelp(HWND,LPSTR,WORD,DWORD); -#endif - #define MAX_PATHNAME_LEN 1024 /* Fallback icon */ diff --git a/programs/progman/program.c b/programs/progman/program.c index adf30ed46fb..d9e4b4a90a6 100644 --- a/programs/progman/program.c +++ b/programs/progman/program.c @@ -198,7 +198,7 @@ HLOCAL PROGRAM_AddProgram(HLOCAL hGroup, HICON hIcon, LPCSTR lpszName, program->hWnd = CreateWindow (STRING_PROGRAM_WIN_CLASS_NAME, (LPSTR)lpszName, - WS_CHILD | WS_OVERLAPPEDWINDOW, + WS_CHILD | WS_CAPTION, x, y, CW_USEDEFAULT, CW_USEDEFAULT, group->hWnd, 0, Globals.hInstance, 0); diff --git a/programs/progman/string.c b/programs/progman/string.c index a04085545c4..be7ae150f20 100644 --- a/programs/progman/string.c +++ b/programs/progman/string.c @@ -5,6 +5,9 @@ */ #include +#ifdef WINELIB +#include +#endif #include "progman.h" /* Class names */ @@ -33,6 +36,9 @@ static LPCSTR StringTableDe[]; VOID STRING_SelectLanguage(LPCSTR lang) { + HMENU hMainMenu; + HLOCAL hGroup; + /* Change string table */ Globals.StringTable = StringTableEn; if (!lstrcmp(lang, "De")) Globals.StringTable = StringTableDe; @@ -51,28 +57,23 @@ VOID STRING_SelectLanguage(LPCSTR lang) lstrcpyn(STRING_SYMBOL_Xx + sizeof(STRING_SYMBOL_Xx) - 3, lang, 3); lstrcpyn(STRING_EXECUTE_Xx + sizeof(STRING_EXECUTE_Xx) - 3, lang, 3); - /* Destroy old menu */ - if (Globals.hMainMenu) + /* Create menu */ + hMainMenu = LoadMenu(Globals.hInstance, STRING_MAIN_Xx); + if (hMainMenu) { - SendMessage(Globals.hMDIWnd, WM_MDISETMENU, (WPARAM) NULL, (LPARAM) NULL); -#if 0 /* FIXME when MDISetMenu is complete */ - DestroyMenu(Globals.hMainMenu); -#endif - } - - /* Create new menu */ - Globals.hMainMenu = LoadMenu(Globals.hInstance, STRING_MAIN_Xx); - if (Globals.hMainMenu) - { - Globals.hFileMenu = GetSubMenu(Globals.hMainMenu, 0); - Globals.hOptionMenu = GetSubMenu(Globals.hMainMenu, 1); - Globals.hWindowsMenu = GetSubMenu(Globals.hMainMenu, 2); + Globals.hFileMenu = GetSubMenu(hMainMenu, 0); + Globals.hOptionMenu = GetSubMenu(hMainMenu, 1); + Globals.hWindowsMenu = GetSubMenu(hMainMenu, 2); if (Globals.hMDIWnd) SendMessage(Globals.hMDIWnd, WM_MDISETMENU, - (WPARAM) Globals.hMainMenu, + (WPARAM) hMainMenu, (LPARAM) Globals.hWindowsMenu); - else SetMenu(Globals.hMainWnd, Globals.hMainMenu); + else SetMenu(Globals.hMainWnd, hMainMenu); + + /* Destroy old menu */ + if (Globals.hMainMenu) DestroyMenu(Globals.hMainMenu); + Globals.hMainMenu = hMainMenu; } /* Unsupported language */ else if(lstrcmp(lang, "En")) STRING_SelectLanguage("En"); @@ -85,6 +86,17 @@ VOID STRING_SelectLanguage(LPCSTR lang) /* have to be last because of * the possible recursion */ Globals.lpszLanguage = lang; +#ifdef WINELIB + if (!lstrcmp(lang, "De")) Options.language = LANG_De; + if (!lstrcmp(lang, "En")) Options.language = LANG_En; + GetSystemMenu(Globals.hMainWnd, TRUE); + for (hGroup = GROUP_FirstGroup(); hGroup; + hGroup = GROUP_NextGroup(hGroup)) + { + GROUP *group = LocalLock(hGroup); + GetSystemMenu(group->hWnd, TRUE); + } +#endif } /* Local Variables: */ diff --git a/programs/progman/winexec.c b/programs/progman/winexec.c deleted file mode 100644 index 722576cc246..00000000000 --- a/programs/progman/winexec.c +++ /dev/null @@ -1,91 +0,0 @@ -#ifdef WINELIB -#include -#include -#include "windows.h" -#include "winbase.h" -#include "options.h" -#include "dos_fs.h" -#include "debug.h" -#include "progman.h" - -#define MAX_CMDLINE_SIZE 256 - -/* FIXME should use WinExec from -lwine */ - -HANDLE ProgmanWinExec( LPSTR lpCmdLine, WORD nCmdShow ) -{ - char wine[MAX_CMDLINE_SIZE]; - char filename[MAX_CMDLINE_SIZE], *p; - char cmdline[MAX_CMDLINE_SIZE]; - const char *argv[10], **argptr; - const char *unixfilename; - int simplename = 1; - - if (fork()) return(INVALID_HANDLE_VALUE); - - strncpy( filename, lpCmdLine, MAX_CMDLINE_SIZE ); - filename[MAX_CMDLINE_SIZE-1] = '\0'; - for (p = filename; *p && (*p != ' ') && (*p != '\t'); p++) - if ((*p == ':') || (*p == ':') || (*p == '/')) simplename = 0; - if (*p) - { - strncpy( cmdline, p + 1, 128 ); - cmdline[127] = '\0'; - } - else cmdline[0] = '\0'; - *p = '\0'; - - if (simplename) unixfilename = filename; - else unixfilename = DOSFS_GetUnixFileName(filename, 0); - - argptr = argv; - *argptr++ = unixfilename; - if (nCmdShow == SW_SHOWMINIMIZED) *argptr++ = "-iconic"; - if (cmdline[0]) *argptr++ = cmdline; - *argptr++ = 0; - execvp(argv[0], (char**)argv); - - PROFILE_GetWineIniString("progman", "wine", "wine", - wine, sizeof(wine)); - argptr = argv; - *argptr++ = wine; - *argptr++ = "-language"; - *argptr++ = Globals.lpszLanguage; - if (nCmdShow == SW_SHOWMINIMIZED) *argptr++ = "-iconic"; - *argptr++ = lpCmdLine; - *argptr++ = 0; - execvp(argv[0] , (char**)argv); - - printf("Cannot exec `%s %s %s%s %s'\n", - wine, "-language", Globals.lpszLanguage, - nCmdShow == SW_SHOWMINIMIZED ? " -iconic" : "", - lpCmdLine); - exit(1); -} - -BOOL ProgmanWinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData) -{ - char str[256]; - dprintf_exec(stddeb,"WinHelp(%s, %u, %lu)\n", - lpHelpFile, wCommand, dwData); - switch(wCommand) { - case 0: - case HELP_HELPONHELP: - GetWindowsDirectory(str, sizeof(str)); - strcat(str, "\\winhelp.exe winhelp.hlp"); - dprintf_exec(stddeb,"'%s'\n", str); - break; - case HELP_INDEX: - GetWindowsDirectory(str, sizeof(str)); - strcat(str, "\\winhelp.exe "); - strcat(str, lpHelpFile); - dprintf_exec(stddeb,"'%s'\n", str); - break; - default: - return FALSE; - } - WinExec(str, SW_SHOWNORMAL); - return(TRUE); -} - -#endif diff --git a/win32/Makefile.in b/win32/Makefile.in index 1c2a1a9fd62..2ff2ccffbf5 100644 --- a/win32/Makefile.in +++ b/win32/Makefile.in @@ -5,6 +5,7 @@ C_SRCS = \ advapi.c \ code_page.c \ console.c \ + cursoricon32.c \ environment.c \ error.c \ except.c \ diff --git a/win32/code_page.c b/win32/code_page.c index 1ec99531ad9..43dc261b196 100644 --- a/win32/code_page.c +++ b/win32/code_page.c @@ -8,6 +8,7 @@ #include "windows.h" #include "winerror.h" #include "kernel32.h" +#include "winnls.h" #include "stddebug.h" #include "debug.h" @@ -47,3 +48,41 @@ int MultiByteToWideChar(UINT page, DWORD flags, char *src, int srclen, { return (srclen==-1) ? strlen(src) * 2: srclen*2; } + +int WideCharToMultiByte(UINT page, DWORD flags, WCHAR *src, int srclen, + char *dst, int dstlen, char* defchar, BOOL *used) +{ + int count = 0; + int dont_copy= (dstlen==0); + if(page!=GetACP() && page!=CP_OEMCP && page!=CP_ACP) + fprintf(stdnimp,"Conversion in CP %d not supported\n",page); + if(flags) + fprintf(stdnimp,"WideCharToMultiByte flags %lx not supported\n",flags); + if(used) + *used=0; + while(srclen && (dont_copy || dstlen)) + { + if(!dont_copy){ + if(*src<256) + *dst = *src; + else + { + /* FIXME: Is this correct ?*/ + if(flags & WC_DEFAULTCHAR){ + *dst = defchar ? *defchar : '?'; + if(used)*used=1; + } + } + dstlen--; + dst++; + } + count++; + if(!*src) + break; + if(srclen!=-1)srclen--; + src++; + } + return count; +} + + diff --git a/win32/cursoricon32.c b/win32/cursoricon32.c new file mode 100644 index 00000000000..633eee242c1 --- /dev/null +++ b/win32/cursoricon32.c @@ -0,0 +1,461 @@ +/* + * Cursor and icon support + * + * Copyright 1995 Alexandre Julliard + * Copyright 1996 Martin von Loewis + */ + +/* + * Theory: + * + * Cursors and icons are stored in a global heap block, with the + * following layout: + * + * CURSORICONINFO info; + * BYTE[] ANDbits; + * BYTE[] XORbits; + * + * The bits structures are in the format of a device-dependent bitmap. + * + * This layout is very sub-optimal, as the bitmap bits are stored in + * the X client instead of in the server like other bitmaps; however, + * some programs (notably Paint Brush) expect to be able to manipulate + * the bits directly :-( + */ + +#include +#include +#include "windows.h" +#include "bitmap.h" +#include "callback.h" +#include "cursoricon.h" +#include "sysmetrics.h" +#include "win.h" +#include "struct32.h" +#include "string32.h" +#include "resource32.h" +#include "stddebug.h" +#include "debug.h" +#include "xmalloc.h" +#include "task.h" + + +/********************************************************************** + * CURSORICON32_FindBestIcon + * + * Find the icon closest to the requested size and number of colors. + */ +static ICONDIRENTRY32 *CURSORICON32_FindBestIcon( CURSORICONDIR32 *dir, + int width, int height, int colors ) +{ + int i, maxcolors, maxwidth, maxheight; + ICONDIRENTRY32 *entry, *bestEntry = NULL; + + if (dir->idCount < 1) + { + fprintf( stderr, "Icon: empty directory!\n" ); + return NULL; + } + if (dir->idCount == 1) return &dir->idEntries[0].icon; /* No choice... */ + + /* First find the exact size with less colors */ + + maxcolors = 0; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth == width) && (entry->bHeight == height) && + (entry->bColorCount <= colors) && (entry->bColorCount > maxcolors)) + { + bestEntry = entry; + maxcolors = entry->bColorCount; + } + if (bestEntry) return bestEntry; + + /* First find the exact size with more colors */ + + maxcolors = 255; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth == width) && (entry->bHeight == height) && + (entry->bColorCount > colors) && (entry->bColorCount <= maxcolors)) + { + bestEntry = entry; + maxcolors = entry->bColorCount; + } + if (bestEntry) return bestEntry; + + /* Now find a smaller one with less colors */ + + maxcolors = maxwidth = maxheight = 0; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth <= width) && (entry->bHeight <= height) && + (entry->bWidth >= maxwidth) && (entry->bHeight >= maxheight) && + (entry->bColorCount <= colors) && (entry->bColorCount > maxcolors)) + { + bestEntry = entry; + maxwidth = entry->bWidth; + maxheight = entry->bHeight; + maxcolors = entry->bColorCount; + } + if (bestEntry) return bestEntry; + + /* Now find a smaller one with more colors */ + + maxcolors = 255; + maxwidth = maxheight = 0; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth <= width) && (entry->bHeight <= height) && + (entry->bWidth >= maxwidth) && (entry->bHeight >= maxheight) && + (entry->bColorCount > colors) && (entry->bColorCount <= maxcolors)) + { + bestEntry = entry; + maxwidth = entry->bWidth; + maxheight = entry->bHeight; + maxcolors = entry->bColorCount; + } + if (bestEntry) return bestEntry; + + /* Now find a larger one with less colors */ + + maxcolors = 0; + maxwidth = maxheight = 255; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth <= maxwidth) && (entry->bHeight <= maxheight) && + (entry->bColorCount <= colors) && (entry->bColorCount > maxcolors)) + { + bestEntry = entry; + maxwidth = entry->bWidth; + maxheight = entry->bHeight; + maxcolors = entry->bColorCount; + } + if (bestEntry) return bestEntry; + + /* Now find a larger one with more colors */ + + maxcolors = maxwidth = maxheight = 255; + for (i = 0, entry = &dir->idEntries[0].icon; i < dir->idCount; i++,entry++) + if ((entry->bWidth <= maxwidth) && (entry->bHeight <= maxheight) && + (entry->bColorCount > colors) && (entry->bColorCount <= maxcolors)) + { + bestEntry = entry; + maxwidth = entry->bWidth; + maxheight = entry->bHeight; + maxcolors = entry->bColorCount; + } + + return bestEntry; +} + + +/********************************************************************** + * CURSORICON32_FindBestCursor + * + * Find the cursor closest to the requested size. + */ +static CURSORDIRENTRY32 *CURSORICON32_FindBestCursor( CURSORICONDIR32 *dir, + int width, int height ) +{ + int i, maxwidth, maxheight; + CURSORDIRENTRY32 *entry, *bestEntry = NULL; + + if (dir->idCount < 1) + { + fprintf( stderr, "Cursor: empty directory!\n" ); + return NULL; + } + if (dir->idCount == 1) return &dir->idEntries[0].cursor; /* No choice... */ + + /* First find the largest one smaller than or equal to the requested size*/ + + maxwidth = maxheight = 0; + for(i = 0,entry = &dir->idEntries[0].cursor; i < dir->idCount; i++,entry++) + if ((entry->wWidth <= width) && (entry->wHeight <= height) && + (entry->wWidth > maxwidth) && (entry->wHeight > maxheight)) + { + bestEntry = entry; + maxwidth = entry->wWidth; + maxheight = entry->wHeight; + } + if (bestEntry) return bestEntry; + + /* Now find the smallest one larger than the requested size */ + + maxwidth = maxheight = 255; + for(i = 0,entry = &dir->idEntries[0].cursor; i < dir->idCount; i++,entry++) + if ((entry->wWidth < maxwidth) && (entry->wHeight < maxheight)) + { + bestEntry = entry; + maxwidth = entry->wWidth; + maxheight = entry->wHeight; + } + + return bestEntry; +} + + +/********************************************************************** + * CURSORICON32_LoadDirEntry + * + * Load the icon/cursor directory for a given resource name and find the + * best matching entry. + */ +static BOOL CURSORICON32_LoadDirEntry(HANDLE hInstance, LPCWSTR name, + int width, int height, int colors, + BOOL fCursor, CURSORICONDIRENTRY32 *dirEntry) +{ + HANDLE32 hRsrc; + HANDLE32 hMem; + CURSORICONDIR32 *dir; + CURSORICONDIRENTRY32 *entry = NULL; + + if (!(hRsrc = FindResource32( hInstance, name, + (LPCWSTR)(fCursor ? RT_GROUP_CURSOR : RT_GROUP_ICON) ))) + return FALSE; + if (!(hMem = LoadResource32( hInstance, hRsrc ))) return FALSE; + if ((dir = (CURSORICONDIR32 *)LockResource32( hMem ))) + { + if (fCursor) + entry = (CURSORICONDIRENTRY32 *)CURSORICON32_FindBestCursor( dir, + width, height ); + else + entry = (CURSORICONDIRENTRY32 *)CURSORICON32_FindBestIcon( dir, + width, height, colors ); + if (entry) *dirEntry = *entry; + } + FreeResource32( hMem ); + return (entry != NULL); +} + + +/********************************************************************** + * CURSORICON32_LoadHandler + * + * Create a cursor or icon from a resource. + */ +static HANDLE CURSORICON32_LoadHandler( HANDLE32 handle, HINSTANCE hInstance, + BOOL fCursor ) +{ + HANDLE hAndBits, hXorBits, hRes; + HDC hdc; + int size, sizeAnd, sizeXor; + POINT hotspot = { 0 ,0 }; + BITMAPOBJ *bmpXor, *bmpAnd; + BITMAPINFO *bmi, *pInfo; + CURSORICONINFO *info; + char *bits; + + hRes=0; + if (fCursor) /* If cursor, get the hotspot */ + { + POINT *pt = (POINT *)LockResource32( handle ); + hotspot = *pt; + bmi = (BITMAPINFO *)(pt + 1); + } + else bmi = (BITMAPINFO *)LockResource32( handle ); + + /* Create a copy of the bitmap header */ + + size = DIB_BitmapInfoSize( bmi, DIB_RGB_COLORS ); + /* Make sure we have room for the monochrome bitmap later on */ + size = MAX( size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD) ); + pInfo = (BITMAPINFO *)xmalloc( size ); + memcpy( pInfo, bmi, size ); + + if (pInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER)) + { + if (pInfo->bmiHeader.biCompression != BI_RGB) + { + fprintf(stderr,"Unknown size for compressed icon bitmap.\n"); + free( pInfo ); + return 0; + } + pInfo->bmiHeader.biHeight /= 2; + } + else if (pInfo->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + BITMAPCOREHEADER *core = (BITMAPCOREHEADER *)pInfo; + core->bcHeight /= 2; + } + else + { + fprintf( stderr, "CURSORICON32_Load: Unknown bitmap length %ld!\n", + pInfo->bmiHeader.biSize ); + free( pInfo ); + return 0; + } + + /* Create the XOR bitmap */ + + if (!(hdc = GetDC( 0 ))) + { + free( pInfo ); + return 0; + } + + hXorBits = CreateDIBitmap( hdc, &pInfo->bmiHeader, CBM_INIT, + (char*)bmi + size, pInfo, DIB_RGB_COLORS ); + + /* Fix the bitmap header to load the monochrome mask */ + + if (pInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER)) + { + BITMAPINFOHEADER *bih = &pInfo->bmiHeader; + RGBQUAD *rgb = pInfo->bmiColors; + bits = (char *)bmi + size + + DIB_GetImageWidthBytes(bih->biWidth,bih->biBitCount)*bih->biHeight; + bih->biBitCount = 1; + bih->biClrUsed = bih->biClrImportant = 2; + rgb[0].rgbBlue = rgb[0].rgbGreen = rgb[0].rgbRed = 0x00; + rgb[1].rgbBlue = rgb[1].rgbGreen = rgb[1].rgbRed = 0xff; + rgb[0].rgbReserved = rgb[1].rgbReserved = 0; + } + else + { + BITMAPCOREHEADER *bch = (BITMAPCOREHEADER *)pInfo; + RGBTRIPLE *rgb = (RGBTRIPLE *)(bch + 1); + bits = (char *)bmi + size + + DIB_GetImageWidthBytes(bch->bcWidth,bch->bcBitCount)*bch->bcHeight; + bch->bcBitCount = 1; + rgb[0].rgbtBlue = rgb[0].rgbtGreen = rgb[0].rgbtRed = 0x00; + rgb[1].rgbtBlue = rgb[1].rgbtGreen = rgb[1].rgbtRed = 0xff; + } + + /* Create the AND bitmap */ + + hAndBits = CreateDIBitmap( hdc, &pInfo->bmiHeader, CBM_INIT, + bits, pInfo, DIB_RGB_COLORS ); + ReleaseDC( 0, hdc ); + + /* Now create the CURSORICONINFO structure */ + + bmpXor = (BITMAPOBJ *) GDI_GetObjPtr( hXorBits, BITMAP_MAGIC ); + bmpAnd = (BITMAPOBJ *) GDI_GetObjPtr( hAndBits, BITMAP_MAGIC ); + sizeXor = bmpXor->bitmap.bmHeight * bmpXor->bitmap.bmWidthBytes; + sizeAnd = bmpAnd->bitmap.bmHeight * bmpAnd->bitmap.bmWidthBytes; + + if (!(hRes = GlobalAlloc( GMEM_MOVEABLE, + sizeof(CURSORICONINFO) + sizeXor + sizeAnd))) + { + DeleteObject( hXorBits ); + DeleteObject( hAndBits ); + return 0; + } + + /* Make it owned by the module */ + if (hInstance) FarSetOwner( hRes, (WORD)(DWORD)GetExePtr(hInstance) ); + + info = (CURSORICONINFO *)GlobalLock( hRes ); + info->ptHotSpot.x = hotspot.x; + info->ptHotSpot.y = hotspot.y; + info->nWidth = bmpXor->bitmap.bmWidth; + info->nHeight = bmpXor->bitmap.bmHeight; + info->nWidthBytes = bmpXor->bitmap.bmWidthBytes; + info->bPlanes = bmpXor->bitmap.bmPlanes; + info->bBitsPerPixel = bmpXor->bitmap.bmBitsPixel; + + /* Transfer the bitmap bits to the CURSORICONINFO structure */ + + GetBitmapBits( hAndBits, sizeAnd, (char *)(info + 1) ); + GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd ); + DeleteObject( hXorBits ); + DeleteObject( hAndBits ); + GlobalUnlock( hRes ); + return hRes; +} + +/********************************************************************** + * CURSORICON32_Load + * + * Load a cursor or icon. + */ +static HANDLE CURSORICON32_Load( HANDLE hInstance, LPCWSTR name, int width, + int height, int colors, BOOL fCursor ) +{ + HANDLE32 handle; + HANDLE hRet; + HANDLE32 hRsrc; + CURSORICONDIRENTRY32 dirEntry; + + if(!hInstance) /* OEM cursor/icon */ + { + WORD resid; + if(HIWORD(name)) + { + LPSTR ansi; + ansi=STRING32_DupUniToAnsi(name); + if(ansi[0]=='#') /*Check for '#xxx' name */ + { + resid=atoi(ansi+1); + free(ansi); + }else{ + free(ansi); + return 0; + } + } + else + resid=(WORD)(int)name; + return OBM_LoadCursorIcon(resid, fCursor); + } + + /* Find the best entry in the directory */ + + if (!CURSORICON32_LoadDirEntry( hInstance, name, width, height, + colors, fCursor, &dirEntry )) return 0; + + /* Load the resource */ + + if (!(hRsrc = FindResource32( hInstance, + (LPWSTR) (DWORD) dirEntry.icon.wResId, + (LPWSTR) (fCursor ? RT_CURSOR : RT_ICON )))) return 0; + if (!(handle = LoadResource32( hInstance, hRsrc ))) return 0; + + hRet = CURSORICON32_LoadHandler( handle, hInstance, fCursor ); + FreeResource32(handle); + return hRet; +} + + +/*********************************************************************** + * LoadCursor + */ +HCURSOR WIN32_LoadCursorW( HANDLE hInstance, LPCWSTR name ) +{ + return CURSORICON32_Load( hInstance, name, + SYSMETRICS_CXCURSOR, SYSMETRICS_CYCURSOR, 1, TRUE); +} + +HCURSOR WIN32_LoadCursorA(HANDLE hInstance, LPCSTR name) +{ + HCURSOR res=0; + if(!HIWORD(name)) + return WIN32_LoadCursorW(hInstance, name); + else { + LPWSTR uni = STRING32_DupAnsiToUni(name); + res = WIN32_LoadCursorW(hInstance, uni); + free(uni); + } + return res; +} + + +/*********************************************************************** + * LoadIcon + */ +HICON WIN32_LoadIconW( HANDLE hInstance, LPCWSTR name ) +{ + return CURSORICON32_Load( hInstance, name, + SYSMETRICS_CXICON, SYSMETRICS_CYICON, + MIN( 16, 1 << screenDepth ), FALSE ); +} + +HICON WIN32_LoadIconA( HANDLE hInstance, LPCSTR name) +{ + HICON res=0; + if(!HIWORD(name)) + return WIN32_LoadIconW(hInstance, name); + else { + LPWSTR uni = STRING32_DupAnsiToUni(name); + res = WIN32_LoadIconW(hInstance, uni); + free(uni); + } + return res; +} + diff --git a/win32/file.c b/win32/file.c index 1dd15bcd02d..a14d6db9176 100644 --- a/win32/file.c +++ b/win32/file.c @@ -474,3 +474,24 @@ static int TranslateCreationFlags(DWORD create_flags) return rc; } + +/************************************************************************** + * GetFileAttributes + */ +DWORD GetFileAttributesA(LPCSTR lpFileName) +{ + struct stat buf; + DWORD res=0; + if(stat(lpFileName,&buf)==-1) + { + SetLastError(ErrnoToLastError(errno)); + return 0; + } + if(buf.st_mode & S_IFREG) + res |= FILE_ATTRIBUTE_NORMAL; + if(buf.st_mode & S_IFDIR) + res |= FILE_ATTRIBUTE_DIRECTORY; + if((buf.st_mode & S_IWRITE) == 0) + res |= FILE_ATTRIBUTE_READONLY; + return res; +} diff --git a/win32/param32.c b/win32/param32.c index 7d6f95af3f3..a5323d2c4d6 100644 --- a/win32/param32.c +++ b/win32/param32.c @@ -10,6 +10,7 @@ #include "windows.h" #include "winerror.h" #include "struct32.h" +#include "stackframe.h" #include "stddebug.h" #include "debug.h" @@ -38,3 +39,10 @@ BOOL WIN32_GetTextExtentPointA(HDC hdc, LPCTSTR str, int length, SIZE32* lpsize) return retval; } + +ATOM WIN32_GlobalAddAtomA(LPCTSTR str) +{ + char buffer[256]; /* 16-bit atoms are limited to 255 anyway */ + lstrcpyn( buffer, str, sizeof(buffer) ); + return GlobalAddAtom(MAKE_SEGPTR(buffer)); +} diff --git a/win32/resource.c b/win32/resource.c index ed81d602750..19a9e4181a1 100644 --- a/win32/resource.c +++ b/win32/resource.c @@ -132,7 +132,7 @@ HANDLE32 LoadResource32( HINSTANCE hModule, HANDLE32 hRsrc ) struct w_files *wptr = wine_files; hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "LoadResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "LoadResource: module=%04x res=%04x\n", hModule, hRsrc ); if (!hRsrc) return 0; while (wptr != NULL && (wptr->hModule != hModule)) @@ -169,7 +169,7 @@ BOOL FreeResource32( HANDLE32 handle ) INT AccessResource32( HINSTANCE hModule, HRSRC hRsrc ) { hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "AccessResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "AccessResource: module=%04x res=%04x\n", hModule, hRsrc ); if (!hRsrc) return 0; fprintf(stderr,"AccessResource32: not implemented\n"); @@ -183,7 +183,7 @@ INT AccessResource32( HINSTANCE hModule, HRSRC hRsrc ) DWORD SizeofResource32( HINSTANCE hModule, HRSRC hRsrc ) { hModule = GetExePtr( hModule ); /* In case we were passed an hInstance */ - dprintf_resource(stddeb, "SizeofResource: module="NPFMT" res="NPFMT"\n", + dprintf_resource(stddeb, "SizeofResource: module=%04x res=%04x\n", hModule, hRsrc ); fprintf(stderr,"SizeofResource32: not implemented\n"); return 0; @@ -203,10 +203,10 @@ HANDLE32 WIN32_LoadAcceleratorsW(HINSTANCE instance, LPCWSTR lpTableName) int i, n; if (HIWORD(lpTableName)) - dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" '%s'\n", + dprintf_accel( stddeb, "LoadAccelerators: %04x '%s'\n", instance, (char *)( lpTableName ) ); else - dprintf_accel( stddeb, "LoadAccelerators: "NPFMT" %04x\n", + dprintf_accel( stddeb, "LoadAccelerators: %04x %04x\n", instance, LOWORD(lpTableName) ); if (!(hRsrc = FindResource32( instance, lpTableName, @@ -261,7 +261,7 @@ WIN32_LoadStringW(HINSTANCE instance, DWORD resource_id, LPWSTR buffer, int bufl int string_num; int i; - dprintf_resource(stddeb, "LoadString: instance = "NPFMT", id = %04x, buffer = %08x, " + dprintf_resource(stddeb, "LoadString: instance = %04x, id = %04x, buffer = %08x, " "length = %d\n", instance, (int)resource_id, (int) buffer, buflen); hrsrc = FindResource32( instance, (LPCWSTR)((resource_id>>4)+1), diff --git a/win32/thread.c b/win32/thread.c index c88dda42e92..5e203c13735 100644 --- a/win32/thread.c +++ b/win32/thread.c @@ -6,11 +6,13 @@ #include #include +#include #include "windows.h" #include "winerror.h" #include "kernel32.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" /*********************************************************************** * GetCurrentThreadId (KERNEL32.200) @@ -36,3 +38,68 @@ HANDLE WINAPI GetCurrentThread(void) return 0; } +/********************************************************************** + * Critical Sections are currently ignored + */ +void WINAPI InitializeCriticalSection(CRITICAL_SECTION *lpCrit) +{ + memset(lpCrit,0,sizeof(CRITICAL_SECTION)); +} + +void WINAPI EnterCriticalSection(CRITICAL_SECTION* lpCrit) +{ + return; +} + +void WINAPI LeaveCriticalSection(CRITICAL_SECTION* lpCrit) +{ + return; +} + +void WINAPI DeleteCriticalSection(CRITICAL_SECTION* lpCrit) +{ + return; +} + +/*********************************************************************** + * Tls is available only for the single thread + */ +static LPVOID* Tls=0; +static int TlsCount=0; + +DWORD WINAPI TlsAlloc() +{ + if(!Tls){ + TlsCount++; + Tls=xmalloc(sizeof(LPVOID)); + return 0; + } + Tls=xrealloc(Tls,sizeof(LPVOID)*(++TlsCount)); + return TlsCount-1; +} + +void TlsFree(DWORD index) +{ + /*FIXME: should remember that it has been freed */ + return; +} + +LPVOID TlsGetValue(DWORD index) +{ + if(index>=TlsCount) + { + /* FIXME: Set last error*/ + return 0; + } + return Tls[index]; +} + +void TlsSetValue(DWORD index,LPVOID value) +{ + if(index>=TlsCount) + { + /* FIXME: Set last error*/ + return; + } + Tls[index]=value; +} diff --git a/win32/user32.c b/win32/user32.c index 3c94151952a..42a45821ba3 100644 --- a/win32/user32.c +++ b/win32/user32.c @@ -322,8 +322,8 @@ HWND USER32_CreateDialogIndirectParamAorW(HINSTANCE hInst,LPVOID templ, /* FIXME: proper modalframe handling ??*/ if (dlgTempl->style & DS_MODALFRAME) exStyle |= WS_EX_DLGMODALFRAME; - /* FIXME: AdjustWindowRectEx */ - + AdjustWindowRectEx( &rect, dlgTempl->style, + hMenu ? TRUE : FALSE , exStyle ); rect.right -= rect.left; rect.bottom -= rect.top; diff --git a/windows/caret.c b/windows/caret.c index 268b937d85a..b753d86218d 100644 --- a/windows/caret.c +++ b/windows/caret.c @@ -2,6 +2,7 @@ * Caret functions * * Copyright 1993 David Metcalfe + * Copyright 1996 Frans van Dorsselaer */ #include "windows.h" @@ -22,8 +23,7 @@ typedef struct short y; short width; short height; - COLORREF color; - HBITMAP bitmap; + HBRUSH hBrush; WORD timeout; WORD timerid; } CARET; @@ -35,7 +35,7 @@ typedef enum CARET_TOGGLE, } DISPLAY_CARET; -static CARET Caret = { (HWND)0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static CARET Caret = { 0, }; /***************************************************************** @@ -52,9 +52,7 @@ HWND CARET_GetHwnd() void CARET_DisplayCaret(DISPLAY_CARET status) { HDC hdc; - HBRUSH hBrush; HBRUSH hPrevBrush; - HRGN rgn; if (Caret.on && (status == CARET_ON)) return; if (!Caret.on && (status == CARET_OFF)) return; @@ -62,21 +60,11 @@ void CARET_DisplayCaret(DISPLAY_CARET status) /* So now it's always a toggle */ Caret.on = !Caret.on; - hdc = GetDC(Caret.hwnd); - if (Caret.bitmap == (HBITMAP)0 || Caret.bitmap == (HBITMAP)1) - hBrush = CreateSolidBrush(Caret.color); - else - hBrush = CreatePatternBrush(Caret.bitmap); - hPrevBrush = SelectObject(hdc, (HANDLE)hBrush); - SetROP2(hdc, R2_XORPEN); - rgn = CreateRectRgn(Caret.x, Caret.y, - Caret.x + Caret.width, - Caret.y + Caret.height); - FillRgn(hdc, rgn, hBrush); - DeleteObject( rgn ); + if (!(hdc = GetDCEx( Caret.hwnd, 0, DCX_USESTYLE | DCX_CACHE ))) return; + hPrevBrush = SelectObject( hdc, Caret.hBrush ); + PatBlt( hdc, Caret.x, Caret.y, Caret.width, Caret.height, PATINVERT ); SelectObject( hdc, hPrevBrush ); - DeleteObject( hBrush ); - ReleaseDC(Caret.hwnd, hdc); + ReleaseDC( Caret.hwnd, hdc ); } @@ -85,8 +73,8 @@ void CARET_DisplayCaret(DISPLAY_CARET status) */ WORD CARET_Callback(HWND hwnd, WORD msg, WORD timerid, LONG ctime) { - dprintf_caret(stddeb,"CARET_Callback: hwnd="NPFMT", timerid=%d, " - "caret=%d\n", hwnd, timerid, Caret.on); + dprintf_caret(stddeb,"CARET_Callback: hwnd=%04x, timerid=%d, caret=%d\n", + hwnd, timerid, Caret.on); CARET_DisplayCaret(CARET_TOGGLE); return 0; @@ -157,34 +145,36 @@ static void CARET_Initialize() */ BOOL CreateCaret(HWND hwnd, HBITMAP bitmap, INT width, INT height) { - dprintf_caret(stddeb,"CreateCaret: hwnd="NPFMT"\n", hwnd); + dprintf_caret(stddeb,"CreateCaret: hwnd=%04x\n", hwnd); if (!hwnd) return FALSE; /* if cursor already exists, destroy it */ if (Caret.hwnd) DestroyCaret(); - if (bitmap && bitmap != (HBITMAP)1) Caret.bitmap = bitmap; - - if (width) - Caret.width = width; + if (bitmap && (bitmap != 1)) + { + BITMAP bmp; + if (!GetObject( bitmap, sizeof(bmp), (LPSTR)&bmp )) return FALSE; + Caret.width = bmp.bmWidth; + Caret.height = bmp.bmHeight; + /* FIXME: we should make a copy of the bitmap instead of a brush */ + Caret.hBrush = CreatePatternBrush( bitmap ); + } else - Caret.width = GetSystemMetrics(SM_CXBORDER); - - if (height) - Caret.height = height; - else - Caret.height = GetSystemMetrics(SM_CYBORDER); + { + Caret.width = width ? width : GetSystemMetrics(SM_CXBORDER); + Caret.height = height ? height : GetSystemMetrics(SM_CYBORDER); + Caret.hBrush = CreateSolidBrush( bitmap ? GetSysColor(COLOR_GRAYTEXT) : + GetSysColor(COLOR_WINDOW) ); + } Caret.hwnd = hwnd; Caret.hidden = 1; Caret.on = FALSE; Caret.x = 0; Caret.y = 0; - if (bitmap == (HBITMAP)1) - Caret.color = GetSysColor(COLOR_GRAYTEXT); - else - Caret.color = GetSysColor(COLOR_WINDOW); + Caret.timeout = GetProfileInt( "windows", "CursorBlinkRate", 750 ); CARET_Initialize(); @@ -201,9 +191,10 @@ BOOL DestroyCaret() { if (!Caret.hwnd) return FALSE; - dprintf_caret(stddeb,"DestroyCaret: hwnd="NPFMT", timerid=%d\n", + dprintf_caret(stddeb,"DestroyCaret: hwnd=%04x, timerid=%d\n", Caret.hwnd, Caret.timerid); + DeleteObject( Caret.hBrush ); CARET_KillTimer(); CARET_DisplayCaret(CARET_OFF); @@ -243,8 +234,8 @@ void HideCaret(HWND hwnd) if (!Caret.hwnd) return; if (hwnd && (Caret.hwnd != hwnd)) return; - dprintf_caret(stddeb,"HideCaret: hwnd="NPFMT", hidden=%d\n", - hwnd, Caret.hidden); + dprintf_caret(stddeb,"HideCaret: hwnd=%04x, hidden=%d\n", + hwnd, Caret.hidden); CARET_KillTimer(); CARET_DisplayCaret(CARET_OFF); @@ -261,7 +252,7 @@ void ShowCaret(HWND hwnd) if (!Caret.hwnd) return; if (hwnd && (Caret.hwnd != hwnd)) return; - dprintf_caret(stddeb,"ShowCaret: hwnd="NPFMT", hidden=%d\n", + dprintf_caret(stddeb,"ShowCaret: hwnd=%04x, hidden=%d\n", hwnd, Caret.hidden); if (Caret.hidden) @@ -284,7 +275,7 @@ void SetCaretBlinkTime(WORD msecs) { if (!Caret.hwnd) return; - dprintf_caret(stddeb,"SetCaretBlinkTime: hwnd="NPFMT", msecs=%d\n", + dprintf_caret(stddeb,"SetCaretBlinkTime: hwnd=%04x, msecs=%d\n", Caret.hwnd, msecs); Caret.timeout = msecs; @@ -300,7 +291,7 @@ WORD GetCaretBlinkTime() { if (!Caret.hwnd) return 0; - dprintf_caret(stddeb,"GetCaretBlinkTime: hwnd="NPFMT", msecs=%d\n", + dprintf_caret(stddeb,"GetCaretBlinkTime: hwnd=%04x, msecs=%d\n", Caret.hwnd, Caret.timeout); return Caret.timeout; @@ -315,8 +306,8 @@ void GetCaretPos(LPPOINT pt) { if (!Caret.hwnd || !pt) return; - dprintf_caret(stddeb,"GetCaretPos: hwnd="NPFMT", pt=%p, x=%d, y=%d\n", - Caret.hwnd, pt, Caret.x, Caret.y); + dprintf_caret(stddeb,"GetCaretPos: hwnd=%04x, pt=%p, x=%d, y=%d\n", + Caret.hwnd, pt, Caret.x, Caret.y); pt->x = Caret.x; pt->y = Caret.y; diff --git a/windows/class.c b/windows/class.c index 527127e069b..04a05df52fa 100644 --- a/windows/class.c +++ b/windows/class.c @@ -159,7 +159,7 @@ ATOM RegisterClass( LPWNDCLASS class ) HCLASS handle, prevClass; int classExtra; - dprintf_class( stddeb, "RegisterClass: wndproc=%08lx hinst="NPFMT" name='%s' background "NPFMT"\n", + dprintf_class( stddeb, "RegisterClass: wndproc=%08lx hinst=%04x name='%s' background %04x\n", (DWORD)class->lpfnWndProc, class->hInstance, HIWORD(class->lpszClassName) ? (char *)PTR_SEG_TO_LIN(class->lpszClassName) : "(int)", @@ -258,11 +258,7 @@ BOOL UnregisterClass( SEGPTR className, HANDLE hinstance ) if (classPtr->wc.hbrBackground) DeleteObject( classPtr->wc.hbrBackground ); GlobalDeleteAtom( classPtr->atomName ); if (HIWORD(classPtr->wc.lpszMenuName)) -#ifdef WINELIB32 USER_HEAP_FREE( (HANDLE)classPtr->wc.lpszMenuName ); -#else - USER_HEAP_FREE( LOWORD(classPtr->wc.lpszMenuName) ); -#endif USER_HEAP_FREE( class ); return TRUE; } @@ -336,7 +332,7 @@ int GetClassName(HWND hwnd, LPSTR lpClassName, short maxCount) CLASS *classPtr; /* FIXME: We have the find the correct hInstance */ - dprintf_class(stddeb,"GetClassName("NPFMT",%p,%d)\n",hwnd,lpClassName,maxCount); + dprintf_class(stddeb,"GetClassName(%04x,%p,%d)\n",hwnd,lpClassName,maxCount); if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0; if (!(classPtr = CLASS_FindClassPtr(wndPtr->hClass))) return 0; @@ -351,7 +347,7 @@ BOOL GetClassInfo( HANDLE hInstance, SEGPTR name, LPWNDCLASS lpWndClass ) { CLASS *classPtr; - dprintf_class( stddeb, "GetClassInfo: hInstance="NPFMT" className=%s\n", + dprintf_class( stddeb, "GetClassInfo: hInstance=%04x className=%s\n", hInstance, HIWORD(name) ? (char *)PTR_SEG_TO_LIN(name) : "(int)" ); diff --git a/windows/dce.c b/windows/dce.c index 4974a2e4193..3ff9f54f94c 100644 --- a/windows/dce.c +++ b/windows/dce.c @@ -108,26 +108,25 @@ static BOOL DCE_GetVisRect( WND *wndPtr, BOOL clientArea, RECT *lprect ) return FALSE; } - while (wndPtr->hwndParent) + while (wndPtr->parent) { - WND *parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - if (!(parentPtr->dwStyle & WS_VISIBLE) || - (parentPtr->flags & WIN_NO_REDRAW) || - (parentPtr->dwStyle & WS_ICONIC)) + wndPtr = wndPtr->parent; + if (!(wndPtr->dwStyle & WS_VISIBLE) || + (wndPtr->flags & WIN_NO_REDRAW) || + (wndPtr->dwStyle & WS_ICONIC)) { SetRectEmpty( lprect ); /* Clip everything */ return FALSE; } - xoffset += parentPtr->rectClient.left; - yoffset += parentPtr->rectClient.top; - OffsetRect( lprect, parentPtr->rectClient.left, - parentPtr->rectClient.top ); + xoffset += wndPtr->rectClient.left; + yoffset += wndPtr->rectClient.top; + OffsetRect( lprect, wndPtr->rectClient.left, + wndPtr->rectClient.top ); /* Warning!! we assume that IntersectRect() handles the case */ /* where the destination is the same as one of the sources. */ - if (!IntersectRect( lprect, lprect, &parentPtr->rectClient )) + if (!IntersectRect( lprect, lprect, &wndPtr->rectClient )) return FALSE; /* Visible rectangle is empty */ - wndPtr = parentPtr; } OffsetRect( lprect, -xoffset, -yoffset ); return TRUE; @@ -143,30 +142,28 @@ static BOOL DCE_GetVisRect( WND *wndPtr, BOOL clientArea, RECT *lprect ) * is destroyed. Used to implement DCX_CLIPSIBLINGS and * DCX_CLIPCHILDREN styles. */ -static HRGN DCE_ClipWindows( HWND hwndStart, HWND hwndEnd, +static HRGN DCE_ClipWindows( WND *pWndStart, WND *pWndEnd, HRGN hrgn, int xoffset, int yoffset ) { HRGN hrgnNew; - WND *wndPtr; - if (!hwndStart) return hrgn; + if (!pWndStart) return hrgn; if (!(hrgnNew = CreateRectRgn( 0, 0, 0, 0 ))) { DeleteObject( hrgn ); return 0; } - for (; hwndStart != hwndEnd; hwndStart = wndPtr->hwndNext) + for (; pWndStart != pWndEnd; pWndStart = pWndStart->next) { - wndPtr = WIN_FindWndPtr( hwndStart ); - if (!(wndPtr->dwStyle & WS_VISIBLE)) continue; - SetRectRgn( hrgnNew, wndPtr->rectWindow.left + xoffset, - wndPtr->rectWindow.top + yoffset, - wndPtr->rectWindow.right + xoffset, - wndPtr->rectWindow.bottom + yoffset ); + if (!(pWndStart->dwStyle & WS_VISIBLE)) continue; + SetRectRgn( hrgnNew, pWndStart->rectWindow.left + xoffset, + pWndStart->rectWindow.top + yoffset, + pWndStart->rectWindow.right + xoffset, + pWndStart->rectWindow.bottom + yoffset ); if (!CombineRgn( hrgn, hrgn, hrgnNew, RGN_DIFF )) break; } DeleteObject( hrgnNew ); - if (hwndStart != hwndEnd) /* something went wrong */ + if (pWndStart != pWndEnd) /* something went wrong */ { DeleteObject( hrgn ); return 0; @@ -207,7 +204,7 @@ HRGN DCE_GetVisRgn( HWND hwnd, WORD flags ) yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top; } else xoffset = yoffset = 0; - hrgn = DCE_ClipWindows( wndPtr->hwndChild, 0, hrgn, xoffset, yoffset ); + hrgn = DCE_ClipWindows( wndPtr->child, NULL, hrgn, xoffset, yoffset ); if (!hrgn) return 0; } @@ -225,8 +222,8 @@ HRGN DCE_GetVisRgn( HWND hwnd, WORD flags ) } if (flags & DCX_CLIPSIBLINGS) { - hrgn = DCE_ClipWindows( GetWindow( wndPtr->hwndParent, GW_CHILD ), - hwnd, hrgn, xoffset, yoffset ); + hrgn = DCE_ClipWindows( wndPtr->parent ? wndPtr->parent->child : NULL, + wndPtr, hrgn, xoffset, yoffset ); if (!hrgn) return 0; } @@ -234,12 +231,11 @@ HRGN DCE_GetVisRgn( HWND hwnd, WORD flags ) while (wndPtr->dwStyle & WS_CHILD) { - hwnd = wndPtr->hwndParent; - wndPtr = WIN_FindWndPtr( hwnd ); + wndPtr = wndPtr->parent; xoffset -= wndPtr->rectClient.left; yoffset -= wndPtr->rectClient.top; - hrgn = DCE_ClipWindows( GetWindow( wndPtr->hwndParent, GW_CHILD ), - hwnd, hrgn, xoffset, yoffset ); + hrgn = DCE_ClipWindows( wndPtr->parent->child, wndPtr, + hrgn, xoffset, yoffset ); if (!hrgn) return 0; } return hrgn; @@ -275,7 +271,7 @@ static void DCE_SetDrawable( WND *wndPtr, DC *dc, WORD flags ) } while (!wndPtr->window) { - wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + wndPtr = wndPtr->parent; dc->w.DCOrgX += wndPtr->rectClient.left; dc->w.DCOrgY += wndPtr->rectClient.top; } @@ -354,12 +350,12 @@ HDC GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) { if (flags & DCX_PARENTCLIP) /* Get a VisRgn for the parent */ { - WND *parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + WND *parentPtr = wndPtr->parent; DWORD newflags = flags & ~(DCX_CLIPSIBLINGS | DCX_CLIPCHILDREN | DCX_WINDOW); if (parentPtr->dwStyle & WS_CLIPSIBLINGS) newflags |= DCX_CLIPSIBLINGS; - hrgnVisible = DCE_GetVisRgn( wndPtr->hwndParent, newflags ); + hrgnVisible = DCE_GetVisRgn( parentPtr->hwndSelf, newflags ); if (flags & DCX_WINDOW) OffsetRgn( hrgnVisible, -wndPtr->rectWindow.left, -wndPtr->rectWindow.top ); @@ -384,7 +380,7 @@ HDC GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags ) SelectVisRgn( hdc, hrgnVisible ); DeleteObject( hrgnVisible ); - dprintf_dc(stddeb, "GetDCEx("NPFMT","NPFMT",0x%lx): returning "NPFMT"\n", + dprintf_dc(stddeb, "GetDCEx(%04x,%04x,0x%lx): returning %04x\n", hwnd, hrgnClip, flags, hdc); return hdc; } @@ -424,7 +420,7 @@ int ReleaseDC( HWND hwnd, HDC hdc ) HANDLE hdce; DCE * dce = NULL; - dprintf_dc(stddeb, "ReleaseDC: "NPFMT" "NPFMT"\n", hwnd, hdc ); + dprintf_dc(stddeb, "ReleaseDC: %04x %04x\n", hwnd, hdc ); for (hdce = firstDCE; (hdce); hdce = dce->hNext) { diff --git a/windows/defdlg.c b/windows/defdlg.c index 90a0a6d5be1..9191ba8ec98 100644 --- a/windows/defdlg.c +++ b/windows/defdlg.c @@ -3,8 +3,7 @@ * * Copyright 1993 Alexandre Julliard * -static char Copyright[] = "Copyright Alexandre Julliard, 1993"; -*/ + */ #include "windows.h" #include "dialog.h" diff --git a/windows/defwnd.c b/windows/defwnd.c index 4e1d060f109..530c5e5fed6 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -122,7 +122,7 @@ LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_MOUSEACTIVATE: if (wndPtr->dwStyle & WS_CHILD) { - LONG ret = SendMessage( wndPtr->hwndParent, WM_MOUSEACTIVATE, + LONG ret = SendMessage( wndPtr->parent->hwndSelf, WM_MOUSEACTIVATE, wParam, lParam ); if (ret) return ret; } @@ -251,7 +251,8 @@ LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_SETCURSOR: if (wndPtr->dwStyle & WS_CHILD) - if (SendMessage(wndPtr->hwndParent, WM_SETCURSOR, wParam, lParam)) + if (SendMessage(wndPtr->parent->hwndSelf, WM_SETCURSOR, + wParam, lParam)) return TRUE; return NC_HandleSetCursor( hwnd, wParam, lParam ); @@ -300,7 +301,7 @@ LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) case WM_SHOWWINDOW: if( !lParam ) return 0; /* sent from ShowWindow */ - if( !(wndPtr->dwStyle & WS_POPUP) || !wndPtr->hwndOwner ) + if( !(wndPtr->dwStyle & WS_POPUP) || !wndPtr->owner ) return 0; if( wndPtr->dwStyle & WS_VISIBLE ) diff --git a/windows/dialog.c b/windows/dialog.c index 90bb72aa198..793cffb9417 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -3,8 +3,7 @@ * * Copyright 1993, 1994 Alexandre Julliard * -static char Copyright[] = "Copyright Alexandre Julliard, 1993, 1994"; -*/ + */ #include #include @@ -59,16 +58,10 @@ BOOL DIALOG_Init() */ HWND DIALOG_GetFirstTabItem( HWND hwndDlg ) { - HWND hwnd; - WND *wndPtr = WIN_FindWndPtr( hwndDlg ); - hwnd = wndPtr->hwndChild; - while(hwnd) - { - wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr->dwStyle & WS_TABSTOP) break; - hwnd = wndPtr->hwndNext; - } - return hwnd; + WND *pWnd = WIN_FindWndPtr( hwndDlg ); + for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next) + if (pWnd->dwStyle & WS_TABSTOP) return pWnd->hwndSelf; + return 0; } @@ -218,8 +211,8 @@ HWND CreateDialogParam( HINSTANCE hInst, SEGPTR dlgTemplate, HGLOBAL hmem; SEGPTR data; - dprintf_dialog(stddeb, "CreateDialogParam: "NPFMT","SPFMT","NPFMT",%08lx,%ld\n", - hInst, dlgTemplate, owner, (DWORD)dlgProc, param ); + dprintf_dialog(stddeb, "CreateDialogParam: %04x,%08lx,%04x,%08lx,%ld\n", + hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param ); if (!(hRsrc = FindResource( hInst, dlgTemplate, RT_DIALOG ))) return 0; if (!(hmem = LoadResource( hInst, hRsrc ))) return 0; @@ -411,7 +404,7 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, SEGPTR dlgTemplate, header->y * yUnit / 8, header->cx * xUnit / 4, header->cy * yUnit / 8, - hwnd, (HMENU)((DWORD)header->id), + hwnd, (HMENU)header->id, dlgInfo->hDialogHeap, (SEGPTR)0 ); } else @@ -422,7 +415,7 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, SEGPTR dlgTemplate, header->y * yUnit / 8, header->cx * xUnit / 4, header->cy * yUnit / 8, - hwnd, (HMENU)((DWORD)header->id), + hwnd, (HMENU)header->id, hInst, (SEGPTR)0 ); } @@ -523,8 +516,8 @@ INT DialogBoxParam( HINSTANCE hInst, SEGPTR dlgTemplate, { HWND hwnd; - dprintf_dialog(stddeb, "DialogBoxParam: "NPFMT","SPFMT","NPFMT",%08lx,%ld\n", - hInst, dlgTemplate, owner, (DWORD)dlgProc, param ); + dprintf_dialog(stddeb, "DialogBoxParam: %04x,%08lx,%04x,%08lx,%ld\n", + hInst, (DWORD)dlgTemplate, owner, (DWORD)dlgProc, param ); hwnd = CreateDialogParam( hInst, dlgTemplate, owner, dlgProc, param ); if (hwnd) return DIALOG_DoDialogBox( hwnd, owner ); return -1; @@ -567,7 +560,7 @@ BOOL EndDialog( HWND hwnd, INT retval ) DIALOGINFO * dlgInfo = (DIALOGINFO *)wndPtr->wExtra; dlgInfo->msgResult = retval; dlgInfo->fEnd = TRUE; - dprintf_dialog(stddeb, "EndDialog: "NPFMT" %d\n", hwnd, retval ); + dprintf_dialog(stddeb, "EndDialog: %04x %d\n", hwnd, retval ); return TRUE; } @@ -698,18 +691,11 @@ int GetDlgCtrlID( HWND hwnd ) */ HWND GetDlgItem( HWND hwndDlg, WORD id ) { - HWND curChild; - WND * childPtr; - WND * wndPtr; + WND *pWnd; - if (!(wndPtr = WIN_FindWndPtr( hwndDlg ))) return 0; - curChild = wndPtr->hwndChild; - while(curChild) - { - childPtr = WIN_FindWndPtr( curChild ); - if (childPtr->wIDmenu == id) return curChild; - curChild = childPtr->hwndNext; - } + if (!(pWnd = WIN_FindWndPtr( hwndDlg ))) return 0; + for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next) + if (pWnd->wIDmenu == id) return pWnd->hwndSelf; return 0; } @@ -811,25 +797,20 @@ WORD IsDlgButtonChecked( HWND hwnd, WORD id ) */ BOOL CheckRadioButton( HWND hwndDlg, UINT firstID, UINT lastID, UINT checkID ) { - HWND button = GetWindow( hwndDlg, GW_CHILD ); - WND *wndPtr; + WND *pWnd = WIN_FindWndPtr( hwndDlg ); + if (!pWnd) return FALSE; - while (button) - { - if (!(wndPtr = WIN_FindWndPtr( button ))) return FALSE; - if ((wndPtr->wIDmenu == firstID) || (wndPtr->wIDmenu == lastID)) break; - button = wndPtr->hwndNext; - } - if (!button) return FALSE; + for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next) + if ((pWnd->wIDmenu == firstID) || (pWnd->wIDmenu == lastID)) break; + if (!pWnd) return FALSE; - if (wndPtr->wIDmenu == lastID) + if (pWnd->wIDmenu == lastID) lastID = firstID; /* Buttons are in reverse order */ - while (button) + while (pWnd) { - if (!(wndPtr = WIN_FindWndPtr( button ))) return FALSE; - SendMessage( button, BM_SETCHECK, (wndPtr->wIDmenu == checkID), 0 ); - if (wndPtr->wIDmenu == lastID) break; - button = wndPtr->hwndNext; + SendMessage(pWnd->hwndSelf, BM_SETCHECK, (pWnd->wIDmenu == checkID),0); + if (pWnd->wIDmenu == lastID) break; + pWnd = pWnd->next; } return TRUE; } @@ -865,46 +846,39 @@ void MapDialogRect( HWND hwnd, LPRECT rect ) */ HWND GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious ) { - HWND hwnd, hwndStart; - WND * dlgPtr, * ctrlPtr, * wndPtr; + WND *pWnd, *pWndStart, *pWndCtrl, *pWndDlg; - if (!(dlgPtr = WIN_FindWndPtr( hwndDlg ))) return 0; - if (!(ctrlPtr = WIN_FindWndPtr( hwndCtrl ))) return 0; - if (ctrlPtr->hwndParent != hwndDlg) return 0; + if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0; + if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0; + if (pWndCtrl->parent != pWndDlg) return 0; - if (!fPrevious && ctrlPtr->hwndNext) /*Check if next control is in group*/ + if (!fPrevious && pWndCtrl->next) /* Check if next control is in group */ { - wndPtr = WIN_FindWndPtr( ctrlPtr->hwndNext ); - if (!(wndPtr->dwStyle & WS_GROUP)) return ctrlPtr->hwndNext; + if (!(pWndCtrl->next->dwStyle & WS_GROUP)) + return pWndCtrl->next->hwndSelf; } /* Now we will have to find the start of the group */ - hwndStart = hwnd = dlgPtr->hwndChild; - while (hwnd) + for (pWnd = pWndStart = pWndDlg->child; pWnd; pWnd = pWnd->next) { - wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr->dwStyle & WS_GROUP) hwndStart = hwnd; /*Start of a group*/ - if (hwnd == hwndCtrl) break; - hwnd = wndPtr->hwndNext; + if (pWnd->dwStyle & WS_GROUP) pWndStart = pWnd; /* Start of a group */ + if (pWnd == pWndCtrl) break; } - if (!hwnd) fprintf(stderr, "GetNextDlgGroupItem: hwnd not in dialog!\n"); + if (!pWnd) fprintf(stderr, "GetNextDlgGroupItem: hwnd not in dialog!\n"); /* only case left for forward search: wraparound */ - if (!fPrevious) return hwndStart; - - hwnd = hwndStart; - wndPtr = WIN_FindWndPtr( hwnd ); - hwnd = wndPtr->hwndNext; - while (hwnd && (hwnd != hwndCtrl)) + if (!fPrevious) return pWndStart->hwndSelf; + + pWnd = pWndStart->next; + while (pWnd && (pWnd != pWndCtrl)) { - wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr->dwStyle & WS_GROUP) break; - hwndStart = hwnd; - hwnd = wndPtr->hwndNext; + if (pWnd->dwStyle & WS_GROUP) break; + pWndStart = pWnd; + pWnd = pWnd->next; } - return hwndStart; + return pWndStart->hwndSelf; } @@ -913,26 +887,24 @@ HWND GetNextDlgGroupItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious ) */ HWND GetNextDlgTabItem( HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious ) { - HWND hwnd, hwndLast; - WND * dlgPtr, * ctrlPtr, * wndPtr; + WND *pWnd, *pWndLast, *pWndCtrl, *pWndDlg; - if (!(dlgPtr = WIN_FindWndPtr( hwndDlg ))) return 0; - if (!(ctrlPtr = WIN_FindWndPtr( hwndCtrl ))) return 0; - if (ctrlPtr->hwndParent != hwndDlg) return 0; + if (!(pWndDlg = WIN_FindWndPtr( hwndDlg ))) return 0; + if (!(pWndCtrl = WIN_FindWndPtr( hwndCtrl ))) return 0; + if (pWndCtrl->parent != pWndDlg) return 0; - hwndLast = hwndCtrl; - hwnd = ctrlPtr->hwndNext; + pWndLast = pWndCtrl; + pWnd = pWndCtrl->next; while (1) { - if (!hwnd) hwnd = dlgPtr->hwndChild; - if (hwnd == hwndCtrl) break; - wndPtr = WIN_FindWndPtr( hwnd ); - if ((wndPtr->dwStyle & WS_TABSTOP) && (wndPtr->dwStyle & WS_VISIBLE)) + if (!pWnd) pWnd = pWndDlg->child; + if (pWnd == pWndCtrl) break; + if ((pWnd->dwStyle & WS_TABSTOP) && (pWnd->dwStyle & WS_VISIBLE)) { - hwndLast = hwnd; + pWndLast = pWnd; if (!fPrevious) break; } - hwnd = wndPtr->hwndNext; + pWnd = pWnd->next; } - return hwndLast; + return pWndLast->hwndSelf; } diff --git a/windows/event.c b/windows/event.c index 203f75be269..eba633f723c 100644 --- a/windows/event.c +++ b/windows/event.c @@ -164,8 +164,8 @@ void EVENT_ProcessEvent( XEvent *event ) XFindContext( display, ((XAnyEvent *)event)->window, winContext, &ptr ); hwnd = (HWND) (int)ptr; - dprintf_event(stddeb, "Got event %s for hwnd "NPFMT"\n", - event_names[event->type], hwnd ); + dprintf_event(stddeb, "Got event %s for hwnd %04x\n", + event_names[event->type], hwnd ); switch(event->type) { @@ -229,7 +229,7 @@ void EVENT_ProcessEvent( XEvent *event ) break; default: - dprintf_event(stddeb, "Unprocessed event %s for hwnd "NPFMT"\n", + dprintf_event(stddeb, "Unprocessed event %s for hwnd %04x\n", event_names[event->type], hwnd ); break; } @@ -522,7 +522,7 @@ static void EVENT_ConfigureNotify( HWND hwnd, XConfigureEvent *event ) if (!(wndPtr = WIN_FindWndPtr( hwnd ))) { - dprintf_event(stddeb, "ConfigureNotify: invalid HWND "NPFMT"\n", hwnd); + dprintf_event(stddeb,"ConfigureNotify: invalid HWND %04x\n",hwnd); return; } @@ -672,7 +672,7 @@ HWND SetCapture( HWND hwnd ) GrabModeAsync, GrabModeAsync, None, None, CurrentTime ) == GrabSuccess) { - dprintf_win(stddeb, "SetCapture: "NPFMT"\n", hwnd); + dprintf_win(stddeb, "SetCapture: %04x\n", hwnd); captureWnd = hwnd; return old_capture_wnd; } diff --git a/windows/focus.c b/windows/focus.c index bbd591bded7..12f3cc93caa 100644 --- a/windows/focus.c +++ b/windows/focus.c @@ -68,8 +68,8 @@ void FOCUS_SwitchFocus(HWND hFocusFrom, HWND hFocusTo) */ HWND SetFocus(HWND hwnd) { - HWND hWndPrevFocus, hwndTop; - WND *wndPtr = WIN_FindWndPtr( hwndTop = hwnd ); + HWND hWndPrevFocus, hwndTop = hwnd; + WND *wndPtr = WIN_FindWndPtr( hwnd ); if (wndPtr) { @@ -79,11 +79,8 @@ HWND SetFocus(HWND hwnd) { if ( wndPtr->dwStyle & ( WS_MINIMIZE | WS_DISABLED) ) return 0; - - hwndTop = wndPtr->hwndParent; - wndPtr = WIN_FindWndPtr( hwndTop ); - if ( !wndPtr ) - return 0; + if (!(wndPtr = wndPtr->parent)) return 0; + hwndTop = wndPtr->hwndSelf; } if( hwnd == hwndFocus ) return hwnd; diff --git a/windows/graphics.c b/windows/graphics.c index ab5cdcc0aba..ba65dbeb9c6 100644 --- a/windows/graphics.c +++ b/windows/graphics.c @@ -967,7 +967,7 @@ BOOL ExtFloodFill( HDC hdc, INT x, INT y, COLORREF color, WORD fillType ) RECT rect; DC *dc; - dprintf_graphics( stddeb, "ExtFloodFill "NPFMT" %d,%d %06lx %d\n", + dprintf_graphics( stddeb, "ExtFloodFill %04x %d,%d %06lx %d\n", hdc, x, y, color, fillType ); dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); if (!dc) diff --git a/windows/hook.c b/windows/hook.c index 1151e143432..dc256859f78 100644 --- a/windows/hook.c +++ b/windows/hook.c @@ -71,7 +71,7 @@ HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask ) if ((id < WH_FIRST_HOOK) || (id > WH_LAST_HOOK)) return 0; if (!(hInst = GetExePtr( hInst ))) return 0; - dprintf_hook( stddeb, "Setting hook %d: %08lx "NPFMT" "NPFMT"\n", + dprintf_hook( stddeb, "Setting hook %d: %08lx %04x %04x\n", id, (DWORD)proc, hInst, hTask ); if (hTask) /* Task-specific hook */ @@ -84,7 +84,7 @@ HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask ) if (id == WH_JOURNALPLAYBACK || id == WH_CBT || id == WH_DEBUG || id == WH_SHELL) { - fprintf( stdnimp, "Unimplemented hook set: (%d,%08lx,"NPFMT","NPFMT")!\n", + fprintf( stdnimp, "Unimplemented hook set: (%d,%08lx,%04x,%04x)!\n", id, (DWORD)proc, hInst, hTask ); } @@ -97,7 +97,7 @@ HANDLE HOOK_SetHook( short id, HOOKPROC proc, HINSTANCE hInst, HTASK hTask ) data->ownerQueue = hQueue; data->ownerModule = hInst; data->inHookProc = 0; - dprintf_hook( stddeb, "Setting hook %d: ret="NPFMT"\n", id, handle ); + dprintf_hook( stddeb, "Setting hook %d: ret=%04x\n", id, handle ); /* Insert it in the correct linked list */ @@ -126,7 +126,7 @@ static BOOL HOOK_RemoveHook( HANDLE hook ) HOOKDATA *data; HANDLE *prevHook; - dprintf_hook( stddeb, "Removing hook "NPFMT"\n", hook ); + dprintf_hook( stddeb, "Removing hook %04x\n", hook ); if (!(data = (HOOKDATA *)USER_HEAP_LIN_ADDR(hook))) return FALSE; if (data->inHookProc) @@ -187,10 +187,10 @@ static DWORD HOOK_CallHook( HANDLE hook, short code, queue->hCurHook = hook; data->inHookProc = 1; - dprintf_hook( stddeb, "Calling hook "NPFMT": %d %04lx %08lx\n", + dprintf_hook( stddeb, "Calling hook %04x: %d %04lx %08lx\n", hook, code, (DWORD)wParam, lParam ); ret = CallHookProc( data->proc, code, wParam, lParam ); - dprintf_hook( stddeb, "Ret hook "NPFMT" = %08lx\n", hook, ret ); + dprintf_hook( stddeb, "Ret hook %04x = %08lx\n", hook, ret ); data->inHookProc = 0; queue->hCurHook = prevHook; diff --git a/windows/mapping.c b/windows/mapping.c index 8c9f1210315..8fb9563d8f5 100644 --- a/windows/mapping.c +++ b/windows/mapping.c @@ -86,7 +86,7 @@ WORD SetMapMode( HDC hdc, WORD mode ) return 1; } - dprintf_gdi(stddeb, "SetMapMode: "NPFMT" %d\n", hdc, mode ); + dprintf_gdi(stddeb, "SetMapMode: %04x %d\n", hdc, mode ); prevMode = dc->w.MapMode; switch(mode) diff --git a/windows/mdi.c b/windows/mdi.c index 37ba8f7e15a..f3f80003d08 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -32,9 +32,9 @@ #include "stddebug.h" #include "debug.h" -void MDI_UpdateFrameText(HWND, HWND, BOOL, LPCSTR); -BOOL MDI_AugmentFrameMenu(MDICLIENTINFO*, HWND, HWND); -BOOL MDI_RestoreFrameMenu(HWND, HWND); +void MDI_UpdateFrameText(WND *, HWND, BOOL, LPCSTR); +BOOL MDI_AugmentFrameMenu(MDICLIENTINFO*, WND *, HWND); +BOOL MDI_RestoreFrameMenu(WND *, HWND); void ScrollChildren(HWND , UINT , WPARAM , LPARAM ); void CalcChildScroll(HWND, WORD); @@ -48,18 +48,11 @@ static LONG MDI_ChildActivate(WND* ,HWND ); * MDI_GetChildByID */ -static HWND MDI_GetChildByID(WND* mdiClient,int id) +static HWND MDI_GetChildByID(WND* wndPtr,int id) { - HWND hWnd = mdiClient->hwndChild; - WND* wndPtr = WIN_FindWndPtr( hWnd ); - - while( wndPtr ) - { - if( wndPtr->wIDmenu == id ) return hWnd; - wndPtr = WIN_FindWndPtr(hWnd = wndPtr->hwndNext); - } - - return 0; + for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next) + if (wndPtr->wIDmenu == id) return wndPtr->hwndSelf; + return 0; } /********************************************************************** @@ -163,37 +156,32 @@ static BOOL MDI_MenuDeleteItem(WND* clientWnd, HWND hWndChild ) */ HWND MDI_GetWindow(WND *clientWnd, HWND hWnd, WORD wTo ) { - HWND hWndNext; - MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra; - WND *wndPtr; + MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra; + WND *wndPtr, *pWnd, *pWndLast; + + if( !hWnd ) hWnd = clientInfo->hwndActiveChild; - if( !hWnd ) hWnd = clientInfo->hwndActiveChild; + if( !(wndPtr = WIN_FindWndPtr(hWnd)) ) return 0; - if( !(wndPtr = WIN_FindWndPtr(hWnd)) ) return 0; - - hWndNext = hWnd; - wTo = wTo ? GW_HWNDPREV : GW_HWNDNEXT; - - while( hWndNext ) + pWnd = wndPtr; + pWndLast = NULL; + for (;;) { - if( clientWnd->hwndChild == hWndNext && wTo == GW_HWNDPREV ) - hWndNext = GetWindow( hWndNext, GW_HWNDLAST); - else if( wndPtr->hwndNext == 0 && wTo == GW_HWNDNEXT ) - hWndNext = clientWnd->hwndChild; - else - hWndNext = GetWindow( hWndNext, wTo ); - - wndPtr = WIN_FindWndPtr( hWndNext ); - - if( (wndPtr->dwStyle & WS_VISIBLE) && - !(wndPtr->dwStyle & WS_DISABLED) ) - break; - - /* check if all windows were iterated through */ - if( hWndNext == hWnd ) break; + pWnd = pWnd->next; + if (!pWnd) pWnd = wndPtr->parent->child; + if (pWnd == wndPtr) /* not found */ + { + if (!wTo || !pWndLast) return 0; + break; + } + if ((pWnd->dwStyle & WS_VISIBLE) && + !(pWnd->dwStyle & WS_DISABLED)) /* found one */ + { + pWndLast = pWnd; + if (!wTo) break; + } } - - return ( hWnd == hWndNext )? 0 : hWndNext; + return pWndLast ? pWndLast->hwndSelf : 0; } @@ -205,7 +193,7 @@ HMENU MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU hmenuFrame, HMENU hmenuWindow) WND *w = WIN_FindWndPtr(hwnd); MDICLIENTINFO *ci; - dprintf_mdi(stddeb, "WM_MDISETMENU: "NPFMT" %04x "NPFMT" "NPFMT"\n", + dprintf_mdi(stddeb, "WM_MDISETMENU: %04x %04x %04x %04x\n", hwnd, fRefresh, hmenuFrame, hmenuWindow); ci = (MDICLIENTINFO *) w->wExtra; @@ -216,7 +204,7 @@ HMENU MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU hmenuFrame, HMENU hmenuWindow) HMENU oldFrameMenu = GetMenu(hwndFrame); if( ci->flagChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu ) - MDI_RestoreFrameMenu(w->hwndParent, ci->flagChildMaximized ); + MDI_RestoreFrameMenu(w->parent, ci->flagChildMaximized ); if( hmenuWindow && hmenuWindow!=ci->hWindowMenu ) { @@ -258,8 +246,7 @@ HMENU MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU hmenuFrame, HMENU hmenuWindow) { SetMenu(hwndFrame, hmenuFrame); if( ci->flagChildMaximized ) - MDI_AugmentFrameMenu(ci, - w->hwndParent, ci->flagChildMaximized ); + MDI_AugmentFrameMenu(ci, w->parent, ci->flagChildMaximized ); return oldFrameMenu; } @@ -321,7 +308,7 @@ HWND MDICreateChild(WND *w, MDICLIENTINFO *ci, HWND parent, LPARAM lParam ) if (hwnd) { MDI_MenuModifyItem(w ,hwnd); - dprintf_mdi(stddeb, "MDICreateChild: created child - "NPFMT"\n",hwnd); + dprintf_mdi(stddeb, "MDICreateChild: created child - %04x\n",hwnd); } else { @@ -341,7 +328,7 @@ void MDI_ChildGetMinMaxInfo(WND* clientWnd, HWND hwnd, MINMAXINFO* lpMinMax ) WND* childWnd = WIN_FindWndPtr(hwnd); RECT rect = clientWnd->rectClient; - MapWindowPoints(clientWnd->hwndParent, + MapWindowPoints(clientWnd->parent->hwndSelf, ((MDICLIENTINFO*)clientWnd->wExtra)->self, (LPPOINT)&rect, 2); AdjustWindowRectEx(&rect, childWnd->dwStyle, 0, childWnd->dwExStyle); @@ -372,7 +359,7 @@ void MDI_SwitchActiveChild(HWND clientHwnd, HWND childHwnd, BOOL wTo ) ci = (MDICLIENTINFO *) w->wExtra; - dprintf_mdi(stddeb, "MDI_SwitchActiveChild: from "NPFMT", to "NPFMT"\n",childHwnd,hwndTo); + dprintf_mdi(stddeb, "MDI_SwitchActiveChild: from %04x, to %04x\n",childHwnd,hwndTo); if ( !hwndTo ) return; @@ -421,9 +408,9 @@ HWND MDIDestroyChild(WND *w_parent, MDICLIENTINFO *ci, HWND parent, ShowWindow( child, SW_HIDE); if( child == ci->flagChildMaximized ) { - MDI_RestoreFrameMenu(w_parent->hwndParent, child); + MDI_RestoreFrameMenu(w_parent->parent, child); ci->flagChildMaximized = 0; - MDI_UpdateFrameText(w_parent->hwndParent,parent,TRUE,NULL); + MDI_UpdateFrameText(w_parent->parent,parent,TRUE,NULL); } MDI_ChildActivate(w_parent,0); @@ -433,7 +420,7 @@ HWND MDIDestroyChild(WND *w_parent, MDICLIENTINFO *ci, HWND parent, ci->nActiveChildren--; - dprintf_mdi(stddeb,"MDIDestroyChild: child destroyed - "NPFMT"\n",child); + dprintf_mdi(stddeb,"MDIDestroyChild: child destroyed - %04x\n",child); if (flagDestroy) { @@ -465,9 +452,9 @@ LONG MDI_ChildActivate(WND *clientPtr, HWND hWndChild) if( wndPtr ) if( wndPtr->dwStyle & WS_DISABLED ) return 0L; - dprintf_mdi(stddeb,"MDI_ChildActivate: "NPFMT"\n", hWndChild); + dprintf_mdi(stddeb,"MDI_ChildActivate: %04x\n", hWndChild); - if( GetActiveWindow() == clientPtr->hwndParent ) + if( GetActiveWindow() == clientPtr->parent->hwndSelf ) isActiveFrameWnd = TRUE; /* deactivate prev. active child */ @@ -550,14 +537,14 @@ MDIWCL* MDI_BuildWCL(WND* clientWnd, int* iTotal) if (!(listTop = (MDIWCL*)malloc( sizeof(MDIWCL) ))) return NULL; - listTop->hChild = clientWnd->hwndChild; + listTop->hChild = clientWnd->child ? clientWnd->child->hwndSelf : 0; listTop->prev = NULL; *iTotal = 1; /* build linked list from top child to bottom */ childWnd = WIN_FindWndPtr( listTop->hChild ); - while( childWnd && childWnd->hwndNext ) + while( childWnd && childWnd->next ) { listNext = (MDIWCL*)xmalloc(sizeof(MDIWCL)); @@ -569,12 +556,12 @@ MDIWCL* MDI_BuildWCL(WND* clientWnd, int* iTotal) (*iTotal)--; } - listNext->hChild = childWnd->hwndNext; + listNext->hChild = childWnd->next->hwndSelf; listNext->prev = listTop; listTop = listNext; (*iTotal)++; - childWnd = WIN_FindWndPtr( childWnd->hwndNext ); + childWnd = childWnd->next; } if( (childWnd->dwStyle & WS_DISABLED) || @@ -641,10 +628,8 @@ LONG MDICascade(HWND parent, MDICLIENTINFO *ci) ysize = rect.bottom - 8 * spacing; xsize = rect.right - 8 * spacing; - dprintf_mdi(stddeb, - "MDICascade: Client wnd at (%ld,%ld) - (%ld,%ld), spacing %d\n", - (LONG)rect.left, (LONG)rect.top, (LONG)rect.right, (LONG)rect.bottom, - spacing); + dprintf_mdi(stddeb, "MDICascade: Client wnd at (%d,%d) - (%d,%d), spacing %d\n", + rect.left, rect.top, rect.right, rect.bottom, spacing); clientWnd = WIN_FindWndPtr( parent ); @@ -658,7 +643,7 @@ LONG MDICascade(HWND parent, MDICLIENTINFO *ci) /* walk list and move windows */ while ( listTop ) { - dprintf_mdi(stddeb, "MDICascade: move "NPFMT" to (%d,%d) size [%d,%d]\n", + dprintf_mdi(stddeb, "MDICascade: move %04x to (%d,%d) size [%d,%d]\n", listTop->hChild, x, y, xsize, ysize); if( listTop->hChild ) @@ -786,19 +771,18 @@ LONG MDITile(HWND parent, MDICLIENTINFO *ci,WORD wParam) /********************************************************************** * MDI_AugmentFrameMenu */ -BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, HWND hFrame, HWND hChild) +BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, WND *frame, HWND hChild) { - WND* frame = WIN_FindWndPtr(hFrame); WND* child = WIN_FindWndPtr(hChild); HMENU hSysPopup = 0; - dprintf_mdi(stddeb,"MDI_AugmentFrameMenu: frame "NPFMT",child "NPFMT"\n",hFrame,hChild); + dprintf_mdi(stddeb,"MDI_AugmentFrameMenu: frame %p,child %04x\n",frame,hChild); if( !frame->wIDmenu || !child->hSysMenu ) return 0; hSysPopup = GetSystemMenu(hChild,FALSE); - dprintf_mdi(stddeb,"got popup "NPFMT"\n in sysmenu "NPFMT"",hSysPopup,child->hSysMenu); + dprintf_mdi(stddeb,"got popup %04x\n in sysmenu %04x",hSysPopup,child->hSysMenu); if( !InsertMenu(frame->wIDmenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP, hSysPopup, (SEGPTR)(DWORD)ci->obmClose) ) @@ -818,7 +802,7 @@ BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, HWND hFrame, HWND hChild) child->dwStyle &= ~WS_SYSMENU; /* redraw frame */ - SetWindowPos(hFrame, 0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | + SetWindowPos(frame->hwndSelf, 0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); return 1; @@ -827,13 +811,12 @@ BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, HWND hFrame, HWND hChild) /********************************************************************** * MDI_RestoreFrameMenu */ -BOOL MDI_RestoreFrameMenu(HWND hFrame, HWND hChild) +BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild) { - WND* frameWnd = WIN_FindWndPtr(hFrame); WND* child = WIN_FindWndPtr(hChild); INT nItems = GetMenuItemCount(frameWnd->wIDmenu) - 1; - dprintf_mdi(stddeb,"MDI_RestoreFrameMenu: for child "NPFMT"\n",hChild); + dprintf_mdi(stddeb,"MDI_RestoreFrameMenu: for child %04x\n",hChild); if( GetMenuItemID(frameWnd->wIDmenu,nItems) != SC_RESTORE ) return 0; @@ -856,12 +839,11 @@ BOOL MDI_RestoreFrameMenu(HWND hFrame, HWND hChild) * * Note: lpTitle can be NULL */ -void MDI_UpdateFrameText(HWND hFrame, HWND hClient, BOOL repaint, LPCSTR lpTitle) +void MDI_UpdateFrameText(WND *frameWnd, HWND hClient, BOOL repaint, LPCSTR lpTitle) { char lpBuffer[MDI_MAXTITLELENGTH+1]; LPSTR lpText = NULL; WND* clientWnd = WIN_FindWndPtr(hClient); - WND* frameWnd = WIN_FindWndPtr(hFrame); MDICLIENTINFO *ci = (MDICLIENTINFO *) clientWnd->wExtra; @@ -934,8 +916,8 @@ void MDI_UpdateFrameText(HWND hFrame, HWND hClient, BOOL repaint, LPCSTR lpTitle XStoreName( display, frameWnd->window, lpBuffer ); if( repaint == MDI_REPAINTFRAME) - SetWindowPos(hFrame, 0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER ); + SetWindowPos(frameWnd->hwndSelf, 0,0,0,0,0, SWP_FRAMECHANGED | + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); } @@ -954,7 +936,7 @@ LRESULT MDIClientWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) MDICLIENTINFO *ci; RECT rect; WND *w = WIN_FindWndPtr(hwnd); - WND *frameWnd = WIN_FindWndPtr( w->hwndParent ); + WND *frameWnd = w->parent; ci = (MDICLIENTINFO *) w->wExtra; @@ -976,21 +958,20 @@ LRESULT MDIClientWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) w->dwStyle |= WS_CLIPCHILDREN; frameWnd->hText = 0; /* will be restored in UpdateFrameText */ - MDI_UpdateFrameText( w->hwndParent, hwnd, MDI_NOFRAMEREPAINT, NULL); + MDI_UpdateFrameText( frameWnd, hwnd, MDI_NOFRAMEREPAINT, NULL); AppendMenu(ccs->hWindowMenu,MF_SEPARATOR,0,(SEGPTR)0); - GetClientRect(w->hwndParent, &rect); + GetClientRect(frameWnd->hwndSelf, &rect); NC_HandleNCCalcSize(hwnd, (NCCALCSIZE_PARAMS*) &rect); w->rectClient = rect; - dprintf_mdi(stddeb,"MDI: Client created - hwnd = "NPFMT", idFirst = %u\n",hwnd,ci->idFirstChild); + dprintf_mdi(stddeb,"MDI: Client created - hwnd = %04x, idFirst = %u\n",hwnd,ci->idFirstChild); return 0; case WM_DESTROY: - if( ci->flagChildMaximized ) - MDI_RestoreFrameMenu(hwnd, w->hwndParent); + if( ci->flagChildMaximized ) MDI_RestoreFrameMenu(w, frameWnd->hwndSelf); if(ci->obmClose) DeleteObject(ci->obmClose); if(ci->obmRestore) DeleteObject(ci->obmRestore); @@ -1164,7 +1145,7 @@ LRESULT DefFrameProc(HWND hwnd, HWND hwndMDIClient, UINT message, break; case WM_SETTEXT: - MDI_UpdateFrameText(hwnd, hwndMDIClient, + MDI_UpdateFrameText(WIN_FindWndPtr(hwnd), hwndMDIClient, MDI_REPAINTFRAME, (LPCSTR)PTR_SEG_TO_LIN(lParam)); return 0; @@ -1205,7 +1186,7 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) DefWindowProc(hwnd, message, wParam, lParam); MDI_MenuModifyItem(clientWnd,hwnd); if( ci->flagChildMaximized == hwnd ) - MDI_UpdateFrameText( clientWnd->hwndParent, ci->self, + MDI_UpdateFrameText( clientWnd->parent, ci->self, MDI_REPAINTFRAME, NULL ); return 0; @@ -1223,7 +1204,7 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; case WM_NCPAINT: - dprintf_mdi(stddeb,"DefMDIChildProc: WM_NCPAINT for "NPFMT", active "NPFMT"\n", + dprintf_mdi(stddeb,"DefMDIChildProc: WM_NCPAINT for %04x, active %04x\n", hwnd, ci->hwndActiveChild ); break; @@ -1235,7 +1216,8 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case SC_MAXIMIZE: if( ci->flagChildMaximized == hwnd) - return SendMessage( clientWnd->hwndParent, message, wParam, lParam); + return SendMessage( clientWnd->parent->hwndSelf, + message, wParam, lParam); break; case SC_NEXTWINDOW: SendMessage( ci->self, WM_MDINEXT, 0, 0); @@ -1265,8 +1247,8 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { ci->flagChildMaximized = 0; - MDI_RestoreFrameMenu( clientWnd->hwndParent, hwnd); - MDI_UpdateFrameText( clientWnd->hwndParent, ci->self, + MDI_RestoreFrameMenu( clientWnd->parent, hwnd); + MDI_UpdateFrameText( clientWnd->parent, ci->self, MDI_REPAINTFRAME, NULL ); } @@ -1280,7 +1262,7 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { SendMessage( hMaxChild, WM_SETREDRAW, FALSE, 0L ); - MDI_RestoreFrameMenu( clientWnd->hwndParent, hMaxChild); + MDI_RestoreFrameMenu( clientWnd->parent, hMaxChild); ShowWindow( hMaxChild, SW_SHOWNOACTIVATE); SendMessage( hMaxChild, WM_SETREDRAW, TRUE, 0L ); @@ -1288,8 +1270,8 @@ LRESULT DefMDIChildProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ci->flagChildMaximized = hwnd; /* !!! */ - MDI_AugmentFrameMenu( ci, clientWnd->hwndParent, hwnd); - MDI_UpdateFrameText( clientWnd->hwndParent, ci->self, + MDI_AugmentFrameMenu( ci, clientWnd->parent, hwnd); + MDI_UpdateFrameText( clientWnd->parent, ci->self, MDI_REPAINTFRAME, NULL ); } @@ -1352,7 +1334,7 @@ BOOL TranslateMDISysAccel(HWND hwndClient, LPMSG msg) return 0; } - dprintf_mdi(stddeb,"TranslateMDISysAccel: wParam = "NPFMT"\n", wParam); + dprintf_mdi(stddeb,"TranslateMDISysAccel: wParam = %04x\n", wParam); SendMessage(ci->hwndActiveChild,WM_SYSCOMMAND, wParam, (LPARAM)msg->wParam); return 1; @@ -1365,17 +1347,13 @@ BOOL TranslateMDISysAccel(HWND hwndClient, LPMSG msg) void CalcChildScroll( HWND hwnd, WORD scroll ) { RECT childRect, clientRect; - HWND hwndChild; + WND *pWnd; + if (!(pWnd = WIN_FindWndPtr( hwnd ))) return; GetClientRect( hwnd, &clientRect ); SetRectEmpty( &childRect ); - hwndChild = GetWindow( hwnd, GW_CHILD ); - while (hwndChild) - { - WND *wndPtr = WIN_FindWndPtr( hwndChild ); - UnionRect( &childRect, &wndPtr->rectWindow, &childRect ); - hwndChild = wndPtr->hwndNext; - } + for (pWnd = pWnd->child; pWnd; pWnd = pWnd->next) + UnionRect( &childRect, &pWnd->rectWindow, &childRect ); UnionRect( &childRect, &clientRect, &childRect ); if ((scroll == SB_HORZ) || (scroll == SB_BOTH)) diff --git a/windows/message.c b/windows/message.c index 8f00ed80595..415f39cc406 100644 --- a/windows/message.c +++ b/windows/message.c @@ -50,6 +50,7 @@ static WORD doubleClickSpeed = 452; */ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) { + WND *pWnd; BOOL eatMsg = FALSE; INT hittest; static DWORD lastClickTime = 0; @@ -75,9 +76,10 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) msg->message, (LPARAM)MAKE_SEGPTR(&hook)); } - if ((hittest = WINPOS_WindowFromPoint( msg->pt, &msg->hwnd )) != HTERROR) + hittest = WINPOS_WindowFromPoint( msg->pt, &pWnd ); + msg->hwnd = pWnd->hwndSelf; + if (hittest != HTERROR) { - /* Send the WM_PARENTNOTIFY message */ if (mouseClick) WIN_SendParentNotify( msg->hwnd, msg->message, 0, @@ -126,9 +128,7 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) if (dbl_click && (hittest == HTCLIENT)) { /* Check whether window wants the double click message. */ - WND * wndPtr = WIN_FindWndPtr( msg->hwnd ); - if (!wndPtr || !(WIN_CLASS_STYLE(wndPtr) & CS_DBLCLKS)) - dbl_click = FALSE; + dbl_click = (WIN_CLASS_STYLE(pWnd) & CS_DBLCLKS) != 0; } if (dbl_click) switch(msg->message) @@ -576,20 +576,20 @@ BOOL PostMessage( HWND hwnd, WORD message, WORD wParam, LONG lParam ) return TRUE; #endif /* CONFIG_IPC */ - if (hwnd == HWND_BROADCAST) { - dprintf_msg(stddeb,"PostMessage // HWND_BROADCAST !\n"); - hwnd = GetTopWindow(GetDesktopWindow()); - while (hwnd) { - if (!(wndPtr = WIN_FindWndPtr(hwnd))) break; - if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) { - dprintf_msg(stddeb,"BROADCAST Message to hWnd="NPFMT" m=%04X w=%04X l=%08lX !\n", - hwnd, message, wParam, lParam); - PostMessage(hwnd, message, wParam, lParam); - } - hwnd = wndPtr->hwndNext; - } - dprintf_msg(stddeb,"PostMessage // End of HWND_BROADCAST !\n"); - return TRUE; + if (hwnd == HWND_BROADCAST) + { + dprintf_msg(stddeb,"PostMessage // HWND_BROADCAST !\n"); + for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) + { + if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) + { + dprintf_msg(stddeb,"BROADCAST Message to hWnd=%04x m=%04X w=%04X l=%08lX !\n", + wndPtr->hwndSelf, message, wParam, lParam); + PostMessage( wndPtr->hwndSelf, message, wParam, lParam ); + } + } + dprintf_msg(stddeb,"PostMessage // End of HWND_BROADCAST !\n"); + return TRUE; } wndPtr = WIN_FindWndPtr( hwnd ); @@ -641,17 +641,14 @@ LRESULT SendMessage( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) if (hwnd == HWND_BROADCAST) { dprintf_msg(stddeb,"SendMessage // HWND_BROADCAST !\n"); - hwnd = GetTopWindow(GetDesktopWindow()); - while (hwnd) - { - if (!(wndPtr = WIN_FindWndPtr(hwnd))) break; + for (wndPtr = WIN_GetDesktop()->child; wndPtr; wndPtr = wndPtr->next) + { if (wndPtr->dwStyle & WS_POPUP || wndPtr->dwStyle & WS_CAPTION) { - dprintf_msg(stddeb,"BROADCAST Message to hWnd="NPFMT" m=%04X w=%04lX l=%08lX !\n", - hwnd, msg, (DWORD)wParam, lParam); - ret |= SendMessage( hwnd, msg, wParam, lParam ); + dprintf_msg(stddeb,"BROADCAST Message to hWnd=%04x m=%04X w=%04lX l=%08lX !\n", + wndPtr->hwndSelf, msg, (DWORD)wParam, lParam); + ret |= SendMessage( wndPtr->hwndSelf, msg, wParam, lParam ); } - hwnd = wndPtr->hwndNext; } dprintf_msg(stddeb,"SendMessage // End of HWND_BROADCAST !\n"); return TRUE; @@ -732,7 +729,7 @@ LONG DispatchMessage( const MSG* msg ) { if (msg->lParam) { -#ifndef WINELIB32 +#ifndef WINELIB HINSTANCE ds = msg->hwnd ? WIN_GetWindowInstance( msg->hwnd ) : (HINSTANCE)CURRENT_DS; #endif @@ -753,7 +750,7 @@ LONG DispatchMessage( const MSG* msg ) if (painting && (wndPtr = WIN_FindWndPtr( msg->hwnd )) && (wndPtr->flags & WIN_NEEDS_BEGINPAINT) && wndPtr->hrgnUpdate) { - fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd "NPFMT"!\n", + fprintf(stderr, "BeginPaint not called on WM_PAINT for hwnd %04x!\n", msg->hwnd); wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT; /* Validate the update region to avoid infinite WM_PAINT loop */ @@ -768,7 +765,7 @@ LONG DispatchMessage( const MSG* msg ) */ WORD RegisterWindowMessage( SEGPTR str ) { - dprintf_msg(stddeb, "RegisterWindowMessage: '"SPFMT"'\n", str ); + dprintf_msg(stddeb, "RegisterWindowMessage: %08lx\n", (DWORD)str ); return GlobalAddAtom( str ); } diff --git a/windows/nonclient.c b/windows/nonclient.c index 917de6ce39f..70b8125d5e9 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -110,9 +110,9 @@ BOOL AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) style |= WS_CAPTION; if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME; - dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%ld,%ld)-(%ld,%ld) %08lx %d %08lx\n", - (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, (LONG)rect->bottom, - style, menu, exStyle ); + dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n", + rect->left, rect->top, rect->right, rect->bottom, + style, menu, exStyle ); NC_AdjustRect( rect, style, menu, exStyle ); return TRUE; @@ -268,8 +268,8 @@ LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ) WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr) return HTERROR; - dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd="NPFMT" pt=%ld,%ld\n", - hwnd, (LONG)pt.x, (LONG)pt.y ); + dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd=%04x pt=%d,%d\n", + hwnd, pt.x, pt.y ); GetWindowRect( hwnd, &rect ); if (!PtInRect( &rect, pt )) return HTNOWHERE; @@ -627,7 +627,7 @@ void NC_DoNCPaint( HWND hwnd, BOOL active, BOOL suppress_menupaint ) WND *wndPtr = WIN_FindWndPtr( hwnd ); - dprintf_nonclient(stddeb, "NC_DoNCPaint: "NPFMT" %d\n", hwnd, active ); + dprintf_nonclient(stddeb, "NC_DoNCPaint: %04x %d\n", hwnd, active ); if (!wndPtr || !(wndPtr->dwStyle & WS_VISIBLE)) return; /* Nothing to do */ if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return; @@ -826,7 +826,7 @@ static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt ) NC_GetInsideRect( hwnd, &rect ); OffsetRect( &rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top ); if (wndPtr->dwStyle & WS_CHILD) - ClientToScreen( wndPtr->hwndParent, (POINT *)&rect ); + ClientToScreen( wndPtr->parent->hwndSelf, (POINT *)&rect ); rect.right = rect.left + SYSMETRICS_CXSIZE; rect.bottom = rect.top + SYSMETRICS_CYSIZE; if (!iconic) NC_DrawSysButton( hwnd, hdc, TRUE ); @@ -864,7 +864,7 @@ static LONG NC_StartSizeMove( HWND hwnd, WPARAM wParam, POINT *capturePoint ) pt.x = wndPtr->rectWindow.left + (rect.right - rect.left) / 2; pt.y = wndPtr->rectWindow.top + rect.top + SYSMETRICS_CYSIZE/2; if (wndPtr->dwStyle & WS_CHILD) - ClientToScreen( wndPtr->hwndParent, &pt ); + ClientToScreen( wndPtr->parent->hwndSelf, &pt ); hittest = HTCAPTION; } else /* SC_SIZE */ @@ -969,7 +969,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) NC_GetMinMaxInfo( hwnd, NULL, NULL, &minTrack, &maxTrack ); sizingRect = wndPtr->rectWindow; if (wndPtr->dwStyle & WS_CHILD) - GetClientRect( wndPtr->hwndParent, &mouseRect ); + GetClientRect( wndPtr->parent->hwndSelf, &mouseRect ); else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN ); if (ON_LEFT_BORDER(hittest)) { @@ -998,7 +998,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) if (wndPtr->dwStyle & WS_CHILD) { /* Retrieve a default cache DC (without using the window style) */ - hdc = GetDCEx( wndPtr->hwndParent, 0, DCX_CACHE ); + hdc = GetDCEx( wndPtr->parent->hwndSelf, 0, DCX_CACHE ); } else { /* Grab the server only when moving top-level windows without desktop */ @@ -1023,7 +1023,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) pt = msg.pt; if (wndPtr->dwStyle & WS_CHILD) - ScreenToClient( wndPtr->hwndParent, &pt ); + ScreenToClient( wndPtr->parent->hwndSelf, &pt ); if (msg.message == WM_KEYDOWN) switch(msg.wParam) @@ -1066,7 +1066,7 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) NC_DrawMovingFrame( hdc, &sizingRect, thickframe ); ReleaseCapture(); - if (wndPtr->dwStyle & WS_CHILD) ReleaseDC( wndPtr->hwndParent, hdc ); + if (wndPtr->dwStyle & WS_CHILD) ReleaseDC( wndPtr->parent->hwndSelf, hdc ); else { ReleaseDC( 0, hdc ); @@ -1294,10 +1294,11 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); - dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %lx %ld,%ld\n", - (DWORD)wParam, (LONG)pt.x, (LONG)pt.y ); + dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %x %d,%d\n", + wParam, pt.x, pt.y ); - if (wndPtr->dwStyle & WS_CHILD) ScreenToClient( wndPtr->hwndParent, &pt ); + if (wndPtr->dwStyle & WS_CHILD) + ScreenToClient( wndPtr->parent->hwndSelf, &pt ); switch (wParam & 0xfff0) { diff --git a/windows/painting.c b/windows/painting.c index d1438d5927d..bd1554c913f 100644 --- a/windows/painting.c +++ b/windows/painting.c @@ -49,7 +49,7 @@ HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps ) DeleteObject( hrgnUpdate ); if (!lps->hdc) { - fprintf( stderr, "GetDCEx() failed in BeginPaint(), hwnd="NPFMT"\n", hwnd ); + fprintf(stderr, "GetDCEx() failed in BeginPaint(), hwnd=%04x\n", hwnd); return 0; } @@ -144,13 +144,13 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) if (rectUpdate) { - dprintf_win( stddeb, "RedrawWindow: "NPFMT" %ld,%ld-%ld,%ld "NPFMT" flags=%04x\n", - hwnd, (LONG)rectUpdate->left, (LONG)rectUpdate->top, - (LONG)rectUpdate->right, (LONG)rectUpdate->bottom, hrgnUpdate, flags); + dprintf_win(stddeb, "RedrawWindow: %04x %d,%d-%d,%d %04x flags=%04x\n", + hwnd, rectUpdate->left, rectUpdate->top, + rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags ); } else { - dprintf_win( stddeb, "RedrawWindow: "NPFMT" NULL "NPFMT" flags=%04x\n", + dprintf_win( stddeb, "RedrawWindow: %04x NULL %04x flags=%04x\n", hwnd, hrgnUpdate, flags); } GetClientRect( hwnd, &rectClient ); @@ -265,30 +265,28 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) { HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); if (!hrgn) return TRUE; - for (hwnd = wndPtr->hwndChild; (hwnd); hwnd = wndPtr->hwndNext) + for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next) { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; CombineRgn( hrgn, hrgnUpdate, 0, RGN_COPY ); OffsetRgn( hrgn, -wndPtr->rectClient.left, -wndPtr->rectClient.top ); - RedrawWindow( hwnd, NULL, hrgn, flags ); + RedrawWindow( wndPtr->hwndSelf, NULL, hrgn, flags ); } DeleteObject( hrgn ); } else { RECT rect; - for (hwnd = wndPtr->hwndChild; (hwnd); hwnd = wndPtr->hwndNext) + for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next) { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) break; if (rectUpdate) { rect = *rectUpdate; OffsetRect( &rect, -wndPtr->rectClient.left, -wndPtr->rectClient.top ); - RedrawWindow( hwnd, &rect, 0, flags ); + RedrawWindow( wndPtr->hwndSelf, &rect, 0, flags ); } - else RedrawWindow( hwnd, NULL, 0, flags ); + else RedrawWindow( wndPtr->hwndSelf, NULL, 0, flags ); } } } diff --git a/windows/property.c b/windows/property.c index ef6a323c159..6927be0f783 100644 --- a/windows/property.c +++ b/windows/property.c @@ -31,7 +31,8 @@ BOOL SetProp( HWND hwnd, SEGPTR str, HANDLE hData ) PROPERTY *prop; WND *wndPtr; - dprintf_prop( stddeb, "SetProp: "NPFMT" "SPFMT" "NPFMT"\n", hwnd, str, hData ); + dprintf_prop( stddeb, "SetProp: %04x %08lx %04x\n", + hwnd, (DWORD)str, hData ); if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; hProp = USER_HEAP_ALLOC( sizeof(PROPERTY) + (HIWORD(str) ? strlen(PTR_SEG_TO_LIN(str)) : 0 )); @@ -62,7 +63,7 @@ HANDLE GetProp( HWND hwnd, SEGPTR str ) HANDLE hProp; WND *wndPtr; - dprintf_prop( stddeb, "GetProp: "NPFMT" "SPFMT"\n", hwnd, str ); + dprintf_prop( stddeb, "GetProp: %04x %08lx\n", hwnd, (DWORD)str ); if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; hProp = wndPtr->hProp; while (hProp) @@ -88,7 +89,7 @@ HANDLE RemoveProp( HWND hwnd, SEGPTR str ) HANDLE *hProp; WND *wndPtr; - dprintf_prop( stddeb, "RemoveProp: "NPFMT" "SPFMT"\n", hwnd, str ); + dprintf_prop( stddeb, "RemoveProp: %04x %08lx\n", hwnd, (DWORD)str ); if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; hProp = &wndPtr->hProp; while (*hProp) @@ -119,14 +120,14 @@ INT EnumProps( HWND hwnd, PROPENUMPROC func ) HANDLE hProp; WND *wndPtr; - dprintf_prop( stddeb, "EnumProps: "NPFMT" %08lx\n", hwnd, (LONG)func ); + dprintf_prop( stddeb, "EnumProps: %04x %08lx\n", hwnd, (LONG)func ); if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; hProp = wndPtr->hProp; while (hProp) { PROPERTY *prop = (PROPERTY *)USER_HEAP_LIN_ADDR(hProp); - dprintf_prop( stddeb, " Callback: atom=%04x data="NPFMT" str='%s'\n", + dprintf_prop( stddeb, " Callback: atom=%04x data=%04x str='%s'\n", prop->atom, prop->hData, prop->string ); /* Already get the next in case the callback */ @@ -134,7 +135,7 @@ INT EnumProps( HWND hwnd, PROPENUMPROC func ) hProp = prop->next; ret = CallEnumPropProc( func, hwnd, prop->atom ? - (LONG)MAKELONG( prop->atom, 0 ) + (LONG)MAKELONG( prop->atom, 0 ) : (LONG)(USER_HEAP_SEG_ADDR(hProp) + ((int)prop->string - (int)prop)), diff --git a/windows/queue.c b/windows/queue.c index 1d0028a4120..06066456894 100644 --- a/windows/queue.c +++ b/windows/queue.c @@ -28,7 +28,7 @@ void QUEUE_DumpQueue( HQUEUE hQueue ) if (!(pq = (MESSAGEQUEUE*) GlobalLock( hQueue )) || GlobalSize(hQueue) < sizeof(MESSAGEQUEUE) + pq->queueSize*sizeof(QMSG)) { - fprintf( stderr, NPFMT " is not a queue handle\n", hQueue ); + fprintf( stderr, "%04x is not a queue handle\n", hQueue ); return; } @@ -68,7 +68,7 @@ void QUEUE_WalkQueues(void) MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock( hQueue ); if (!queue) { - fprintf( stderr, "*** Bad queue handle "NPFMT"\n", hQueue ); + fprintf( stderr, "*** Bad queue handle %04x\n", hQueue ); return; } fprintf( stderr, "%04x %5d %4d %04x %s\n", @@ -198,7 +198,7 @@ int QUEUE_FindMsg( MESSAGEQUEUE * msgQueue, HWND hwnd, int first, int last ) { int i, pos = msgQueue->nextMessage; - dprintf_msg(stddeb,"MSG_FindMsg: hwnd=0x"NPFMT"\n\n", hwnd ); + dprintf_msg(stddeb,"MSG_FindMsg: hwnd=%04x\n\n", hwnd ); if (!msgQueue->msgCount) return -1; if (!hwnd && !first && !last) return pos; diff --git a/windows/scroll.c b/windows/scroll.c index 95a88e88177..4259dbf76c6 100644 --- a/windows/scroll.c +++ b/windows/scroll.c @@ -78,32 +78,26 @@ HRGN SCROLL_TraceChildren( HWND hScroll, short dx, short dy, WORD dcx) BOOL SCROLL_ScrollChildren( HWND hScroll, short dx, short dy) { WND *wndPtr = WIN_FindWndPtr(hScroll); - HWND hWnd = wndPtr->hwndChild; HRGN hUpdateRgn; BOOL b = 0; if( !wndPtr || ( !dx && !dy )) return 0; - dprintf_scroll(stddeb,"SCROLL_ScrollChildren: hwnd "NPFMT" dx=%i dy=%i\n",hScroll,dx,dy); + dprintf_scroll(stddeb,"SCROLL_ScrollChildren: hwnd %04x dx=%i dy=%i\n",hScroll,dx,dy); /* get a region in client rect invalidated by siblings and ansectors */ hUpdateRgn = SCROLL_TraceChildren(hScroll, dx , dy, DCX_CLIPSIBLINGS); - /* update children coordinates */ - while( hWnd ) - { - wndPtr = WIN_FindWndPtr( hWnd ); - + /* update children coordinates */ + for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next) + { /* we can check if window intersects with clipRect parameter * and do not move it if not - just a thought. - AK */ - - SetWindowPos(hWnd,0,wndPtr->rectWindow.left + dx, - wndPtr->rectWindow.top + dy, 0,0, SWP_NOZORDER | - SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | - SWP_DEFERERASE ); - - hWnd = wndPtr->hwndNext; + SetWindowPos(wndPtr->hwndSelf, 0, wndPtr->rectWindow.left + dx, + wndPtr->rectWindow.top + dy, 0,0, SWP_NOZORDER | + SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW | + SWP_DEFERERASE ); } /* invalidate uncovered region and paint frames */ @@ -209,11 +203,9 @@ BOOL ScrollDC(HDC hdc, short dx, short dy, LPRECT rc, LPRECT cliprc, short width, height; DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC); - dprintf_scroll(stddeb,"ScrollDC: dx=%d dy=%d, hrgnUpdate="NPFMT" rc=%i %i %i %i\n", - dx,dy,hrgnUpdate,(int)((rc)?rc->left:0), - (int)((rc)?rc->top:0), - (int)((rc)?rc->right:0), - (int)((rc)?rc->bottom:0)); + dprintf_scroll(stddeb,"ScrollDC: dx=%d dy=%d, hrgnUpdate=%04x rc=%d %d %d %d\n", + dx,dy,hrgnUpdate,((rc)?rc->left:0), ((rc)?rc->top:0), + ((rc)?rc->right:0), ((rc)?rc->bottom:0)); if (rc == NULL) return FALSE; diff --git a/windows/timer.c b/windows/timer.c index 1be4855d5e7..ca1a620ee38 100644 --- a/windows/timer.c +++ b/windows/timer.c @@ -114,7 +114,7 @@ BOOL TIMER_CheckTimer( LONG *next, MSG *msg, HWND hwnd, BOOL remove ) TIMER_RestartTimer( pTimer, curTime ); } - dprintf_timer(stddeb, "Timer expired: %p, "NPFMT", %04x, %04x, %08lx\n", + dprintf_timer(stddeb, "Timer expired: %p, %04x, %04x, %04x, %08lx\n", pTimer, pTimer->hwnd, pTimer->msg, pTimer->id, (DWORD)pTimer->proc); /* Build the message */ msg->hwnd = pTimer->hwnd; @@ -170,7 +170,7 @@ static WORD TIMER_SetTimer( HWND hwnd, WORD id, WORD timeout, pTimer->timeout = timeout; pTimer->expires = GetTickCount() + timeout; pTimer->proc = proc; - dprintf_timer(stddeb, "Timer added: %p, "NPFMT", %04x, %04x, %08lx\n", + dprintf_timer(stddeb, "Timer added: %p, %04x, %04x, %04x, %08lx\n", pTimer, pTimer->hwnd, pTimer->msg, pTimer->id, (DWORD)pTimer->proc); TIMER_InsertTimer( pTimer ); QUEUE_IncTimerCount( GetTaskQueue(0) ); @@ -217,7 +217,7 @@ static BOOL TIMER_KillTimer( HWND hwnd, WORD id, BOOL sys ) */ WORD SetTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc ) { - dprintf_timer(stddeb, "SetTimer: "NPFMT" %d %d %08lx\n", hwnd, id, timeout, (LONG)proc ); + dprintf_timer(stddeb, "SetTimer: %04x %d %d %08lx\n", hwnd, id, timeout, (LONG)proc ); return TIMER_SetTimer( hwnd, id, timeout, proc, FALSE ); } @@ -227,7 +227,7 @@ WORD SetTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc ) */ WORD SetSystemTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc ) { - dprintf_timer(stddeb, "SetSystemTimer: "NPFMT" %d %d %08lx\n", + dprintf_timer(stddeb, "SetSystemTimer: %04x %d %d %08lx\n", hwnd, id, timeout, (LONG)proc ); return TIMER_SetTimer( hwnd, id, timeout, proc, TRUE ); } @@ -238,7 +238,7 @@ WORD SetSystemTimer( HWND hwnd, WORD id, WORD timeout, FARPROC proc ) */ BOOL KillTimer( HWND hwnd, WORD id ) { - dprintf_timer(stddeb, "KillTimer: "NPFMT" %d\n", hwnd, id ); + dprintf_timer(stddeb, "KillTimer: %04x %d\n", hwnd, id ); return TIMER_KillTimer( hwnd, id, FALSE ); } @@ -248,6 +248,6 @@ BOOL KillTimer( HWND hwnd, WORD id ) */ BOOL KillSystemTimer( HWND hwnd, WORD id ) { - dprintf_timer(stddeb, "KillSystemTimer: "NPFMT" %d\n", hwnd, id ); + dprintf_timer(stddeb, "KillSystemTimer: %04x %d\n", hwnd, id ); return TIMER_KillTimer( hwnd, id, TRUE ); } diff --git a/windows/win.c b/windows/win.c index eb7f3d1c611..8511a73c5af 100644 --- a/windows/win.c +++ b/windows/win.c @@ -27,7 +27,9 @@ /* #define DEBUG_MENU */ #include "debug.h" -static HWND hwndDesktop = 0; +/* Desktop window */ +static WND *pWndDesktop = NULL; + static HWND hwndSysModal = 0; static WORD wDragWidth = 4; @@ -47,6 +49,12 @@ WND * WIN_FindWndPtr( HWND hwnd ) if (!hwnd) return NULL; ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd ); if (ptr->dwMagic != WND_MAGIC) return NULL; + if (ptr->hwndSelf != hwnd) + { + fprintf( stderr, "Can't happen: hwnd %04x self pointer is %04x\n", + hwnd, ptr->hwndSelf ); + return NULL; + } return ptr; } @@ -72,14 +80,14 @@ void WIN_DumpWindow( HWND hwnd ) if (!GetClassName( hwnd, className, sizeof(className ) )) strcpy( className, "#NULL#" ); - fprintf( stderr, "Window %04x:\n", hwnd ); + fprintf( stderr, "Window %04x (%p):\n", hwnd, ptr ); fprintf( stderr, - "next=%04x child=%04x parent=%04x owner=%04x class=%04x '%s'\n" + "next=%p child=%p parent=%p owner=%p class=%04x '%s'\n" "inst=%04x taskQ=%04x updRgn=%04x active=%04x hdce=%04x idmenu=%04x\n" "style=%08lx exstyle=%08lx wndproc=%08lx text=%04x '%s'\n" "client=%d,%d-%d,%d window=%d,%d-%d,%d iconpos=%d,%d maxpos=%d,%d\n" "sysmenu=%04x flags=%04x props=%04x vscroll=%04x hscroll=%04x\n", - ptr->hwndNext, ptr->hwndChild, ptr->hwndParent, ptr->hwndOwner, + ptr->next, ptr->child, ptr->parent, ptr->owner, ptr->hClass, className, ptr->hInstance, ptr->hmemTaskQ, ptr->hrgnUpdate, ptr->hwndLastActive, ptr->hdce, ptr->wIDmenu, ptr->dwStyle, ptr->dwExStyle, (DWORD)ptr->lpfnWndProc, ptr->hText, @@ -113,19 +121,20 @@ void WIN_WalkWindows( HWND hwnd, int indent ) CLASS *classPtr; char className[80]; - if (!hwnd) hwnd = hwndDesktop; + ptr = hwnd ? WIN_FindWndPtr( hwnd ) : pWndDesktop; + if (!ptr) + { + fprintf( stderr, "*** Invalid window handle\n" ); + return; + } + if (!indent) /* first time around */ fprintf( stderr, "%-16.16s %-8.8s %-6.6s %-17.17s %-8.8s %s\n", "hwnd", " wndPtr", "queue", "Class Name", " Style", " WndProc"); - while (hwnd) + while (ptr) { - fprintf( stderr, "%*s%04x%*s", indent, "", hwnd, 13-indent, "" ); - if (!(ptr = WIN_FindWndPtr( hwnd ))) - { - fprintf( stderr, "*** Invalid window handle\n" ); - return; - } + fprintf(stderr, "%*s%04x%*s", indent, "", ptr->hwndSelf, 13-indent,""); if (!(classPtr = CLASS_FindClassPtr( ptr->hClass ))) strcpy( className, "#NULL#" ); else GlobalGetAtomName( classPtr->atomName, className, sizeof(className) ); @@ -136,8 +145,8 @@ void WIN_WalkWindows( HWND hwnd, int indent ) HIWORD(ptr->lpfnWndProc), LOWORD(ptr->lpfnWndProc)); - if (ptr->hwndChild) WIN_WalkWindows( ptr->hwndChild, indent+1 ); - hwnd = ptr->hwndNext; + if (ptr->child) WIN_WalkWindows( ptr->child->hwndSelf, indent+1 ); + ptr = ptr->next; } } @@ -150,10 +159,7 @@ void WIN_WalkWindows( HWND hwnd, int indent ) Window WIN_GetXWindow( HWND hwnd ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); - while (wndPtr && !wndPtr->window) - { - wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - } + while (wndPtr && !wndPtr->window) wndPtr = wndPtr->parent; return wndPtr ? wndPtr->window : 0; } @@ -165,20 +171,12 @@ Window WIN_GetXWindow( HWND hwnd ) */ BOOL WIN_UnlinkWindow( HWND hwnd ) { - HWND * curWndPtr; - WND *parentPtr, *wndPtr; + WND *wndPtr, **ppWnd; - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; - if (!(parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ))) return FALSE; - - curWndPtr = &parentPtr->hwndChild; - - while (*curWndPtr != hwnd) - { - WND * curPtr = WIN_FindWndPtr( *curWndPtr ); - curWndPtr = &curPtr->hwndNext; - } - *curWndPtr = wndPtr->hwndNext; + if (!(wndPtr = WIN_FindWndPtr( hwnd )) || !wndPtr->parent) return FALSE; + ppWnd = &wndPtr->parent->child; + while (*ppWnd != wndPtr) ppWnd = &(*ppWnd)->next; + *ppWnd = wndPtr->next; return TRUE; } @@ -192,30 +190,24 @@ BOOL WIN_UnlinkWindow( HWND hwnd ) */ BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter ) { - HWND * hwndPtr = NULL; /* pointer to hwnd to change */ - WND *wndPtr, *parentPtr; + WND *wndPtr, **ppWnd; - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; - if (!(parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ))) return FALSE; + if (!(wndPtr = WIN_FindWndPtr( hwnd )) || !wndPtr->parent) return FALSE; if ((hwndInsertAfter == HWND_TOP) || (hwndInsertAfter == HWND_BOTTOM)) { - hwndPtr = &parentPtr->hwndChild; /* Point to first sibling hwnd */ + ppWnd = &wndPtr->parent->child; /* Point to first sibling hwnd */ if (hwndInsertAfter == HWND_BOTTOM) /* Find last sibling hwnd */ - while (*hwndPtr) - { - WND * nextPtr = WIN_FindWndPtr( *hwndPtr ); - hwndPtr = &nextPtr->hwndNext; - } + while (*ppWnd) ppWnd = &(*ppWnd)->next; } else /* Normal case */ { WND * afterPtr = WIN_FindWndPtr( hwndInsertAfter ); - if (afterPtr) hwndPtr = &afterPtr->hwndNext; + if (!afterPtr) return FALSE; + ppWnd = &afterPtr->next; } - if (!hwndPtr) return FALSE; - wndPtr->hwndNext = *hwndPtr; - *hwndPtr = hwnd; + wndPtr->next = *ppWnd; + *ppWnd = wndPtr; return TRUE; } @@ -230,22 +222,21 @@ HWND WIN_FindWinToRepaint( HWND hwnd ) WND * wndPtr; /* Note: the desktop window never gets WM_PAINT messages */ - if (!hwnd) hwnd = GetTopWindow( hwndDesktop ); - for ( ; hwnd != 0; hwnd = wndPtr->hwndNext ) + wndPtr = hwnd ? WIN_FindWndPtr( hwnd ) : pWndDesktop->child; + for ( ; wndPtr; wndPtr = wndPtr->next) { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; - dprintf_win( stddeb, "WIN_FindWinToRepaint: "NPFMT", style %08lx\n", - hwnd, wndPtr->dwStyle ); + dprintf_win( stddeb, "WIN_FindWinToRepaint: %04x, style %08lx\n", + wndPtr->hwndSelf, wndPtr->dwStyle ); if (!(wndPtr->dwStyle & WS_VISIBLE) || (wndPtr->flags & WIN_NO_REDRAW)) continue; if ((wndPtr->dwStyle & WS_MINIMIZE) && (WIN_CLASS_INFO(wndPtr).hIcon)) continue; if (wndPtr->hrgnUpdate || (wndPtr->flags & WIN_INTERNAL_PAINT)) - return hwnd; - if (wndPtr->hwndChild) + return wndPtr->hwndSelf; + if (wndPtr->child) { HWND child; - if ((child = WIN_FindWinToRepaint( wndPtr->hwndChild ))) + if ((child = WIN_FindWinToRepaint( wndPtr->child->hwndSelf ))) return child; } } @@ -266,15 +257,15 @@ void WIN_SendParentNotify( HWND hwnd, WORD event, WORD idChild, LONG lValue ) while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) { if (wndPtr->dwExStyle & WS_EX_NOPARENTNOTIFY) break; + wndPtr = wndPtr->parent; #ifdef WINELIB32 - SendMessage( wndPtr->hwndParent, WM_PARENTNOTIFY, + SendMessage( wndPtr->hwndSelf, WM_PARENTNOTIFY, MAKEWPARAM(event,idChild), (LPARAM)lValue ); #else - SendMessage( wndPtr->hwndParent, WM_PARENTNOTIFY, event, + SendMessage( wndPtr->hwndSelf, WM_PARENTNOTIFY, event, MAKELPARAM(LOWORD(lValue), idChild) ); #endif - wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); } } @@ -297,6 +288,7 @@ static void WIN_DestroyWindow( HWND hwnd ) if (!wndPtr || !classPtr) return; WIN_UnlinkWindow( hwnd ); /* Remove the window from the linked list */ wndPtr->dwMagic = 0; /* Mark it as invalid */ + wndPtr->hwndSelf = 0; if ((wndPtr->hrgnUpdate) || (wndPtr->flags & WIN_INTERNAL_PAINT)) { if (wndPtr->hrgnUpdate) DeleteObject( wndPtr->hrgnUpdate ); @@ -321,55 +313,57 @@ static void WIN_DestroyWindow( HWND hwnd ) */ BOOL WIN_CreateDesktopWindow(void) { - WND *wndPtr; HCLASS hclass; CLASS *classPtr; HDC hdc; + HWND hwndDesktop; if (!(hclass = CLASS_FindClassByName( DESKTOP_CLASS_ATOM, 0, &classPtr ))) return FALSE; hwndDesktop = USER_HEAP_ALLOC( sizeof(WND)+classPtr->wc.cbWndExtra ); if (!hwndDesktop) return FALSE; - wndPtr = (WND *) USER_HEAP_LIN_ADDR( hwndDesktop ); + pWndDesktop = (WND *) USER_HEAP_LIN_ADDR( hwndDesktop ); - wndPtr->hwndNext = 0; - wndPtr->hwndChild = 0; - wndPtr->dwMagic = WND_MAGIC; - wndPtr->hwndParent = 0; - wndPtr->hwndOwner = 0; - wndPtr->hClass = hclass; - wndPtr->hInstance = 0; - wndPtr->rectWindow.left = 0; - wndPtr->rectWindow.top = 0; - wndPtr->rectWindow.right = SYSMETRICS_CXSCREEN; - wndPtr->rectWindow.bottom = SYSMETRICS_CYSCREEN; - wndPtr->rectClient = wndPtr->rectWindow; - wndPtr->rectNormal = wndPtr->rectWindow; - wndPtr->ptIconPos.x = -1; - wndPtr->ptIconPos.y = -1; - wndPtr->ptMaxPos.x = -1; - wndPtr->ptMaxPos.y = -1; - wndPtr->hmemTaskQ = 0; /* Desktop does not belong to a task */ - wndPtr->hrgnUpdate = 0; - wndPtr->hwndLastActive = hwndDesktop; - wndPtr->lpfnWndProc = classPtr->wc.lpfnWndProc; - wndPtr->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; - wndPtr->dwExStyle = 0; - wndPtr->hdce = 0; - wndPtr->hVScroll = 0; - wndPtr->hHScroll = 0; - wndPtr->wIDmenu = 0; - wndPtr->hText = 0; - wndPtr->flags = 0; - wndPtr->window = rootWindow; - wndPtr->hSysMenu = 0; - wndPtr->hProp = 0; - EVENT_RegisterWindow( wndPtr->window, hwndDesktop ); + pWndDesktop->next = NULL; + pWndDesktop->child = NULL; + pWndDesktop->parent = NULL; + pWndDesktop->owner = NULL; + pWndDesktop->dwMagic = WND_MAGIC; + pWndDesktop->hwndSelf = hwndDesktop; + pWndDesktop->hClass = hclass; + pWndDesktop->hInstance = 0; + pWndDesktop->rectWindow.left = 0; + pWndDesktop->rectWindow.top = 0; + pWndDesktop->rectWindow.right = SYSMETRICS_CXSCREEN; + pWndDesktop->rectWindow.bottom = SYSMETRICS_CYSCREEN; + pWndDesktop->rectClient = pWndDesktop->rectWindow; + pWndDesktop->rectNormal = pWndDesktop->rectWindow; + pWndDesktop->ptIconPos.x = -1; + pWndDesktop->ptIconPos.y = -1; + pWndDesktop->ptMaxPos.x = -1; + pWndDesktop->ptMaxPos.y = -1; + pWndDesktop->hmemTaskQ = 0; /* Desktop does not belong to a task */ + pWndDesktop->hrgnUpdate = 0; + pWndDesktop->hwndLastActive = hwndDesktop; + pWndDesktop->lpfnWndProc = classPtr->wc.lpfnWndProc; + pWndDesktop->dwStyle = WS_VISIBLE | WS_CLIPCHILDREN | + WS_CLIPSIBLINGS; + pWndDesktop->dwExStyle = 0; + pWndDesktop->hdce = 0; + pWndDesktop->hVScroll = 0; + pWndDesktop->hHScroll = 0; + pWndDesktop->wIDmenu = 0; + pWndDesktop->hText = 0; + pWndDesktop->flags = 0; + pWndDesktop->window = rootWindow; + pWndDesktop->hSysMenu = 0; + pWndDesktop->hProp = 0; + EVENT_RegisterWindow( pWndDesktop->window, hwndDesktop ); SendMessage( hwndDesktop, WM_NCCREATE, 0, 0 ); if ((hdc = GetDC( hwndDesktop )) != 0) { - SendMessage( hwndDesktop, WM_ERASEBKGND, (WPARAM)hdc, 0 ); + SendMessage( hwndDesktop, WM_ERASEBKGND, hdc, 0 ); ReleaseDC( hwndDesktop, hdc ); } return TRUE; @@ -416,7 +410,7 @@ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, else dprintf_win( stddeb, "%04x ", LOWORD(className) ); - dprintf_win(stddeb, "%08lx %08lx %d,%d %dx%d "NPFMT" "NPFMT" "NPFMT" %08lx\n", + dprintf_win(stddeb, "%08lx %08lx %d,%d %dx%d %04x %04x %04x %08lx\n", exStyle, style, x, y, width, height, parent, menu, instance, (DWORD)data); @@ -433,7 +427,7 @@ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, { /* Make sure parent is valid */ if (!IsWindow( parent )) { - dprintf_win(stddeb,"CreateWindowEx: Parent "NPFMT" is not a window\n", parent); + dprintf_win(stddeb,"CreateWindowEx: Parent %04x is not a window\n", parent); return 0; } } @@ -472,12 +466,13 @@ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, /* Fill the structure */ wndPtr = (WND *) USER_HEAP_LIN_ADDR( hwnd ); - wndPtr->hwndNext = 0; - wndPtr->hwndChild = 0; + wndPtr->next = NULL; + wndPtr->child = NULL; + wndPtr->parent = (style & WS_CHILD) ? WIN_FindWndPtr( parent ) : pWndDesktop; + wndPtr->owner = (style & WS_CHILD) ? NULL : WIN_FindWndPtr(WIN_GetTopParent(parent)); wndPtr->window = 0; wndPtr->dwMagic = WND_MAGIC; - wndPtr->hwndParent = (style & WS_CHILD) ? parent : hwndDesktop; - wndPtr->hwndOwner = (style & WS_CHILD) ? 0 : WIN_GetTopParent(parent); + wndPtr->hwndSelf = hwnd; wndPtr->hClass = class; wndPtr->hInstance = instance; wndPtr->ptIconPos.x = -1; @@ -644,7 +639,7 @@ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, } else if (style & WS_VISIBLE) ShowWindow( hwnd, SW_SHOW ); - dprintf_win(stddeb, "CreateWindowEx: return "NPFMT" \n", hwnd); + dprintf_win(stddeb, "CreateWindowEx: return %04x\n", hwnd); return hwnd; } @@ -657,11 +652,11 @@ BOOL DestroyWindow( HWND hwnd ) WND * wndPtr; CLASS * classPtr; - dprintf_win(stddeb, "DestroyWindow ("NPFMT")\n", hwnd); + dprintf_win(stddeb, "DestroyWindow(%04x)\n", hwnd); /* Initialisation */ - if (hwnd == hwndDesktop) return FALSE; /* Can't destroy desktop */ + if (hwnd == pWndDesktop->hwndSelf) return FALSE; /* Can't destroy desktop*/ if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; if (!(classPtr = CLASS_FindClassPtr( wndPtr->hClass ))) return FALSE; @@ -678,22 +673,21 @@ BOOL DestroyWindow( HWND hwnd ) for (;;) { - HWND hwndSibling = GetWindow( hwnd, GW_HWNDFIRST ); - while (hwndSibling) + WND *siblingPtr = wndPtr->parent->child; /* First sibling */ + while (siblingPtr) { - WND *siblingPtr = WIN_FindWndPtr( hwndSibling ); - if (siblingPtr->hwndOwner == hwnd) break; - hwndSibling = siblingPtr->hwndNext; + if (siblingPtr->owner == wndPtr) break; + siblingPtr = siblingPtr->next; } - if (hwndSibling) DestroyWindow( hwndSibling ); + if (siblingPtr) DestroyWindow( siblingPtr->hwndSelf ); else break; } /* Send destroy messages and destroy children */ SendMessage( hwnd, WM_DESTROY, 0, 0 ); - while (wndPtr->hwndChild) /* The child removes itself from the list */ - DestroyWindow( wndPtr->hwndChild ); + while (wndPtr->child) /* The child removes itself from the list */ + DestroyWindow( wndPtr->child->hwndSelf ); SendMessage( hwnd, WM_NCDESTROY, 0, 0 ); /* Destroy the window */ @@ -733,7 +727,7 @@ HWND FindWindow( SEGPTR ClassMatch, LPSTR TitleMatch ) { HCLASS hclass; CLASS *classPtr; - HWND hwnd; + WND *wndPtr; if (ClassMatch) { @@ -743,32 +737,40 @@ HWND FindWindow( SEGPTR ClassMatch, LPSTR TitleMatch ) } else hclass = 0; - hwnd = GetTopWindow( hwndDesktop ); - while(hwnd) + wndPtr = pWndDesktop->child; + while (wndPtr) { - WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!hclass || (wndPtr->hClass == hclass)) { /* Found matching class */ - if (!TitleMatch) return hwnd; + if (!TitleMatch) return wndPtr->hwndSelf; if (wndPtr->hText) { char *textPtr = (char *) USER_HEAP_LIN_ADDR( wndPtr->hText ); - if (!strcmp( textPtr, TitleMatch )) return hwnd; + if (!strcmp( textPtr, TitleMatch )) return wndPtr->hwndSelf; } } - hwnd = wndPtr->hwndNext; + wndPtr = wndPtr->next; } return 0; } +/********************************************************************** + * WIN_GetDesktop + */ +WND *WIN_GetDesktop(void) +{ + return pWndDesktop; +} + + /********************************************************************** * GetDesktopWindow (USER.286) */ HWND GetDesktopWindow(void) { - return hwndDesktop; + return pWndDesktop->hwndSelf; } @@ -780,7 +782,7 @@ HWND GetDesktopWindow(void) */ HWND GetDesktopHwnd(void) { - return hwndDesktop; + return pWndDesktop->hwndSelf; } @@ -843,7 +845,7 @@ WORD GetWindowWord( HWND hwnd, short offset ) fprintf(stderr,"GetWindowWord called with offset %d.\n",offset); return 0; #else - case GWW_HWNDPARENT: return (WORD)wndPtr->hwndParent; + case GWW_HWNDPARENT: return wndPtr->parent ? wndPtr->parent->hwndSelf : 0; case GWW_HINSTANCE: return (WORD)wndPtr->hInstance; #endif } @@ -904,8 +906,8 @@ LONG GetWindowLong( HWND hwnd, short offset ) case GWL_EXSTYLE: return wndPtr->dwExStyle; case GWL_WNDPROC: return (LONG)wndPtr->lpfnWndProc; #ifdef WINELIB32 - case GWW_HWNDPARENT: return (LONG)wndPtr->hwndParent; - case GWW_HINSTANCE: return (LONG)wndPtr->hInstance; + case GWW_HWNDPARENT: return wndPtr->parent ? wndPtr->parent->hwndSelf : 0; + case GWW_HINSTANCE: return wndPtr->hInstance; #endif } return 0; @@ -937,10 +939,9 @@ LONG SetWindowLong( HWND hwnd, short offset, LONG newval ) /******************************************************************* * GetWindowText (USER.36) */ -int WIN16_GetWindowText( HWND hwnd, SEGPTR lpString, int nMaxCount ) +int WIN16_GetWindowText( HWND hwnd, SEGPTR lpString, INT nMaxCount ) { - return (int)SendMessage(hwnd, WM_GETTEXT, (WORD)nMaxCount, - (DWORD)lpString); + return (int)SendMessage(hwnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); } int GetWindowText( HWND hwnd, LPSTR lpString, int nMaxCount ) @@ -964,7 +965,7 @@ int GetWindowText( HWND hwnd, LPSTR lpString, int nMaxCount ) */ void WIN16_SetWindowText( HWND hwnd, SEGPTR lpString ) { - SendMessage( hwnd, WM_SETTEXT, 0, (DWORD)lpString ); + SendMessage( hwnd, WM_SETTEXT, 0, (LPARAM)lpString ); } void SetWindowText( HWND hwnd, LPCSTR lpString ) @@ -1006,8 +1007,8 @@ HWND GetParent(HWND hwnd) { WND *wndPtr = WIN_FindWndPtr(hwnd); if (!wndPtr) return 0; - return (wndPtr->dwStyle & WS_CHILD) ? - wndPtr->hwndParent : wndPtr->hwndOwner; + wndPtr = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->parent : wndPtr->owner; + return wndPtr ? wndPtr->hwndSelf : 0; } @@ -1018,13 +1019,9 @@ HWND GetParent(HWND hwnd) */ HWND WIN_GetTopParent( HWND hwnd ) { - while (hwnd) - { - WND *wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr->dwStyle & WS_CHILD) hwnd = wndPtr->hwndParent; - else break; - } - return hwnd; + WND *wndPtr = WIN_FindWndPtr( hwnd ); + while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) wndPtr = wndPtr->parent; + return wndPtr ? wndPtr->hwndSelf : 0; } @@ -1033,23 +1030,21 @@ HWND WIN_GetTopParent( HWND hwnd ) */ HWND SetParent(HWND hwndChild, HWND hwndNewParent) { - HWND temp; + HWND oldParent; WND *wndPtr = WIN_FindWndPtr(hwndChild); - if (!wndPtr || !(wndPtr->dwStyle & WS_CHILD)) return 0; + WND *pWndParent = WIN_FindWndPtr( hwndNewParent ); + if (!wndPtr || !pWndParent || !(wndPtr->dwStyle & WS_CHILD)) return 0; - temp = wndPtr->hwndParent; + oldParent = wndPtr->parent->hwndSelf; WIN_UnlinkWindow(hwndChild); - if (hwndNewParent) - wndPtr->hwndParent = hwndNewParent; - else - wndPtr->hwndParent = GetDesktopWindow(); + if (hwndNewParent) wndPtr->parent = pWndParent; WIN_LinkWindow(hwndChild, HWND_BOTTOM); if (IsWindowVisible(hwndChild)) UpdateWindow(hwndChild); - return temp; + return oldParent; } @@ -1062,8 +1057,8 @@ BOOL IsChild( HWND parent, HWND child ) WND * wndPtr = WIN_FindWndPtr( child ); while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) { - if (wndPtr->hwndParent == parent) return TRUE; - wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + wndPtr = wndPtr->parent; + if (wndPtr->hwndSelf == parent) return TRUE; } return FALSE; } @@ -1078,7 +1073,7 @@ BOOL IsWindowVisible( HWND hwnd ) while (wndPtr && (wndPtr->dwStyle & WS_CHILD)) { if (!(wndPtr->dwStyle & WS_VISIBLE)) return FALSE; - wndPtr = WIN_FindWndPtr( wndPtr->hwndParent ); + wndPtr = wndPtr->parent; } return (wndPtr && (wndPtr->dwStyle & WS_VISIBLE)); } @@ -1091,7 +1086,7 @@ BOOL IsWindowVisible( HWND hwnd ) HWND GetTopWindow( HWND hwnd ) { WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr) return wndPtr->hwndChild; + if (wndPtr && wndPtr->child) return wndPtr->child->hwndSelf; else return 0; } @@ -1106,50 +1101,34 @@ HWND GetWindow( HWND hwnd, WORD rel ) switch(rel) { case GW_HWNDFIRST: - if (wndPtr->hwndParent) - { - WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - return parentPtr->hwndChild; - } + if (wndPtr->parent) return wndPtr->parent->child->hwndSelf; else return 0; case GW_HWNDLAST: - if (!wndPtr->hwndParent) return 0; /* Desktop window */ - while (wndPtr->hwndNext) - { - hwnd = wndPtr->hwndNext; - wndPtr = WIN_FindWndPtr( hwnd ); - } - return hwnd; + if (!wndPtr->parent) return 0; /* Desktop window */ + while (wndPtr->next) wndPtr = wndPtr->next; + return wndPtr->hwndSelf; case GW_HWNDNEXT: - return wndPtr->hwndNext; + if (!wndPtr->next) return 0; + return wndPtr->next->hwndSelf; - case GW_HWNDPREV: - { - HWND hwndPrev; - - if (wndPtr->hwndParent) - { - WND * parentPtr = WIN_FindWndPtr( wndPtr->hwndParent ); - hwndPrev = parentPtr->hwndChild; - } - else return 0; /* Desktop window */ - if (hwndPrev == hwnd) return 0; - while (hwndPrev) - { - wndPtr = WIN_FindWndPtr( hwndPrev ); - if (wndPtr->hwndNext == hwnd) break; - hwndPrev = wndPtr->hwndNext; - } - return hwndPrev; - } + case GW_HWNDPREV: + if (!wndPtr->parent) return 0; /* Desktop window */ + wndPtr = wndPtr->parent->child; /* First sibling */ + if (wndPtr->hwndSelf == hwnd) return 0; /* First in list */ + while (wndPtr->next) + { + if (wndPtr->next->hwndSelf == hwnd) return wndPtr->hwndSelf; + wndPtr = wndPtr->next; + } + return 0; case GW_OWNER: - return wndPtr->hwndOwner; + return wndPtr->owner ? wndPtr->owner->hwndSelf : 0; case GW_CHILD: - return wndPtr->hwndChild; + return wndPtr->child ? wndPtr->child->hwndSelf : 0; } return 0; } @@ -1169,13 +1148,13 @@ HWND GetNextWindow( HWND hwnd, WORD flag ) */ void ShowOwnedPopups( HWND owner, BOOL fShow ) { - HWND hwnd = GetWindow( hwndDesktop, GW_CHILD ); - while (hwnd) + WND *pWnd = pWndDesktop->child; + while (pWnd) { - WND *wnd = WIN_FindWndPtr(hwnd); - if (wnd->hwndOwner == owner && (wnd->dwStyle & WS_POPUP)) - ShowWindow( hwnd, fShow ? SW_SHOW : SW_HIDE ); - hwnd = wnd->hwndNext; + if (pWnd->owner && (pWnd->owner->hwndSelf == owner) && + (pWnd->dwStyle & WS_POPUP)) + ShowWindow( pWnd->hwndSelf, fShow ? SW_SHOW : SW_HIDE ); + pWnd = pWnd->next; } } @@ -1197,7 +1176,6 @@ HWND GetLastActivePopup(HWND hwnd) */ BOOL EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) { - HWND hwnd; WND *wndPtr; HWND *list, *pWnd; int count; @@ -1209,21 +1187,14 @@ BOOL EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) /* First count the windows */ count = 0; - for (hwnd = GetTopWindow(hwndDesktop); hwnd != 0; hwnd = wndPtr->hwndNext) - { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; - count++; - } + for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next) count++; if (!count) return TRUE; /* Now build the list of all windows */ - if (!(list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; - for (hwnd = GetTopWindow(hwndDesktop), pWnd = list; hwnd != 0; hwnd = wndPtr->hwndNext) - { - wndPtr = WIN_FindWndPtr( hwnd ); - *pWnd++ = hwnd; - } + if (!(pWnd = list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; + for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next) + *pWnd++ = wndPtr->hwndSelf; /* Now call the callback function for every window */ @@ -1243,7 +1214,6 @@ BOOL EnumWindows( WNDENUMPROC lpEnumFunc, LPARAM lParam ) */ BOOL EnumTaskWindows( HTASK hTask, WNDENUMPROC lpEnumFunc, LPARAM lParam ) { - HWND hwnd; WND *wndPtr; HWND *list, *pWnd; HANDLE hQueue = GetTaskQueue( hTask ); @@ -1255,21 +1225,15 @@ BOOL EnumTaskWindows( HTASK hTask, WNDENUMPROC lpEnumFunc, LPARAM lParam ) /* First count the windows */ count = 0; - for (hwnd = GetTopWindow(hwndDesktop); hwnd != 0; hwnd = wndPtr->hwndNext) - { - if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; + for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next) if (wndPtr->hmemTaskQ == hQueue) count++; - } if (!count) return TRUE; /* Now build the list of all windows */ - if (!(list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; - for (hwnd = GetTopWindow(hwndDesktop), pWnd = list; hwnd != 0; hwnd = wndPtr->hwndNext) - { - wndPtr = WIN_FindWndPtr( hwnd ); - if (wndPtr->hmemTaskQ == hQueue) *pWnd++ = hwnd; - } + if (!(pWnd = list = (HWND *)malloc( sizeof(HWND) * count ))) return FALSE; + for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next) + if (wndPtr->hmemTaskQ == hQueue) *pWnd++ = wndPtr->hwndSelf; /* Now call the callback function for every window */ @@ -1295,24 +1259,23 @@ BOOL EnumTaskWindows( HTASK hTask, WNDENUMPROC lpEnumFunc, LPARAM lParam ) * o call ourselves with the next child window * */ -static BOOL WIN_EnumChildWin(HWND hwnd, FARPROC wndenumprc, LPARAM lParam) +static BOOL WIN_EnumChildWin( WND *wndPtr, FARPROC wndenumprc, LPARAM lParam ) { - WND *wndPtr; - HWND hwndN,hwndCh; - - while (hwnd) + WND *pWndNext, *pWndChild; + while (wndPtr) { - if (!(wndPtr=WIN_FindWndPtr(hwnd))) return 0; - hwndN=wndPtr->hwndNext; /* storing hwnd is a way to avoid.. */ - hwndCh=wndPtr->hwndChild; /* ..side effects after wndenumprc */ - if (!CallEnumWindowsProc( wndenumprc, hwnd, lParam )) return 0; - if (IsWindow(hwndCh)) /* to prevent too early termination */ - if (!WIN_EnumChildWin(hwndCh, wndenumprc, lParam)) return 0; - hwnd=hwndN; + pWndNext = wndPtr->next; /* storing hwnd is a way to avoid.. */ + pWndChild = wndPtr->child; /* ..side effects after wndenumprc */ + if (!CallEnumWindowsProc( wndenumprc, wndPtr->hwndSelf, lParam )) + return 0; + if (IsWindow(pWndChild->hwndSelf)) /*to prevent too early termination*/ + if (!WIN_EnumChildWin(pWndChild, wndenumprc, lParam)) return 0; + wndPtr = pWndNext; } return 1; } + /******************************************************************* * EnumChildWindows (USER.55) * @@ -1328,27 +1291,19 @@ BOOL EnumChildWindows(HWND hwnd, WNDENUMPROC wndenumprc, LPARAM lParam) if (hwnd == 0) return 0; if (!(wndPtr = WIN_FindWndPtr(hwnd))) return 0; - hwnd = wndPtr->hwndChild; - return WIN_EnumChildWin(hwnd, wndenumprc, lParam); + return WIN_EnumChildWin(wndPtr->child, wndenumprc, lParam); } /******************************************************************* - * AnyPopup [USER.52] + * AnyPopup (USER.52) */ -BOOL AnyPopup() +BOOL AnyPopup(void) { - WND *wndPtr = WIN_FindWndPtr(hwndDesktop); - HWND hwnd = wndPtr->hwndChild; - - for( ; hwnd ; hwnd = wndPtr->hwndNext ) - { - wndPtr = WIN_FindWndPtr(hwnd); - if(wndPtr->hwndOwner) - if(wndPtr->dwStyle & WS_VISIBLE) - return TRUE; - } - return FALSE; + WND *wndPtr; + for (wndPtr = pWndDesktop->child; wndPtr; wndPtr = wndPtr->next) + if (wndPtr->owner && (wndPtr->dwStyle & WS_VISIBLE)) return TRUE; + return FALSE; } /******************************************************************* @@ -1358,7 +1313,7 @@ BOOL FlashWindow(HWND hWnd, BOOL bInvert) { WND *wndPtr = WIN_FindWndPtr(hWnd); - dprintf_win(stddeb,"FlashWindow: "NPFMT"\n", hWnd); + dprintf_win(stddeb,"FlashWindow: %04x\n", hWnd); if (!wndPtr) return FALSE; @@ -1401,7 +1356,7 @@ HWND SetSysModalWindow(HWND hWnd) { HWND hWndOldModal = hwndSysModal; hwndSysModal = hWnd; - dprintf_win(stdnimp,"EMPTY STUB !! SetSysModalWindow("NPFMT") !\n", hWnd); + dprintf_win(stdnimp,"EMPTY STUB !! SetSysModalWindow(%04x) !\n", hWnd); return hWndOldModal; } @@ -1422,7 +1377,6 @@ HWND GetSysModalWindow(void) */ BOOL DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo ) { - HWND hWnd; BOOL wParam,bResult = 0; POINT pt; LPDRAGINFO ptrDragInfo = (LPDRAGINFO) PTR_SEG_TO_LIN(spDragInfo); @@ -1443,32 +1397,29 @@ BOOL DRAG_QueryUpdate( HWND hQueryWnd, SEGPTR spDragInfo ) { tempRect = ptrQueryWnd->rectClient; if(ptrQueryWnd->dwStyle & WS_CHILD) - MapWindowPoints(ptrQueryWnd->hwndParent,0,(LPPOINT)&tempRect,2); + MapWindowPoints(ptrQueryWnd->parent->hwndSelf,0,(LPPOINT)&tempRect,2); if( PtInRect(&tempRect,pt) ) { wParam = 0; - ptrWnd = WIN_FindWndPtr(hWnd = ptrQueryWnd->hwndChild); - - for( ;ptrWnd ;ptrWnd = WIN_FindWndPtr(hWnd = ptrWnd->hwndNext) ) - if( ptrWnd->dwStyle & WS_VISIBLE ) + + for (ptrWnd = ptrQueryWnd->child; ptrWnd ;ptrWnd = ptrWnd->next) + if( ptrWnd->dwStyle & WS_VISIBLE ) { - GetWindowRect(hWnd,&tempRect); + GetWindowRect(ptrWnd->hwndSelf,&tempRect); - if( PtInRect(&tempRect,pt) ) - break; + if( PtInRect(&tempRect,pt) ) + break; } if(ptrWnd) - dprintf_msg(stddeb,"DragQueryUpdate: hwnd = "NPFMT", %i %i - %i %i\n",hWnd, - (int)ptrWnd->rectWindow.left,(int)ptrWnd->rectWindow.top, - (int)ptrWnd->rectWindow.right,(int)ptrWnd->rectWindow.bottom); - else - dprintf_msg(stddeb,"DragQueryUpdate: hwnd = "NPFMT"\n",hWnd); - - if(ptrWnd) - if( !(ptrWnd->dwStyle & WS_DISABLED) ) - bResult = DRAG_QueryUpdate(hWnd, spDragInfo); + { + dprintf_msg(stddeb,"DragQueryUpdate: hwnd = %04x, %d %d - %d %d\n", + ptrWnd->hwndSelf, ptrWnd->rectWindow.left, ptrWnd->rectWindow.top, + ptrWnd->rectWindow.right, ptrWnd->rectWindow.bottom ); + if( !(ptrWnd->dwStyle & WS_DISABLED) ) + bResult = DRAG_QueryUpdate(ptrWnd->hwndSelf, spDragInfo); + } if(bResult) return bResult; } @@ -1598,7 +1549,7 @@ DWORD DragObject(HWND hwndScope, HWND hWnd, WORD wObj, HANDLE hOfStruct, lpDragInfo->pt = msg.pt; /* update DRAGINFO struct */ - dprintf_msg(stddeb,"drag: lpDI->hScope = "NPFMT"\n",lpDragInfo->hScope); + dprintf_msg(stddeb,"drag: lpDI->hScope = %04x\n",lpDragInfo->hScope); if( (btemp = (WORD)DRAG_QueryUpdate(hwndScope, spDragInfo)) > 0 ) hCurrentCursor = hCursor; diff --git a/windows/winpos.c b/windows/winpos.c index 139a6ce891a..29f3d704f3d 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -42,8 +42,8 @@ void WINPOS_FindIconPos( HWND hwnd ) short x, y, xspacing, yspacing; WND * wndPtr = WIN_FindWndPtr( hwnd ); - if (!wndPtr) return; - GetClientRect( wndPtr->hwndParent, &rectParent ); + if (!wndPtr || !wndPtr->parent) return; + GetClientRect( wndPtr->parent->hwndSelf, &rectParent ); if ((wndPtr->ptIconPos.x >= rectParent.left) && (wndPtr->ptIconPos.x + SYSMETRICS_CXICON < rectParent.right) && (wndPtr->ptIconPos.y >= rectParent.top) && @@ -57,11 +57,10 @@ void WINPOS_FindIconPos( HWND hwnd ) for (x = rectParent.left; x<=rectParent.right-xspacing; x += xspacing) { /* Check if another icon already occupies this spot */ - HWND hwndChild = GetWindow( wndPtr->hwndParent, GW_CHILD ); - while (hwndChild) + WND *childPtr = wndPtr->parent->child; + while (childPtr) { - WND *childPtr = WIN_FindWndPtr( hwndChild ); - if ((childPtr->dwStyle & WS_MINIMIZE) && (hwndChild != hwnd)) + if ((childPtr->dwStyle & WS_MINIMIZE) && (childPtr != wndPtr)) { if ((childPtr->rectWindow.left < x + xspacing) && (childPtr->rectWindow.right >= x) && @@ -69,10 +68,9 @@ void WINPOS_FindIconPos( HWND hwnd ) (childPtr->rectWindow.bottom > y - yspacing)) break; /* There's a window in there */ } - - hwndChild = childPtr->hwndNext; + childPtr = childPtr->next; } - if (!hwndChild) + if (!childPtr) { /* No window was found, so it's OK for us */ wndPtr->ptIconPos.x = x + (xspacing - SYSMETRICS_CXICON) / 2; @@ -129,7 +127,7 @@ void GetWindowRect( HWND hwnd, LPRECT rect ) *rect = wndPtr->rectWindow; if (wndPtr->dwStyle & WS_CHILD) - MapWindowPoints( wndPtr->hwndParent, 0, (POINT *)rect, 2 ); + MapWindowPoints( wndPtr->parent->hwndSelf, 0, (POINT *)rect, 2 ); } @@ -173,26 +171,24 @@ void ScreenToClient( HWND hwnd, LPPOINT lppnt ) * * Find the window and hittest for a given point. */ -INT WINPOS_WindowFromPoint( POINT pt, HWND *phwnd ) +INT WINPOS_WindowFromPoint( POINT pt, WND **ppWnd ) { WND *wndPtr; - HWND hwnd; INT hittest = HTERROR; INT x, y; - *phwnd = 0; + *ppWnd = NULL; x = pt.x; y = pt.y; - hwnd = GetWindow( GetDesktopWindow(), GW_CHILD ); + wndPtr = WIN_GetDesktop()->child; for (;;) { - while (hwnd) + while (wndPtr) { /* If point is in window, and window is visible, and it */ /* is enabled (or it's a top-level window), then explore */ /* its children. Otherwise, go to the next window. */ - wndPtr = WIN_FindWndPtr( hwnd ); if ((wndPtr->dwStyle & WS_VISIBLE) && (!(wndPtr->dwStyle & WS_DISABLED) || ((wndPtr->dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)) && @@ -201,7 +197,7 @@ INT WINPOS_WindowFromPoint( POINT pt, HWND *phwnd ) (y >= wndPtr->rectWindow.top) && (y < wndPtr->rectWindow.bottom)) { - *phwnd = hwnd; /* Got a suitable window */ + *ppWnd = wndPtr; /* Got a suitable window */ /* If window is minimized or disabled, return at once */ if (wndPtr->dwStyle & WS_MINIMIZE) return HTCAPTION; @@ -215,35 +211,34 @@ INT WINPOS_WindowFromPoint( POINT pt, HWND *phwnd ) x -= wndPtr->rectClient.left; y -= wndPtr->rectClient.top; - hwnd = wndPtr->hwndChild; + wndPtr = wndPtr->child; } - else hwnd = wndPtr->hwndNext; + else wndPtr = wndPtr->next; } /* If nothing found, return the desktop window */ - if (!*phwnd) + if (!*ppWnd) { - *phwnd = GetDesktopWindow(); + *ppWnd = WIN_GetDesktop(); return HTCLIENT; } - wndPtr = WIN_FindWndPtr( *phwnd ); /* Send the WM_NCHITTEST message (only if to the same task) */ - if (wndPtr->hmemTaskQ != GetTaskQueue(0)) return HTCLIENT; - hittest = (INT)SendMessage( *phwnd, WM_NCHITTEST, 0, + if ((*ppWnd)->hmemTaskQ != GetTaskQueue(0)) return HTCLIENT; + hittest = (INT)SendMessage( (*ppWnd)->hwndSelf, WM_NCHITTEST, 0, MAKELONG( pt.x, pt.y ) ); if (hittest != HTTRANSPARENT) return hittest; /* Found the window */ /* If no children found in last search, make point relative to parent*/ - if (!hwnd) + if (!wndPtr) { - x += wndPtr->rectClient.left; - y += wndPtr->rectClient.top; + x += (*ppWnd)->rectClient.left; + y += (*ppWnd)->rectClient.top; } /* Restart the search from the next sibling */ - hwnd = wndPtr->hwndNext; - *phwnd = wndPtr->hwndParent; + wndPtr = (*ppWnd)->next; + *ppWnd = wndPtr->parent; } } @@ -253,9 +248,9 @@ INT WINPOS_WindowFromPoint( POINT pt, HWND *phwnd ) */ HWND WindowFromPoint( POINT pt ) { - HWND hwnd; - WINPOS_WindowFromPoint( pt, &hwnd ); - return hwnd; + WND *pWnd; + WINPOS_WindowFromPoint( pt, &pWnd ); + return pWnd->hwndSelf; } @@ -293,31 +288,36 @@ void MapWindowPoints( HWND hwndFrom, HWND hwndTo, LPPOINT lppt, WORD count ) if( hwndFrom == hwndTo ) return; /* Translate source window origin to screen coords */ - while(hwndFrom) + if (hwndFrom) { - if (!(wndPtr = WIN_FindWndPtr( hwndFrom ))) - { - fprintf( stderr, "MapWindowPoints: bad hwndFrom = "NPFMT"\n", - hwndFrom); - return; - } - origin.x += wndPtr->rectClient.left; - origin.y += wndPtr->rectClient.top; - hwndFrom = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->hwndParent : 0; + if (!(wndPtr = WIN_FindWndPtr( hwndFrom ))) + { + fprintf(stderr,"MapWindowPoints: bad hwndFrom = %04x\n",hwndFrom); + return; + } + while (wndPtr->parent) + { + origin.x += wndPtr->rectClient.left; + origin.y += wndPtr->rectClient.top; + wndPtr = wndPtr->parent; + } } /* Translate origin to destination window coords */ - while(hwndTo) + if (hwndTo) { - if (!(wndPtr = WIN_FindWndPtr( hwndTo ))) - { - fprintf(stderr,"MapWindowPoints: bad hwndTo = "NPFMT"\n", hwndTo ); - return; - } - origin.x -= wndPtr->rectClient.left; - origin.y -= wndPtr->rectClient.top; - hwndTo = (wndPtr->dwStyle & WS_CHILD) ? wndPtr->hwndParent : 0; - } + if (!(wndPtr = WIN_FindWndPtr( hwndTo ))) + { + fprintf(stderr,"MapWindowPoints: bad hwndTo = %04x\n", hwndTo ); + return; + } + while (wndPtr->parent) + { + origin.x -= wndPtr->rectClient.left; + origin.y -= wndPtr->rectClient.top; + wndPtr = wndPtr->parent; + } + } /* Translate points */ for (i = 0, curpt = lppt; i < count; i++, curpt++) @@ -391,7 +391,7 @@ BOOL MoveWindow( HWND hwnd, short x, short y, short cx, short cy, BOOL repaint) { int flags = SWP_NOZORDER | SWP_NOACTIVATE; if (!repaint) flags |= SWP_NOREDRAW; - dprintf_win(stddeb, "MoveWindow: "NPFMT" %d,%d %dx%d %d\n", + dprintf_win(stddeb, "MoveWindow: %04x %d,%d %dx%d %d\n", hwnd, x, y, cx, cy, repaint ); return SetWindowPos( hwnd, 0, x, y, cx, cy, flags ); } @@ -410,7 +410,7 @@ BOOL ShowWindow( HWND hwnd, int cmd ) if (!wndPtr) return FALSE; - dprintf_win(stddeb,"ShowWindow: hwnd="NPFMT", cmd=%d\n", hwnd, cmd); + dprintf_win(stddeb,"ShowWindow: hwnd=%04x, cmd=%d\n", hwnd, cmd); wasVisible = (wndPtr->dwStyle & WS_VISIBLE) != 0; @@ -717,11 +717,8 @@ BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus ) if (!(wndPtr->dwStyle & WS_CHILD)) { /* check Z-order and bring hWnd to the top */ - wndTemp = WIN_FindWndPtr( GetDesktopWindow() ); - - for( ; wndTemp; wndTemp = WIN_FindWndPtr( wndTemp->hwndNext )) - if( wndTemp->dwStyle & WS_VISIBLE ) - break; + for (wndTemp = WIN_GetDesktop()->child; wndTemp; wndTemp = wndTemp->next) + if (wndTemp->dwStyle & WS_VISIBLE) break; if( wndTemp != wndPtr ) SetWindowPos(hWnd, HWND_TOP, 0,0,0,0, @@ -761,18 +758,7 @@ BOOL WINPOS_SetActiveWindow( HWND hWnd, BOOL fMouse, BOOL fChangeFocus ) /* walk up to the first unowned window */ wndTemp = wndPtr; - - while(wndTemp->hwndOwner) - { - wndTemp = WIN_FindWndPtr(wndTemp->hwndOwner); - if( !wndTemp) - { - /* there must be an unowned window in hierarchy */ - dprintf_win(stddeb,"WINPOS_ActivateWindow: broken owner list\n"); - wndTemp = wndPtr; - break; - } - } + while (wndTemp->owner) wndTemp = wndTemp->owner; /* and set last active owned popup */ wndTemp->hwndLastActive = hWnd; @@ -829,8 +815,8 @@ BOOL WINPOS_ChangeActiveWindow( HWND hWnd, BOOL mouseMsg ) return FALSE; /* switch desktop queue to current active here */ - if( wndPtr->hwndParent == GetDesktopWindow()) - { } + if( wndPtr->parent == WIN_GetDesktop()) + WIN_GetDesktop()->hmemTaskQ = wndPtr->hmemTaskQ; return TRUE; } @@ -898,8 +884,7 @@ LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ) static void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter ) { BOOL movingUp; - HWND hwndCur; - WND *wndPtr = WIN_FindWndPtr( hwnd ); + WND *pWndAfter, *pWndCur, *wndPtr = WIN_FindWndPtr( hwnd ); /* We have two possible cases: * - The window is moving up: we have to invalidate all areas @@ -914,51 +899,50 @@ static void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter ) } else if (hwndAfter == HWND_BOTTOM) { - if (!wndPtr->hwndNext) return; /* Already at the bottom */ + if (!wndPtr->next) return; /* Already at the bottom */ movingUp = FALSE; } else { - if (wndPtr->hwndNext == hwndAfter) return; /* Already placed right */ + if (!(pWndAfter = WIN_FindWndPtr( hwndAfter ))) return; + if (wndPtr->next == pWndAfter) return; /* Already placed right */ /* Determine which window we encounter first in Z-order */ - hwndCur = GetWindow( wndPtr->hwndParent, GW_CHILD ); - while ((hwndCur != hwnd) && (hwndCur != hwndAfter)) - hwndCur = GetWindow( hwndCur, GW_HWNDNEXT ); - movingUp = (hwndCur == hwndAfter); + pWndCur = wndPtr->parent->child; + while ((pWndCur != wndPtr) && (pWndCur != pWndAfter)) + pWndCur = pWndCur->next; + movingUp = (pWndCur == pWndAfter); } if (movingUp) { - HWND hwndPrevAfter = wndPtr->hwndNext; + WND *pWndPrevAfter = wndPtr->next; WIN_UnlinkWindow( hwnd ); WIN_LinkWindow( hwnd, hwndAfter ); - hwndCur = wndPtr->hwndNext; - while (hwndCur != hwndPrevAfter) + pWndCur = wndPtr->next; + while (pWndCur != pWndPrevAfter) { - WND *curPtr = WIN_FindWndPtr( hwndCur ); - RECT rect = curPtr->rectWindow; + RECT rect = pWndCur->rectWindow; OffsetRect( &rect, -wndPtr->rectClient.left, -wndPtr->rectClient.top ); RedrawWindow( hwnd, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE ); - hwndCur = curPtr->hwndNext; + pWndCur = pWndCur->next; } } else /* Moving down */ { - hwndCur = wndPtr->hwndNext; + pWndCur = wndPtr->next; WIN_UnlinkWindow( hwnd ); WIN_LinkWindow( hwnd, hwndAfter ); - while (hwndCur != hwnd) + while (pWndCur != wndPtr) { - WND *curPtr = WIN_FindWndPtr( hwndCur ); RECT rect = wndPtr->rectWindow; - OffsetRect( &rect, -curPtr->rectClient.left, - -curPtr->rectClient.top ); - RedrawWindow( hwndCur, &rect, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | - RDW_FRAME | RDW_ERASE ); - hwndCur = curPtr->hwndNext; + OffsetRect( &rect, -pWndCur->rectClient.left, + -pWndCur->rectClient.top ); + RedrawWindow( pWndCur->hwndSelf, &rect, 0, RDW_INVALIDATE | + RDW_ALLCHILDREN | RDW_FRAME | RDW_ERASE ); + pWndCur = pWndCur->next; } } } @@ -1055,7 +1039,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y, (hwndInsertAfter == HWND_NOTOPMOST)) hwndInsertAfter = HWND_TOP; /* hwndInsertAfter must be a sibling of the window */ if ((hwndInsertAfter != HWND_TOP) && (hwndInsertAfter != HWND_BOTTOM) && - (wndPtr->hwndParent != WIN_FindWndPtr(hwndInsertAfter)->hwndParent)) + (wndPtr->parent != WIN_FindWndPtr(hwndInsertAfter)->parent)) return FALSE; /* Fill the WINDOWPOS structure */ @@ -1133,7 +1117,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y, HRGN hrgn2 = CreateRectRgnIndirect( &wndPtr->rectWindow ); HRGN hrgn3 = CreateRectRgn( 0, 0, 0, 0 ); CombineRgn( hrgn3, hrgn1, hrgn2, RGN_DIFF ); - RedrawWindow( wndPtr->hwndParent, NULL, hrgn3, + RedrawWindow( wndPtr->parent->hwndSelf, NULL, hrgn3, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASE ); /* DCE_GetVisRgn should be called for old coordinates @@ -1182,7 +1166,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y, else { if (!(flags & SWP_NOREDRAW)) - RedrawWindow( wndPtr->hwndParent, &wndPtr->rectWindow, 0, + RedrawWindow( wndPtr->parent->hwndSelf, &wndPtr->rectWindow, 0, RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN | RDW_ERASE ); } @@ -1197,7 +1181,8 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y, if (!IsWindow(newActive) || (newActive == winpos.hwnd)) { newActive = GetTopWindow( GetDesktopWindow() ); - if (newActive == winpos.hwnd) newActive = wndPtr->hwndNext; + if (newActive == winpos.hwnd) + newActive = wndPtr->next ? wndPtr->next->hwndSelf : 0; } WINPOS_ChangeActiveWindow( newActive, FALSE ); } @@ -1219,7 +1204,7 @@ BOOL SetWindowPos( HWND hwnd, HWND hwndInsertAfter, INT x, INT y, RDW_ALLCHILDREN | /*FIXME: this should not be necessary*/ RDW_INVALIDATE | RDW_FRAME | RDW_ERASE ); if (!(flags & SWP_DEFERERASE)) - RedrawWindow( wndPtr->hwndParent, NULL, 0, + RedrawWindow( wndPtr->parent->hwndSelf, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW ); /* And last, send the WM_WINDOWPOSCHANGED message */ @@ -1268,10 +1253,11 @@ HDWP DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter, INT x, INT y, pDWP = (DWP *) USER_HEAP_LIN_ADDR( hdwp ); if (!pDWP) return 0; + if (hwnd == GetDesktopWindow()) return 0; /* All the windows of a DeferWindowPos() must have the same parent */ - parent = WIN_FindWndPtr( hwnd )->hwndParent; + parent = WIN_FindWndPtr( hwnd )->parent->hwndSelf; if (pDWP->actualCount == 0) pDWP->hwndParent = parent; else if (parent != pDWP->hwndParent) { @@ -1355,7 +1341,7 @@ BOOL EndDeferWindowPos( HDWP hdwp ) */ void TileChildWindows( HWND parent, WORD action ) { - printf("STUB TileChildWindows("NPFMT", %d)\n", parent, action); + printf("STUB TileChildWindows(%04x, %d)\n", parent, action); } /*********************************************************************** @@ -1363,5 +1349,5 @@ void TileChildWindows( HWND parent, WORD action ) */ void CascadeChildWindows( HWND parent, WORD action ) { - printf("STUB CascadeChildWindows("NPFMT", %d)\n", parent, action); + printf("STUB CascadeChildWindows(%04x, %d)\n", parent, action); }