Page 1 of 4
CustomButtons
Posted: Sat Oct 21, 2006 5:22 am
by netmaestro
This is a PureBasic library that allows you to create buttons with any look or shape you want, perfect for applying to skinned windows. All functions in the lib should be W9x compatible, so you don't need XP to create cool custom buttons. Here's a quick test:
http://www.networkmaestro.com/CustomButtonTest.exe
And here is the library package:
http://www.networkmaestro.com/CustomButton.zip
Basically you supply an image strip with four equal-sized images, one to display each of the button states Disabled, Unpressed, Hover, Pressed. You create the gadget with one call, so it's very easy to use.
In the demo, the second button enables the first one, and the third disables it again. It just shows all four looks.
Posted: Sat Oct 21, 2006 8:31 am
by srod
Great work as always.
That is brilliant.

Posted: Sat Oct 21, 2006 8:47 am
by Droopy
Thanks man

Posted: Sat Oct 21, 2006 9:14 am
by netmaestro
Thanks for the kind words and backatcha, srod!
My apologies, in the course of the last couple days I reworked the logic in this library and I notice that the version I released on the forum still asks for a background color parameter (second last parameter) This is not used by the lib anymore and is completely ignored. I've updated the lib and help file/examples, so if you'd rather not put redundant parameters in, you can download the updated version. Again, sorry for my inattention to this particular detail.
Posted: Sat Oct 21, 2006 10:32 am
by mskuma
Thanks netmaestro - very nice work as usual. I wondered about the mouse down action though. Unless I'm mistaken, when you press a button and hold the mouse button down and move off the button, then move back over it (while the mouse button is still down) the mouse down artwork should show. In that case, I think yours shows the mouse hover artwork. If the intention is that your button is a windows button replacement, it should behave like a regular windows button. Then again that might not be the intention, so in that case, please disregard the comment.
If I can nitpick just a little bit more - the only other nice thing to have would be an alpha-blended edge, then it would be absolutely perfect. [edit: I could be wrong.. that was just judging from the demo - I haven't tried it with the lib - in that case, apologies]
Posted: Sat Oct 21, 2006 10:47 am
by netmaestro
It reverts immediately to unpushed when you move off while pressed, on my computer anyway. That's identical to the normal button behaviour afaik.
Some tips are probably in order for achieving good results regarding transparency. All the tools are provided to skin the button either transparently or based on window background. If I had a round button that I wanted to show alphablended on a patterned background, I probably wouldn't use transparency for that. I'd make the button images in a good quality photo editor against the patterned background and call the CustomButton function with #CB_SolidBrush, which tells it that it's to draw the full button rectangle without transparency. That way, your round button will look as nice as you were able to achieve in the photo editor because its background is a snippet of the window pattern brush.
Posted: Sat Oct 21, 2006 11:01 am
by mskuma
netmaestro wrote:It reverts immediately to unpushed when you move off while pressed, on my computer anyway. That's identical to the normal button behaviour afaik.
As I wrote, I'm talking about when you rollback over the button with the mouse down.
Posted: Sat Oct 21, 2006 11:04 am
by netmaestro
Yes, I just saw that part, I didn't see it the first time, I'll definitely take a look, thanks for pointing it out.
Posted: Sat Oct 21, 2006 11:10 am
by netmaestro
I wondered about the mouse down action though.
Fixed. Thanks for the report. I hadn't noticed it before.
Posted: Sat Oct 21, 2006 11:16 am
by mskuma
Thanks alot. I'm not sure, did you update the demo exe? I just redownloaded it, but I think it still does the same thing.
Posted: Sat Oct 21, 2006 11:18 am
by netmaestro
Good point, the demo exe. I might take a few minutes and make a nice alphablended example for that.
Posted: Sat Oct 21, 2006 12:15 pm
by netmaestro
Demo is updated, shows alphablending and correct mousemove behaviour. The second button toggles the first one enabled and disabled to show all four states.
Posted: Sat Oct 21, 2006 12:30 pm
by mskuma
netmaestro wrote:correct mousemove behaviour
Almost correct. Holding the mouse down should only affect the button you originally pressed. Yours will apply the mouse down affect to the neighbouring button, which is not what Windows does. To confirm what does happen, open up calculator and press and hold a button, then move over to the next button (while the mouse button is depressed) and you'll see nothing happens to neighbouring buttons.
Posted: Sat Oct 21, 2006 1:15 pm
by netmaestro
Ok, I think I have it. Could you redownload and test all the combinations and permutations of mousebutton-up and mousebutton-down surfing over the buttons and see if everything works as it should? I've tried it a lot and can't make it do anything unexpected, but I could easily miss something. Thanks!
Posted: Sat Oct 21, 2006 1:52 pm
by mskuma
On my machine, the first couple of passes moving from pressing the left graphic button, holding the mouse button down and moving to the right button (with mouse still held down) & back to the left button again worked ok (i.e. only showing mouse-down artwork on the left button) but after several repetitions of moving to the right button and back to the left and vice-versa, all with the mouse held down, eventually I could see the same issue again (right button's mouse down art appearing when it shouldn't). I could see the same issue if I started from the right button. Running XP Pro.