 |
|
 |
The are some things to be changed.
iconbutton.h:
afx_msg LRESULT OnNcHitTest(CPoint point); void SetItalic ( BOOL bVal = true ) { m_TextMetrics.tmItalic = (BYTE)bVal; NewFont (); };
void SetUnderline ( BOOL bVal = true ) { m_TextMetrics.tmUnderlined = (BYTE)bVal; NewFont (); };
void SetStrikeOut ( BOOL bVal = true ) { m_TextMetrics.tmStruckOut = (BYTE)bVal; NewFont (); };
iconbutton.cpp:
LRESULT CIconButton::OnNcHitTest(CPoint point)
buttondemodlg.cpp:
::MessageBeep ((UINT) -1 );
@RedFraggle: Thanks for better Tooltips
modified 24 Oct '11.
|
|
|
|
 |
|
 |
Hello,
thanks for sharing your code corrections to keep it running in higher VS´s
Greetings Alex.
|
|
|
|
 |
|
 |
Very good one. Thank you very much.
|
|
|
|
 |
|
 |
Can I use this code in commercial program, what is the licence.
|
|
|
|
 |
|
 |
Yes for sure. You can use it in your commercial app. the code is under the "The Code Project Open License (CPOL)" license
* Source Code and Executable Files can be used in commercial applications;
* Source Code and Executable Files can be redistributed; and
* Source Code can be modified to create derivative works.
* No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is provided "as-is".
Regards
Alex.
modified on Sunday, September 20, 2009 10:51 AM
|
|
|
|
 |
|
|
 |
|
 |
I´m glad that you like the code.
Thank you !
Alex.
|
|
|
|
 |
|
 |
Thanks a lot for your class!
The only thing i do not like so much is the Tooltips. They come too soon (no delay) and look a littlebit 'fat'
I would prefer standard tooltip control...
I found an easy way to change that (i took this code out of a class found on codeguru,
http://www.codeguru.com/article.php/c2241 Chart Drawing Solution by Massimo Colurcio)
In the header, add/or change:
void SetTipText ( const CString &sTxt ) ;
bool ActivateToolTip(bool bActivate);
protected:
bool InitToolTip();
//{{AFX_MSG(CIconButton)
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_MSG
private:
CToolTipCtrl m_tt;
and in the cpp implement:
void CIconButton::SetTipText ( const CString &sTxt )
{
InitToolTip();
// If there is no tooltip defined then add it
if (m_tt.GetToolCount() == 0)
{
CRect rect;
GetClientRect(rect);
m_tt.AddTool(this, sTxt, rect, 1);
}
m_tt.UpdateTipText(sTxt, this, 1);
m_tt.Activate(sTxt.IsEmpty()?false:true);
return ;
};
BOOL CIconButton::PreTranslateMessage(MSG* pMsg)
{
InitToolTip();
m_tt.RelayEvent(pMsg);
return __super::PreTranslateMessage(pMsg);
}
bool CIconButton::InitToolTip()
{
if (m_tt.m_hWnd == NULL) {
m_tt.Create(this);
m_tt.Activate(true);
m_tt.SendMessage(TTM_SETMAXTIPWIDTH, 0, 400);
}
return true;
}
bool CIconButton::ActivateToolTip(bool bActivate)
{
if (m_tt.GetToolCount() == 0)
return false;
// Activate tooltip
m_tt.Activate(bActivate);
return true;
}
you also have to throw away all the old tooltip drawing, just search for 'tip' in the code
|
|
|
|
 |
|
 |
Thank you for your compliment and thanks for this enhancement.
Greets Alex.
|
|
|
|
 |
|
 |
Simple and nice
|
|
|
|
 |
|
 |
how to make colorful button such as red ,blue not gray
|
|
|
|
 |
|
|
 |
|
 |
Why after i Extract the demo file but inside the file can't see the dsw file so how can i open with program visual c++
|
|
|
|
 |
|
 |
The click speed of your button isn't as good as a normal buttons.
Try clicking the botton more than once, or double click it.
Andreas.
|
|
|
|
 |
|
 |
Hi !
I am personnaly gratefull to the job done here because I have
a project with code size limitations.
The objective of code bellow is reached, at less for me !
( Never think size do not matter
Thanks again...
|
|
|
|
 |
|
 |
I don't quite get it. Why reinvent the wheel when Davide Calabro and Davide Pizollato have already done this and then some?
Davide Calabro's CButtonST
Davide Pizolatto's CxShadeButton
|
|
|
|
 |
|
|
 |
|
 |
Yes, it's lightweight, but this is not embedded programming. A person can save 10K, but what is the value if it's overwhelmed by the multi megabyte size of the application. It is like withdrawing a drop of water from a lake. (Sorry, about that last statement. I'm reading too much "Romance of the Three Kingdoms".)
Even if a person was interested in lightweight classes, who can resist the allure of Davide Calabro's flat feature, 9 shadings, transparency, and bitmap support? It is like looking upon the PS2 for the first time and then glancing back at the playstation 1. (That last statement has nothing to do with "Romance of the Three Kingdoms".)
|
|
|
|
 |
|
 |
Read "Getting Real" : Always underdo competition, go for less features.
But since you're doing MFC, I guess you don't mind useless bloat.
What am I doing, replying on CodeProject, sheesh
|
|
|
|
 |
|
 |
Allow me to cite another rule. Do not reinvent the wheel. If someone must develop an alternative, then he should justify why he is doing so, hopefully something beyond inflating one's ego.
Now as for your approach of underdo. Underdo will not work if the programmers are left feeling hungry. If CButtonST and like offer more, why would programmers ever gravitate toward an underdeveloped alternative? All technology is gravitating toward making stuff chock full of features. Even with your beloved ruby language, ruby is rich in features and that makes everyone fall in love with it.
|
|
|
|
 |
|
 |
Well done...
|
|
|
|
 |
|
 |
Hi, i got a big project now a want a owner draw button and find your code.
iam at the starting of c++ and now i get this error
avedit.cpp(23) : error C2370: 'THIS_FILE' : redefinition; different storage class
iconbutton.cpp(7) : see declaration of 'THIS_FILE'
and i dunno how to fix it :\
maybe some one of you can help me
Big Thanks
MfG
Benjamin R.
|
|
|
|
 |
|
 |
Mh ok .. my mistake ..
i do suck
Sorry :\
|
|
|
|
 |
|
|
 |
|
 |
can you control the place of the icon and the text on the cbutton??
i mean, can you decide to place the text right or left, idem for the icon ??
|
|
|
|
 |