WinAPI/C++/Dialog - ChooseColor() ignoring mouse

I have a Windows dialog-based application here. I have a button that calls ChooseColor() to let the user select a new color for the program. However, when I click the button, the color dialog opens, but the mouse and keyboard appear to be completely ignored on it.

I've never seen this happen before, does anyone know what could cause this?? The relevant code is included below.

static int select_color(HWND hwnd, COLORREF old_attr)
static CHOOSECOLOR cc ;
static COLORREF crCustColors[16] ;

// init-int this array did not affect the mouse problem
// uint idx ;
// for (idx=0; idx<16; idx++) {
// crCustColors[idx] = RGB(idx, idx, idx) ;
// }

ZeroMemory(&cc, sizeof(cc));
cc.lStructSize = sizeof (CHOOSECOLOR) ;
cc.rgbResult = old_attr ;
cc.lpCustColors = crCustColors ;
// cc.hwndOwner = hwnd ; // this hangs parent, as well as me

if (ChooseColor(&cc) == TRUE) {
return (int) cc.rgbResult ;
} else {
return -1 ;

case WM_COMMAND: // for keyboard handling
{ // create local context
DWORD cmd = HIWORD (wParam) ;
DWORD target = LOWORD(wParam) ;

switch (cmd) {
switch(target) {
result = select_color(hwnd, test_init.set_bit) ;
if (result >= 0) {
// do something with the value
} //lint !e744 switch target
return true;
} //lint !e744 switch cmd

Later note: I created a stripped-down version of this application, which demonstrates this issue. I don't see any way to attach a file here, but the package can be downloaded from my website:

This is built using MinGW toolchain. It has been tested on multiple Win7/64bit and WinXP/SP3/32bit machines, all showing the same behavior.
Last edited on
Topic archived. No new replies allowed.