This is a little custom control I coded some time ago. I had a dialog box where you could select several colors, so I put several buttons coloured as the selected colors, when you clicked on them ChooseColor would be invoked.
I'm not sure I've explained myself well, so to make up for my bad english ;) I'll post some code here. It's not optimized at all, actually I coded it in a hurry, so I'll appreciate any help from you coding gurus here. I have also hardcoded a couple of values, so I'm not sure it works fine for every Windows, or with different schemes.

Hope It's useful. :)

EDIT: I've decided to post an attachment instead of pasting the code here. Now I've also included a test program. Tried to add a new feature (sending BN_CLICKED messages when a new color was picked), but it didn't work... :( )
Posted on 2003-07-07 11:03:56 by QvasiModo
Here's the attachment.

EDIT: Attachment deleted to save space (85 downloads). See bottom of thread.
Posted on 2003-07-07 15:44:10 by QvasiModo
New version!

Corrected a few bugs, but there's one I still couldn't get rid of - it seems to flicker whenever you click on it. I'm pretty sure the DrawControlFrame call is responsible for the flicker, as it (appears to be) doesn't just draw the frame, but also paints the rest of the control as well... Anyway, it's not that bad, you won't even notice unless your button is HUGE and you click on it several times per second :grin:

I also tried to use a standard push button instead of this control, and colour it by responding to notify messages, but it didn't work. I've read somewhere in this board that it was impossible. I wonder if the DrawControlFrame API has anything to do with it... :confused:

I'm attaching the new source, together with my test programs... Try it and tell me what you think :)

EDIT: Attachment deleted to save space (36 downloads). See bottom of thread.
Posted on 2003-07-10 16:09:17 by QvasiModo
This is probably my final version, unless there are bugs to fix, requests to add features :grin: or if I decide it's a good time to learn how to use those XP themes in custom controls.

It doesn't seem to ficker anymore, so I guess it's finished. This is freeware... if you ever use it in your programs, please let me know :)

EDIT: Attachment deleted to save space (36 downloads). See bottom of thread.
Posted on 2003-07-16 16:33:08 by QvasiModo
Updated:
- Renamed to "ColorBtn", because RadAsm already comes with a custom control of that name.
- Added support for RadAsm, now it can be integrated with the dialog editor (see readme file).
- A series of small improvements in the code, I can't remember anyway.

This is my first try at RadAsm custom control interface, so feel free to post any comments/bugs/suggestions, etc...

EDIT: Attachment deleted to save space (33 downloads). See bottom of thread.
Posted on 2003-08-21 18:28:13 by QvasiModo

New version!
Corrected a few bugs, but there's one I still couldn't get rid of - it seems to flicker

What is really flickering, that's Clock in WinNT :tongue: :tongue: :tongue:

Nice work, QvasiModo :alright:

since you use
        invoke SendDlgItemMessage,hwnd,IDC_COLOR2,CLBM_SETCOLOR,00FFFFFFh,0     ;white

invoke SendDlgItemMessage,hwnd,IDC_COLOR3,CLBM_SETCOLOR,000000FFh,0 ;red
invoke SendDlgItemMessage,hwnd,IDC_COLOR4,CLBM_SETCOLOR,0000FF00h,0 ;green
invoke SendDlgItemMessage,hwnd,IDC_COLOR5,CLBM_SETCOLOR,00FF0000h,0 ;blue

I'd like to know what do you think of my post to
this thread

NaN seems some missunderstanding me
or maybe :stupid:
Posted on 2003-08-21 19:56:29 by S.T.A.S.
You're right, it is a good idea. NaN's last post there seems to follow your proposal. However it's too big for this particular program (it doesn't make so many calls to SendMessage). It would be good to know exactly at wich point does it save bytes...
In any case, your first version can be slightly modified to store both the control ID and wParam, I'll try that and see if any bytes are saved :)
Posted on 2003-08-22 10:07:36 by QvasiModo

It would be good to know exactly at wich point does it save bytes...

Each call takes some bytes, and push, too ;)
You'll never write:
mov , eax
mov , eax
mov , eax
....
You'll write a loop instead

Why not use this techic in other ways? We're at asm :alright:

P.S. I'm from 8bit old box, so it's just some kind of my madness :grin:
Posted on 2003-08-22 18:29:06 by S.T.A.S.
New update...
Posted on 2003-08-29 15:15:37 by QvasiModo