1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salshl.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
33 #include <tools/svwin.h>
34 #include <saldata.hxx>
35 #include <tools/debug.hxx>
37 // =======================================================================
39 SalShlData aSalShlData
;
41 // =======================================================================
49 BOOL WINAPI
DllMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
54 WIN_BOOL WINAPI
_CRT_INIT( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
);
57 WIN_BOOL WINAPI
LibMain( HINSTANCE hInst
, DWORD nReason
, LPVOID pReserved
)
60 // Unsere DLL-Initialisierung
61 if ( nReason
== DLL_PROCESS_ATTACH
)
62 aSalShlData
.mhInst
= hInst
;
66 if ( _CRT_init() == -1 )
68 if ( !_CRT_INIT( hInst
, nReason
, pReserved
) )
80 // =======================================================================
82 HCURSOR
ImplLoadSalCursor( int nId
)
84 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
86 HCURSOR hCursor
= LoadCursor( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
88 DBG_ASSERT( hCursor
, "cursor not found in sal resource" );
93 // -----------------------------------------------------------------------
95 HBITMAP
ImplLoadSalBitmap( int nId
)
97 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
99 HBITMAP hBitmap
= LoadBitmap( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
) );
101 DBG_ASSERT( hBitmap
, "bitmap not found in sal resource" );
106 // -----------------------------------------------------------------------
108 BOOL
ImplLoadSalIcon( int nId
, HICON
& rIcon
, HICON
& rSmallIcon
)
110 DBG_ASSERT( aSalShlData
.mhInst
, "no DLL instance handle" );
112 SalData
* pSalData
= GetSalData();
114 // check the cache first
115 SalIcon
*pSalIcon
= pSalData
->mpFirstIcon
;
118 if( pSalIcon
->nId
!= nId
)
119 pSalIcon
= pSalIcon
->pNext
;
122 rIcon
= pSalIcon
->hIcon
;
123 rSmallIcon
= pSalIcon
->hSmallIcon
;
124 return (rSmallIcon
!= 0);
128 // Try at first to load the icons from the application exe file
129 rIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
130 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
134 // If the application don't provide these icons, then we try
135 // to load the icon from the VCL resource
136 rIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
137 IMAGE_ICON
, GetSystemMetrics( SM_CXICON
), GetSystemMetrics( SM_CYICON
),
141 rSmallIcon
= (HICON
)LoadImage( aSalShlData
.mhInst
, MAKEINTRESOURCE( nId
),
142 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
150 rSmallIcon
= (HICON
)LoadImage( pSalData
->mhInst
, MAKEINTRESOURCE( nId
),
151 IMAGE_ICON
, GetSystemMetrics( SM_CXSMICON
), GetSystemMetrics( SM_CYSMICON
),
158 pSalIcon
= new SalIcon();
160 pSalIcon
->hIcon
= rIcon
;
161 pSalIcon
->hSmallIcon
= rSmallIcon
;
162 pSalIcon
->pNext
= pSalData
->mpFirstIcon
;
163 pSalData
->mpFirstIcon
= pSalIcon
;
166 return (rSmallIcon
!= 0);