LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Userform with logo and without closebtn

Hi folks,

I am not an VBA expert and found some code snips in the net.
First one hides the close button in user forms, second one sets
individual logo in the menu bar of the user form. Maybe any
one can help me combine this code snips ot at least help to
understand, what the coding does:

The declaration of lib "user32" is the same in both cases.
Only difference:

Private Const GWL_STYLE As Long = -16
Private Const WS_SYSMENU As Long = &H80000

Private hWndForm As Long
Private bCloseBtn As Boolean

Private Sub UserForm_Initialize()
' Find handle depending on Excel Version

If Val(Application.Version) = 9 Then
hWndForm = FindWindow("ThunderDFrame", Me.Caption)
Else
hWndForm = FindWindow("ThunderXFrame", Me.Caption)
End If

bCloseBtn = False
SetUserFormStyle <-- this is the sub which hides the close button
End Sub

Private Sub SetUserFormStyle()
' Hide close button in userform
Dim frmStyle As Long

If hWndForm = 0 Then Exit Sub

frmStyle = GetWindowLong(hWndForm, GWL_STYLE)

If bCloseBtn Then
frmStyle = frmStyle Or WS_SYSMENU
Else
frmStyle = frmStyle And Not WS_SYSMENU
End If

SetWindowLong hWndForm, GWL_STYLE, frmStyle
DrawMenuBar hWndForm
End Sub

Until here it works fine. Now I want to add some lines as follows:

hIcon = Image3.Picture
SendMessage hWndForm, &H80, True, hIcon
SendMessage hWndForm, &H80, False, hIcon
frm = GetWindowLong(hWndForm, -20)
frm = frm And Not &H1
SetWindowLong hWndForm, -20, frm

DrawMenuBar hWndForm

I do not understand the meaning of the lines, but I am sure
that some commands overwrite the other.
Is there any way to combine this snips ?

Thanks in advandced

Regards

Klaus
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO KEEP A LOGO ON ALL THE PAGES Parameswaran Excel Discussion (Misc queries) 1 June 23rd 09 02:42 PM
Signature or Logo Vercingetorix.XIII[_2_] Excel Worksheet Functions 3 September 23rd 08 10:01 PM
Logo missing SallyNBS Excel Discussion (Misc queries) 3 June 6th 06 05:36 PM
Logo within a cell maryj Excel Discussion (Misc queries) 1 July 19th 05 04:04 PM
Excel Logo RTP Excel Discussion (Misc queries) 1 February 7th 05 03:37 PM


All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"