Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / vcl / win / window / salobj.cxx
blobad352217ed898d6db0e941746fc11b5e09bee9a7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <string.h>
22 #include <svsys.h>
24 #include <vcl/svapp.hxx>
26 #include <win/wincomp.hxx>
27 #include <win/saldata.hxx>
28 #include <win/salinst.h>
29 #include <win/salframe.h>
30 #include <win/salobj.h>
32 #include <comphelper/windowserrorstring.hxx>
34 static bool ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild )
36 if ( hWndParent == hWndChild )
37 return TRUE;
39 HWND hTempWnd = ::GetParent( hWndChild );
40 while ( hTempWnd )
42 // stop searching if not a child window
43 if ( !(GetWindowStyle( hTempWnd ) & WS_CHILD) )
44 return FALSE;
45 if ( hTempWnd == hWndParent )
46 return TRUE;
47 hTempWnd = ::GetParent( hTempWnd );
50 return FALSE;
53 WinSalObject* ImplFindSalObject( HWND hWndChild )
55 SalData* pSalData = GetSalData();
56 WinSalObject* pObject = pSalData->mpFirstObject;
57 while ( pObject )
59 if ( ImplIsSysWindowOrChild( pObject->mhWndChild, hWndChild ) )
60 return pObject;
62 pObject = pObject->mpNextObject;
65 return nullptr;
68 WinSalFrame* ImplFindSalObjectFrame( HWND hWnd )
70 WinSalFrame* pFrame = nullptr;
71 WinSalObject* pObject = ImplFindSalObject( hWnd );
72 if ( pObject )
74 // find matching frame
75 HWND hWnd2 = ::GetParent( pObject->mhWnd );
76 pFrame = GetSalData()->mpFirstFrame;
77 while ( pFrame )
79 if ( pFrame->mhWnd == hWnd2 )
80 break;
82 pFrame = pFrame->mpNextFrame;
86 return pFrame;
89 LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
91 // Used for Unicode and none Unicode
92 SalData* pSalData = GetSalData();
94 if ( (nCode >= 0) && lParam )
96 CWPSTRUCT* pData = reinterpret_cast<CWPSTRUCT*>(lParam);
97 if ( (pData->message != WM_KEYDOWN) &&
98 (pData->message != WM_KEYUP) )
99 pSalData->mnSalObjWantKeyEvt = 0;
102 // check if we need to process data for a SalObject-window
103 WinSalObject* pObject;
104 if ( pData->message == WM_SETFOCUS )
106 pObject = ImplFindSalObject( pData->hwnd );
107 if ( pObject )
109 pObject->mhLastFocusWnd = pData->hwnd;
110 if ( ImplSalYieldMutexTryToAcquire() )
112 pObject->CallCallback( SalObjEvent::GetFocus );
113 ImplSalYieldMutexRelease();
115 else
117 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
118 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
122 else if ( pData->message == WM_KILLFOCUS )
124 pObject = ImplFindSalObject( pData->hwnd );
125 if ( pObject && !ImplFindSalObject( reinterpret_cast<HWND>(pData->wParam) ) )
127 // only call LoseFocus, if truly no child window gets the focus
128 if ( !pData->wParam || !ImplFindSalObject( reinterpret_cast<HWND>(pData->wParam) ) )
130 if ( ImplSalYieldMutexTryToAcquire() )
132 pObject->CallCallback( SalObjEvent::LoseFocus );
133 ImplSalYieldMutexRelease();
135 else
137 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
138 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
141 else
142 pObject->mhLastFocusWnd = reinterpret_cast<HWND>(pData->wParam);
147 return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam );
150 bool ImplSalPreDispatchMsg( const MSG* pMsg )
152 // Used for Unicode and none Unicode
153 SalData* pSalData = GetSalData();
154 WinSalObject* pObject;
156 if ( (pMsg->message == WM_LBUTTONDOWN) ||
157 (pMsg->message == WM_RBUTTONDOWN) ||
158 (pMsg->message == WM_MBUTTONDOWN) )
160 ImplSalYieldMutexAcquireWithWait();
161 pObject = ImplFindSalObject( pMsg->hwnd );
162 if ( pObject && !pObject->IsMouseTransparent() )
164 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0);
165 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
167 ImplSalYieldMutexRelease();
170 if ( (pMsg->message == WM_KEYDOWN) ||
171 (pMsg->message == WM_KEYUP) )
173 // process KeyEvents even if the control does not process them itself
174 // SysKeys are processed as WM_SYSCOMMAND
175 // Char-Events are not processed, as they are not accelerator-relevant
176 bool bWantedKeyCode = FALSE;
177 // A-Z, 0-9 only when combined with the Control-key
178 if ( ((pMsg->wParam >= 65) && (pMsg->wParam <= 90)) ||
179 ((pMsg->wParam >= 48) && (pMsg->wParam <= 57)) )
181 if ( GetKeyState( VK_CONTROL ) & 0x8000 )
182 bWantedKeyCode = TRUE;
184 else if ( ((pMsg->wParam >= VK_F1) && (pMsg->wParam <= VK_F24)) ||
185 ((pMsg->wParam >= VK_SPACE) && (pMsg->wParam <= VK_HELP)) ||
186 (pMsg->wParam == VK_BACK) || (pMsg->wParam == VK_TAB) ||
187 (pMsg->wParam == VK_CLEAR) || (pMsg->wParam == VK_RETURN) ||
188 (pMsg->wParam == VK_ESCAPE) )
189 bWantedKeyCode = TRUE;
190 if ( bWantedKeyCode )
192 ImplSalYieldMutexAcquireWithWait();
193 pObject = ImplFindSalObject( pMsg->hwnd );
194 if ( pObject )
195 pSalData->mnSalObjWantKeyEvt = pMsg->wParam;
196 ImplSalYieldMutexRelease();
199 // check WM_SYSCHAR, to activate menu with Alt key
200 else if ( pMsg->message == WM_SYSCHAR )
202 pSalData->mnSalObjWantKeyEvt = 0;
204 sal_uInt16 nKeyCode = LOWORD( pMsg->wParam );
205 // only 0-9 and A-Z
206 if ( ((nKeyCode >= 48) && (nKeyCode <= 57)) ||
207 ((nKeyCode >= 65) && (nKeyCode <= 90)) ||
208 ((nKeyCode >= 97) && (nKeyCode <= 122)) )
210 bool bRet = FALSE;
211 ImplSalYieldMutexAcquireWithWait();
212 pObject = ImplFindSalObject( pMsg->hwnd );
213 if ( pObject )
215 if ( pMsg->hwnd == ::GetFocus() )
217 WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
218 if ( pFrame )
220 if ( ImplHandleSalObjSysCharMsg( pFrame->mhWnd, pMsg->wParam, pMsg->lParam ) )
221 bRet = TRUE;
225 ImplSalYieldMutexRelease();
226 if ( bRet )
227 return TRUE;
230 else
231 pSalData->mnSalObjWantKeyEvt = 0;
233 return FALSE;
236 void ImplSalPostDispatchMsg( const MSG* pMsg )
238 // Used for Unicode and none Unicode
239 SalData *pSalData = GetSalData();
241 if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) )
243 if ( pSalData->mnSalObjWantKeyEvt == pMsg->wParam )
245 pSalData->mnSalObjWantKeyEvt = 0;
246 if ( pMsg->hwnd == ::GetFocus() )
248 ImplSalYieldMutexAcquireWithWait();
249 WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
250 if ( pFrame )
251 ImplHandleSalObjKeyMsg( pFrame->mhWnd, pMsg->message, pMsg->wParam, pMsg->lParam );
252 ImplSalYieldMutexRelease();
257 pSalData->mnSalObjWantKeyEvt = 0;
260 LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
262 WinSalObject* pSysObj;
263 LRESULT nRet = 0;
265 switch( nMsg )
267 case WM_ERASEBKGND:
268 nRet = 1;
269 rDef = FALSE;
270 break;
271 case WM_PAINT:
273 PAINTSTRUCT aPs;
274 BeginPaint( hWnd, &aPs );
275 EndPaint( hWnd, &aPs );
276 rDef = FALSE;
278 break;
280 case WM_PARENTNOTIFY:
282 UINT nNotifyMsg = LOWORD( wParam );
283 if ( (nNotifyMsg == WM_LBUTTONDOWN) ||
284 (nNotifyMsg == WM_RBUTTONDOWN) ||
285 (nNotifyMsg == WM_MBUTTONDOWN) )
287 ImplSalYieldMutexAcquireWithWait();
288 pSysObj = GetSalObjWindowPtr( hWnd );
289 if ( pSysObj && !pSysObj->IsMouseTransparent() )
290 pSysObj->CallCallback( SalObjEvent::ToTop );
291 ImplSalYieldMutexRelease();
294 break;
296 case WM_MOUSEACTIVATE:
298 ImplSalYieldMutexAcquireWithWait();
299 pSysObj = GetSalObjWindowPtr( hWnd );
300 if ( pSysObj && !pSysObj->IsMouseTransparent() )
302 BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
303 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
305 ImplSalYieldMutexRelease();
307 break;
309 case SALOBJ_MSG_TOTOP:
310 if ( ImplSalYieldMutexTryToAcquire() )
312 pSysObj = GetSalObjWindowPtr( hWnd );
313 pSysObj->CallCallback( SalObjEvent::ToTop );
314 ImplSalYieldMutexRelease();
315 rDef = FALSE;
317 else
319 BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
320 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
322 break;
324 case SALOBJ_MSG_POSTFOCUS:
325 if ( ImplSalYieldMutexTryToAcquire() )
327 pSysObj = GetSalObjWindowPtr( hWnd );
328 HWND hFocusWnd = ::GetFocus();
329 SalObjEvent nEvent;
330 if ( hFocusWnd && ImplIsSysWindowOrChild( hWnd, hFocusWnd ) )
331 nEvent = SalObjEvent::GetFocus;
332 else
333 nEvent = SalObjEvent::LoseFocus;
334 pSysObj->CallCallback( nEvent );
335 ImplSalYieldMutexRelease();
337 else
339 BOOL const ret = PostMessageW(hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
340 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
342 rDef = FALSE;
343 break;
345 case WM_SIZE:
347 HWND hWndChild = GetWindow( hWnd, GW_CHILD );
348 if ( hWndChild )
350 SetWindowPos( hWndChild,
351 nullptr, 0, 0, static_cast<int>(LOWORD( lParam )), static_cast<int>(HIWORD( lParam )),
352 SWP_NOZORDER | SWP_NOACTIVATE );
355 rDef = FALSE;
356 break;
358 case WM_CREATE:
360 // Save the window instance at the window handle.
361 // Can also be used for the A-Version, because the struct
362 // to access lpCreateParams is the same structure
363 CREATESTRUCTW* pStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
364 pSysObj = static_cast<WinSalObject*>(pStruct->lpCreateParams);
365 SetSalObjWindowPtr( hWnd, pSysObj );
366 // set HWND already here,
367 // as instance data might be used during CreateWindow() events
368 pSysObj->mhWnd = hWnd;
369 rDef = FALSE;
371 break;
374 return nRet;
377 LRESULT CALLBACK SalSysObjWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
379 int bDef = TRUE;
380 LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
381 if ( bDef )
382 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
383 return nRet;
386 LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
388 LRESULT nRet = 0;
390 switch( nMsg )
392 // clear background for plugins
393 case WM_ERASEBKGND:
395 WinSalObject* pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
397 if( pSysObj && !pSysObj->IsEraseBackgroundEnabled() )
399 // do not erase background
400 nRet = 1;
401 rDef = FALSE;
404 break;
406 case WM_PAINT:
408 PAINTSTRUCT aPs;
409 BeginPaint( hWnd, &aPs );
410 EndPaint( hWnd, &aPs );
411 rDef = FALSE;
413 break;
415 case WM_MOUSEMOVE:
416 case WM_LBUTTONDOWN:
417 case WM_MBUTTONDOWN:
418 case WM_RBUTTONDOWN:
419 case WM_LBUTTONUP:
420 case WM_MBUTTONUP:
421 case WM_RBUTTONUP:
423 WinSalObject* pSysObj;
424 pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
426 if( pSysObj && pSysObj->IsMouseTransparent() )
428 // forward mouse events to parent frame
429 HWND hWndParent = ::GetParent( pSysObj->mhWnd );
431 // transform coordinates
432 POINT pt;
433 pt.x = static_cast<long>(LOWORD( lParam ));
434 pt.y = static_cast<long>(HIWORD( lParam ));
435 MapWindowPoints( hWnd, hWndParent, &pt, 1 );
436 lParam = MAKELPARAM( static_cast<WORD>(pt.x), static_cast<WORD>(pt.y) );
438 nRet = SendMessageW( hWndParent, nMsg, wParam, lParam );
439 rDef = FALSE;
442 break;
445 return nRet;
448 LRESULT CALLBACK SalSysObjChildWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
450 int bDef = TRUE;
451 LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
452 if ( bDef )
453 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
454 return nRet;
457 SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent )
459 SalData* pSalData = GetSalData();
461 // install hook, if it is the first SalObject
462 if ( !pSalData->mpFirstObject )
464 pSalData->mhSalObjMsgHook = SetWindowsHookExW( WH_CALLWNDPROC,
465 SalSysMsgProc,
466 pSalData->mhInst,
467 pSalData->mnAppThreadId );
470 if ( !pSalData->mbObjClassInit )
472 WNDCLASSEXW aWndClassEx;
473 aWndClassEx.cbSize = sizeof( aWndClassEx );
474 aWndClassEx.style = 0;
475 aWndClassEx.lpfnWndProc = SalSysObjWndProcW;
476 aWndClassEx.cbClsExtra = 0;
477 aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
478 aWndClassEx.hInstance = pSalData->mhInst;
479 aWndClassEx.hIcon = nullptr;
480 aWndClassEx.hIconSm = nullptr;
481 aWndClassEx.hCursor = LoadCursor( nullptr, IDC_ARROW );
482 aWndClassEx.hbrBackground = nullptr;
483 aWndClassEx.lpszMenuName = nullptr;
484 aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEW;
485 if ( RegisterClassExW( &aWndClassEx ) )
487 // Clean background first because of plugins.
488 aWndClassEx.cbWndExtra = 0;
489 aWndClassEx.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
490 aWndClassEx.lpfnWndProc = SalSysObjChildWndProcW;
491 aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEW;
492 if ( RegisterClassExW( &aWndClassEx ) )
493 pSalData->mbObjClassInit = true;
497 if ( pSalData->mbObjClassInit )
499 WinSalObject* pObject = new WinSalObject;
501 // #135235# Clip siblings of this
502 // SystemChildWindow. Otherwise, DXCanvas (using a hidden
503 // SystemChildWindow) clobbers applets/plugins during
504 // animations .
505 HWND hWnd = CreateWindowExW( 0, SAL_OBJECT_CLASSNAMEW, L"",
506 WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0,
507 pParent->mhWnd, nullptr,
508 pInst->mhInst, pObject );
510 HWND hWndChild = nullptr;
511 if ( hWnd )
513 // #135235# Explicitly stack SystemChildWindows in
514 // the order they're created - since there's no notion
515 // of zorder.
516 SetWindowPos(hWnd,HWND_TOP,0,0,0,0,
517 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOSIZE);
518 hWndChild = CreateWindowExW( 0, SAL_OBJECT_CHILDCLASSNAMEW, L"",
519 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
520 0, 0, 0, 0,
521 hWnd, nullptr,
522 pInst->mhInst, nullptr );
525 if ( !hWndChild )
527 SAL_WARN("vcl", "CreateWindowExW failed: " << WindowsErrorString(GetLastError()));
529 delete pObject;
530 return nullptr;
533 if ( hWnd )
535 pObject->mhWnd = hWnd;
536 pObject->mhWndChild = hWndChild;
537 pObject->maSysData.hWnd = hWndChild;
538 return pObject;
542 return nullptr;
545 WinSalObject::WinSalObject()
547 SalData* pSalData = GetSalData();
549 mhWnd = nullptr;
550 mhWndChild = nullptr;
551 mhLastFocusWnd = nullptr;
552 maSysData.nSize = sizeof( SystemEnvData );
553 mpStdClipRgnData = nullptr;
555 // Insert object in objectlist
556 mpNextObject = pSalData->mpFirstObject;
557 pSalData->mpFirstObject = this;
560 WinSalObject::~WinSalObject()
562 SalData* pSalData = GetSalData();
564 // remove frame from framelist
565 if ( this == pSalData->mpFirstObject )
567 pSalData->mpFirstObject = mpNextObject;
569 // remove hook, if it is the last SalObject
570 if ( !pSalData->mpFirstObject )
571 UnhookWindowsHookEx( pSalData->mhSalObjMsgHook );
573 else
575 WinSalObject* pTempObject = pSalData->mpFirstObject;
576 while ( pTempObject->mpNextObject != this )
577 pTempObject = pTempObject->mpNextObject;
579 pTempObject->mpNextObject = mpNextObject;
582 // destroy cache data
583 delete [] reinterpret_cast<BYTE*>(mpStdClipRgnData);
585 HWND hWndParent = ::GetParent( mhWnd );
587 if ( mhWndChild )
588 DestroyWindow( mhWndChild );
589 if ( mhWnd )
590 DestroyWindow( mhWnd );
592 // reset palette, if no external child window is left,
593 // as they might have overwritten our palette
594 if ( hWndParent &&
595 ::GetActiveWindow() == hWndParent &&
596 !GetWindow( hWndParent, GW_CHILD ) )
597 SendMessageW( hWndParent, SAL_MSG_FORCEPALETTE, 0, 0 );
600 void WinSalObject::ResetClipRegion()
602 SetWindowRgn( mhWnd, nullptr, TRUE );
605 void WinSalObject::BeginSetClipRegion( sal_uLong nRectCount )
607 sal_uLong nRectBufSize = sizeof(RECT)*nRectCount;
608 if ( nRectCount < SAL_CLIPRECT_COUNT )
610 if ( !mpStdClipRgnData )
611 mpStdClipRgnData = reinterpret_cast<RGNDATA*>(new BYTE[sizeof(RGNDATA)-1+(SAL_CLIPRECT_COUNT*sizeof(RECT))]);
612 mpClipRgnData = mpStdClipRgnData;
614 else
615 mpClipRgnData = reinterpret_cast<RGNDATA*>(new BYTE[sizeof(RGNDATA)-1+nRectBufSize]);
616 mpClipRgnData->rdh.dwSize = sizeof( RGNDATAHEADER );
617 mpClipRgnData->rdh.iType = RDH_RECTANGLES;
618 mpClipRgnData->rdh.nCount = nRectCount;
619 mpClipRgnData->rdh.nRgnSize = nRectBufSize;
620 SetRectEmpty( &(mpClipRgnData->rdh.rcBound) );
621 mpNextClipRect = reinterpret_cast<RECT*>(&(mpClipRgnData->Buffer));
622 mbFirstClipRect = TRUE;
625 void WinSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
627 RECT* pRect = mpNextClipRect;
628 RECT* pBoundRect = &(mpClipRgnData->rdh.rcBound);
629 long nRight = nX + nWidth;
630 long nBottom = nY + nHeight;
632 if ( mbFirstClipRect )
634 pBoundRect->left = nX;
635 pBoundRect->top = nY;
636 pBoundRect->right = nRight;
637 pBoundRect->bottom = nBottom;
638 mbFirstClipRect = FALSE;
640 else
642 if ( nX < pBoundRect->left )
643 pBoundRect->left = static_cast<int>(nX);
645 if ( nY < pBoundRect->top )
646 pBoundRect->top = static_cast<int>(nY);
648 if ( nRight > pBoundRect->right )
649 pBoundRect->right = static_cast<int>(nRight);
651 if ( nBottom > pBoundRect->bottom )
652 pBoundRect->bottom = static_cast<int>(nBottom);
655 pRect->left = static_cast<int>(nX);
656 pRect->top = static_cast<int>(nY);
657 pRect->right = static_cast<int>(nRight);
658 pRect->bottom = static_cast<int>(nBottom);
659 mpNextClipRect++;
662 void WinSalObject::EndSetClipRegion()
664 HRGN hRegion;
666 // create a ClipRegion from the vcl::Region data
667 if ( mpClipRgnData->rdh.nCount == 1 )
669 RECT* pRect = &(mpClipRgnData->rdh.rcBound);
670 hRegion = CreateRectRgn( pRect->left, pRect->top,
671 pRect->right, pRect->bottom );
673 else
675 sal_uLong nSize = mpClipRgnData->rdh.nRgnSize+sizeof(RGNDATAHEADER);
676 hRegion = ExtCreateRegion( nullptr, nSize, mpClipRgnData );
677 if ( mpClipRgnData != mpStdClipRgnData )
678 delete [] reinterpret_cast<BYTE*>(mpClipRgnData);
681 SAL_WARN_IF( !hRegion, "vcl", "SalObject::EndSetClipRegion() - Can't create ClipRegion" );
682 SetWindowRgn( mhWnd, hRegion, TRUE );
685 void WinSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
687 sal_uLong nStyle = 0;
688 bool bVisible = (GetWindowStyle( mhWnd ) & WS_VISIBLE) != 0;
689 if ( bVisible )
691 ShowWindow( mhWnd, SW_HIDE );
692 nStyle |= SWP_SHOWWINDOW;
694 SetWindowPos( mhWnd, nullptr,
695 static_cast<int>(nX), static_cast<int>(nY), static_cast<int>(nWidth), static_cast<int>(nHeight),
696 SWP_NOZORDER | SWP_NOACTIVATE | nStyle );
699 void WinSalObject::Show( bool bVisible )
701 if ( bVisible )
702 ShowWindow( mhWnd, SW_SHOWNORMAL );
703 else
704 ShowWindow( mhWnd, SW_HIDE );
707 void WinSalObject::Enable( bool bEnable )
709 EnableWindow( mhWnd, bEnable );
712 void WinSalObject::GrabFocus()
714 if ( mhLastFocusWnd &&
715 IsWindow( mhLastFocusWnd ) &&
716 ImplIsSysWindowOrChild( mhWndChild, mhLastFocusWnd ) )
717 ::SetFocus( mhLastFocusWnd );
718 else
719 ::SetFocus( mhWndChild );
722 const SystemEnvData* WinSalObject::GetSystemData() const
724 return &maSysData;
727 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */