Fullscreen caption bar

A full screen caption bar for applications that is running full screen and need to have some extra features. This is the same caption bar used on the VNC clones.

Check it out on:
Codeproject.com
Codeguru.com
Planetsourcecode.com

Fullscreen caption bar

FullScreenHeader.zip 74.77 kB
FullScreenHeaderSrc.zip (7.52 kB)

Fullscreen captionbar

Environment: VC6 SP5, NT4 SP3, Win9x, Win2k and WinXP

Introduction

After working with Remote Desktop from Microsoft, I saw the full screen caption bar
that came on top. The FullScreenHeader is a look alike of that caption, it is made in Win32 and I’ve tried to make it somehow custom.

This is my first Win32 app every released, and it may be errors on it. Please point out any errors done! :-)

Why did I made this? Well it is the really good opensource util called
RealVNC (http://www.realvnc.com). It is a
"remote desktop" freeware with very nice clones. Check them out to
UltraVNC (http://www.ultravnc.com) and
TightVNC (http://www.tightvnc.com). Many
features added and I’ve already implemented the caption on each of these
versions. Hopefully this get integrated in feature releases of every VNC. If not
you can download all the versions from my website: http://lars.werner.no

Using the code

You need to add five resources to you’re project. Plus one context menu.

 c++ |  copy code |? 
01
void CTitleBar::LoadPictures()
02
03
04
    {
05
    	hClose=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_CLOSE));
06
    	hMaximize=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MAXIMIZE));
07
    	hMinimize=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MINIMIZE));
08
    	hPinUp=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PINUP));
09
    	hPinDown=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PINDOWN));
10
}


These pictures are included in the demoproject. All pictures should be the same size, but you decide the width and height. See “customize” for more info.

You also need to add an context menu to the resource, default name is IDR_tbMENU.
If you have set the tbLastIsStandard=TRUE then you have to add 3
"default" entries to the menu. From the bottom: Close, Minmize and
Restore. All IDs used on each item can be set to eg: IDC_NULL since it is not in
use. The flag tbWMCOMMANDIDStart/End set the range for the IDs used in a context
menu internally.
If you want to add other entries to the context menu, you can add it above the 3
default entries if you’re using them. The parent will get an
WM_USER+tbWMUSERID+nItem sendt to its messagequeue. (Se "Customize"
for options that are available to you)

Implementing in MFC:

 c++ |  copy code |? 
1
//Header
2
CTitleBar *TitleBar;
3
//Eg in OnInitDialog() procedure
4
TitleBar=new CTitleBar(AfxGetInstanceHandle(), this->GetSafeHwnd());
5
//Eg on OnCancel()
6
delete TitleBar;

You can also declare it without pointers:
 c++ |  copy code |? 
1
//Header
2
CTitleBar TitleBar;
3
//Eg in OnInitDialog() procedure
4
Title.Create(AfxGetInstanceHandle(), this->GetSafeHwnd());

Here is a simple Win32 example. It uses the desktop hwnd to create a child toolbar.
 c++ |  copy code |? 
