home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / DELPHI / COLOR / COLORAPP.PAS < prev    next >
Pascal/Delphi Source File  |  1995-04-27  |  3KB  |  105 lines

  1. program ColorApp;
  2.  
  3. {---------------------------------------------------------------------
  4. Example application for the custom control Color (Colors.DLL) of
  5. the SMWCC 2.0 Custom Control Pack
  6.  
  7. Copyright (C) by Sebastian Modersohn
  8.  
  9. Note: This code file isn't documented into detail. If you have
  10.       questions to *THIS* code file or want to know some details
  11.       please contact me via CompuServe, ID 100340,1474.
  12. ---------------------------------------------------------------------}
  13.  
  14. {$IFNDEF AUTOLOAD}
  15.  
  16.   You HAVE to compile this program with the global defined symbol "AUTOLOAD" !
  17.   This demonstrates the autoloading feature of the import unit Color!
  18. {$ENDIF}
  19.  
  20. {$R ColorApp}
  21.  
  22. uses WinTypes, WinProcs, OWindows, ODialogs, Strings, BWCC,
  23.      {the import unit and the constant unit for the control}
  24.      Color, ColorCo;
  25.  
  26. {some Id's}
  27. const id_Color1      =101;
  28.       id_Color2      =102;
  29.       id_Check       =103;
  30.  
  31. type
  32.   pColorWindow = ^tColorWindow;
  33.   tColorWindow = object(tDlgWindow)
  34.     Color1, Color2: pColor;
  35.     Check: pCheckBox;
  36.     constructor Init(AParent: PWindowsObject; AName: PChar);
  37.  
  38.     procedure WMColorChanged(var Msg: TMessage);
  39.       virtual wm_first + wm_ColorChanged;
  40.  
  41.     procedure Ok(var Msg: TMessage);
  42.       virtual id_First + id_OK;
  43.     procedure Help(var Msg: TMessage);
  44.       virtual id_First + idHelp;
  45.   end;
  46.  
  47. {App initializes the main window}
  48.   pColorApp = ^tColorApp;
  49.   tColorApp = object(tApplication)
  50.     procedure InitMainWindow; virtual;
  51.   end;
  52.  
  53. { tColorWindow }
  54.  
  55. constructor tColorWindow.Init(AParent: PWindowsObject; AName: PChar);
  56. begin
  57.   inherited Init(AParent, AName);
  58.   {simple initializing with the Parent (@Self) and the ID}
  59.   Color1:=New(pColor, InitResource(@Self, id_Color1));
  60.   Color2:=New(pColor, InitResource(@Self, id_Color2));
  61.   Check:=New(pCheckBox, InitResource(@Self, id_Check));
  62. end;
  63.  
  64. {Notification message for monitoring the changes of the color-selection}
  65. procedure TColorWindow.WMColorChanged(var Msg: TMessage);
  66. begin
  67.   {wParam=ID; see help for more info}
  68.   if Msg.wParam=id_Color2 then
  69.   begin
  70.     if Check^.GetCheck=bf_Checked then
  71.     begin
  72.       Color1^.SetBKColor(Color2^.GetFGColor);
  73.     end else
  74.     begin
  75.       Color1^.SetFGColor(Color2^.GetFGColor);
  76.     end;
  77.   end;
  78. end;
  79.  
  80. procedure TColorWindow.Ok(var Msg: TMessage);
  81. begin
  82.   CloseWindow;
  83. end;
  84.  
  85. procedure TColorWindow.Help(var Msg: TMessage);
  86. begin
  87.   WinHelp(HWindow, HelpFile, Help_Context, 100);
  88. end;
  89.  
  90. { TColorApp }
  91.  
  92. procedure TColorApp.InitMainWindow;
  93. begin
  94.   MainWindow := New(PColorWindow, Init(nil, MakeIntResource(100)));
  95. end;
  96.  
  97. var
  98.   App: TColorApp;
  99.  
  100. begin
  101.   App.Init('Color Demo');
  102.   App.Run;
  103.   App.Done;
  104. end.
  105.