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 .
22 #include <tools/debug.hxx>
23 #include <win/saldata.hxx>
25 // =======================================================================
27 SalShlData aSalShlData
;
29 // =======================================================================
35 sal_Bool WINAPI
DllMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
40 BOOL WINAPI
_CRT_INIT( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
);
43 BOOL WINAPI
LibMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
46 // Unsere DLL-Initialisierung
47 if ( nReason
== DLL_PROCESS_ATTACH
)
48 aSalShlData
.mhInst
= hInst
;
52 if ( _CRT_init() == -1 )
54 if ( !_CRT_INIT( hInst
, nReason
, pReserved
) )
65 // =======================================================================
67 HCURSOR
ImplLoadSalCursor( int nId
)
69 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
71 HCURSOR hCursor
= LoadCursor( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
73 DBG_ASSERT( hCursor
, "cursor not found in sal resource" );
78 // -----------------------------------------------------------------------
80 HBITMAP
ImplLoadSalBitmap( int nId
)
82 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
84 HBITMAP hBitmap
= LoadBitmap( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
86 DBG_ASSERT( hBitmap
, "bitmap not found in sal resource" );
91 // -----------------------------------------------------------------------
93 sal_Bool
ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
)
95 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
97 SalData
* pSalData
= GetSalData();
99 // check the cache first
100 SalIcon
*pSalIcon
= pSalData
->mpFirstIcon
;
103 if( pSalIcon
->nId
!= nId
)
104 pSalIcon
= pSalIcon
->pNext
;
107 rIcon
= pSalIcon
->hIcon
;
108 rSmallIcon
= pSalIcon
->hSmallIcon
;
109 return (rSmallIcon
!= 0);
113 // Try at first to load the icons from the application exe file
114 rIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
115 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
119 // If the application don't provide these icons, then we try
120 // to load the icon from the VCL resource
121 rIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
122 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
126 rSmallIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
127 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
135 rSmallIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
136 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
143 pSalIcon
= new SalIcon();
145 pSalIcon
->hIcon
= rIcon
;
146 pSalIcon
->hSmallIcon
= rSmallIcon
;
147 pSalIcon
->pNext
= pSalData
->mpFirstIcon
;
148 pSalData
->mpFirstIcon
= pSalIcon
;
151 return (rSmallIcon
!= 0);
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */