Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. WinAPI/C++/Dialog - ChooseColor() ignoring mouse

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

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++data-structuresquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Derell Licht
    wrote on last edited by
    #1

    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 //************ 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: home.comcast.net/~derelict/files/ChooseColor.hang.zip This is built using MinGW toolchain. It has been tested on multiple Win7/64bit and WinXP/SP3/32bit machines, all showing the same behavior.

    L 1 Reply Last reply
    0
    • D Derell Licht

      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 //************ 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: home.comcast.net/~derelict/files/ChooseColor.hang.zip This is built using MinGW toolchain. It has been tested on multiple Win7/64bit and WinXP/SP3/32bit machines, all showing the same behavior.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I just tried the above code and it works fine.

      Veni, vidi, abiit domum

      D 1 Reply Last reply
      0
      • L Lost User

        I just tried the above code and it works fine.

        Veni, vidi, abiit domum

        D Offline
        D Offline
        Derell Licht
        wrote on last edited by
        #3

        Huh?!?!? You can select cells in the color dialog, and the cancel/okay buttons work?? That's bizarre... Did you build with MinGW ? If so, what version? (though I don't think that matters)... I also went back to another small dialog-based application that I wrote some time ago, and pasted the select_color() function into it and called it from a button, and that worked fine as well. This is really twisting my brain in a knot !!!!!

        L 1 Reply Last reply
        0
        • D Derell Licht

          Huh?!?!? You can select cells in the color dialog, and the cancel/okay buttons work?? That's bizarre... Did you build with MinGW ? If so, what version? (though I don't think that matters)... I also went back to another small dialog-based application that I wrote some time ago, and pasted the select_color() function into it and called it from a button, and that worked fine as well. This is really twisting my brain in a knot !!!!!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Derell Licht wrote:

          Did you build with MinGW ?

          No, just standard Win32 code. I suspect there is something else happening in your code that causes this problem.

          Veni, vidi, abiit domum

          D 1 Reply Last reply
          0
          • L Lost User

            Derell Licht wrote:

            Did you build with MinGW ?

            No, just standard Win32 code. I suspect there is something else happening in your code that causes this problem.

            Veni, vidi, abiit domum

            D Offline
            D Offline
            Derell Licht
            wrote on last edited by
            #5

            Please clarify... when you say "I just tried the above code and it works fine.", do you mean you put the code fragment that I printed, in another program and ran it? I was hoping you downloaded and built my sample code... I guess that would be a problem if you don't use MinGW. I agree that it is something in my code, but I'm damned if I can figure out what !! I'm comparing the stripped-down failing code against another working Win32 utility that I have (where the button code works fine), and for the life of me I cannot figure out what the difference is!! What I'm doing now, is I made a copy of the working project, and am pasting pieces of my target project into it, one piece at a time, until I hopefully find what breaks the color dialog. My great fear is that I'll never find it, and the copied project will work fine - and I'll NEVER figure out why this one is broken... :wtf: //************************ Later note: yeah, I got the application completely ported over from the original project to the new project based on a dialog where the ChooseColor() worked properly, and the entire project works fine. Of course, I can't find any difference between the two, that could explain the original problem. I guess I'll never know...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups