Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




CommitLineData
b31da37a 1Attribute VB_Name = "FixWindowIcon"\r
2Option Explicit\r
3\r
4Private Const WM_SETICON = &H80\r
5Private Const ICON_SMALL = 0\r
6Private Const IMAGE_ICON = 1\r
7Private Const LR_DEFAULTSIZE = &H40\r
8\r
9Private Declare Function GetModuleHandle Lib "Kernel32.dll" _\r
10 Alias "GetModuleHandleA" _\r
11 (ByRef lpModuleName As Any) As Long\r
12Private Declare Function LoadImage Lib "User32.dll" _\r
13 Alias "LoadImageA" ( _\r
14 ByVal hinst As Long, _\r
15 ByRef lpszName As Any, _\r
16 ByVal uType As Long, _\r
17 ByVal cxDesired As Long, _\r
18 ByVal cyDesired As Long, _\r
19 ByVal fuLoad As Long) As Long\r
20Private Declare Function SendMessageA Lib _\r
21 "User32.dll" _\r
22 (ByVal hWnd As Long, _\r
23 ByVal Msg As Long, _\r
24 ByVal Wp As Long, _\r
25 Lp As Any) As Long\r
26\r
27Sub FixIcon(hWnd As Long, lpszName)\r
28Dim hModule As Long, hIcon As Long, szName As String, nName As Long, Width As Long, Height As Long\r
29hModule = GetModuleHandle(ByVal 0&)\r
30If hModule = 0 Then Exit Sub\r
31Width = Abs(GetReg("HKEY_USERS\.Default\Control Panel\Desktop\WindowMetrics\CaptionWidth", -270)) / Screen.TwipsPerPixelX - 2\r
32Height = Abs(GetReg("HKEY_USERS\.Default\Control Panel\Desktop\WindowMetrics\CaptionHeight", -270)) / Screen.TwipsPerPixelY - 2\r
33If VarType(lpszName) = vbString Then\r
34 szName = lpszName\r
35 hIcon = LoadImage(hModule, szName, IMAGE_ICON, Width, Height, LR_DEFAULTSIZE)\r
36ElseIf VarType(lpszName) = vbByte Or VarType(lpszName) = vbInteger Or VarType(lpszName) = vbLong Then\r
37 nName = lpszName\r
38 hIcon = LoadImage(hModule, ByVal nName, IMAGE_ICON, Width, Height, LR_DEFAULTSIZE)\r
39End If\r
40If hIcon = 0 Then Exit Sub\r
41SendMessageA hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon\r
42End Sub\r