VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



FYI: Alt+Tab Icon Updating

by LaVolpe (66 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB Script
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

How do you change the icon that appears in the Alt+Tab window? This is nothing new can be found on MSDN. The notes I added here are of interest. More info for skinning forms. Changing a form's icon doesn't affect the Alt+Tab window; you need to change the icon in an upper level, hidden window. Code below shows how. Notes to keep in mind.... The icon does NOT have to be one assigned to a form! If not, the only thing to remember is to cache that icon handle and don't destroy it until your application closes or you reassign using the same code below. Should you not cache the icon, and it is destroyed, the Alt+Tab will show a "blank/invisible" icon instead.

Rate FYI: Alt+Tab Icon Updating

Public Sub SetApplicationIcon _
  (hIcon As Long, mainHwnd As Long)
' hIcon must be a 32x32 pixel icon
' mainHwnd can be any open form
' This will not work in IDE but 
' works when compiled
Dim tHwnd As Long, cParent As Long
Const ICON_BIG As Long = 1
Const GWL_HWNDPARENT = (-8)
' Get starting point
tHwnd = GetWindowLong(mainHwnd, GWL_HWNDPARENT)
' Get EXE's wrapper class 
' (all VB compiled apps have them)
Do While tHwnd
  cParent = tHwnd
  tHwnd = GetWindowLong(cParent, _
            GWL_HWNDPARENT)
Loop
On Error Resume Next
' tell the wrapper class what icon to use
PostMessage cParent, WM_SETICON, _
   ICON_BIG, ByVal hIcon
End Sub

Download this snippet    Add to My Saved Code

FYI: Alt+Tab Icon Updating Comments

No comments have been posted about FYI: Alt+Tab Icon Updating. Why not be the first to post a comment about FYI: Alt+Tab Icon Updating.

Post your comment

Subject:
Message:
0/1000 characters