|
Actually, i'm not very familiar with the .NET, but i think that it doesn't support more than 16 colors, the toolbar has not that option, but thank you i will add it soon.
|
|
|
|
|
First of all well done for the excellent job.
I have succesfully got the toolbar and statusbar to work in my SDI app however when I use the menu, the gripper and popups at the top work ok but when I pull down a menu they still appear in the old way. What am I doing wrong.
Secondly I also notice that when I startup my app the menu is like overwritten with the original old one causing a slight jitter in the app.
Once again well done
Shaun
|
|
|
|
|
The Menues are not made by me, i only include this with some fixes, that i did to the version of Jean, the menu that i'm doing is the one in the beta version, it still need some work, anyway if you want to know how to impement the menues to your app, check this http://www.codeproject.com/menu/menuxp2.asp, this is the original one, mine only have fixes, that's all it's the same.
|
|
|
|
|
The jitter can be resolved by changing CXPMenuBar::LoadMenuBar() to use SendMessage instead of PostMessage when its removing the old menu. Using PostMessage delays the message being processed for a while so you briefly have two menus.
--
AnthonyJ@planetquake.com
www.btinternet.com/~AnthonyJ
|
|
|
|
|
At first nice Tool...;)
Is it possible to add a ComboBox like WordStyle?
Thanks Tino
|
|
|
|
|
Yeap, it's posible, i'll be posting my new code with the flat menu, and with a new ComboBox, i just need time.
|
|
|
|
|
...thanks Tino
|
|
|
|
|
At first nice Tool...;)
Is it possible to add a ComboBox with WordStyle?
Thanks Tino
|
|
|
|
|
Is there a way to get the text labels on the right of each icon on the menu bar.
|
|
|
|
|
This work is so great! I excited by it. But here still has some bug.
When I started the demo exe, and the MDI child window in normal state. And click the control menu(just the child window icon), the menu(it has move,
size, restore, etc. menu items) drop down. But the menu has still old style.
And you maximum the child window. Click the child control menu(child window icon at menu bar), the control menu drop down with new style, all right. BUT:
you restore the child window, and click the control menu. Only menu background
with nothing menu item display.
|
|
|
|
|
Using this code replace CXPToolbar with CToolbarXP is better
This is code of CToolbarXP.cpp and replace XPToolbar.h with ToolbarXP.h
///////////////////////////////////////////////////////////////////////////////
//
// ToolBarXP.cpp: implementation of the CToolBarXP class.
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ToolBarXP.h"
#include "Draw.h"
#pragma warning(disable : 4244)
#pragma message("You are using CToolBarXP")
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
///////////////////////////////////////////////////////////////////////////////
CToolBarXP::CToolBarXP () : m_bCheckVisibility (false)
{
}
///////////////////////////////////////////////////////////////////////////////
BOOL CToolBarXP::LoadToolBar (UINT nIDResource)
{
if ( !CToolBar::LoadToolBar (nIDResource) )
{
return false;
}
SetBorders (CRect(2,2,3,2));
SendMessage (TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS);
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool CToolBarXP::InsertControl (int nIndex, CWnd& Ctrl)
{
TBBUTTON tbbutton;
int nCount = DefWindowProc (TB_BUTTONCOUNT, 0, 0);
CWindowRect rcCtrl (Ctrl);
tbbutton.iBitmap = rcCtrl.Width();
tbbutton.idCommand = Ctrl.GetDlgCtrlID();
tbbutton.fsState = 0;
tbbutton.fsStyle = TBSTYLE_SEP;
tbbutton.bReserved[0] = 0;
tbbutton.bReserved[1] = 0;
tbbutton.iString = -1;
tbbutton.dwData = NULL;
if ( nIndex < 0 || nIndex > nCount )
{
nIndex = nCount;
}
if ( GetToolBarCtrl().InsertButton (nIndex, &tbbutton) )
{
m_bDelayedButtonLayout = true;
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
LRESULT CToolBarXP::DefWindowProc (UINT nMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = CToolBar::DefWindowProc (nMsg, wParam, lParam);
if ( m_bCheckVisibility && nMsg == TB_GETBUTTON )
{
TBBUTTON* pButton = (TBBUTTON*)lParam;
if ( IS_CONTROL(*pButton) )
{
if ( m_bCheckVisibility == 1 ) pButton->fsState |= TBSTATE_HIDDEN;
else pButton->fsState &= ~TBSTATE_HIDDEN;
}
}
return lRes;
}
///////////////////////////////////////////////////////////////////////////////
CSize CToolBarXP::CalcDynamicLayout (int nLength, DWORD dwMode)
{
bool bHideControls = (dwMode & LM_VERTDOCK) == LM_VERTDOCK;
m_bCheckVisibility = (BYTE)(bHideControls ? 1 : 2);
CSize size = CToolBar::CalcDynamicLayout (nLength, dwMode);
m_bCheckVisibility = false;
if ( dwMode & LM_COMMIT )
{
TBBUTTON tbbutton;
int nCount = DefWindowProc (TB_BUTTONCOUNT, 0, 0);
for ( int i = 0; i < nCount; i++ )
{
VERIFY(DefWindowProc (TB_GETBUTTON, i, (LPARAM)&tbbutton));
if ( !IS_CONTROL(tbbutton) )
{
continue;
}
CWnd* pWnd = GetDlgItem (tbbutton.idCommand);
if ( pWnd == NULL )
{
continue;
}
if ( bHideControls )
{
GetToolBarCtrl().HideButton (tbbutton.idCommand, true);
pWnd->ShowWindow (SW_HIDE);
}
else
{
GetToolBarCtrl().HideButton (tbbutton.idCommand, false);
// Update control position
CRect rcControl;
VERIFY (DefWindowProc (TB_GETITEMRECT, i, (LPARAM)&rcControl));
rcControl.DeflateRect (1, 1);
CWindowRect rcCtrl (pWnd);
int nNoSize = 0;
if ( rcControl.Width() == rcCtrl.Width() )
{
nNoSize = SWP_NOSIZE;
}
pWnd->SetWindowPos (NULL, rcControl.left, rcControl.top, rcControl.Width(), rcControl.Height(),
nNoSize|SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW);
}
}
}
return size;
}
///////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CToolBarXP, CToolBar)
ON_WM_NCPAINT()
ON_WM_NCCALCSIZE()
ON_WM_PAINT()
ON_NOTIFY_REFLECT(TBN_DROPDOWN, OnButtonDropDown)
END_MESSAGE_MAP()
IMPLEMENT_DYNAMIC(CToolBarXP, CToolBar)
///////////////////////////////////////////////////////////////////////////////
// Paint the toolbar
void CToolBarXP::OnPaint ()
{
if ( m_bDelayedButtonLayout )
{
Layout();
}
CPaintDC cDC (this);
CRect rcClip;
cDC.GetClipBox (rcClip);
cDC.SetBkMode (TRANSPARENT);
cDC.SelectObject (CFont::FromHandle ((HFONT)GetStockObject (DEFAULT_GUI_FONT)));
cDC.FillSolidRect (rcClip, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), 20, 0));
CPoint ptCursor;
::GetCursorPos (&ptCursor);
ScreenToClient (&ptCursor);
CClientRect rcClient (this);
HIMAGELIST m_hImageList = (HIMAGELIST)DefWindowProc (TB_GETIMAGELIST, 0, 0);
TBBUTTON tbbutton;
int nCount = DefWindowProc (TB_BUTTONCOUNT, 0, 0);
int nHotItem = GetToolBarCtrl().GetHotItem();
for ( int i = 0; i < nCount; i++ )
{
VERIFY(DefWindowProc (TB_GETBUTTON, i, (LPARAM)&tbbutton));
if ( !IS_VISIBLE(tbbutton) )
{
continue;
}
CRect rcButton;
VERIFY(DefWindowProc (TB_GETITEMRECT, i, (LPARAM)&rcButton));
if ( !CRect().IntersectRect (rcClip, rcButton) )
{
continue;
}
bool bOver = nHotItem == i && IS_ENABLED(tbbutton);
bool bPressed = false;
if ( IS_INDETERMINATE(tbbutton) )
{
CPenDC pen (cDC, ::GetSysColor (COLOR_3DSHADOW));
cDC.MoveTo (rcButton.left, rcButton.bottom);
cDC.LineTo (rcButton.left, rcButton.top);
cDC.LineTo (rcButton.right-1, rcButton.top);
cDC.LineTo (rcButton.right-1, rcButton.bottom-1);
cDC.LineTo (rcButton.left, rcButton.bottom-1);
bOver = true;
}
else if ( bOver || IS_CHECKED(tbbutton) )
{
bPressed = KEYDOWN(VK_LBUTTON) && rcButton.PtInRect (ptCursor);
if ( IS_DROPDOWN(tbbutton) && bPressed )
{
bPressed = ptCursor.x < rcButton.right-13;
if ( bPressed )
{
rcButton.right -= 13;
}
}
COLORREF crHighLight = ::GetSysColor (COLOR_HIGHLIGHT);
CPenDC pen (cDC, crHighLight);
CBrushDC brush (cDC, bPressed||(bOver&&IS_CHECKED(tbbutton)) ? HLS_TRANSFORM (crHighLight, +50, -50) : (bOver ? HLS_TRANSFORM (crHighLight, +70, -57) : HLS_TRANSFORM (crHighLight, +80, -66)));
cDC.Rectangle (&rcButton);
if ( IS_DROPDOWN(tbbutton) )
{
if ( bPressed )
{
int nLeft = rcButton.left;
rcButton.left = rcButton.right-1;
rcButton.right += 13;
brush.Color (HLS_TRANSFORM (crHighLight, +70, -66));
cDC.Rectangle (&rcButton);
rcButton.left = nLeft;
}
else
{
cDC.MoveTo (rcButton.right-14, rcButton.top);
cDC.LineTo (rcButton.right-14, rcButton.bottom);
}
}
}
if ( IS_SEPARATOR(tbbutton) )
{
CPenDC pen (cDC, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -15, 0));
if ( IS_WRAP(tbbutton) )
{
cDC.MoveTo (rcClient.left+2, rcButton.bottom-4);
cDC.LineTo (rcClient.right-2, rcButton.bottom-4);
}
else
{
cDC.MoveTo ((rcButton.right+rcButton.left)/2-1, rcButton.top+2);
cDC.LineTo ((rcButton.right+rcButton.left)/2-1, rcButton.bottom-2);
}
}
else if ( !IS_CONTROL(tbbutton) )
{
if ( IS_DROPDOWN(tbbutton) )
{
CPenDC pen (cDC, ( bOver && !IS_INDETERMINATE(tbbutton) ) ? RGB(0,0,0) : ::GetSysColor (IS_ENABLED(tbbutton) ? COLOR_BTNTEXT : COLOR_GRAYTEXT));
cDC.MoveTo (rcButton.right-9, (rcButton.top+rcButton.bottom)/2-1);
cDC.LineTo (rcButton.right-4, (rcButton.top+rcButton.bottom)/2-1);
cDC.MoveTo (rcButton.right-8, (rcButton.top+rcButton.bottom)/2);
cDC.LineTo (rcButton.right-5, (rcButton.top+rcButton.bottom)/2);
cDC.SetPixel (rcButton.right-7, (rcButton.top+rcButton.bottom)/2+1, pen.Color());
rcButton.right -= 14;
}
if ( tbbutton.iBitmap >= 0 )
{
if ( !IS_ENABLED(tbbutton) || (bOver && !bPressed) )
{
HICON hIcon = ImageList_ExtractIcon (NULL, m_hImageList, tbbutton.iBitmap);
cDC.DrawState (CPoint (rcButton.left + ( bOver ? 4 : 3 ), rcButton.top + ( bOver ? 4 : 3 )), m_sizeImage, hIcon, DSS_MONO, CBrush (bOver ? (IS_INDETERMINATE(tbbutton) ? HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -20, 0) : HLS_TRANSFORM (::GetSysColor (COLOR_HIGHLIGHT), +50, -66)) : HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -27, 0)));
DestroyIcon (hIcon);
}
if ( IS_ENABLED(tbbutton) )
{
::ImageList_Draw (m_hImageList, tbbutton.iBitmap, cDC.m_hDC,
rcButton.left + ( (bOver && !bPressed) ? 2 : 3 ), rcButton.top + ( (bOver && !bPressed) ? 2 : 3 ), ILD_TRANSPARENT);
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
void CToolBarXP::OnButtonDropDown (NMHDR* lpnmhdr, LRESULT* plResult)
{
LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR)lpnmhdr;
*plResult = TBDDRET_DEFAULT;
if ( !m_pDockSite->SendMessage (WM_COMMAND, DROPDOWN(lpnmtb->iItem)) )
{
*plResult = TBDDRET_TREATPRESSED;
}
}
void CToolBarXP::OnNcPaint()
{
EraseNonClient(); //don't do it here
}
void CToolBarXP::DrawGripper(CWindowDC *pDC, CRect& rectWindow)
{
// get the gripper rect (1 pixel smaller than toolbar)
CRect gripper = rectWindow;
//Disable these line to disable the XP Gripper
if (m_brGripperHorz.GetSafeHandle () == NULL)
{
CreateGripperBrush ();
}
pDC->FillSolidRect(gripper, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), 20, 0));
//pDC->FillSolidRect(gripper, ::GetSysColor (COLOR_BTNFACE));//Enable this to get the classic color
if (m_dwStyle & CBRS_FLOATING)
{ // no grippers
}
else if (m_dwStyle & CBRS_ORIENT_HORZ)
{ // gripper at left
gripper.right = gripper.left+3;
//pDC->Draw3dRect(gripper,::GetSysColor(COLOR_3DHIGHLIGHT),::GetSysColor(COLOR_3DSHADOW));//Enable this to get the classic gripper
gripper.OffsetRect(+4,0);
gripper.DeflateRect(0,6);
pDC->FillRect (gripper,&m_brGripperHorz);//Disable This to disable the XP Gripper
rectWindow.left += 8;
} else
{ // gripper at top
gripper.bottom = gripper.top+3;
//pDC->Draw3dRect(gripper,::GetSysColor(COLOR_3DHIGHLIGHT),::GetSysColor(COLOR_3DSHADOW));//Enable this to get the classic look
gripper.OffsetRect(0,+4);
gripper.DeflateRect(6,0);
pDC->FillRect (gripper,&m_brGripperVert);//Disable this to disable the XP Gripper
rectWindow.top += 8;
}
}
void CToolBarXP::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp)
{
CToolBar::OnNcCalcSize(bCalcValidRects,lpncsp);
// adjust non-client area for gripper at left or top
if (m_dwStyle & CBRS_FLOATING)
{ // no grippers
}
else if (m_dwStyle & CBRS_ORIENT_HORZ)
{
// let's move a little to make some space
lpncsp->rgrc[0].left += 0;
lpncsp->rgrc[0].right += 3;
lpncsp->rgrc[0].top += -1;
lpncsp->rgrc[0].bottom += 2;
}
else
{ // now moving down
lpncsp->rgrc[0].top += 4;
lpncsp->rgrc[0].bottom += 5;
}
}
void CToolBarXP::EraseNonClient(/*BOOL bRaised*/)
{
// get window DC that is clipped to the non-client area
CWindowDC dc(this);
CRect rectClient;
GetClientRect(rectClient);
CRect rectWindow;
GetWindowRect(rectWindow);
ScreenToClient(rectWindow);
rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
dc.ExcludeClipRect(rectClient); // draw borders in non-client area
rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
DrawBorders(&dc, rectWindow); // erase parts not drawn
dc.IntersectClipRect(rectWindow);
SendMessage(WM_ERASEBKGND, (WPARAM)dc.m_hDC);
dc.SetBkColor(::GetSysColor(COLOR_3DFACE));
DrawGripper(&dc, rectWindow); // lets draw some grippers
}
void CToolBarXP::DrawBorders(CDC* pDC, CRect& rect)
{
ASSERT_VALID(this);
ASSERT_VALID(pDC);
DWORD dwStyle = m_dwStyle;
if (!(dwStyle & CBRS_BORDER_ANY))
return;
// prepare for dark lines
ASSERT(rect.top == 0 && rect.left == 0);
COLORREF clr = ::GetSysColor(COLOR_BTNFACE);
if(dwStyle&CBRS_BORDER_RIGHT)
pDC->FillSolidRect(rect.right,0,-1,rect.Height(),clr); //right
if(dwStyle&CBRS_BORDER_BOTTOM)
pDC->FillSolidRect(0,rect.Width()-1, -1,rect.bottom,clr); //bottom
if(dwStyle&CBRS_BORDER_TOP)
pDC->FillSolidRect(0,0,rect.Width()-1 ,1,clr); //top
if(dwStyle&CBRS_BORDER_LEFT)
pDC->FillSolidRect(0,0,1,rect.Height() - 1,clr); //left
if(dwStyle&CBRS_BORDER_TOP)
++rect.top;
if(dwStyle&CBRS_BORDER_RIGHT)
--rect.right;
if(dwStyle&CBRS_BORDER_BOTTOM)
--rect.bottom;
if(dwStyle&CBRS_BORDER_LEFT)
++rect.left;
}
// This will make the XP style grippers, COOOL
void CToolBarXP::CreateGripperBrush ()
{
ASSERT (m_brGripperHorz.GetSafeHandle () == NULL);
ASSERT (m_brGripperVert.GetSafeHandle () == NULL);
WORD horzHatchBits [8] = { 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00 };
CBitmap bmpGripperHorz;
bmpGripperHorz.CreateBitmap (8, 8, 1, 1, horzHatchBits);
m_brGripperHorz.CreatePatternBrush (&bmpGripperHorz);
WORD vertHatchBits[8] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
CBitmap bmpGripperVert;
bmpGripperVert.CreateBitmap (8, 8, 1, 1, vertHatchBits);
m_brGripperVert.CreatePatternBrush (&bmpGripperVert);
}
Now the Toolbar is ok
|
|
|
|
|
I did not understand what bug you fixed. Simple bug in your code : in ToolBarXP.cpp insert #include "Tools.h"
Simvolokov Michael
|
|
|
|
|
The XP sytle StatusBar and ToolBar work very well but I have problems using the MenuBar.
I have added a member variable "CXPMenuBar m_wndMenuBar" to my MainFrm.h file and pasted the code from OnCreate() over to my MainFrm.cpp file but I get
some error messages from the linker.
(non-resolved external symbols public: virtual __thiscall CXPMenuBar::~CXPMenuBar(void)" (??1CXPMenuBar@@UAE@XZ) .......)
Can anybody help ?
|
|
|
|
|
I´m sorry - I have solved the problem now. I forgot one of the .cpp files.
|
|
|
|
|
I've just seen demo program. It looks great but... there is a problem with menu toolbar. When you maximize MDI-child window and then put a toolbar with new,open,etc buttons in the same line with menubar, buttons:minimize,restore,close for MDIChild are unavailable - they are on the right-hand end of a menu toolbar, but it's width equals program window's width and they are outside main window and invisible (if you click menubar to move it you can see that it's border goes outside main window). I haven't seen the code yet and I don't know if it is easy to fix. Could you think about this problem?
Thanks,
Maciek
|
|
|
|
|
Yeap, i have to fix that, thanks
|
|
|
|
|
If you are using code from Jean-Michel as you say, why is there no copyright or any kind of indication in the source. Either in the header or the source files. Also, you mention you dropped in other files so you would be able to have a menu go with it. But the authors tag is gone.
I think its great you found some stuff you could use here. But i dont think its asking alot to mention the original authors if you are using portions of their work. Dont remove people tags either. even if you dont want to include any of your own.
|
|
|
|
|
The controls that i use are the draw(.h, .cpp) and tools(.h,.cpp), i didn't remove anything of this, these are in that way, the toolbar, i was made by me innspired on the toolbar of Jean.
|
|
|
|
|
Hello,
at least for me, the menu accelerator keys are not working. Before I start looking for the possible cause of the problem, are they supposed to work or is accelerator handling not implemented?
Thanks,
Thilo
Setup Specialist 2001 - Software Installation at Your Fingertips
Download FREE Evaluation Version at http://www.setupspecialist.com/
|
|
|
|
|
Is not implemented, i'm working on that
|
|
|
|
|
Quick fix:
Add this to your Mainframe file(.cpp)
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if (m_wndMenuBar.TranslateFrameMessage(pMsg))
return TRUE;
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}
And this to the Mainframe.h in public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
|
|
|
I've Ctrl+O, Ctrl+N and they are working.
Maciek
|
|
|
|
|
I've just realised you are talking about something else.
Sorry.
Maciek
|
|
|
|
|