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.Flags = CC_RGBINIT | CC_FULLOPEN ;
// cc.hwndOwner = hwnd ; // this hangs parent, as well as me
//******************************************************************
case WM_COMMAND: // for keyboard handling
{ // create local context
DWORD cmd = HIWORD (wParam) ;
DWORD target = LOWORD(wParam) ;
switch (cmd) {
case BN_CLICKED:
switch(target) {
case IDB_ATTR_SET:
result = select_color(hwnd, test_init.set_bit) ;
if (result >= 0) {
// do something with the value
}
break;
} //lint !e744 switch target
return true;
} //lint !e744 switch cmd
I built a stripped-down version of the offending program, in case anyone wishes to take a look at it. It requires MinGW toolchain to compile. If one presses the Set, Clear, or Bgnd buttons, it will call ChooseColor() to open the color dialog, but it is not possible to click on anything in the color dialog. Interestingly, the Exit button on the main program still works, and is the only way to close the program at this point.
I have tested this on multiple Win7/64bit and WinXP/SP3/32bit machines. I also tried building the program with three different versions of MinGW; none made any difference in this behavior.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.