home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / mswindo / programm / misc / 3480 < prev    next >
Encoding:
Text File  |  1992-11-17  |  1.9 KB  |  68 lines

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!munnari.oz.au!metro!grivel!alsvid!elli!pshepher
  2. From: pshepher@elli.une.edu.au (Philip Shepherd)
  3. Newsgroups: comp.os.ms-windows.programmer.misc
  4. Subject: Re: Dialog Box Background Colour
  5. Message-ID: <694@elli.une.edu.au>
  6. Date: 17 Nov 92 00:18:49 GMT
  7. Organization: University of New England - Northern Rivers (Lismore)
  8. Lines: 58
  9.  
  10.  
  11. In "comp.os.ms-windows.programmer.misc", sean@sun-3 wrote:-
  12. >Hi
  13. >
  14. >I'm having trouble trying to change the background colour of my 
  15. >dialog boxes. I'm using Borland's Object Windows. The following
  16. >fragment of code is what I'm using at the moment, but it has NO
  17. >effect!! However if I use the exact same code fragment for a class
  18. >derived from TWindow it works fine! I've designed my dialog boxes 
  19. >in the Resource Workshop if that makes any difference.
  20. >
  21. >Has anybody else done this??
  22. >
  23.  
  24.  
  25. The answer is you need to process the WM_CTLCOLOR as follows:-
  26.  
  27. ------------------- Start of .h ---------------------------------------
  28. class TMyDialog : public TDialog {
  29.   ...
  30.     virtual void WMCtlColor(RTMessage Msg) = [WM_FIRST + WM_CTLCOLOR];
  31.   ...
  32. };
  33.  
  34. -------------------- Start of .cpp ------------------------------------
  35. void TMyDialog::WMCtlColor(RTMessage Msg)
  36. {
  37.     SetBkMode(Msg.WParam, TRANSPARENT);
  38.  
  39.     switch (Msg.LP.Hi) {
  40.     case CTLCOLOR_EDIT:
  41.     Msg.Result = EditBrush;
  42.     break;
  43.     case CTLCOLOR_DLG:
  44.     case CTLCOLOR_STATIC:
  45.     Msg.Result = DialogBrush;
  46.     break;
  47.     case CTLCOLOR_LISTBOX:
  48.     case CTLCOLOR_BTN:
  49.     case CTLCOLOR_MSGBOX:
  50.     case CTLCOLOR_SCROLLBAR:
  51.     default:
  52.     Msg.Result = ButtonBrush;
  53.     }
  54. }
  55. -------------------------- End of .cpp --------------------------------
  56.  
  57. the important part is setting Msg.Result to a suitable brush handle when
  58. Msg.LP.Hi = CTLCOLOR_DLG.
  59.  
  60. Good luck
  61.  
  62. Phil
  63. -- 
  64. Philip     Shepherd                      Internet: pshepher@loki.une.oz.au
  65. University of NewEngland
  66. Northern Rivers
  67. Lismore NSW Australia
  68.