Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / vcl / win / window / salobj.cxx
blob9840994bc9faeb658713769eb55acd76fddab346
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>
25 #include <sal/log.hxx>
27 #include <win/wincomp.hxx>
28 #include <win/saldata.hxx>
29 #include <win/salinst.h>
30 #include <win/salframe.h>
31 #include <win/salobj.h>
33 #include <comphelper/windowserrorstring.hxx>
35 static bool ImplIsSysWindowOrChild( HWND hWndParent, HWND hWndChild )
37 if ( hWndParent == hWndChild )
38 return TRUE;
40 HWND hTempWnd = ::GetParent( hWndChild );
41 while ( hTempWnd )
43 // stop searching if not a child window
44 if ( !(GetWindowStyle( hTempWnd ) & WS_CHILD) )
45 return FALSE;
46 if ( hTempWnd == hWndParent )
47 return TRUE;
48 hTempWnd = ::GetParent( hTempWnd );
51 return FALSE;
54 WinSalObject* ImplFindSalObject( HWND hWndChild )
56 SalData* pSalData = GetSalData();
57 WinSalObject* pObject = pSalData->mpFirstObject;
58 while ( pObject )
60 if ( ImplIsSysWindowOrChild( pObject->mhWndChild, hWndChild ) )
61 return pObject;
63 pObject = pObject->mpNextObject;
66 return nullptr;
69 static WinSalFrame* ImplFindSalObjectFrame( HWND hWnd )
71 WinSalFrame* pFrame = nullptr;
72 WinSalObject* pObject = ImplFindSalObject( hWnd );
73 if ( pObject )
75 // find matching frame
76 HWND hWnd2 = ::GetParent( pObject->mhWnd );
77 pFrame = GetSalData()->mpFirstFrame;
78 while ( pFrame )
80 if ( pFrame->mhWnd == hWnd2 )
81 break;
83 pFrame = pFrame->mpNextFrame;
87 return pFrame;
90 static LRESULT CALLBACK SalSysMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
92 // Used for Unicode and none Unicode
93 SalData* pSalData = GetSalData();
95 if ( (nCode >= 0) && lParam )
97 CWPSTRUCT* pData = reinterpret_cast<CWPSTRUCT*>(lParam);
98 if ( (pData->message != WM_KEYDOWN) &&
99 (pData->message != WM_KEYUP) )
100 pSalData->mnSalObjWantKeyEvt = 0;
103 // check if we need to process data for a SalObject-window
104 WinSalObject* pObject;
105 if ( pData->message == WM_SETFOCUS )
107 pObject = ImplFindSalObject( pData->hwnd );
108 if ( pObject )
110 pObject->mhLastFocusWnd = pData->hwnd;
111 if ( ImplSalYieldMutexTryToAcquire() )
113 pObject->CallCallback( SalObjEvent::GetFocus );
114 ImplSalYieldMutexRelease();
116 else
118 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
119 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
123 else if ( pData->message == WM_KILLFOCUS )
125 pObject = ImplFindSalObject( pData->hwnd );
126 if ( pObject && !ImplFindSalObject( reinterpret_cast<HWND>(pData->wParam) ) )
128 // only call LoseFocus, if truly no child window gets the focus
129 if ( !pData->wParam || !ImplFindSalObject( reinterpret_cast<HWND>(pData->wParam) ) )
131 if ( ImplSalYieldMutexTryToAcquire() )
133 pObject->CallCallback( SalObjEvent::LoseFocus );
134 ImplSalYieldMutexRelease();
136 else
138 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
139 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
142 else
143 pObject->mhLastFocusWnd = reinterpret_cast<HWND>(pData->wParam);
148 return CallNextHookEx( pSalData->mhSalObjMsgHook, nCode, wParam, lParam );
151 bool ImplSalPreDispatchMsg( const MSG* pMsg )
153 // Used for Unicode and none Unicode
154 SalData* pSalData = GetSalData();
155 WinSalObject* pObject;
157 if ( (pMsg->message == WM_LBUTTONDOWN) ||
158 (pMsg->message == WM_RBUTTONDOWN) ||
159 (pMsg->message == WM_MBUTTONDOWN) )
161 ImplSalYieldMutexAcquireWithWait();
162 pObject = ImplFindSalObject( pMsg->hwnd );
163 if ( pObject && !pObject->IsMouseTransparent() )
165 BOOL const ret = PostMessageW(pObject->mhWnd, SALOBJ_MSG_TOTOP, 0, 0);
166 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
168 ImplSalYieldMutexRelease();
171 if ( (pMsg->message == WM_KEYDOWN) ||
172 (pMsg->message == WM_KEYUP) )
174 // process KeyEvents even if the control does not process them itself
175 // SysKeys are processed as WM_SYSCOMMAND
176 // Char-Events are not processed, as they are not accelerator-relevant
177 bool bWantedKeyCode = FALSE;
178 // A-Z, 0-9 only when combined with the Control-key
179 if ( ((pMsg->wParam >= 65) && (pMsg->wParam <= 90)) ||
180 ((pMsg->wParam >= 48) && (pMsg->wParam <= 57)) )
182 if ( GetKeyState( VK_CONTROL ) & 0x8000 )
183 bWantedKeyCode = TRUE;
185 else if ( ((pMsg->wParam >= VK_F1) && (pMsg->wParam <= VK_F24)) ||
186 ((pMsg->wParam >= VK_SPACE) && (pMsg->wParam <= VK_HELP)) ||
187 (pMsg->wParam == VK_BACK) || (pMsg->wParam == VK_TAB) ||
188 (pMsg->wParam == VK_CLEAR) || (pMsg->wParam == VK_RETURN) ||
189 (pMsg->wParam == VK_ESCAPE) )
190 bWantedKeyCode = TRUE;
191 if ( bWantedKeyCode )
193 ImplSalYieldMutexAcquireWithWait();
194 pObject = ImplFindSalObject( pMsg->hwnd );
195 if ( pObject )
196 pSalData->mnSalObjWantKeyEvt = pMsg->wParam;
197 ImplSalYieldMutexRelease();
200 // check WM_SYSCHAR, to activate menu with Alt key
201 else if ( pMsg->message == WM_SYSCHAR )
203 pSalData->mnSalObjWantKeyEvt = 0;
205 sal_uInt16 nKeyCode = LOWORD( pMsg->wParam );
206 // only 0-9 and A-Z
207 if ( ((nKeyCode >= 48) && (nKeyCode <= 57)) ||
208 ((nKeyCode >= 65) && (nKeyCode <= 90)) ||
209 ((nKeyCode >= 97) && (nKeyCode <= 122)) )
211 bool bRet = FALSE;
212 ImplSalYieldMutexAcquireWithWait();
213 pObject = ImplFindSalObject( pMsg->hwnd );
214 if ( pObject )
216 if ( pMsg->hwnd == ::GetFocus() )
218 WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
219 if ( pFrame )
221 if ( ImplHandleSalObjSysCharMsg( pFrame->mhWnd, pMsg->wParam, pMsg->lParam ) )
222 bRet = TRUE;
226 ImplSalYieldMutexRelease();
227 if ( bRet )
228 return TRUE;
231 else
232 pSalData->mnSalObjWantKeyEvt = 0;
234 return FALSE;
237 void ImplSalPostDispatchMsg( const MSG* pMsg )
239 // Used for Unicode and none Unicode
240 SalData *pSalData = GetSalData();
242 if ( (pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP) )
244 if ( pSalData->mnSalObjWantKeyEvt == pMsg->wParam )
246 pSalData->mnSalObjWantKeyEvt = 0;
247 if ( pMsg->hwnd == ::GetFocus() )
249 ImplSalYieldMutexAcquireWithWait();
250 WinSalFrame* pFrame = ImplFindSalObjectFrame( pMsg->hwnd );
251 if ( pFrame )
252 ImplHandleSalObjKeyMsg( pFrame->mhWnd, pMsg->message, pMsg->wParam, pMsg->lParam );
253 ImplSalYieldMutexRelease();
258 pSalData->mnSalObjWantKeyEvt = 0;
261 static LRESULT CALLBACK SalSysObjWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
263 WinSalObject* pSysObj;
264 LRESULT nRet = 0;
266 switch( nMsg )
268 case WM_ERASEBKGND:
269 nRet = 1;
270 rDef = FALSE;
271 break;
272 case WM_PAINT:
274 PAINTSTRUCT aPs;
275 BeginPaint( hWnd, &aPs );
276 EndPaint( hWnd, &aPs );
277 rDef = FALSE;
279 break;
281 case WM_PARENTNOTIFY:
283 UINT nNotifyMsg = LOWORD( wParam );
284 if ( (nNotifyMsg == WM_LBUTTONDOWN) ||
285 (nNotifyMsg == WM_RBUTTONDOWN) ||
286 (nNotifyMsg == WM_MBUTTONDOWN) )
288 ImplSalYieldMutexAcquireWithWait();
289 pSysObj = GetSalObjWindowPtr( hWnd );
290 if ( pSysObj && !pSysObj->IsMouseTransparent() )
291 pSysObj->CallCallback( SalObjEvent::ToTop );
292 ImplSalYieldMutexRelease();
295 break;
297 case WM_MOUSEACTIVATE:
299 ImplSalYieldMutexAcquireWithWait();
300 pSysObj = GetSalObjWindowPtr( hWnd );
301 if ( pSysObj && !pSysObj->IsMouseTransparent() )
303 BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
304 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
306 ImplSalYieldMutexRelease();
308 break;
310 case SALOBJ_MSG_TOTOP:
311 if ( ImplSalYieldMutexTryToAcquire() )
313 pSysObj = GetSalObjWindowPtr( hWnd );
314 pSysObj->CallCallback( SalObjEvent::ToTop );
315 ImplSalYieldMutexRelease();
316 rDef = FALSE;
318 else
320 BOOL const ret = PostMessageW( hWnd, SALOBJ_MSG_TOTOP, 0, 0 );
321 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
323 break;
325 case SALOBJ_MSG_POSTFOCUS:
326 if ( ImplSalYieldMutexTryToAcquire() )
328 pSysObj = GetSalObjWindowPtr( hWnd );
329 HWND hFocusWnd = ::GetFocus();
330 SalObjEvent nEvent;
331 if ( hFocusWnd && ImplIsSysWindowOrChild( hWnd, hFocusWnd ) )
332 nEvent = SalObjEvent::GetFocus;
333 else
334 nEvent = SalObjEvent::LoseFocus;
335 pSysObj->CallCallback( nEvent );
336 ImplSalYieldMutexRelease();
338 else
340 BOOL const ret = PostMessageW(hWnd, SALOBJ_MSG_POSTFOCUS, 0, 0);
341 SAL_WARN_IF(0 == ret, "vcl", "ERROR: PostMessage() failed!");
343 rDef = FALSE;
344 break;
346 case WM_SIZE:
348 HWND hWndChild = GetWindow( hWnd, GW_CHILD );
349 if ( hWndChild )
351 SetWindowPos( hWndChild,
352 nullptr, 0, 0, static_cast<int>(LOWORD( lParam )), static_cast<int>(HIWORD( lParam )),
353 SWP_NOZORDER | SWP_NOACTIVATE );
356 rDef = FALSE;
357 break;
359 case WM_CREATE:
361 // Save the window instance at the window handle.
362 // Can also be used for the A-Version, because the struct
363 // to access lpCreateParams is the same structure
364 CREATESTRUCTW* pStruct = reinterpret_cast<CREATESTRUCTW*>(lParam);
365 pSysObj = static_cast<WinSalObject*>(pStruct->lpCreateParams);
366 SetSalObjWindowPtr( hWnd, pSysObj );
367 // set HWND already here,
368 // as instance data might be used during CreateWindow() events
369 pSysObj->mhWnd = hWnd;
370 rDef = FALSE;
372 break;
375 return nRet;
378 static LRESULT CALLBACK SalSysObjWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
380 int bDef = TRUE;
381 LRESULT nRet = SalSysObjWndProc( hWnd, nMsg, wParam, lParam, bDef );
382 if ( bDef )
383 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
384 return nRet;
387 static LRESULT CALLBACK SalSysObjChildWndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam, int& rDef )
389 LRESULT nRet = 0;
391 switch( nMsg )
393 // clear background for plugins
394 case WM_ERASEBKGND:
396 WinSalObject* pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
398 if( pSysObj && !pSysObj->IsEraseBackgroundEnabled() )
400 // do not erase background
401 nRet = 1;
402 rDef = FALSE;
405 break;
407 case WM_PAINT:
409 PAINTSTRUCT aPs;
410 BeginPaint( hWnd, &aPs );
411 EndPaint( hWnd, &aPs );
412 rDef = FALSE;
414 break;
416 case WM_MOUSEMOVE:
417 case WM_LBUTTONDOWN:
418 case WM_MBUTTONDOWN:
419 case WM_RBUTTONDOWN:
420 case WM_LBUTTONUP:
421 case WM_MBUTTONUP:
422 case WM_RBUTTONUP:
424 WinSalObject* pSysObj;
425 pSysObj = GetSalObjWindowPtr( ::GetParent( hWnd ) );
427 if( pSysObj && pSysObj->IsMouseTransparent() )
429 // forward mouse events to parent frame
430 HWND hWndParent = ::GetParent( pSysObj->mhWnd );
432 // transform coordinates
433 POINT pt;
434 pt.x = static_cast<long>(LOWORD( lParam ));
435 pt.y = static_cast<long>(HIWORD( lParam ));
436 MapWindowPoints( hWnd, hWndParent, &pt, 1 );
437 lParam = MAKELPARAM( static_cast<WORD>(pt.x), static_cast<WORD>(pt.y) );
439 nRet = SendMessageW( hWndParent, nMsg, wParam, lParam );
440 rDef = FALSE;
443 break;
446 return nRet;
449 static LRESULT CALLBACK SalSysObjChildWndProcW( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam )
451 int bDef = TRUE;
452 LRESULT nRet = SalSysObjChildWndProc( hWnd, nMsg, wParam, lParam, bDef );
453 if ( bDef )
454 nRet = DefWindowProcW( hWnd, nMsg, wParam, lParam );
455 return nRet;
458 SalObject* ImplSalCreateObject( WinSalInstance* pInst, WinSalFrame* pParent )
460 SalData* pSalData = GetSalData();
462 // install hook, if it is the first SalObject
463 if ( !pSalData->mpFirstObject )
465 pSalData->mhSalObjMsgHook = SetWindowsHookExW( WH_CALLWNDPROC,
466 SalSysMsgProc,
467 pSalData->mhInst,
468 pSalData->mnAppThreadId );
471 if ( !pSalData->mbObjClassInit )
473 WNDCLASSEXW aWndClassEx;
474 aWndClassEx.cbSize = sizeof( aWndClassEx );
475 aWndClassEx.style = 0;
476 aWndClassEx.lpfnWndProc = SalSysObjWndProcW;
477 aWndClassEx.cbClsExtra = 0;
478 aWndClassEx.cbWndExtra = SAL_OBJECT_WNDEXTRA;
479 aWndClassEx.hInstance = pSalData->mhInst;
480 aWndClassEx.hIcon = nullptr;
481 aWndClassEx.hIconSm = nullptr;
482 aWndClassEx.hCursor = LoadCursor( nullptr, IDC_ARROW );
483 aWndClassEx.hbrBackground = nullptr;
484 aWndClassEx.lpszMenuName = nullptr;
485 aWndClassEx.lpszClassName = SAL_OBJECT_CLASSNAMEW;
486 if ( RegisterClassExW( &aWndClassEx ) )
488 // Clean background first because of plugins.
489 aWndClassEx.cbWndExtra = 0;
490 aWndClassEx.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
491 aWndClassEx.lpfnWndProc = SalSysObjChildWndProcW;
492 aWndClassEx.lpszClassName = SAL_OBJECT_CHILDCLASSNAMEW;
493 if ( RegisterClassExW( &aWndClassEx ) )
494 pSalData->mbObjClassInit = true;
498 if ( pSalData->mbObjClassInit )
500 WinSalObject* pObject = new WinSalObject;
502 // #135235# Clip siblings of this
503 // SystemChildWindow. Otherwise, DXCanvas (using a hidden
504 // SystemChildWindow) clobbers applets/plugins during
505 // animations .
506 HWND hWnd = CreateWindowExW( 0, SAL_OBJECT_CLASSNAMEW, L"",
507 WS_CHILD | WS_CLIPSIBLINGS, 0, 0, 0, 0,
508 pParent->mhWnd, nullptr,
509 pInst->mhInst, pObject );
511 HWND hWndChild = nullptr;
512 if ( hWnd )
514 // #135235# Explicitly stack SystemChildWindows in
515 // the order they're created - since there's no notion
516 // of zorder.
517 SetWindowPos(hWnd,HWND_TOP,0,0,0,0,
518 SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOSIZE);
519 hWndChild = CreateWindowExW( 0, SAL_OBJECT_CHILDCLASSNAMEW, L"",
520 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
521 0, 0, 0, 0,
522 hWnd, nullptr,
523 pInst->mhInst, nullptr );
526 if ( !hWndChild )
528 SAL_WARN("vcl", "CreateWindowExW failed: " << WindowsErrorString(GetLastError()));
530 delete pObject;
531 return nullptr;
534 if ( hWnd )
536 pObject->mhWnd = hWnd;
537 pObject->mhWndChild = hWndChild;
538 pObject->maSysData.hWnd = hWndChild;
539 return pObject;
543 return nullptr;
546 WinSalObject::WinSalObject()
548 SalData* pSalData = GetSalData();
550 mhWnd = nullptr;
551 mhWndChild = nullptr;
552 mhLastFocusWnd = nullptr;
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_uInt32 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: */