home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1992 / 20 / ln1120 / custom2.pas < prev    next >
Pascal/Delphi Source File  |  1992-07-30  |  2KB  |  87 lines

  1. {
  2. Title:  Revised CUSTOM1.PAS
  3. Caption:  The highlighted areas show where we have added code to
  4. fix a painting problem in the listboxes of the Open common dialog
  5. customized with BWCC controls.  When a WM_ERASEBKGND message is received,
  6. the TCDListBox object forces the entire listbox rectangle to
  7. be erased with the system window background color (normally white).
  8. TBWCCFileDlg.Init constructs one of these listbox objects for each
  9. of the two listboxes in the Open common dialog.
  10. }
  11.  
  12. unit custom2;  { REVISED }
  13.  
  14. interface
  15.  
  16. uses winprocs, wintypes, wobjects, bwcc, utest2;
  17.  
  18. type
  19.   PBWCCFileDlg = ^TBWCCFileDlg;
  20.   TBWCCFileDlg = object(TFileDlg)
  21.     constructor Init(AParent : PWindowsObject;
  22.                      AFlags   : Longint;
  23.                      AFileName : Pchar;
  24.                      ANameLength : Integer);
  25.   end;
  26.  
  27. implementation
  28.  
  29. {$R custom1}
  30. uses commdlg;
  31.  
  32. {***EDITOR: Begin highlight or bold}
  33. type
  34.   PCDListBox = ^TCDListBox;
  35.   TCDListBox = object(TListBox)
  36.     Brush: HBrush;
  37.     constructor InitResource(AParent: PWindowsObject; ResourceID: Word);
  38.     destructor Done; virtual;
  39.     procedure WMEraseBkgnd(var Msg : TMessage);
  40.         virtual wm_first+wm_EraseBkgnd;
  41.   end;
  42.  
  43. constructor TCDListBox.InitResource(AParent: PWindowsObject; ResourceID: Word);
  44. begin
  45.   TListbox.InitResource(AParent, ResourceID);
  46.   Brush := CreateSolidBrush( GetSysColor( COLOR_WINDOW));
  47. end;
  48.  
  49. destructor TCDListBox.Done;
  50. begin
  51.   DeleteObject(Brush);
  52.   TListbox.Done;
  53. end;
  54.  
  55. procedure TCDListBox.WMEraseBkgnd(var Msg: TMessage);
  56. var
  57.   R : TRect;
  58. begin                          
  59.    GetClientRect(hWindow,R);
  60.    FillRect(hDC(Msg.wParam),R,Brush);
  61.    Msg.Result := 1;
  62. end;
  63. {***EDITOR: End highlight or bold}
  64.  
  65. constructor TBWCCFileDlg.Init(AParent : PWindowsObject;
  66.                               AFlags   : Longint;
  67.                               AFileName : Pchar;
  68.                               ANameLength : Integer);
  69. {***EDITOR: Begin highlight or bold}
  70. var
  71.   Dummy: PWindowsObject;
  72. {***EDITOR: End highlight or bold}
  73. begin
  74.   TFileDlg.Init(AParent, AFlags, AFileName, ANameLength);
  75.   with OFN do
  76.   begin
  77.     Flags := Flags or OFN_EnableTemplate;
  78.     lpTemplateName := 'FileOpen_BWCC';
  79.   end;
  80. {***EDITOR: Begin highlight or bold}
  81.   Dummy := New(PCDListBox, InitResource(@Self, 1120));
  82.   Dummy := New(PCDListBox, InitResource(@Self, 1121));
  83. {***EDITOR: End highlight or bold}
  84. end;
  85.  
  86. end.
  87.