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 ever released, and there may be errors on it. Please point out any errors done! :-)

Why did I make this? Well, there is this really good open source util called RealVNC. It is a "remote desktop" freeware with very nice clones. Check them out to UltraVNC and TightVNC. Many features have been added and I've already implemented the caption on each of these versions. Hopefully, this gets integrated in future releases of every VNC. If not, you can download all the versions from my website.

Using the code

You need to add five resources to your project. Plus one context menu.

These pictures are included in the demo project. All pictures should be the same size, but you can decide the width and height. See "customize" for more info.

You also need to add a 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, Minimize and Restore. All IDs used on each item can be set to e.g.: IDC_NULL since it is not in use. The flag tbWMCOMMANDIDStart/End sets 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 a WM_USER+tbWMUSERID+nItem sent to its message queue. (See "Customize" for options that are available to you.)

void DisplayWindow(BOOL Show, BOOL SetHideFlag=FALSE) - DisplayWindow is an alternative to ShowWindow. It adds the "slide" of the window. The option SetTheHideflag is an override so when it is true and window scrolls 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 changed in compile time for the caption bar. Here is a complete list:

//Width of captionbar
#define tbWidth 500
//Height of captionbar
#define tbHeigth 20
//Default size on picture (cx)
#define tbcxPicture 16
//Default size on picture (cy)
#define tbcyPicture 14
//Topmargin
#define tbTopSpace 3
//Leftmargin
#define tbLeftSpace 20
//Rightmargin
#define tbRightSpace 20
//Space between buttons
#define tbButtonSpace 1
//Font name used in the caption
#define tbFont "Arial"
//Size of font
#define tbFontSize 10
//Color of text
#define tbTextColor RGB(255,255,255)
//Backgroundcolor - Start of gradient
#define tbStartColor RGB(0,128,192)
//Backgroundcolor - End of gradient
#define tbEndColor RGB(0,0,192)
#define tbGradientWay TRUE
//TRUE = Vertical, FALSE = Horiz. If you don't like gradient set
//tbStartColor=tbEndColor
//Color of the border around captionbar
#define tbBorderPenColor RGB(255,255,255)
//Color of the shadow of the captionbar (bottom)
#define tbBorderPenShadow RGB(100,100,100)
#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
//Width of the pen used to draw the border
#define tbBorderWidth 2
//Hide window when created
#define tbHideAtStartup TRUE
//Is the pin pushed in or out at startup (INVERTED!)
#define tbPinNotPushedIn FALSE
//Animate window to scroll up/down
#define tbScrollWindow TRUE
//Timer variable for scrolling the window (cycletime) [ms]
#define tbScrollDelay 20
#define tbAutoScrollTime 10
//* tbAutoScrollDelay milliseconds steps. Meaning if it is 10 then
//= 10 (steps) * 100ms (tbAutoScrollDelay) = 1000ms delay
//Timer id - Internally used but it can make conflicks!
#define tbScrollTimerID 1
//Timer id - Internally used but it can make conflicks!
#define tbAutoScrollTimer 2
#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
//Resource ID - closebutton
#define tbIDC_CLOSE 10
//Resource ID - maximizebutton
#define tbIDC_MAXIMIZE 20
//Resource ID - minimizebutton
#define tbIDC_MINIMIZE 30
//Resource ID - pinbutton
#define tbIDC_PIN 40
#define tbDefault FALSE
//FALSE = Send a custon WM message, TRUE = Send Minimize, maximize
//and close to parent (normal Sendmessage and Showmessage commands)
//Message to send to parent on close-event
#define tbWM_CLOSE WM_USER+1000
//Message to send to parent on minimize-event
#define tbWM_MINIMIZE WM_USER+1001
//Message to send to parent on maximize-event
#define tbWM_MAXIMIZE WM_USER+1002
//Resource name for the contextmenu
#define tbMENUID IDR_tbMENU
#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
#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. A 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 closes, you can destroy the object.

This bug will be sorted out in a later version.

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

Comments and Discussions

Use mouse Button Up event, not Button Down to trigger minimize and close. This is standard frame window behavior.

Example: on an open window like IE or Notepad, click and hold mouse button over the close button. The close button will appear in "down" state. While holding button, drag mouse away from the button and release. Button returns to normal state and window does not close. Users will expect your frame window to do the same.

Edit: I just noticed this is only an issue in maximized / full screen. In normal overlapped frame window - works fine.

I guess I've never used ALT-TAB on the fullscreen demoproject It's been a while since I've programmed this, but I think the fullscreen app sets the "always on top" function (so it gets over the start-menu) and to handle eg ALT-TAB can be done by storing a BOOL that tells you if you are in fullscreen or not. And then handle the OnFocus (or simular) that checks the fullscreenbit, and if it has lost focus, it should remove the "always on top" bit.

Maybe I'll try to implement it into an upgrade later But I've just started in a new job, and it's taking my time!

For the time being I have reverted to using the FullScreenHandler class described by Paul DiLascia in http://msdn.microsoft.com/msdnmag/issues/02/12/CQA/default.aspxbut when I have time I want to combine it with your caption bar, because I like the roll-in effect.The bar is great for dummy users, who don't find their way back to "normal" mode. I think a lot of our users will get "stuck" in full-screen mode, so the caption bar is a highly visible, yet unintrusive emergence brake.

It shouldn't be a problem implementing the captionbar into the code given by DiLascia. You can create the fullscreencaptionbar at startup, and hide it until the trigger for fullscreen in DiLascia code.