1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <tools/debug.hxx>
22 #include <win/saldata.hxx>
24 SalShlData aSalShlData
;
26 extern "C" BOOL WINAPI
DllMain(HINSTANCE hInst
, DWORD nReason
, LPVOID
)
28 if ( nReason
== DLL_PROCESS_ATTACH
)
29 aSalShlData
.mhInst
= hInst
;
33 HCURSOR
ImplLoadSalCursor( int nId
)
35 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
37 HCURSOR hCursor
= LoadCursor( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
39 DBG_ASSERT( hCursor
, "cursor not found in sal resource" );
44 HBITMAP
ImplLoadSalBitmap( int nId
)
46 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
48 HBITMAP hBitmap
= LoadBitmap( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
50 DBG_ASSERT( hBitmap
, "bitmap not found in sal resource" );
55 bool ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
)
57 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
59 SalData
* pSalData
= GetSalData();
61 // check the cache first
62 SalIcon
*pSalIcon
= pSalData
->mpFirstIcon
;
65 if( pSalIcon
->nId
!= nId
)
66 pSalIcon
= pSalIcon
->pNext
;
69 rIcon
= pSalIcon
->hIcon
;
70 rSmallIcon
= pSalIcon
->hSmallIcon
;
71 return (rSmallIcon
!= 0);
75 // Try at first to load the icons from the application exe file
76 rIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
77 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
81 // If the application don't provide these icons, then we try
82 // to load the icon from the VCL resource
83 rIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
84 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
88 rSmallIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
89 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
97 rSmallIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
98 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
105 pSalIcon
= new SalIcon();
107 pSalIcon
->hIcon
= rIcon
;
108 pSalIcon
->hSmallIcon
= rSmallIcon
;
109 pSalIcon
->pNext
= pSalData
->mpFirstIcon
;
110 pSalData
->mpFirstIcon
= pSalIcon
;
113 return (rSmallIcon
!= 0);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */