Re: Re: Is CBitmapButton the right tool for a push like checkbox?

Jim Barry <[email protected]>
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
On 31 July 2010 10:20, addicted2freefall <addicted2freefall-/[email protected]>wrote:

> This project must be ready for presentation by Monday morning, so I'd
> prefer to stick with the simplest method that works if I can, so if CButton
> with a PBUTTON_IMAGELIST will give me the pushlike behaviour without having
> to add custom coding, I'd like to go that route - at least for now!
>

I guess it's a bit late now, but anyway...


> I've created a test harness project for the toolbar, and I've uploaded it
> to RapidShare - if anyone wants to have a look at the code and see if they
> can get it going, here's the VS2008 project link:
>
> http://rapidshare.com/files/410153950/CustomToolbar.rar


BCM_SETIMAGELIST does work, but the problem is that there seems to be no way
to explicitly turn off the button border. However, I discovered that if you
use BUTTON_IMAGELIST_ALIGN_CENTER and make the button exactly the same size
as the image, then the button border is no longer visible. On Vista/Win7,
you get image transition effects thrown in for free, which is pretty nice.

In your PlayerToolbar.h file, replace all occurrences of CBitmapButton with
CButton. Then, in your InitialiseControls() function, change your loop like
this:

for( int n = 0; n < nElements; n ++ )
{
    pBtn = pButtons[n];
    pLst = pILs[n];
    nImgID = btnImgIDs[n];
    nCtrlID = ctrlIDs[n];

    pLst->CreateFromImage( nImgID, 25, 1, CLR_NONE, IMAGE_BITMAP,
LR_CREATEDIBSECTION );
    *pBtn = GetDlgItem(nCtrlID);
    RECT rect = { 0, 0, 0, 0 };
    BUTTON_IMAGELIST bil = { pLst->m_hImageList, rect,
BUTTON_IMAGELIST_ALIGN_CENTER };
    pBtn->SetImageList(&bil);
    pBtn->SetWindowPos(0, 0, 0, 25, 25, SWP_NOZORDER | SWP_NOMOVE);
}

Finally, modify your image-list bitmaps so that they contain four images:
normal, hot, pressed, disabled. It seems that you must include a "disabled"
image for it to work - I have no idea why.

Cheers,

- Jim


[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/wtl/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/wtl/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.