Userform with logo and without closebtn
Hi Klaus,
To make simple, in a standard module:
Private Declare Function FindWindow& Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName$ _
, ByVal lpWindowName$)
Private Declare Function SendMessage& Lib "user32" _
Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg& _
, ByVal wParam&, lParam As Any)
Private Declare Function RemoveMenu& Lib "user32" _
(ByVal hMenu&, ByVal nPosition&, ByVal wFlags&)
Private Declare Function GetSystemMenu& Lib "user32" _
(ByVal hWnd&, ByVal bRevert&)
Private Sub ChangeMenuBar(frm As Object)
Dim hWnd&, hIcon&
With frm
..Image3.Visible = False
hWnd = FindWindow(vbNullString, .Caption)
hIcon = .Image3.Picture.Handle
SendMessage hWnd, &H80, 0, ByVal hIcon
RemoveMenu GetSystemMenu(hWnd, 0), &HF060, 0
..Show
End With
End Sub
Sub UserForm1Show()
On Error Resume Next
Call ChangeMenuBar(UserForm1)
End Sub
Sub UserForm2Show()
On Error Resume Next
Call ChangeMenuBar(UserForm2)
End Sub
Regards,
MP
"Klaus Heinrich" a écrit dans le message de news:
...
Hi Michel,
optimizing my code I declared APIs in general module now and reduced
form initalization to the following lines:
Private Sub UserForm_Initialize()
Dim hWnd&: hWnd = FindWindow(vbNullString, Me.Caption)
Image3.Visible = False ' hide image3 on form
SendMessage hWnd, &H80, 0, ByVal Image3.Picture.Handle
RemoveMenu GetSystemMenu(hWnd, 0), &HF060, 0
End Sub
If I want to use a sub like this and call it during initialization of
several forms
I can not use "Me" but I have to transmitt it to the sub. How can
I do this ?
Sub ChangeMenuBar()
Dim hWnd&: hWnd = FindWindow(vbNullString, Me.Caption) <----
Image3.Visible = False ' hide image3 on form
SendMessage hWnd, &H80, 0, ByVal Image3.Picture.Handle
RemoveMenu GetSystemMenu(hWnd, 0), &HF060, 0
End Sub
Thanks
Klaus
Michel Pierron schrieb:
Re Klaus Heinrich,
It is normal; if you want to have an icon, you cannot remove the
totality
of the system menu.
MP
|