CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2014
    Posts
    5

    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.Flags = CC_RGBINIT | CC_FULLOPEN ;
    // 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) {
    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


  2. #2
    Join Date
    Feb 2014
    Posts
    5

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

    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.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured