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)
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.
void CTitleBar::LoadPictures()
{
hClose=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_CLOSE));
hMaximize=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MAXIMIZE));
hMinimize=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_MINIMIZE));
hPinUp=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PINUP));
hPinDown=LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PINDOWN));
}
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:
//Header
CTitleBar *TitleBar;
//Eg in OnInitDialog() procedure
TitleBar=new CTitleBar(AfxGetInstanceHandle(), this->GetSafeHwnd());
//Eg on OnCancel()
delete TitleBar;
You can also declare it without pointers:
//Header
CTitleBar TitleBar;
//Eg in OnInitDialog() procedure
Title.Create(AfxGetInstanceHandle(), this->GetSafeHwnd());
Here is a simple Win32 example. It uses the desktop hwnd to create a child toolbar.
#include "stdafx.h"
#include "res\Resource.h"
#include "FullScreenTitleBar.h"
CTitleBar *TitleBar;
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
intnCmdShow)
{
// TODO: Place code here.
TitleBar=new CTitleBar(hInstance, ::GetDesktopWindow());
MSG msg;
//Wait until loop is finished
while ( GetMessage(&msg, NULL, 0,0) )
{
DispatchMessage(&msg);
}
//Delete and quit program
delete TitleBar;
return 0;
}
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:
#define tbWidth 500 //Width of captionbar
#define tbHeigth 20 //Height of captionbar
#define tbcxPicture 16 //Default size on picture (cx)
#define tbcyPicture 14 //Default size on picture (cy)
#define tbTopSpace 3 //Topmargin
#define tbLeftSpace 20 //Leftmargin
#define tbRightSpace 20 //Rightmargin
#define tbButtonSpace 1 //Space between buttons
#define tbFont "Arial" //Font name used in the caption
#define tbFontSize 10 //Size of font
#define tbTextColor RGB(255,255,255) //Color of text
#define tbStartColor RGB(0,128,192) //Backgroundcolor - Start of gradient
#define tbEndColor RGB(0,0,192) //Backgroundcolor - End of gradient
#define tbGradientWay TRUE //TRUE = Vertical, FALSE = Horiz. If you don't like gradient set tbStartColor=tbEndColor
#define tbBorderPenColor RGB(255,255,255) //Color of the border around captionbar
#define tbBorderPenShadow RGB(100,100,100) //Color of the shadow of the captionbar (bottom)
#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
#define tbBorderWidth 2 //Width of the pen used to draw the border
#define tbHideAtStartup TRUE //Hide window when created
#define tbPinNotPushedIn FALSE //Is the pin pushed in or out at startup (INVERTED!)
#define tbScrollWindow TRUE //Animate window to scroll up/down
#define tbScrollDelay 20 //Timer variable for scrolling the window (cycletime) [ms]
#define tbAutoScrollTime 10 //* tbAutoScrollDelay milliseconds steps. Meaning if it is 10 then = 10 (steps) * 100ms (tbAutoScrollDelay) = 1000ms delay
#define tbScrollTimerID 1 //Timer id - Internally used but it can make conflicks!
#define tbAutoScrollTimer 2 //Timer id - Internally used but it can make conflicks!
#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
#define tbIDC_CLOSE 10 //Resource ID - closebutton
#define tbIDC_MAXIMIZE 20 //Resource ID - maximizebutton
#define tbIDC_MINIMIZE 30 //Resource ID - minimizebutton
#define tbIDC_PIN 40 //Resource ID - pinbutton
#define tbDefault FALSE //FALSE = Send a custon WM message, TRUE = Send Minimize, maximize and close to parent (normal Sendmessage and Showmessage commands)
#define tbWM_CLOSE WM_USER+1000 //Message to send to parent on close-event
#define tbWM_MINIMIZE WM_USER+1001 //Message to send to parent on minimize-event
#define tbWM_MAXIMIZE WM_USER+1002 //Message to send to parent on maximize-event
#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.
Pranz Oliver: Set the tbPinNotPushedIn to FALSE and the PIN will be default pushed in 🙂
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 ?
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)
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?
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?? 🙂