01
#include "stdafx.h"
02
#include "res\\Resource.h"
03
#include "FullScreenTitleBar.h"
04
CTitleBar *TitleBar;
05
int APIENTRY WinMain(HINSTANCE hInstance,
06
HINSTANCE hPrevInstance,
07
LPSTR lpCmdLine,
08
intnCmdShow)
09
10
11
    {
12
    	// TODO: Place code here.
13
    	TitleBar=new CTitleBar(hInstance, ::GetDesktopWindow());
14
    	MSG msg;
15
    	//Wait until loop is finished
16
    	while ( GetMessage(&msg, NULL, 0,0) )
17
18
19
        	{
20
        		DispatchMessage(&msg);
21
22
        	//Delete and quit program
23
        	delete TitleBar;
24
        	return 0;
25
    }


This ends how to implement the captionbar on Win32/MFC. Here are the rest of the public variables:
void Create(HINSTANCE hInst, HWND ParentWindow) – Create a new caption bar
void SetText(LPTSTR TextOut) – Set a headertext
void DisplayWindow(BOOL Show, BOOL SetHideFlag=FALSE) – Displaywindow is an alternative to showwindow. It adds the “slide” of the window. The option “SetTheHideflag” is a override so when it is true and window scroll to top it will call a ShowWindow(m_hWnd, SW_HIDE)
HWND GetSafeHwnd() – Returns the HWND for the main window

Customizing

There are several options that might be change in compiletime for the captionbar. Her is a complete list:

 c++ |  copy code |? 
01
#define tbWidth			500 //Width of captionbar
02
    #define tbHeigth		20 //Height of captionbar
03
    #define tbcxPicture		16 //Default size on picture (cx)
04
    #define tbcyPicture		14 //Default size on picture (cy)
05
    #define tbTopSpace		3 //Topmargin
06
    #define tbLeftSpace		20 //Leftmargin
07
    #define tbRightSpace		20 //Rightmargin
08
    #define tbButtonSpace		1 //Space between buttons
09
    #define tbFont			"Arial" //Font name used in the caption
10
    #define tbFontSize		10 //Size of font
11
    #define tbTextColor		RGB(255,255,255) //Color of text
12
    #define tbStartColor		RGB(0,128,192) //Backgroundcolor - Start of gradient
13
    #define tbEndColor		RGB(0,0,192) //Backgroundcolor - End of gradient
14
    #define tbGradientWay		TRUE	//TRUE = Vertical, FALSE = Horiz. If you don't like gradient set tbStartColor=tbEndColor
15
    #define tbBorderPenColor	RGB(255,255,255) //Color of the border around captionbar
16
    #define tbBorderPenShadow	RGB(100,100,100) //Color of the shadow of the captionbar (bottom)
17
    #define tbTriangularPoint	10 //Triangularpoint is how many pixel if should move on the left and right side to make the captionbar not so like the other captionbars
18
    #define tbBorderWidth		2 //Width of the pen used to draw the border
19
    #define tbHideAtStartup		TRUE //Hide window when created
20
    #define tbPinNotPushedIn	FALSE //Is the pin pushed in or out at startup (INVERTED!)
21
    #define tbScrollWindow		TRUE //Animate window to scroll up/down
22
    #define tbScrollDelay		20 //Timer variable for scrolling the window (cycletime) [ms]
23
    #define tbAutoScrollTime	10 //* tbAutoScrollDelay milliseconds steps. Meaning if it is 10 then = 10 (steps) * 100ms (tbAutoScrollDelay) = 1000ms delay
24
    #define tbScrollTimerID		1 //Timer id - Internally used but it can make conflicks!
25
    #define tbAutoScrollTimer	2 //Timer id - Internally used but it can make conflicks!
26
    #define tbAutoScrollDelay	100 //Timer variable for how many times the cursor is not over the window. If it is tbAutoScrollTime then it will hide if autohide
27
    #define tbIDC_CLOSE		10 //Resource ID - closebutton
28
    #define tbIDC_MAXIMIZE		20 //Resource ID - maximizebutton
29
    #define tbIDC_MINIMIZE		30 //Resource ID - minimizebutton
30
    #define tbIDC_PIN		40 //Resource ID - pinbutton
31
    #define tbDefault		FALSE //FALSE = Send a custon WM message, TRUE = Send Minimize, maximize and close to parent (normal Sendmessage and Showmessage commands)
32
    #define tbWM_CLOSE		WM_USER+1000 //Message to send to parent on close-event
33
    #define tbWM_MINIMIZE		WM_USER+1001 //Message to send to parent on minimize-event
34
    #define tbWM_MAXIMIZE		WM_USER+1002 //Message to send to parent on maximize-event
35
    #define tbMENUID 		IDR_tbMENU //Resource name for the contextmenu #define tbWMCOMMANDIDStart 50000 //Start: This is the internal id number sendt into the WM_COMMAND on each item #define tbWMCOMMANDIDEnd 51000 //End: This is the internal id number sendt into the WM_COMMAND on each item #define tbWMUSERID 2000 //This is WM_USER+n setting. Eg: if first item is clicked you will get an WM_USER+n+0 to the parent, and WM_USER+n+1 for the next item ect ect (sendt to parent) #define tbLastIsStandard TRUE //TRUE = Bottom of the menu is close, minimize and restore, FALSE = Every item is sendt as WM_USER+n to parent

All other variables (private) should not be tweaked, it may cause failure in
other procedures in the program. Modify on own risk :)

Known issues

Sometimes when you delete the caption bar a destroywindow is called. Since the window is made as a child it will send a message to the parent asking to close. This might cause the parent to close also.

An solution to this problem is to create the caption bar on runtime, hide it and show it as you need it. And when the main program close, you can destroy the object.
This bug will be sorted out in an later version.

If you encounter that no messages are being sent to your parent window,
please check the tbDefault variable. If the user press the context menu it will
send a "click" to any of the buttons in the parent, and use the parameters
used at the buttons.

5 comments to Fullscreen caption bar

  • Too bad you didn’t implement this with multi-monitor support – the API’s existed since Win98. I’m trying to fix UltraVNC to properly support multi-monitors on the client side. Any chance you want to help me fix up the parts pertaining to your toolbar code?? :-)

  • xu guocheng

    I try to display your “Fullscreen caption bar” on the full screen of another process without using hook, but it cannot appear.
    And sometime the window of your “Fullscreen caption bar” will be messed by mouse cursor of another process when I using hook. The reason may be captured by the full screen, but I can judge whether the cursor is in “Fullscreen caption bar” by using WM_MOUSEMOVE of thefull screen window.
    Is there any way to make it can display on the full screen of any process?

  • xu guocheng: I’ve never tried it without implementing it into to my own software. It is created as always on top, but do you have any graphic or some beta software so I can test it myself? (Just email me on lars@werner.no)

  • Pranz Oliver

    I’m using UltraVNC and withit your connection bar and like it very well on my pc. Additional I want to use it on a terminal-hardware with touch-screen. Because the calibration of the touch is never totaly exact I have poblems to get the first pixel line.
    Like the original RDP-connection bar you implemented a feature to pin the bar. Is it possible to have it pinned by default ?

  • Pranz Oliver: Set the tbPinNotPushedIn to FALSE and the PIN will be default pushed in :)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>