|
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
|
|
|
|
|
Although it's technically possible, I imagine some problems:
the mask bitmap is actually used for:
1) clipping region
2) transparency
If you're interested to transparency only, the button should be rectangular (no clipping region), but I don't know if this is ok for your application. In this case I prefer the icons, like in the CxShadeButton or CButtonST articles (for example a flat button with 72x72 icons).
If you also need an irregular region, the clipping region should be the combination of the 3 masks to avoid button malfunctions, but the user could click the button when the mouse is outside the images, and I don't think it's a good behavior...
|
|
|
|
|
Good work done, buddy. I like this button class.
Hush..Hush.. thought I heard you calling my name now...
|
|
|
|
|
this class has a serious error on following senario
"when the mouse is on the center of an elliptic button there is no responce from button "
|
|
|
|
|
It was a little bug in the region function; this happen
when there are less than 2 white pixels in the right side of the mask.
to fix this I changed the lines 308 and 312 in xSkinButton.cpp:
line 308:
if (wasfirst && ((ismask && (j==(bm.bmWidth-1)))||(ismask ^(j<bm.bmWidth)))){
line 312:
pRects[ pRgnData->nCount++ ] = CRect( first, bm.bmHeight - i - 1, j+(j==(bm.bmWidth-1)), bm.bmHeight - i );
With this the bitmaps don't need the white border around.
|
|
|
|
|
Did you draw the bitmap button "button1(round button)"?
In case me, the picture draw in paint shop pro.
by the way, problem is to be set transparency in background.
please! help me......
jang ki-young
|
|
|
|
|
Did you draw the bitmap button "button1(round button)"?
In case me, the picture draw in paint shop pro.
by the way, problem is to be set transparency in background.
please! help me......
jang ki-young
|
|
|
|
|
Hi,
I just want to use this special button as part of a dynamic
application. This means all of my button will be generated
at runtime and has "ownerdraw" as property set.
All button will be generated by an own class called "InputButton"
and the method "DrawItem".
So how can I use CxSkinButton to tune my application ?
Robert
|
|
|
|
|
You can declare CxSkinButton instead of CButton or you can subclass a CxSkinButton to one of your existing button
|
|
|
|
|
I really like your class, however I am writting an app which needs to be able to run with 256 colours. This causes real ugliness. I have tried to fix this using MS's CDib class (from the KB) to carry around palettes and stuff but the best I can manage to get is nice looking buttons UNLESS they are ovelapped transparent buttons. In this case they look crap.
So what I'm getting at is
1. Have you got your own version which deals with this which you haven't shared?
2. Given your greater skill in playing this game, could you in the future look
into it.
Many thanks
Julien.
|
|
|
|
|
try to use the same palette for all the bitmaps...
|
|
|
|
|
It may be helpful to us casual browsers if you listed how this is different or is an improvement over mfc's CBitmapButton class I haven't had a chance to look at the code but the example graphics look cool!
|
|
|
|