|
Hi!
I have a small improvement for the tooltip of a CxSkinButton. With this function you can colorize the tooltip as you want. The first COLORREF ist the text color, the second is the background color.
<br />
void CxSkinButton::SetToolTipColor(COLORREF crText, COLORREF crBkgnd)<br />
{<br />
if(m_tooltip.m_hWnd != NULL)<br />
{<br />
if(crText != NULL )<br />
m_tooltip.SetTipTextColor(crText);<br />
<br />
if(crBkgnd != NULL)<br />
m_tooltip.SetTipBkColor(crBkgnd);<br />
}<br />
}<br />
Perhaps someone will have use for it...
bye...
|
|
|
|
|
Thank you. Maybe it's time to update the article
|
|
|
|
|
Sorry, I made a small mistake in the 'SetToolTipColor' function.
If you check the COLORREF for not NULL you can't set the COLORREF to #000000 (black).
So the correct code is:
void CxSkinButton::SetToolTipColor(COLORREF crText, COLORREF crBkgnd)
{
if(m_tooltip.m_hWnd != NULL)
{
m_tooltip.SetTipTextColor(crText);
m_tooltip.SetTipBkColor(crBkgnd);
}
}
Here is another small function for the compensation of my bug
Call this function if you have enough of those colorized tooltips...
void CxSkinButton::ResetToolTipColor()
{
if(m_tooltip.m_hWnd != NULL)
{
m_tooltip.SetTipTextColor(GetSysColor(COLOR_INFOTEXT));
m_tooltip.SetTipBkColor(GetSysColor(COLOR_INFOBK));
}
} The function will set the tooltip text and background color to the system default.
|
|
|
|
|
Hi,
I've added a multiple line support for scinned buttons. The method CxSkinButton::DrawItem looks
now like follows:
void CxSkinButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT (lpDrawItemStruct);
//TRACE("* Captured: %08X\n", ::GetCapture());
//Check if the button state in not in inconsistent mode...
POINT mouse_position;
if ((m_button_down) && (::GetCapture() == m_hWnd) && (::GetCursorPos(&mouse_position))){
if (::WindowFromPoint(mouse_position) == m_hWnd){
if ((GetState() & BST_PUSHED) != BST_PUSHED) {
//TRACE("* Inconsistency up detected! Fixing.\n");
SetState(TRUE);
return;
}
} else {
if ((GetState() & BST_PUSHED) == BST_PUSHED) {
//TRACE("* Inconsistency up detected! Fixing.\n");
SetState(FALSE);
return;
}
}
}
CString sCaption;
CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC); // get device context
RECT r=lpDrawItemStruct->rcItem; // context rectangle
int cx = r.right - r.left ; // get width
int cy = r.bottom - r.top ; // get height
// get text box position
RECT tr={r.left+m_FocusRectMargin+2,r.top,r.right-m_FocusRectMargin-2,r.bottom};
//R.K. 07.03.03 New values for multi-line support
RECT rectsave = tr;
int hsize;
int iret;
GetWindowText(sCaption); // get button text
pDC->SetBkMode(TRANSPARENT);
// Select the correct skin
if (lpDrawItemStruct->itemState & ODS_DISABLED){ // DISABLED BUTTON
if(m_bDisabled.m_hObject==NULL)
// no skin selected for disabled state -> standard button
pDC->FillSolidRect(&r,GetSysColor(COLOR_BTNFACE));
else // paint the skin
DrawBitmap(pDC,(HBITMAP)m_bDisabled,r,m_DrawMode);
// if needed, draw the standard 3D rectangular border
if (m_Border) pDC->DrawEdge(&r,EDGE_RAISED,BF_RECT);
// paint the etched button text
pDC->SetTextColor(GetSysColor(COLOR_3DHILIGHT));
//RK pDC->DrawText(sCaption,&tr,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
// R.K. 07.03.03 Calculate new values for multi-line support
hsize = tr.bottom - tr.top; // Check maxsize of Rect
// Calc hsize of multiline text
iret = pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CALCRECT|DT_CENTER);
tr = rectsave;
tr.top = (hsize - iret) / 2;
pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CENTER);
pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
OffsetRect(&tr,-1,-1);
//RK pDC->DrawText(sCaption,&tr,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
hsize = tr.bottom - tr.top;
iret = pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CALCRECT|DT_CENTER);
tr = rectsave;
tr.top = (hsize - iret) / 2;
pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CENTER);
} else {
// SELECTED (DOWN) BUTTON
if ((lpDrawItemStruct->itemState & ODS_SELECTED)){
if(m_bDown.m_hObject==NULL)
// no skin selected for selected state -> standard button
pDC->FillSolidRect(&r,GetSysColor(COLOR_BTNFACE));
else { // paint the skin
DrawBitmap(pDC,(HBITMAP)m_bDown,r,m_DrawMode);
}
OffsetRect(&tr,1,1); //shift text
// if needed, draw the standard 3D rectangular border
if (m_Border) pDC->DrawEdge(&r,EDGE_SUNKEN,BF_RECT);
} else {
// DEFAULT BUTTON
if(m_bNormal.m_hObject==NULL)
// no skin selected for normal state -> standard button
pDC->FillSolidRect(&r,GetSysColor(COLOR_BTNFACE));
else // paint the skin
if ((m_tracking)&&(m_bOver.m_hObject!=NULL)){
DrawBitmap(pDC,(HBITMAP)m_bOver,r,m_DrawMode);
} else {
DrawBitmap(pDC,(HBITMAP)m_bNormal,r,m_DrawMode);
}
// if needed, draw the standard 3D rectangular border
if (m_Border) pDC->DrawEdge(&r,EDGE_RAISED,BF_RECT);
}
// paint the focus rect
if ((lpDrawItemStruct->itemState & ODS_FOCUS)&&(m_FocusRectMargin>0)){
r.left += m_FocusRectMargin ;
r.top += m_FocusRectMargin ;
r.right -= m_FocusRectMargin ;
r.bottom -= m_FocusRectMargin ;
DrawFocusRect (lpDrawItemStruct->hDC, &r) ;
}
// paint the enabled button text
pDC->SetTextColor(m_TextColor);
//RK pDC->DrawText(sCaption,&tr,DT_SINGLELINE|DT_VCENTER|DT_CENTER);
int hsize = tr.bottom - tr.top;
int iret = pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CALCRECT|DT_CENTER);
tr = rectsave;
tr.top = (hsize - iret) / 2;
pDC->DrawText(sCaption,&tr, DT_WORDBREAK|DT_CENTER);
}
}
Hope this is helpful.
Robert
|
|
|
|
|
Hi,
I tried your version of multiline, but in the demo-version, it shows de radiobuttons and checkboxes aren't properly displayed anymore. What I mean is that they seem to "forget" there checked status.
For normal pushbuttons, it works, but only when checking the "multiline"-option in the resource-properties of the multiline-button.
Have you noticed this problem also? Any idea how to solve it?
Greetz,
Peggy
|
|
|
|
|
I have a set of buttons on my dialog. I've implemented a resize button class that inherits from CxResizeButton and uses SetWindowPos to set the dialog's size.
The dialog also has a layout manager I wrote that monitors onSize and repositions the buttons and other controls.
If I don't enable WS_CLIPCHILDREN I get lots of flickering, which is logical since the entire background is redraw and so are the masked buttons I have on it. If I enable this style, There is no flickering during resizing, but for some reason the buttons don't display correctly. From what I've managed to figure, the mask is scaled 1 extra pixel to the left of the button, creating a vertical line that has a buggy display instead of displaying the background image.
any idea why this happens ?
thanks for your time guys
|
|
|
|
|
I try to show a popup menu besiding the button through RButtonDown message.
1. Add OnRButtonDown() function.
2. Use TrackPopupMenu() to popup menu besiding the button.
3. Menu appears.
4. Selects a item of menu or clicks any point on screen out of the
region of button to make the menu disapper.
5. An error occured.
77F767CD int 3
Could anyone kindly give me some advice?
Best regards!
|
|
|
|
|
Hi,
thanks for very good works.
BoundsCheck report that an error at the
SelectClipRgn((HDC)GetDC(), hClipRgn);
which the HDC is not valid.
I change the (HDC)GetDC() to GetDC()->m_hDC
this time the SelectClipRgn just return an
ERROR if you change it to:
if(SelectClipRgn(GetDC()->m_hDC, hClipRgn)==ERROR)
AfxMessageBox("ERROR");
it seems that some thing is wrong with the
hClipRgn.
Anyone can help me?
Thanks
|
|
|
|
|
Dear All,
I well appreciated your program (CxSkinButton) and I like it a lot espacially the interaction between the mouse and the check box (eyes with different color ; blue eye, red eye and gray eye). In your code, you are using for each check box different bitmap with the same size. I would like kindly ask you 2 questions :
1- How can I use a bitmap bigger than that used in your code ( I want to use a bitmap that has a size bigger than IDB_EYERED, IDB_EYEBLU or IDB_EYEGRAY.....) ?
2- When running the executable file of your code, How can I switch blue eye with red eye by clicking somewhere and without clicking on the check box ?
Thanks a lot for your help
email : abersabel2@hotmail.com
I love programming with vc++
|
|
|
|
|
Hi,
first, thank you for the class.
Second, Visual Studio reported a memory leak to me at line 227 and 237 in function DrawBitmap, when you delete the previously created compatible DC. I changed the code to call the CDC member function DeleteDC and everything is fine now
< DeleteDC(dcMask);
> dcMask.DeleteDC();
< DeleteDC(dcBmp);
> dcBmp.DeleteDC();
Dirk
|
|
|
|
|
Thank you
|
|
|
|
|
pleas help me
I'm quite new to vc++ 6.0, i can see the CxSkinButton class, but it dosent shows ...
I kan do work with classes and objects, but that Class Wizard is complicated
"Create (or edit) a member variable for each button you want to customize as CxSkinButton. If the Class Wizard doesn't show the CxSkinButton type, select CButton and then edit the code manually."
please help me, thx
|
|
|
|
|
Maybe you are here:
cxskinwzd.jpg (32.8 Kb)
Use CButton as variable type and click Ok, then open the header where the button
has been declared and replace CButton m_button1; with
CxSkinButton <br />
m_button1;
|
|
|
|
|
thanks man, that was the problem, i couldnt find the object definition m_button in the header files ... now is solved
you are so kind, I have an another question to you, why all these Control IDs no longer in use (IDC_...) cant be removed directly from the Class Wizard, what is the meaning that doing that manually and deleting them from the Resource.h ?
thx allot Davide
|
|
|
|
|
and with the View\Resource Symbols... menu?
|
|
|
|
|
thanks again, i made a foll of my self hahaha
|
|
|
|
|
I am using this class as the child of a CFrameWnd derived class and the ON_UPDATE_COMMAND_UI() handlers that I have set are not getting called.
Does anyone know why?
Thanks.
--
Dana Holt
Xenos Software
|
|
|
|
|
void CxSkinButton::FillWithBitmap(CDC* dc, HBITMAP hbmp, RECT r)
{
if(!hbmp) return;
CDC memdc;
memdc.CreateCompatibleDC(dc);
memdc.SelectObject(hbmp);//parameter should be a pointer?
int w = r.right - r.left;
int h = r.bottom - r.top;
int x,y,z; //what does x,y,z mean?
int bx=GetBitmapWidth(hbmp);
int by=GetBitmapHeight(hbmp);
for (y = r.top ; y < h ; y += by){
if ((y+by)>h) by=h-y;
z=bx;
for (x = r.left ; x < w ; x += z){
if ((x+z)>w) z=w-x;
dc->BitBlt(x, y, z, by, &memdc, 0, 0, SRCCOPY);
}
}
DeleteDC(memdc);
}
BOOL CxSkinButton::OnEraseBkgnd(CDC* pDC)
{return 1; } // doesn't erase the button background
//I can not understand deffernce between return 1 and return 0.
sorry I am poor in English ,and quite new to vc++
|
|
|
|
|
I was about to use your class when this class be problem.
I'd like to change whole screen area and buttons in the area over scaned image.
but, whole screen area images are not scaned well.
I added derivative buttons to CxSkinButton, loadbitmap of #2 be performed but getbitmap of #3 be not.
1: CBitmap tempBmp;
2: BOOL bRet = tempBmp.LoadBitmap(IDB_MAIN_BACK);
3: int nRet = tempBmp.GetBitmap(&m_backBM);
|
|
|
|
|
I can't see the problem
|
|
|
|
|
In SetSkin() I have found on my machine that this call fails:
SelectClipRgn((HDC)GetDC(),hClipRgn);
but can be fixed by substituting:
SelectClipRgn(GetDC()->m_hDC,hClipRgn);
|
|
|
|
|
LRESULT CxSkinButton::OnBMSetCheck(WPARAM wparam, LPARAM)
function should be changed -
instead of ::PostMessage(hwnd2, WM_CXSHADE_RADIO, 0, 0);
better too use ::SendMessage(hwnd2, WM_CXSHADE_RADIO, 0, 0);,
otherwise, messages may get lost, for instance if you want to
set radiobuttons states from OnRadioButton() functions.
|
|
|
|
|
Thank you!
|
|
|
|
|
I forgot to delete an object in the file xSkinButton.cpp at Line 363:
HRGN hr=CreateRectRgn(pRects[i].left, pRects[i].top, pRects[i].right, pRects[i].bottom);
VERIFY(CombineRgn(hRgn, hRgn, hr, RGN_OR)!=ERROR);
if (hr) DeleteObject(hr);
|
|
|
|
|
hi, i*ve used your button class and it works fine.
but with my own drawn buttons i've a problem. I will get an assertion failure when compiling under w2000.....what specification does the button must have ?????
thanx for help
|
|
|
|
|