home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!munnari.oz.au!metro!grivel!alsvid!elli!pshepher
- From: pshepher@elli.une.edu.au (Philip Shepherd)
- Newsgroups: comp.os.ms-windows.programmer.misc
- Subject: Re: Dialog Box Background Colour
- Message-ID: <694@elli.une.edu.au>
- Date: 17 Nov 92 00:18:49 GMT
- Organization: University of New England - Northern Rivers (Lismore)
- Lines: 58
-
-
- In "comp.os.ms-windows.programmer.misc", sean@sun-3 wrote:-
- >Hi
- >
- >I'm having trouble trying to change the background colour of my
- >dialog boxes. I'm using Borland's Object Windows. The following
- >fragment of code is what I'm using at the moment, but it has NO
- >effect!! However if I use the exact same code fragment for a class
- >derived from TWindow it works fine! I've designed my dialog boxes
- >in the Resource Workshop if that makes any difference.
- >
- >Has anybody else done this??
- >
-
-
- The answer is you need to process the WM_CTLCOLOR as follows:-
-
- ------------------- Start of .h ---------------------------------------
- class TMyDialog : public TDialog {
- ...
- virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR];
- ...
- };
-
- -------------------- Start of .cpp ------------------------------------
- void TMyDialog::WMCtlColor(RTMessage Msg)
- {
- SetBkMode(Msg.WParam, TRANSPARENT);
-
- switch (Msg.LP.Hi) {
- case CTLCOLOR_EDIT:
- Msg.Result = EditBrush;
- break;
- case CTLCOLOR_DLG:
- case CTLCOLOR_STATIC:
- Msg.Result = DialogBrush;
- break;
- case CTLCOLOR_LISTBOX:
- case CTLCOLOR_BTN:
- case CTLCOLOR_MSGBOX:
- case CTLCOLOR_SCROLLBAR:
- default:
- Msg.Result = ButtonBrush;
- }
- }
- -------------------------- End of .cpp --------------------------------
-
- the important part is setting Msg.Result to a suitable brush handle when
- Msg.LP.Hi = CTLCOLOR_DLG.
-
- Good luck
-
- Phil
- --
- Philip Shepherd Internet: pshepher@loki.une.oz.au
- University of NewEngland
- Northern Rivers
- Lismore NSW Australia
-