diff --git a/reactos/win32ss/include/callback.h b/reactos/win32ss/include/callback.h index d491f96c9c8..4955befea45 100644 --- a/reactos/win32ss/include/callback.h +++ b/reactos/win32ss/include/callback.h @@ -12,7 +12,8 @@ #define USER32_CALLBACK_CLIENTLOADLIBRARY (8) #define USER32_CALLBACK_GETCHARSETINFO (9) #define USER32_CALLBACK_COPYIMAGE (10) -#define USER32_CALLBACK_MAXIMUM (10) +#define USER32_CALLBACK_SETWNDICONS (11) +#define USER32_CALLBACK_MAXIMUM (11) typedef struct _WINDOWPROC_CALLBACK_ARGUMENTS { @@ -105,9 +106,17 @@ typedef struct _GET_CHARSET_INFO CHARSETINFO Cs; } GET_CHARSET_INFO, *PGET_CHARSET_INFO; +typedef struct _SETWNDICONS_CALLBACK_ARGUMENTS +{ + HICON hIconSmWindows; + HICON hIconWindows; +} SETWNDICONS_CALLBACK_ARGUMENTS, *PSETWNDICONS_CALLBACK_ARGUMENTS; + NTSTATUS WINAPI User32CallCopyImageFromKernel(PVOID Arguments, ULONG ArgumentLength); NTSTATUS WINAPI +User32CallSetWndIconsFromKernel(PVOID Arguments, ULONG ArgumentLength); +NTSTATUS WINAPI User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength); NTSTATUS WINAPI User32CallSendAsyncProcForKernel(PVOID Arguments, ULONG ArgumentLength); diff --git a/reactos/win32ss/include/ntgdityp.h b/reactos/win32ss/include/ntgdityp.h index 956c6d2ca82..d0f6b60c31b 100644 --- a/reactos/win32ss/include/ntgdityp.h +++ b/reactos/win32ss/include/ntgdityp.h @@ -742,5 +742,6 @@ ASSERT_PFN(DeriveSurface); ASSERT_PFN(QueryGlyphAttrs); ASSERT_PFN(Notify); ASSERT_PFN(SynchronizeSurface); +ASSERT_PFN(ResetDevice); #endif diff --git a/reactos/win32ss/include/ntuser.h b/reactos/win32ss/include/ntuser.h index e64fa9dfa30..1677a769216 100644 --- a/reactos/win32ss/include/ntuser.h +++ b/reactos/win32ss/include/ntuser.h @@ -69,6 +69,7 @@ typedef enum _USERTHREADINFOCLASS UserThreadWOWInformation, UserThreadHungStatus, UserThreadInitiateShutdown, + UserThreadEndShutdown, UserThreadUseActiveDesktop, UserThreadUseDesktop, @@ -119,6 +120,7 @@ typedef struct _DESKTOPINFO HWND hTaskManWindow; HWND hProgmanWindow; HWND hShellWindow; + struct _WND * spwndShell; PPROCESSINFO ppiShellProcess; @@ -857,7 +859,7 @@ typedef struct _PERUSERSERVERINFO TEXTMETRICW tmSysFont; DPISERVERINFO dpiSystem; HICON hIconSmWindows; - HICON hIcoWindows; + HICON hIconWindows; DWORD dwKeyCache; DWORD dwAsyncKeyCache; ULONG cCaptures; diff --git a/reactos/win32ss/user/ntuser/callback.c b/reactos/win32ss/user/ntuser/callback.c index 833da09d684..3d6c53dc1d7 100644 --- a/reactos/win32ss/user/ntuser/callback.c +++ b/reactos/win32ss/user/ntuser/callback.c @@ -881,7 +881,6 @@ co_IntClientThreadSetup(VOID) return Status; } - HANDLE FASTCALL co_IntCopyImage(HANDLE hnd, UINT type, INT desiredx, INT desiredy, UINT flags) { @@ -993,4 +992,53 @@ co_IntGetCharsetInfo(LCID Locale, PCHARSETINFO pCs) return TRUE; } +BOOL FASTCALL +co_IntSetWndIcons(VOID) +{ + NTSTATUS Status; + ULONG ArgumentLength, ResultLength; + PVOID Argument, ResultPointer; + PSETWNDICONS_CALLBACK_ARGUMENTS Common; + + ArgumentLength = ResultLength = 0; + Argument = ResultPointer = NULL; + + ArgumentLength = sizeof(SETWNDICONS_CALLBACK_ARGUMENTS); + + Argument = IntCbAllocateMemory(ArgumentLength); + if (NULL == Argument) + { + ERR("Set Window Icons callback failed: out of memory\n"); + return FALSE; + } + Common = (PSETWNDICONS_CALLBACK_ARGUMENTS) Argument; + + UserLeaveCo(); + + Status = KeUserModeCallback(USER32_CALLBACK_SETWNDICONS, + Argument, + ArgumentLength, + &ResultPointer, + &ResultLength); + + + UserEnterCo(); + + /* FIXME: Need to setup Registry System Cursor & Icons via Callbacks at init time! */ + gpsi->hIconSmWindows = Common->hIconSmWindows; + gpsi->hIconWindows = Common->hIconWindows; + + ERR("hIconSmWindows %p hIconWindows %p \n",gpsi->hIconSmWindows,gpsi->hIconWindows); + + IntCbFreeMemory(Argument); + + if (!NT_SUCCESS(Status)) + { + ERR("Set Window Icons callback failed!\n"); + return FALSE; + } + + return TRUE; +} + /* EOF */ diff --git a/reactos/win32ss/user/ntuser/callback.h b/reactos/win32ss/user/ntuser/callback.h index 5537e726ec8..0464b48501d 100644 --- a/reactos/win32ss/user/ntuser/callback.h +++ b/reactos/win32ss/user/ntuser/callback.h @@ -69,3 +69,5 @@ APIENTRY co_IntGetCharsetInfo(LCID Locale, PCHARSETINFO pCs); HANDLE FASTCALL co_IntCopyImage(HANDLE,UINT,INT,INT,UINT); + +BOOL FASTCALL co_IntSetWndIcons(VOID); diff --git a/reactos/win32ss/user/ntuser/class.c b/reactos/win32ss/user/ntuser/class.c index 6bf41a6217d..6b11866eb3f 100644 --- a/reactos/win32ss/user/ntuser/class.c +++ b/reactos/win32ss/user/ntuser/class.c @@ -1899,8 +1899,6 @@ UserSetClassLongPtr(IN PCLS Class, if (hIconSmIntern) Class->CSF_flags |= CSF_CACHEDSMICON; //// FIXME: Very hacky here but it passes the tests.... - //// We should not kill a users handle!!! - if (Class->hIconSm) IntClassDestroyIcon(Class->hIconSm); // Fixes 1013 Ret = 0; // Fixes 1009 } Class->hIconSm = (HANDLE)NewLong; diff --git a/reactos/win32ss/user/ntuser/defwnd.c b/reactos/win32ss/user/ntuser/defwnd.c index ff14af4283c..f5445803fad 100644 --- a/reactos/win32ss/user/ntuser/defwnd.c +++ b/reactos/win32ss/user/ntuser/defwnd.c @@ -172,6 +172,7 @@ IntDefWindowProc( BOOL Ansi) { LRESULT lResult = 0; + USER_REFERENCE_ENTRY Ref; if (Msg > WM_USER) return 0; @@ -205,6 +206,20 @@ IntDefWindowProc( case WM_CLIENTSHUTDOWN: return IntClientShutdown(Wnd, wParam, lParam); + case WM_APPCOMMAND: + ERR("WM_APPCOMMAND\n"); + if ( (Wnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD && + Wnd != co_GetDesktopWindow(Wnd) ) + { + if (!co_HOOK_CallHooks(WH_SHELL, HSHELL_APPCOMMAND, wParam, lParam)) + co_IntShellHookNotify(HSHELL_APPCOMMAND, wParam, lParam); + break; + } + UserRefObjectCo(Wnd->spwndParent, &Ref); + lResult = co_IntSendMessage(UserHMGetHandle(Wnd->spwndParent), WM_APPCOMMAND, wParam, lParam); + UserDerefObjectCo(Wnd->spwndParent); + break; + case WM_CTLCOLORMSGBOX: case WM_CTLCOLOREDIT: case WM_CTLCOLORLISTBOX: @@ -303,20 +318,22 @@ IntDefWindowProc( return lResult; } -static HICON NC_IconForWindow( PWND pWnd ) +HICON FASTCALL NC_IconForWindow( PWND pWnd ) { HICON hIcon = 0; + // First thing to do, init the Window Logo icons. + if (!gpsi->hIconSmWindows) co_IntSetWndIcons(); - if (!pWnd->pcls || pWnd->fnid == FNID_DESKTOP) return hIcon; + if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconSmProp); + if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconProp); if (!hIcon) hIcon = pWnd->pcls->hIconSm; if (!hIcon) hIcon = pWnd->pcls->hIcon; if (!hIcon && pWnd->style & DS_MODALFRAME) - { // Fake it out for now, we use it as a test. - hIcon = (HICON)1; - /* FIXME: Need to setup Registry System Cursor & Icons via Callbacks at init time! */ + { if (!hIcon) hIcon = gpsi->hIconSmWindows; // Both are IDI_WINLOGO Small - if (!hIcon) hIcon = gpsi->hIcoWindows; // Reg size. + if (!hIcon) hIcon = gpsi->hIconWindows; // Reg size. + hIcon = (HICON)1; } return hIcon; } diff --git a/reactos/win32ss/user/ntuser/painting.c b/reactos/win32ss/user/ntuser/painting.c index 52e2b5fa274..72e6287c092 100644 --- a/reactos/win32ss/user/ntuser/painting.c +++ b/reactos/win32ss/user/ntuser/painting.c @@ -1987,9 +1987,7 @@ BOOL UserDrawCaption( if (!hIcon && pWnd) { - hIcon = pWnd->pcls->hIconSm; // FIXME: Windows does not do that - if(!hIcon) - hIcon = pWnd->pcls->hIcon; + hIcon = NC_IconForWindow( pWnd ); } if (hIcon) diff --git a/reactos/win32ss/user/ntuser/painting.h b/reactos/win32ss/user/ntuser/painting.h index f2b31b6e6e0..f584cd1ea54 100644 --- a/reactos/win32ss/user/ntuser/painting.h +++ b/reactos/win32ss/user/ntuser/painting.h @@ -10,3 +10,4 @@ BOOL FASTCALL IntValidateParent(PWND Child, HRGN hValidateRgn, BOOL Recurse); BOOL FASTCALL IntIsWindowDirty(PWND); BOOL FASTCALL IntEndPaint(PWND,PPAINTSTRUCT); HDC FASTCALL IntBeginPaint(PWND,PPAINTSTRUCT); +HICON FASTCALL NC_IconForWindow( PWND ); diff --git a/reactos/win32ss/user/ntuser/prop.c b/reactos/win32ss/user/ntuser/prop.c index 5628d333b35..5ffc7b74ec5 100644 --- a/reactos/win32ss/user/ntuser/prop.c +++ b/reactos/win32ss/user/ntuser/prop.c @@ -30,6 +30,15 @@ IntGetProp(PWND Window, ATOM Atom) return(NULL); } +HANDLE +FASTCALL +UserGetProp(PWND pWnd, ATOM Atom) +{ + PPROPERTY Prop; + Prop = IntGetProp(pWnd, Atom); + return Prop ? Prop->Data : NULL; +} + BOOL FASTCALL IntRemoveProp(PWND Window, ATOM Atom) { diff --git a/reactos/win32ss/user/ntuser/prop.h b/reactos/win32ss/user/ntuser/prop.h index 08045569027..9ba3eaf0260 100644 --- a/reactos/win32ss/user/ntuser/prop.h +++ b/reactos/win32ss/user/ntuser/prop.h @@ -3,3 +3,4 @@ PPROPERTY FASTCALL IntGetProp(PWND,ATOM); BOOL FASTCALL IntRemoveProp(PWND,ATOM); BOOL FASTCALL IntSetProp(PWND, ATOM, HANDLE); +HANDLE FASTCALL UserGetProp(PWND, ATOM); diff --git a/reactos/win32ss/user/ntuser/window.c b/reactos/win32ss/user/ntuser/window.c index 428d6444bbe..5aa8ee92d6c 100644 --- a/reactos/win32ss/user/ntuser/window.c +++ b/reactos/win32ss/user/ntuser/window.c @@ -426,6 +426,8 @@ static LRESULT co_UserFreeWindow(PWND Window, PWND Child; PMENU_OBJECT Menu; BOOLEAN BelongsToThreadData; + PLIST_ENTRY ListEntry; + PPROPERTY Property; ASSERT(Window); @@ -554,6 +556,14 @@ static LRESULT co_UserFreeWindow(PWND Window, IntUnlinkWindow(Window); + ListEntry = Window->PropListHead.Flink; + while (ListEntry != &Window->PropListHead) + { + Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry); + ListEntry = ListEntry->Flink; + IntRemoveProp(Window, Property->Atom); + } + UserReferenceObject(Window); UserDeleteObject(Window->head.h, TYPE_WINDOW); diff --git a/reactos/win32ss/user/user32/include/user32p.h b/reactos/win32ss/user/user32/include/user32p.h index 1df2c173c2e..4edf1649f9d 100644 --- a/reactos/win32ss/user/user32/include/user32p.h +++ b/reactos/win32ss/user/user32/include/user32p.h @@ -32,6 +32,7 @@ extern HINSTANCE hImmInstance; extern RTL_CRITICAL_SECTION gcsUserApiHook; extern USERAPIHOOK guah; extern HINSTANCE ghmodUserApiHook; +extern HICON hIconSmWindows, hIconWindows; #define IS_ATOM(x) \ (((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000)) @@ -101,5 +102,6 @@ BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down ); HWND* WIN_ListChildren (HWND hWndparent); VOID DeleteFrameBrushes(VOID); BOOL WINAPI GdiValidateHandle(HGDIOBJ); +HANDLE FASTCALL UserGetProp(HWND hWnd, ATOM Atom); /* EOF */ diff --git a/reactos/win32ss/user/user32/misc/dllmain.c b/reactos/win32ss/user/user32/misc/dllmain.c index 156629e7075..7876056e05c 100644 --- a/reactos/win32ss/user/user32/misc/dllmain.c +++ b/reactos/win32ss/user/user32/misc/dllmain.c @@ -15,6 +15,7 @@ PSERVERINFO gpsi = NULL; ULONG_PTR g_ulSharedDelta; BOOLEAN gfLogonProcess = FALSE; BOOLEAN gfServerProcess = FALSE; +HICON hIconSmWindows = NULL, hIconWindows = NULL; WCHAR szAppInit[KEY_LENGTH]; @@ -207,6 +208,7 @@ PVOID apfnDispatch[USER32_CALLBACK_MAXIMUM + 1] = User32CallClientLoadLibraryFromKernel, User32CallGetCharsetInfo, User32CallCopyImageFromKernel, + User32CallSetWndIconsFromKernel, }; /* @@ -352,11 +354,38 @@ DllMain( return TRUE; } + +VOID +FASTCALL +GetConnected(VOID) +{ + USERCONNECT UserCon; +// ERR("GetConnected\n"); + + if ((PTHREADINFO)NtCurrentTeb()->Win32ThreadInfo == NULL) + NtUserGetThreadState(THREADSTATE_GETTHREADINFO); + + if (gpsi && g_ppi) return; +// FIXME HAX: Due to the "Dll Initialization Bug" we have to call this too. + GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL); + + NtUserProcessConnect( NtCurrentProcess(), + &UserCon, + sizeof(USERCONNECT)); + + g_ppi = GetWin32ClientInfo()->ppi; + g_ulSharedDelta = UserCon.siClient.ulSharedDelta; + gpsi = SharedPtrToUser(UserCon.siClient.psi); + gHandleTable = SharedPtrToUser(UserCon.siClient.aheList); + gHandleEntries = SharedPtrToUser(gHandleTable->handles); + +} + NTSTATUS WINAPI User32CallClientThreadSetupFromKernel(PVOID Arguments, ULONG ArgumentLength) { - ERR("GetConnected\n"); + ERR("ClientThreadSetup\n"); ClientThreadSetup(); return ZwCallbackReturn(NULL, 0, STATUS_SUCCESS); } @@ -374,3 +403,20 @@ User32CallGetCharsetInfo(PVOID Arguments, ULONG ArgumentLength) return ZwCallbackReturn(Arguments, ArgumentLength, Ret ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL); } + +NTSTATUS +WINAPI +User32CallSetWndIconsFromKernel(PVOID Arguments, ULONG ArgumentLength) +{ + PSETWNDICONS_CALLBACK_ARGUMENTS Common = Arguments; + + if (!hIconSmWindows) + { + hIconSmWindows = LoadImageW(0, IDI_WINLOGO, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); + hIconWindows = LoadImageW(0, IDI_WINLOGO, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + } + Common->hIconSmWindows = hIconSmWindows; + Common->hIconWindows = hIconWindows; + + return ZwCallbackReturn(Arguments, ArgumentLength, STATUS_SUCCESS); +} diff --git a/reactos/win32ss/user/user32/windows/defwnd.c b/reactos/win32ss/user/user32/windows/defwnd.c index 2fed939fb4d..6920cb0c3ee 100644 --- a/reactos/win32ss/user/user32/windows/defwnd.c +++ b/reactos/win32ss/user/user32/windows/defwnd.c @@ -982,6 +982,68 @@ UserSendUiUpdateMsg(HWND hwnd, LPARAM lParam) return TRUE; } +// WM_SETICON +LRESULT FASTCALL +DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) +{ + HICON hIcon, hIconSmall, hIconOld; + + if ( wParam > ICON_SMALL2 ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + hIconSmall = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp); + hIcon = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconProp); + + hIconOld = wParam == ICON_BIG ? hIcon : hIconSmall; + + switch(wParam) + { + case ICON_BIG: + hIcon = (HICON)lParam; + break; + case ICON_SMALL: + hIconSmall = (HICON)lParam; + break; + case ICON_SMALL2: + ERR("FIXME: Set ICON_SMALL2 support!\n"); + default: + break; + } + + NtUserSetProp(UserHMGetHandle(pWnd), gpsi->atomIconProp, hIcon); + NtUserSetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp, hIconSmall); + + if ((pWnd->style & WS_CAPTION ) == WS_CAPTION) + DefWndNCPaint(UserHMGetHandle(pWnd), HRGN_WINDOW, -1); /* Repaint caption */ + + return (LRESULT)hIconOld; +} + +LRESULT FASTCALL +DefWndGetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) +{ + HICON hIconRet; + if ( wParam > ICON_SMALL2 ) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + switch(wParam) + { + case ICON_BIG: + hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconProp); + break; + case ICON_SMALL: + case ICON_SMALL2: + hIconRet = UserGetProp(UserHMGetHandle(pWnd), gpsi->atomIconSmProp); + break; + default: + break; + } + return (LRESULT)hIconRet; +} VOID FASTCALL DefWndScreenshot(HWND hWnd) @@ -1523,19 +1585,12 @@ User32DefWindowProc(HWND hWnd, case WM_SETICON: { - INT Index = (wParam != 0) ? GCL_HICON : GCL_HICONSM; - HICON hOldIcon = (HICON)GetClassLongPtrW(hWnd, Index); - SetClassLongPtrW(hWnd, Index, lParam); - SetWindowPos(hWnd, 0, 0, 0, 0, 0, - SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | - SWP_NOACTIVATE | SWP_NOZORDER); - return ((LRESULT)hOldIcon); + return DefWndSetIcon(pWnd, wParam, lParam); } case WM_GETICON: { - INT Index = (wParam == ICON_BIG) ? GCL_HICON : GCL_HICONSM; - return (GetClassLongPtrW(hWnd, Index)); + return DefWndGetIcon(pWnd, wParam, lParam); } case WM_HELP: diff --git a/reactos/win32ss/user/user32/windows/nonclient.c b/reactos/win32ss/user/user32/windows/nonclient.c index 713e2c00d0c..1f8803a4aa5 100644 --- a/reactos/win32ss/user/user32/windows/nonclient.c +++ b/reactos/win32ss/user/user32/windows/nonclient.c @@ -24,6 +24,7 @@ #include #include +WINE_DEFAULT_DEBUG_CHANNEL(user32); #define HAS_DLGFRAME(Style, ExStyle) \ (((ExStyle) & WS_EX_DLGMODALFRAME) || \ @@ -124,18 +125,15 @@ UserGetWindowIcon(HWND hwnd) SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); - if (!hIcon) - SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); - - if (!hIcon) - SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon); - - if (!hIcon) - hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICONSM); - - if (!hIcon) - hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICON); - + if (!hIcon) hIcon = UserGetProp(hwnd, gpsi->atomIconSmProp); + if (!hIcon) hIcon = UserGetProp(hwnd, gpsi->atomIconProp); + if (!hIcon) hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICONSM); + if (!hIcon) hIcon = (HICON)GetClassLongPtr(hwnd, GCL_HICON); + if (!hIcon && (GetWindowLongW( hwnd, GWL_STYLE ) & DS_MODALFRAME)) + { + if (!hIcon) hIcon = gpsi->hIconSmWindows; // Both are IDI_WINLOGO Small + if (!hIcon) hIcon = gpsi->hIconWindows; // Reg size. + } return hIcon; } @@ -1035,6 +1033,14 @@ DefWndNCLButtonDown(HWND hWnd, WPARAM wParam, LPARAM lParam) case HTBOTTOMLEFT: case HTBOTTOMRIGHT: { + /* Old comment: + * "make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU" + * This was previously done by setting wParam=SC_SIZE + wParam - 2 + */ + /* But that is not what WinNT does. Instead it sends this. This + * is easy to differentiate from HTSYSMENU, because HTSYSMENU adds + * SC_MOUSEMENU into wParam. + */ SendMessageW(hWnd, WM_SYSCOMMAND, SC_SIZE + wParam - (HTLEFT - WMSZ_LEFT), lParam); break; } @@ -1073,25 +1079,125 @@ DefWndNCLButtonDblClk(HWND hWnd, WPARAM wParam, LPARAM lParam) return(0); } -VOID -DefWndTrackScrollBar(HWND hWnd, WPARAM wParam, POINT Point) +/*********************************************************************** + * NC_HandleNCRButtonDown + * + * Handle a WM_NCRBUTTONDOWN message. Called from DefWindowProc(). + */ +LRESULT NC_HandleNCRButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) { - //INT ScrollBar; + MSG msg; + INT hittest = wParam; - if ((wParam & 0xfff0) == SC_HSCROLL) - { - if ((wParam & 0x0f) != HTHSCROLL) - return; - //ScrollBar = SB_HORZ; - } - else - { - if ((wParam & 0x0f) != HTVSCROLL) - return; - //ScrollBar = SB_VERT; - } + switch (hittest) + { + case HTCAPTION: + case HTSYSMENU: + if (!GetSystemMenu( hwnd, FALSE )) break; - /* FIXME */ + SetCapture( hwnd ); + for (;;) + { + if (!GetMessageW( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST )) break; + if (CallMsgFilterW( &msg, MSGF_MAX )) continue; + if (msg.message == WM_RBUTTONUP) + { + hittest = DefWndNCHitTest( hwnd, msg.pt ); + break; + } + if (hwnd != GetCapture()) return 0; + } + ReleaseCapture(); + if (hittest == HTCAPTION || hittest == HTSYSMENU) + { + ERR("Msg pt %x and Msg.lParam %x and lParam %x\n",MAKELONG(msg.pt.x,msg.pt.y),msg.lParam,lParam); + SendMessageW( hwnd, WM_SYSCOMMAND, SC_MOUSEMENU + HTSYSMENU, msg.lParam ); + } + break; + } + return 0; +} + +/*********************************************************************** + * NcGetInsideRect + * + * Get the 'inside' rectangle of a window, i.e. the whole window rectangle + * but without the borders (if any). + * The rectangle is in window coordinates (for drawing with GetWindowDC()). + */ +static void FASTCALL +NcGetInsideRect(HWND Wnd, RECT *Rect) +{ + DWORD Style; + DWORD ExStyle; + + GetWindowRect(Wnd, Rect); + Rect->right = Rect->right - Rect->left; + Rect->left = 0; + Rect->bottom = Rect->bottom - Rect->top; + Rect->top = 0; + + Style = GetWindowLongPtrW(Wnd, GWL_STYLE); + if (0 != (Style & WS_ICONIC)) + { + return; + } + + /* Remove frame from rectangle */ + ExStyle = GetWindowLongPtrW(Wnd, GWL_EXSTYLE); + if (HAS_THICKFRAME(Style, ExStyle)) + { + InflateRect(Rect, - GetSystemMetrics(SM_CXFRAME), - GetSystemMetrics(SM_CYFRAME)); + } + else if (HAS_DLGFRAME(Style, ExStyle)) + { + InflateRect(Rect, - GetSystemMetrics(SM_CXDLGFRAME), - GetSystemMetrics(SM_CYDLGFRAME)); + } + else if (HAS_THINFRAME(Style, ExStyle)) + { + InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER)); + } + + /* We have additional border information if the window + * is a child (but not an MDI child) */ + if (0 != (Style & WS_CHILD) + && 0 == (ExStyle & WS_EX_MDICHILD)) + { + if (0 != (ExStyle & WS_EX_CLIENTEDGE)) + { + InflateRect(Rect, - GetSystemMetrics(SM_CXEDGE), - GetSystemMetrics(SM_CYEDGE)); + } + if (0 != (ExStyle & WS_EX_STATICEDGE)) + { + InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER)); + } + } +} + +/*********************************************************************** + * NcGetSysPopupPos + */ +void FASTCALL +NcGetSysPopupPos(HWND Wnd, RECT *Rect) +{ + RECT WindowRect; + + if (IsIconic(Wnd)) + { + GetWindowRect(Wnd, Rect); + } + else + { + NcGetInsideRect(Wnd, Rect); + GetWindowRect(Wnd, &WindowRect); + OffsetRect(Rect, WindowRect.left, WindowRect.top); + if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & WS_CHILD)) + { + ClientToScreen(GetParent(Wnd), (POINT *) Rect); + } + Rect->right = Rect->left + GetSystemMetrics(SM_CYCAPTION) - 1; + Rect->bottom = Rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; + } } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -1251,85 +1357,3 @@ DrawCaptionTempA( } return ret; } - -/*********************************************************************** - * NcGetInsideRect - * - * Get the 'inside' rectangle of a window, i.e. the whole window rectangle - * but without the borders (if any). - * The rectangle is in window coordinates (for drawing with GetWindowDC()). - */ -static void FASTCALL -NcGetInsideRect(HWND Wnd, RECT *Rect) -{ - DWORD Style; - DWORD ExStyle; - - GetWindowRect(Wnd, Rect); - Rect->right = Rect->right - Rect->left; - Rect->left = 0; - Rect->bottom = Rect->bottom - Rect->top; - Rect->top = 0; - - Style = GetWindowLongPtrW(Wnd, GWL_STYLE); - if (0 != (Style & WS_ICONIC)) - { - return; - } - - /* Remove frame from rectangle */ - ExStyle = GetWindowLongPtrW(Wnd, GWL_EXSTYLE); - if (HAS_THICKFRAME(Style, ExStyle)) - { - InflateRect(Rect, - GetSystemMetrics(SM_CXFRAME), - GetSystemMetrics(SM_CYFRAME)); - } - else if (HAS_DLGFRAME(Style, ExStyle)) - { - InflateRect(Rect, - GetSystemMetrics(SM_CXDLGFRAME), - GetSystemMetrics(SM_CYDLGFRAME)); - } - else if (HAS_THINFRAME(Style, ExStyle)) - { - InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER)); - } - - /* We have additional border information if the window - * is a child (but not an MDI child) */ - if (0 != (Style & WS_CHILD) - && 0 == (ExStyle & WS_EX_MDICHILD)) - { - if (0 != (ExStyle & WS_EX_CLIENTEDGE)) - { - InflateRect(Rect, - GetSystemMetrics(SM_CXEDGE), - GetSystemMetrics(SM_CYEDGE)); - } - if (0 != (ExStyle & WS_EX_STATICEDGE)) - { - InflateRect(Rect, - GetSystemMetrics(SM_CXBORDER), - GetSystemMetrics(SM_CYBORDER)); - } - } -} - -/*********************************************************************** - * NcGetSysPopupPos - */ -void FASTCALL -NcGetSysPopupPos(HWND Wnd, RECT *Rect) -{ - RECT WindowRect; - - if (IsIconic(Wnd)) - { - GetWindowRect(Wnd, Rect); - } - else - { - NcGetInsideRect(Wnd, Rect); - GetWindowRect(Wnd, &WindowRect); - OffsetRect(Rect, WindowRect.left, WindowRect.top); - if (0 != (GetWindowLongPtrW(Wnd, GWL_STYLE) & WS_CHILD)) - { - ClientToScreen(GetParent(Wnd), (POINT *) Rect); - } - Rect->right = Rect->left + GetSystemMetrics(SM_CYCAPTION) - 1; - Rect->bottom = Rect->top + GetSystemMetrics(SM_CYCAPTION) - 1; - } -} diff --git a/reactos/win32ss/user/user32/windows/prop.c b/reactos/win32ss/user/user32/windows/prop.c index 16bbbd50059..8f9b1b8c2c4 100644 --- a/reactos/win32ss/user/user32/windows/prop.c +++ b/reactos/win32ss/user/user32/windows/prop.c @@ -18,8 +18,8 @@ */ /* * PROJECT: ReactOS user32.dll - * FILE: lib/user32/windows/input.c - * PURPOSE: Input + * FILE: user/user32/windows/prop.c + * PURPOSE: Window Property * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * UPDATE HISTORY: * 09-05-2001 CSH Created @@ -63,6 +63,14 @@ IntGetProp(HWND hWnd, ATOM Atom) return NULL; } +HANDLE +FASTCALL +UserGetProp(HWND hWnd, ATOM Atom) +{ + PPROPERTY Prop; + Prop = IntGetProp(hWnd, Atom); + return Prop ? Prop->Data : NULL; +} /* FUNCTIONS *****************************************************************/