1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
30 #include <tools/svwin.h>
31 #include <saldata.hxx>
32 #include <tools/debug.hxx>
34 // =======================================================================
36 SalShlData aSalShlData
;
38 // =======================================================================
46 sal_Bool WINAPI
DllMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
51 BOOL WINAPI
_CRT_INIT( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
);
54 BOOL WINAPI
LibMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
57 // Unsere DLL-Initialisierung
58 if ( nReason
== DLL_PROCESS_ATTACH
)
59 aSalShlData
.mhInst
= hInst
;
63 if ( _CRT_init() == -1 )
65 if ( !_CRT_INIT( hInst
, nReason
, pReserved
) )
77 // =======================================================================
79 HCURSOR
ImplLoadSalCursor( int nId
)
81 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
83 HCURSOR hCursor
= LoadCursor( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
85 DBG_ASSERT( hCursor
, "cursor not found in sal resource" );
90 // -----------------------------------------------------------------------
92 HBITMAP
ImplLoadSalBitmap( int nId
)
94 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
96 HBITMAP hBitmap
= LoadBitmap( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
98 DBG_ASSERT( hBitmap
, "bitmap not found in sal resource" );
103 // -----------------------------------------------------------------------
105 sal_Bool
ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
)
107 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
109 SalData
* pSalData
= GetSalData();
111 // check the cache first
112 SalIcon
*pSalIcon
= pSalData
->mpFirstIcon
;
115 if( pSalIcon
->nId
!= nId
)
116 pSalIcon
= pSalIcon
->pNext
;
119 rIcon
= pSalIcon
->hIcon
;
120 rSmallIcon
= pSalIcon
->hSmallIcon
;
121 return (rSmallIcon
!= 0);
125 // Try at first to load the icons from the application exe file
126 rIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
127 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
131 // If the application don't provide these icons, then we try
132 // to load the icon from the VCL resource
133 rIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
134 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
138 rSmallIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
139 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
147 rSmallIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
148 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
155 pSalIcon
= new SalIcon();
157 pSalIcon
->hIcon
= rIcon
;
158 pSalIcon
->hSmallIcon
= rSmallIcon
;
159 pSalIcon
->pNext
= pSalData
->mpFirstIcon
;
160 pSalData
->mpFirstIcon
= pSalIcon
;
163 return (rSmallIcon
!= 0);