' Load the application's form and application icons
' from a resource file.
Private Sub SetApplicationIcons()
Dim hIcon As Long
Dim app_hwnd As Long
' Load the form's icon.
Me.Icon = LoadResPicture("FORMICON", vbResIcon)
' Load the big icon and get its handle.
picBigIcon.AutoRedraw = True
picBigIcon.AutoSize = True
picBigIcon.Visible = False
picBigIcon.Picture = LoadResPicture("APPICON", _
vbResIcon)
hIcon = picBigIcon.Picture
' Set the big icon for the topmost window.
app_hwnd = TopmostWindowHandle(Me)
SendMessage app_hwnd, WM_SETICON, ICON_BIG, ByVal hIcon
End Sub
' Return this window's topmost window's handle.
Private Function TopmostWindowHandle(ByVal frm As Form) As _
Long
Dim status As Long
Dim app_hwnd As Long
' Get the topmost window's handle.
status = GetWindowLong(frm.hWnd, GWL_HWNDPARENT)
Do While status <> 0
app_hwnd = status
status = GetWindowLong(app_hwnd, GWL_HWNDPARENT)
Loop
TopmostWindowHandle = app_hwnd
End Function
|