Originally Posted by Nox ferocia
using vb6 I wanted to dynamically assign the form icon based on the user enviroment setting
In regard to your question:
"must I add each resolution seperately?" - you don't have to, it's up to you
To detect for a resolution change the windows message you are looking for is WM_DISPLAYCHANGE. Here's some subclassing code:
The Screen object also has this info. You could put a detect routine in your form load or have it run as a loop in a timer:
There's also the GetSystemMetrics
with the SM_CYSCREEN parameter.
As regards using different icons in VB, here's some reading:
"Working with Icons in VB"
You can also use the SendMessage
API to change your form's icon at runtime:
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Declare Function DestroyIcon Lib "user32" _
(ByVal hIcon As Long) As Long
Declare Function LoadImage Lib "user32" Alias "LoadImageA" _
(ByVal hInst As Long, ByVal lpsz As String, _
ByVal un1 As Long, ByVal n1 As Long, _
ByVal n2 As Long, ByVal un2 As Long) As Long
Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Public Const WM_SETICON = &H80
Public Const ICON_SMALL = 0
Public Const IMAGE_ICON = 1
Public Const LR_LOADFROMFILE = &H10
Private Sub Form_Open(Cancel As Integer)
SendMessage Me.hwnd, WM_SETICON, ICON_SMALL, _
LoadImage(0, "C:\TEST.ICO", IMAGE_ICON, 0, 0, LR_LOADFROMFILE)
Private Sub Form_Close()
Dim hIcon As Long
hIcon = SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0)
If hIcon <> 0 Then DestroyIcon hIcon
from this Russian page:
Which is similiar to the code in this Microsoft article:
"How to Associate a Custom Icon with a Form"
...or you can use an external dll to store your icon resources and load them at runtime.
Using resources located in an external dll file
In the above link note the use of "Private Const ICON_BIG = 1"
A little extra info (tips):
When storing icons in the Imagelist control (so they become part of the frx file and are compiled with your exe): "Always use the 'custom' setting for the imagelist size. I once used the predefined 16x16 size and it was messing my icons up, but when I removed them all and set it to a custom they came out much better."
In regard to getting at (loading) different sizes of icons the second parameter of LoadPicture determines the icon size loaded (vbLPSmall, vbLPLarge, vbLPSmallShell, vbLPLargeShell):
Visible Cues from a Minimized Form
Suppose you want a form to perform a task while minimized, then notify the user without a message box and while remaining minimized. You can send a message via a changing icon on the minimized form in the taskbar.
Create a form containing a timer and an image list. Set the timer's Interval property to 2000, then use the ImageList control's Custom property to add three images. Finally, add this code to the Timer event:
Private Sub Timer1_Timer()
Static iImage As Integer
iImage = iImage + 1
If iImage > 3 Then iImage = 1
Me.Icon = ImageList1.ListImages(iImage).Picture
(from angelfire site with popup - sorry):
In regard to your last question
how I might provide the user with a button to set my application as the default for files of the type it uses
"Creating and associating my own file type"