?
Solved

Form title bar font and colour?????

Posted on 2003-03-04
9
Medium Priority
?
328 Views
Last Modified: 2013-12-03
Hi All

I new to this area and i think that this question may be a little tricky....

I want to change the title bar colour from the windows standard to a chosen colour of my choice, preferably a different colour and may be a fade, but i also want to change the font.

The key point is that i do not want to change this for all programs running, just the one i want to distribute.

This code must work for all Ms Windows platforms, from Windows 95 and beyond.

Any help would be grateful.

Thanks all.
0
Comment
Question by:MikeMinton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 6

Expert Comment

by:marconovaro
ID: 8063546

You can do something like this:
draw a picturebox in the form, and set the border of the form to "None".
Then, you'll need subclassing in order to know when the user tries to click your new caption bar.
Here is an example (with code) of how to do that:

"Moving Forms and Creating Resize Gripper Boxes"
http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/Reliable_Interception_of_WM_NCHITTEST/article.asp

Hope this helps
M
0
 
LVL 2

Expert Comment

by:Hossy
ID: 8063652
right, marco

mike, you'll essentially need to create your own titlebar since windows draws the title bar and not the program.
0
 

Author Comment

by:MikeMinton
ID: 8063831
Thanks M

But, only problem with your code is that the form then no longer becomes 3d and looks quite basic, not only that but the picture box is only a single colour.

Thanks

Mike
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MikeMinton
ID: 8063879
Does anyone then know how to make a form 3d if the form has no border?
0
 

Author Comment

by:MikeMinton
ID: 8063972
Does anyone then know how to make a form 3d if the form has no border?
0
 
LVL 6

Accepted Solution

by:
marconovaro earned 400 total points
ID: 8064256

Ok, so: do not modify the border style, and add this code to the one you downloaded:

Option Explicit

Public Enum SysMet
    SM_CXSCREEN = 0
    SM_CYSCREEN = 1
    SM_CXVSCROLL = 2
    SM_CYHSCROLL = 3
    SM_CYCAPTION = 4
    SM_CXBORDER = 5
    SM_CYBORDER = 6
    SM_CXDLGFRAME = 7
    SM_CYDLGFRAME = 8
    SM_CYVTHUMB = 9
    SM_CXHTHUMB = 10
    SM_CXICON = 11
    SM_CYICON = 12
    SM_CXCURSOR = 13
    SM_CYCURSOR = 14
    SM_CYMENU = 15
    SM_CXFULLSCREEN = 16
    SM_CYFULLSCREEN = 17
    SM_CYKANJIWINDOW = 18
    SM_MOUSEPRESENT = 19
    SM_CYVSCROLL = 20
    SM_CXHSCROLL = 21
    SM_DEBUG = 22
    SM_SWAPBUTTON = 23
    SM_RESERVED1 = 24
    SM_RESERVED2 = 25
    SM_RESERVED3 = 26
    SM_RESERVED4 = 27
    SM_CXMIN = 28
    SM_CYMIN = 29
    SM_CXSIZE = 30
    SM_CYSIZE = 31
    SM_CXFRAME = 32
    SM_CYFRAME = 33
    SM_CXMINTRACK = 34
    SM_CYMINTRACK = 35
    SM_CXDOUBLECLK = 36
    SM_CYDOUBLECLK = 37
    SM_CXICONSPACING = 38
    SM_CYICONSPACING = 39
    SM_MENUDROPALIGNMENT = 40
    SM_PENWINDOWS = 41
    SM_DBCSENABLED = 42
    SM_CMOUSEBUTTONS = 43
    SM_CMETRICS = 44
End Enum

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Const SWW_HPARENT = (-8)
Private Const WM_MOVE = &H3

Implements ISubclass

Private Sub Form_Load()

    SetParent TitleBar.hWnd, 0
    SetWindowLong TitleBar.hWnd, SWW_HPARENT, Me.hWnd
    AttachMessage Me, hWnd, WM_MOVE

End Sub

Private Property Let ISubclass_MsgResponse(ByVal RHS As SSubTimer6.EMsgResponse)

    '

End Property

Private Property Get ISubclass_MsgResponse() As SSubTimer6.EMsgResponse

    ISubclass_MsgResponse = emrPostProcess

End Property

Private Function ISubclass_WindowProc(ByVal hWnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Dim xyFrame As Long
    Dim tmpWrct As RECT
    Dim tbHeight As Long
    GetWindowRect Me.hWnd, tmpWrct
    xyFrame = GetSystemMetrics(SysMet.SM_CXFRAME)
    tbHeight = GetSystemMetrics(SysMet.SM_CYCAPTION)

    If iMsg = WM_MOVE Then
   
        SetWindowPos TitleBar.hWnd, _
           0, LOWORD(lParam), _
           Top / 15 + xyFrame, _
           tmpWrct.Right - tmpWrct.Left - xyFrame * 2, tbHeight - 1, 0

    End If

End Function

Private Function LOWORD(dwValue As Long) As Long

    CopyMemory LOWORD, dwValue, 2

End Function

This will draw your pictureBox (TitleBar) on top of the windows one, so you can use a normal window as a starting point.
Hope this helps.
M
0
 
LVL 1

Assisted Solution

by:BWarmuskerken
BWarmuskerken earned 400 total points
ID: 8064410
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9024134
Hi MikeMinton,
It appears that you have forgotten to close this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: marconovaro and BWarmuskerken

MikeMinton, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept THIS comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question