You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I didn't! The WinAPI help file said to use RemoveProp() for each property
that was added using SetProp. I put RemoveProp() in the WM_DESTROY message
handler, so as each control in the dialog is destroyed the properties are
removed as well. I haven't checked for memory leaks yet, but I think I have
it right.
Mark, your code looks like a snippet from a drawing routine (WM_PAINT)... if the conrtol is not drawn by you (ie, it is a standard control), the callback must intercept %WM_CTLCOLORxxxx messages.
The "usual" approach is to define a custom message in the callback, say, (%WM_USER + 700&) and the code in that handler stores the color information and invalidates the control. This triggers the control repaint, which sends the appropriate %WM_CTLCOLORxxx message, and your new color for the control are used.
You could use STATIC variables to save the color state, or like Edwin suggests, SetProp() and GetProp().
So, when you wish to change the color from outside of the callback, you simply send the custom message to the parent window.
While there are other ways to do it, this strategy keeps all of the dialog-specific code within the callback, and not scattered throughout the program.
There is one fly in the ointment though - the %WM_CTLCOLORBTN message wont allow you to change the color of buttons... the usual workaround here is to use owner-draw or superclassed buttons.
How does one change the fore/background colors of a DDT Label control outside of
the dialog callback? I've searched the forums and found examples of how to change
the colors inside the callback but nothing else. I tried this code but it didn't work:
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: