Solved

Making a Custom Caption Bar

Posted on 2004-10-05
8
529 Views
Last Modified: 2010-04-05
I need to make the caption bar on my main form wider to make it stand out from other forms/frames on the screen.
Also I need to put a bitmap or glyph logo on the left side of the bar.

I have been reading questions that involve the use of system metrics.  Is this the best way to go ?  What are the index values for system metrics ?  Can you set them in the same way ?

Or any other ideas ...

Any help appreciated

Thanks
Richard
0
Comment
Question by:diver999
  • 5
  • 2
8 Comments
 
LVL 33

Expert Comment

by:Slick812
ID: 12229159
hello diver999 , drawing your own caption bar on a non-caption window is not so easy, and there are several factors you may need to code for. .
There is code at this EE question, that does a custom painted caption bar -


http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20462056.html

you might look at this and get some ideas about how to do it. .

this seems to give you a caption heught mesurement -

captionHeight := GetSystemMetrics(SM_CYCAPTION);
0
 
LVL 1

Expert Comment

by:Bart_Thomas
ID: 12229182
Check: http://www.g32.org/vcl/index.html
There's an example how to create your own "toolbar".
0
 
LVL 33

Expert Comment

by:Slick812
ID: 12229217
and, as a note, that was done before the XP Theme and it's new caption look,
0
 

Author Comment

by:diver999
ID: 12256611
Where can I fiind the meanings and index constants for SystemMetrics ?
Is there a similar command for setting the parameters ?

R
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 33

Expert Comment

by:Slick812
ID: 12261478
???
I guess you mean the index constants for "GetSystemMetrics" ?
not sure how to answer? The GetSystemMetrics( ) function is a windows API function, which is in the Delphi windows.pas unit. .
For basic usage information for the windows API methods and structures, I look in the Win32  API  Help that comes with Delphi. . . If you want more recent API information you can use the MSDN web site, the Library is a good place to start  , , at -

http://msdn.microsoft.com/library/default.asp

use the "Search For" to find info, ,

you can see about the GetSystemMetrics function at -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp

as for setting some system parameters. . . I do not remember anything for setting that, but you can look at the SystemParametersInfo( ) function at -

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp

But I know from experience, if you change a system paramterer, and your users notice it, they will   LOUDLY   complain about it! ! !


0
 

Author Comment

by:diver999
ID: 12267372
That's some good information...

I am relaxed about complaints because this is for a dedicated application.

I have been able to change things like COLOR_INACTIVETEXT, using SetSysColors.  However, one thing I really want to do is change COLOR_INACTIVECAPTION and COLOR_GRADIENTINACTIVECAPTION but, although I can see the screen refresh, no colour change takes place.

Also, using SPI I can increase the height of the caption bar - but when I do this, it applies to everything.  Do you know if there is there any way of applying it to just one form ???

Thanks for your interest
Richard
0
 
LVL 33

Expert Comment

by:Slick812
ID: 12268569
I have seen questions here at EE about changing just one form's caption bar (height, color, buttons) and not other forms captions, and in those questions it was the opinion of several, that this is not posible (and I also think that, is NOT posible), but there may be some new XP thing that I do not know about, however, I really doubt it, , , I do not think the system will draw a custom caption for you. . .

as to the SetSysColors not showing, I really am not sure about this, and have no direct experiece with trying to do that,, , , but my thought is - - it may be that you will need to refresh the windows (have them redrawn) to change their color, if this does not work maybe a reboot? I can not remember much about that, I think some changes require a reboot? I may can find something about that, but I don't have much time now to research that, sorry.
0
 
LVL 33

Accepted Solution

by:
Slick812 earned 200 total points
ID: 12269042
if you are not in XP themes then you might consider code like this to draw a caption bar -

procedure DoCapDraw;
var
fDC: HDC;
RectR: TRect;
begin
fDC := GetDC(hForm1);
SetRect(RectR,30,101,430,127); // use a Rect at the top, this only for example
DrawCaption(hForm1, fDC, RectR, DC_ACTIVE or DC_ICON or DC_TEXT or DC_GRADIENT);
SetRect(RectR,407,107,424,122);
DrawFrameControl(fDC,RectR,DFC_CAPTION,DFCS_CAPTIONCLOSE);
ReleaseDC(hForm1, fDC);
end;

if you want XP  theme look then it gets more complicated, you might could use the  DrawThemeBackground( ) function with the WP_CAPTION  and CS_ACTIVE parameters, , , you could try the  WP_MINBUTTON and MINBS_NORMAL for the minimize buttom
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now