Originally posted by: aprock
Great class, but your class seems to have this AWFUL habit of freeing resources which were allocated externally. This causes no end of problems if you switch bitmaps frequently.
- Andrew
ReplyOriginally posted by: M Smythe
Certainly makes MFC GUI's a bit more exciting.
Great work!!!!!!.
Many thanks
Reply
Originally posted by: Davide Calabro'
I'm aware that hundreds of people are using
CButtonST in their applications all around
the world; however I've received very few
money supports for my classes. I do this
mainly for fun but spending hours and hours is
becoming hard in terms of time and in terms of
resources (hardware failures the last one).
Only on CodeProject, for example, near 160.000
people visited the CButtonST page; if I'd got
a support from even the half of them I could
finally get a better house where live :)
I'm also trying to buy a fast notebook to be
able to work on my classes when I'm away from
home due to my job.
So, if you find CButtonST worth 1$ just put
it into an envelope and send to the following
address:
Davide Calabro'
P.O. Box 65
21019 Somma Lombardo (VA)
Italy
Please donate,
Davide Calabro'
Originally posted by: Davide Calabro'
CButtonST version 3.6 has the ability to change the menu just before it is displayed. This means that now menu items can be disabled.
It can be found at http://www.softechsoftware.it
Davide Calabro'
Originally posted by: sun
Add SetBkColor function in you code.
ReplyOriginally posted by: sun
If I don't set Dialog Back Color,the transparent is good,but when i use this function after,the button's background is Gray,How to fix it???
//Set Dialog BackColor
HBRUSH CMyDlg:OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_DLG)
return (m_brush); //draw dialog other color
else
return (CDialog::OnCtlColor(pDC, pWnd, nCtlColor));
}
//One Button On InitDialog
{
...
//set white color is transparent
m_btnMin.SetBitmaps(IDB_MIN, RGB(255,255,255));
...
}
//first setfocus
void CMyDlg::OnSetFocus(CWnd* pOldWnd)
{
CDialog::OnSetFocus(pOldWnd);
// Do only once
if (m_bFirstTime == TRUE)
{
m_bFirstTime = FALSE;
//...
m_btnMin.DrawTransparent(TRUE);
//...
}
}
Reply
Originally posted by: xtz
//I set m_menuPopup is public access,and invoke this function in my initdialog
m_btnMain.m_menuPopup.LoadCheckmarkBitmap(IDB_UNCHECK,IDB_CHECK);
and this
void CMyDlg::OnUpdateMmenuAutorun(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(m_bIsAutoRun);
}
//when click it ,switch m_bIsAutoRun into true & false
It doesn't work!!!
ReplyOriginally posted by: J.R.
//Just add a this funktion declaration in BtnST.h:
//and add a this funktion implementation in BtnST.cpp:
return ::EnableMenuItem(m_hMenu, uIDEnableItem, uEnable);
//Then to enable or disable a menu item call this funtion like this:
m_ctrlOperationerBtn.EnableMenuItem(ID_MY_MENU_ITEM_XXX, MF_ENABLED); //Enable.
///////////////////////////////////////////////
//First create a applikation global message for example in your Stdafx.h file like this:
//Add the next code line in BtnST.cpp in function OnClicked() after the ::GetSubMenu(m_hMenu, 0) call like this:
//Then catch the message in the parent class to your CButtonST control by adding a line in the message map like this:
//And then add the function OnBntSTMenuShow() that will enable and disable the menu items.
/ J.R.
Hello!
There was no solution implemented to disable menu items so i did
one simple solution to get a round that! Not for BTNST_USE_BCMENU.
BOOL EnableMenuItem(UINT uIDEnableItem, UINT uEnable);
BOOL CButtonST::EnableMenuItem(UINT uIDEnableItem, UINT uEnable)
{
if(! m_hMenu)
return FALSE;
}
m_ctrlOperationerBtn.EnableMenuItem(ID_MY_MENU_ITEM_XXX, MF_GRAYED); //Disable.
I will implement a solution that sends a CN_UPDATE_COMMAND_UI
message that you can catch in your class by the message-loop
message ON_UPDATE_COMMAND_UI(ID_MENU_XXX, OnUpdateMenuXXX)
But i don�t have time for that rigth now!
So i did a quick and dirty implementation that notifys the
parent to the CButtonST control that the menu i about to be displayed!
Note that if you have more then one CButtonST with menu�s the
same message will be send for all your controls with this solution!
But you can check with button that is active by calling GetFocus() or some thing like that!
#define WM_BNTST_MENU_SHOW (WM_USER + 22279)
HMENU hSubMenu = ::GetSubMenu(m_hMenu, 0);
GetParent()->SendNotifyMessage(WM_BNTST_MENU_SHOW, 0, 0);
BEGIN_MESSAGE_MAP(CPifsMainPage, CPropertyPage)
//{{AFX_MSG_MAP(CPifsMainPage)
ON_CBN_SELENDOK(IDC_P3_PROJEKT_CBO, OnSelendokP3ProjektCbo)
ON_WM_LBUTTONDBLCLK()
ON_WM_TIMER()
ON_WM_SIZE()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_SILENTMODE_CHECK, OnSilentModeCheck)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_BNTST_MENU_SHOW, OnBntSTMenuShow)
END_MESSAGE_MAP()
//Example:
void CPifsMainPage::OnBntSTMenuShow()
{
// Her i check a member variable and disable all menu items if it�s empty else i enable them.
if(m_currProjektData.sNamn.Compare("") == 0)
{
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_FU_PMACTION_TYPE, MF_GRAYED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_FU_PMCALENDER_TYPE, MF_GRAYED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_AO, MF_GRAYED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_UPDATE_AO, MF_GRAYED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_IMPORT_AO, MF_GRAYED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_CLEANUP_FROM_P3, MF_GRAYED);
}
else
{
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_FU_PMACTION_TYPE, MF_ENABLED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_FU_PMCALENDER_TYPE, MF_ENABLED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_NEW_AO, MF_ENABLED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_UPDATE_AO, MF_ENABLED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_IMPORT_AO, MF_ENABLED);
m_ctrlOperationerBtn.EnableMenuItem(ID_OPERATION_CLEANUP_FROM_P3, MF_ENABLED);
}
}
Originally posted by: J.R,
Hello!
Fist thanks for this great class!
I wonder if there is a simple way to disable menu items like i do with the menu�s items in the menu-bar on the ON_UPDATE_COMMAND_UI message, when i have a CButtonST control with a menu?
Thanks / J.R.
Originally posted by: GraduateCat
Love the ShadeButtons.
Reply