The greying of disabled controls is performed by the OS itself. You say it's disabled and the OS uses the appropriate colors as defined in the system palette to display them. These colors are system wide and whilst you can change them, you would affect all other apps on the desktop which isn't very freindly.

The second alternative is to create your own application palette that has the same colors for disabled controls as for enabled, and then realize that palette when required. This is a lot of work, and Win32::Gui doesn't support these functions, so you would have to use Win32::API to get at them.

A third alternative would be to place a transparent window that does nothing over the top of the control that you wish to disable. This transparent window would serve to prevent the user from clicking on the control, by intercepting the clicks and discarding them. Teh fly in that ointment is that you would also have to arrange for focus changes caused by keyboard input (tabbing) to be intercepted. Again, quite a lot of work involved, though I think Win32::Gui gives you most of what you need to do this.

A fourth possibility would be to intercept the WM_DISABLE message for the control, do a grab of the bits of the window, pass the disable message through to the system so that all it's associated functions happen. You would also intercept the WM_PAINT message and blit the bits you grabbed earlier back onto the screen when the control redraws. This is fairly simple to do, though again, I think you would probably need to use Win32::API to get at some of the functions required. It may also cause some flashing of the disabled controls when they are redrawn unless you do it correctly.

There may be another simpler method, but I am not aware of it.

All in all, doing any of these is non-trivial, and of course prompts the question, why? Why would you want to have a disabled control masquerade as enabled?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^5: Disable Control in Win32::GUI by BrowserUk
in thread Disable Control in Win32::GUI by ChrisR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.