|
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
|
|
|
|
|
Cheers for great class, although I have one minor suggestion...
I recently had to write software for all flavours of Win32 where there was a danger of being run under Win95 pre IE3 (albeit a very minor chance).
I was willing to sacrifice the mouse tracking under this particular OS (95 w/o IE3) so I altered the code to use GetProcAddress() to test for existance of TrackMouseEvent().
This will at least allow the software to run on 95 w/o IE3.
I was wondering why this hadn't been done, are there some subtleties that I'm missing?
Thanks,
Neil
|
|
|
|
|
Skipping the call to TrackMouseEvent( ) simply kills the hover feature.
Calling GetProcAddress() it's safe, anyway there is a chance for win95
without IE3: the class calls _TrackMouseEvent() , not TrackMouseEvent() .
_TrackMouseEvent() was inserted into common controls dll, "comctl32.dll",
so if you ship your program with a setup that incudes the updated version of
Mfc42.dll and Comctl32.dll (and maybe Advapi32.dll and Oleaut32.dll ),
the button can use the hover feature.
|
|
|
|
|
Unfortunatly I have to distribute as a single executeable to be ran directly (from login scripts) and I don't want to start messing with peoples dll's.
The number of people with classic 95 is tiny (possibly non-existance) so I decided that they would simply have to live without the mouse over.
I was just wondering if there was a subtle reason why you had not worked around it youself if it is the only piece of functionality that fails under classic 95?
Its not a major concern, I was just curious if I was missing something.
Thanks for the reply,
Neil
|
|
|
|
|
There are other ways to capture the mouse movement, take a look at the button st code you'll see how to do this and it works in all platforms wiht out any modifications;)
|
|
|
|
|
CButtonST uses _TrackMouseEvent too, what's the difference?
|
|
|
|
|
If you don't want to use a masked bitmap for transparent bitmap, you can load it with:
::LoadImage(AfxGetInstanceHandle(),szID,IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS|LR_LOADTRANSPARENT);
This will use the top-left pixel color as the transparent color and map the button color to it.
|
|
|
|
|
This is a nice class, thanks David!
I wanted a way to use a transparent colour in bitmaps, to match the interface's grey colour properly, but I found using a mask image wasn't completely successful - it didn't draw the down state the way I wanted.
I did something like Gilad suggested:
In SetSkin()
//if (normal>0) m_bNormal.LoadBitmap(normal); //change this line...
// replace with this
if (normal>0){
HBITMAP hNormal=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(normal),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS);
m_bNormal.Attach(hNormal);
}
Now everything that is colour RGB(192,192,192) (the light grey in the resource editor palette) in your UP image will be repainted with the standard interface grey. Et voila!
You can always derive a new version of the class and override SetSkin to make the changes, if you don't want to alter the original.
Hope this is helpful to other beginners (like me).
Cheers,
Mike
|
|
|
|
|
Or even simipler, for the same effect:
// change this...
if (normal>0) m_bNormal.LoadBitmap(normal);
// to this...
if (normal>0) m_bNormal.LoadMappedBitmap(normal);
Mike
|
|
|
|
|
I did something like that some while ago. Instead of calling a function with 5 or 6 bitmap's IDs, you can set it all into one bitmap (like the toolbar) and use it.
For example, you can define the bitmap order: Normal,Pushed,Disabled
#define STATE_Normal 0
#define STATE_Pushed 1
#define STATE_Disabled 2
In the Init function, you add:
BITMAP bitmap;
CBitmap::FromHandle(hBitmap)->GetBitmap(&bitmap);
m_nWidth=bitmap.bmWidth;
m_nHeight=bitmap.bmHeight;
When you need to draw the image you add:
int x=(drawstate)*m_nWidth;
dc.BitBlt(0,0,m_nWidth,m_nHeight,&bitmapDC,x,0,SRCCOPY);
This will make it easier to handle the bitmaps. In case you want to replace them or edit them, you only need to access one file.
Other than that, wonderful work
|
|
|
|
|
That's a nice suggestion. I also implemented something like that some time ago
Another suggestion is to attach an ImageList to the button and then, for each state, set the index of the image to show.
- Thales
|
|
|
|
|
This can help the programmer. My suggestion was to help the user. In image list, you still need to edit each image separately. If you use a single bitmap, it's easier to handle it. Another idea is to use a single bitmap and transfer it to the image list.
|
|
|
|
|
Hi,
I love your class it was just what I was looking for. Already tried using it in my application, but found out that I need a mask value for "Down" and a mask value for "Over",.. the bitmaps I have are not the same. Is this going to be something you will implement? if not,.. then I'll do
Peter Marino ( IO Interactive )
www.marino.dk
|
|
|
|
|