adding button to titlebar

i would like to add a button to titlebar in vb6. the button should be able to show tooltip and it should be compatible with XP.

thanks in advance
kolistivraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stephen MandersonSoftware EngineerCommented:
Hi there, this will allow you to creat your own title bar with buttons.


'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Set form BorderStyle property to 0-None.You can add your own Command Buttons to the
'Title Bar.
'Insert this code to the module :

Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function DrawCaption Lib "User32" (ByVal hwnd As Long, ByVal hdc As _
Long, pcRect As RECT, ByVal un As Long) As Long
Declare Function SetRect Lib "User32" (lpRect As RECT, ByVal X1 As Long, ByVal _
Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hwnd As _
Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Sub ReleaseCapture Lib "User32" ()
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2

'Insert this code to your form:

'Here you can change the title bar width.
Const TitleWidth = 20
Dim r As RECT

Private Sub Form_Load()
Form1.AutoRedraw = True
Me.Cls
Me.ScaleMode = vbPixels
SetRect r, 0, 0, Me.ScaleWidth, TitleWidth
'To change the title bar color, replace the two '&H9' below with
'&H18' or '&H19' or '&H28'
DrawCaption Me.hwnd, Me.hdc, r, &H9
End Sub

Private Sub Form_Resize()
SetRect r, 0, 0, Me.ScaleWidth, TitleWidth
DrawCaption Me.hwnd, Me.hdc, r, &H9
End Sub

'The following code allow the user to move the form by pressing on the title bar. If you
'don't want this option, don't add the code below.
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Y > TitleWidth Then Exit Sub
Dim lngReturnValue As Long
If Button = 1 Then
Call ReleaseCapture
lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub

Manderson
0
kolistivraAuthor Commented:
thx for your effort but what i want is not drawing a titlebar from beginning. if you look at emule, you can see what i mean better.

thanks
0
Stephen MandersonSoftware EngineerCommented:
Sorry, there has been a similar question asked before.

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20149057.html

Hope this helps you find an answer.

Manderson
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

kolistivraAuthor Commented:
yes, this is similar to what i want but:

i want a button, normal button. no images or something, a button with a dot or a letter on it.
also, it doesn't show any tooltip.

thanks
0
Stephen MandersonSoftware EngineerCommented:
0
kolistivraAuthor Commented:
it almost is what i want :)

the problem i have with it is about the icon. i am using win xp with windows classis style theme and the icon seems much bigger than it is. also, the system menu doesn't appear when i click on somewhere on titlebar. besides, it is wonderful.

if you can solve this problems, this one will be just what i want :)

thanks
0
Stephen MandersonSoftware EngineerCommented:
Hi there, you would have to add a manifest file. It tells you at the bottom of the above link how to do it.

Regards
Manderson
0
Stephen MandersonSoftware EngineerCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.