ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Std XL icons on my Forms (https://www.excelbanter.com/excel-programming/388134-std-xl-icons-my-forms.html)

Graham Y

Std XL icons on my Forms
 
I am creating a little form and I wanted to add the standard question icon,
but I can't see how to do it.
Pointers (or some code) please.

RB Smissaert

Std XL icons on my Forms
 
In it's simplest form:

Put all this in the Userform code module:

Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function LoadStandardIcon Lib "user32" _
Alias "LoadIconA" _
(ByVal hInstance As Long, _
ByVal lpIconNum As
enStandardIconEnum) _
As Long
Private Declare Function DrawIcon Lib "user32" _
(ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal hIcon As Long) As Long
Private Enum enStandardIconEnum
IDI_APPLICATION = 32512&
IDI_ASTERISK = 32516&
IDI_EXCLAMATION = 32515&
IDI_HAND = 32513&
IDI_ERROR = IDI_HAND
IDI_INFORMATION = IDI_ASTERISK
IDI_QUESTION = 32514&
IDI_WARNING = IDI_EXCLAMATION
IDI_WINLOGO = 32517
End Enum

Private Sub CommandButton1_Click()

Dim hwnd As Long
Dim hdc As Long

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub

Load the form in the usual way and click the button.
You will have to work it out a bit further, but this should work.


RBS


"Graham Y" wrote in message
...
I am creating a little form and I wanted to add the standard question icon,
but I can't see how to do it.
Pointers (or some code) please.



RB Smissaert

Std XL icons on my Forms
 
Or you can do:

Private Sub UserForm_Activate()

Dim hwnd As Long
Dim hdc As Long

DoEvents 'this is needed

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub


RBS

"RB Smissaert" wrote in message
...
In it's simplest form:

Put all this in the Userform code module:

Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function LoadStandardIcon Lib "user32" _
Alias "LoadIconA" _
(ByVal hInstance As Long, _
ByVal lpIconNum As
enStandardIconEnum) _
As Long
Private Declare Function DrawIcon Lib "user32" _
(ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal hIcon As Long) As Long
Private Enum enStandardIconEnum
IDI_APPLICATION = 32512&
IDI_ASTERISK = 32516&
IDI_EXCLAMATION = 32515&
IDI_HAND = 32513&
IDI_ERROR = IDI_HAND
IDI_INFORMATION = IDI_ASTERISK
IDI_QUESTION = 32514&
IDI_WARNING = IDI_EXCLAMATION
IDI_WINLOGO = 32517
End Enum

Private Sub CommandButton1_Click()

Dim hwnd As Long
Dim hdc As Long

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub

Load the form in the usual way and click the button.
You will have to work it out a bit further, but this should work.


RBS


"Graham Y" wrote in message
...
I am creating a little form and I wanted to add the standard question
icon,
but I can't see how to do it.
Pointers (or some code) please.




Graham Y

Std XL icons on my Forms
 
Thanks that looks like what I was expecting I know nothing about API calls.
Thanks
Are there any good (free) resources of such info?

"RB Smissaert" wrote:

Or you can do:

Private Sub UserForm_Activate()

Dim hwnd As Long
Dim hdc As Long

DoEvents 'this is needed

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub


RBS

"RB Smissaert" wrote in message
...
In it's simplest form:

Put all this in the Userform code module:

Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function LoadStandardIcon Lib "user32" _
Alias "LoadIconA" _
(ByVal hInstance As Long, _
ByVal lpIconNum As
enStandardIconEnum) _
As Long
Private Declare Function DrawIcon Lib "user32" _
(ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal hIcon As Long) As Long
Private Enum enStandardIconEnum
IDI_APPLICATION = 32512&
IDI_ASTERISK = 32516&
IDI_EXCLAMATION = 32515&
IDI_HAND = 32513&
IDI_ERROR = IDI_HAND
IDI_INFORMATION = IDI_ASTERISK
IDI_QUESTION = 32514&
IDI_WARNING = IDI_EXCLAMATION
IDI_WINLOGO = 32517
End Enum

Private Sub CommandButton1_Click()

Dim hwnd As Long
Dim hdc As Long

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub

Load the form in the usual way and click the button.
You will have to work it out a bit further, but this should work.


RBS


"Graham Y" wrote in message
...
I am creating a little form and I wanted to add the standard question
icon,
but I can't see how to do it.
Pointers (or some code) please.





RB Smissaert

Std XL icons on my Forms
 
Yes, go to this site:
http://www.allapi.net/
and get the API guide.

RBS

"Graham Y" wrote in message
...
Thanks that looks like what I was expecting I know nothing about API
calls.
Thanks
Are there any good (free) resources of such info?

"RB Smissaert" wrote:

Or you can do:

Private Sub UserForm_Activate()

Dim hwnd As Long
Dim hdc As Long

DoEvents 'this is needed

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub


RBS

"RB Smissaert" wrote in message
...
In it's simplest form:

Put all this in the Userform code module:

Option Explicit
Private Declare Function FindWindow _
Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As
Long
Private Declare Function LoadStandardIcon Lib "user32" _
Alias "LoadIconA" _
(ByVal hInstance As Long, _
ByVal lpIconNum As
enStandardIconEnum) _
As Long
Private Declare Function DrawIcon Lib "user32" _
(ByVal hdc As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal hIcon As Long) As Long
Private Enum enStandardIconEnum
IDI_APPLICATION = 32512&
IDI_ASTERISK = 32516&
IDI_EXCLAMATION = 32515&
IDI_HAND = 32513&
IDI_ERROR = IDI_HAND
IDI_INFORMATION = IDI_ASTERISK
IDI_QUESTION = 32514&
IDI_WARNING = IDI_EXCLAMATION
IDI_WINLOGO = 32517
End Enum

Private Sub CommandButton1_Click()

Dim hwnd As Long
Dim hdc As Long

hwnd = FindWindow(vbNullString, Me.Caption)
hdc = GetDC(hwnd)

DrawIcon hdc, 10, 10&, LoadStandardIcon(0&, IDI_QUESTION)

End Sub

Load the form in the usual way and click the button.
You will have to work it out a bit further, but this should work.


RBS


"Graham Y" wrote in message
...
I am creating a little form and I wanted to add the standard question
icon,
but I can't see how to do it.
Pointers (or some code) please.






All times are GMT +1. The time now is 01:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com