home *** CD-ROM | disk | FTP | other *** search
/ PC Expert 29 / Pce29cd.iso / RUNIMAGE / DELPHI40 / DEMOS / ACTIVEX / DELCTRLS / monthcalendarimpl1.pas < prev    next >
Pascal/Delphi Source File  |  1998-06-16  |  12KB  |  430 lines

  1. unit MonthCalendarImpl1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, ActiveX, Classes, Controls, Graphics, Menus, Forms, StdCtrls,
  7.   ComServ, StdVCL, AXCtrls, DelCtrls_TLB, ComCtrls;
  8.  
  9. type
  10.   TMonthCalendarX = class(TActiveXControl, IMonthCalendarX)
  11.   private
  12.     { Private declarations }
  13.     FDelphiControl: TMonthCalendar;
  14.     FEvents: IMonthCalendarXEvents;
  15.     procedure ClickEvent(Sender: TObject);
  16.     procedure DblClickEvent(Sender: TObject);
  17.     procedure GetMonthInfoEvent(Sender: TObject; Month: Cardinal;
  18.       var MonthBoldInfo: Cardinal);
  19.     procedure KeyPressEvent(Sender: TObject; var Key: Char);
  20.   protected
  21.     { Protected declarations }
  22.     procedure DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage); override;
  23.     procedure EventSinkChanged(const EventSink: IUnknown); override;
  24.     procedure InitializeControl; override;
  25.     function ClassNameIs(const Name: WideString): WordBool; safecall;
  26.     function DrawTextBiDiModeFlags(Flags: Integer): Integer; safecall;
  27.     function DrawTextBiDiModeFlagsReadingOnly: Integer; safecall;
  28.     function Get_AutoSize: WordBool; safecall;
  29.     function Get_BiDiMode: TxBiDiMode; safecall;
  30.     function Get_Cursor: Smallint; safecall;
  31.     function Get_Date: Double; safecall;
  32.     function Get_DoubleBuffered: WordBool; safecall;
  33.     function Get_DragCursor: Smallint; safecall;
  34.     function Get_DragMode: TxDragMode; safecall;
  35.     function Get_Enabled: WordBool; safecall;
  36.     function Get_EndDate: Double; safecall;
  37.     function Get_FirstDayOfWeek: TxCalDayOfWeek; safecall;
  38.     function Get_Font: IFontDisp; safecall;
  39.     function Get_ImeMode: TxImeMode; safecall;
  40.     function Get_ImeName: WideString; safecall;
  41.     function Get_MaxDate: Double; safecall;
  42.     function Get_MaxSelectRange: Integer; safecall;
  43.     function Get_MinDate: Double; safecall;
  44.     function Get_MultiSelect: WordBool; safecall;
  45.     function Get_ParentFont: WordBool; safecall;
  46.     function Get_ShowToday: WordBool; safecall;
  47.     function Get_ShowTodayCircle: WordBool; safecall;
  48.     function Get_Visible: WordBool; safecall;
  49.     function Get_WeekNumbers: WordBool; safecall;
  50.     function GetControlsAlignment: TxAlignment; safecall;
  51.     function IsRightToLeft: WordBool; safecall;
  52.     function UseRightToLeftAlignment: WordBool; safecall;
  53.     function UseRightToLeftReading: WordBool; safecall;
  54.     function UseRightToLeftScrollBar: WordBool; safecall;
  55.     procedure _Set_Font(const Value: IFontDisp); safecall;
  56.     procedure AboutBox; safecall;
  57.     procedure FlipChildren(AllLevels: WordBool); safecall;
  58.     procedure InitiateAction; safecall;
  59.     procedure Set_AutoSize(Value: WordBool); safecall;
  60.     procedure Set_BiDiMode(Value: TxBiDiMode); safecall;
  61.     procedure Set_Cursor(Value: Smallint); safecall;
  62.     procedure Set_Date(Value: Double); safecall;
  63.     procedure Set_DoubleBuffered(Value: WordBool); safecall;
  64.     procedure Set_DragCursor(Value: Smallint); safecall;
  65.     procedure Set_DragMode(Value: TxDragMode); safecall;
  66.     procedure Set_Enabled(Value: WordBool); safecall;
  67.     procedure Set_EndDate(Value: Double); safecall;
  68.     procedure Set_FirstDayOfWeek(Value: TxCalDayOfWeek); safecall;
  69.     procedure Set_Font(const Value: IFontDisp); safecall;
  70.     procedure Set_ImeMode(Value: TxImeMode); safecall;
  71.     procedure Set_ImeName(const Value: WideString); safecall;
  72.     procedure Set_MaxDate(Value: Double); safecall;
  73.     procedure Set_MaxSelectRange(Value: Integer); safecall;
  74.     procedure Set_MinDate(Value: Double); safecall;
  75.     procedure Set_MultiSelect(Value: WordBool); safecall;
  76.     procedure Set_ParentFont(Value: WordBool); safecall;
  77.     procedure Set_ShowToday(Value: WordBool); safecall;
  78.     procedure Set_ShowTodayCircle(Value: WordBool); safecall;
  79.     procedure Set_Visible(Value: WordBool); safecall;
  80.     procedure Set_WeekNumbers(Value: WordBool); safecall;
  81.   end;
  82.  
  83. implementation
  84.  
  85. uses ComObj, About18;
  86.  
  87. { TMonthCalendarX }
  88.  
  89. procedure TMonthCalendarX.DefinePropertyPages(DefinePropertyPage: TDefinePropertyPage);
  90. begin
  91.   { Define property pages here.  Property pages are defined by calling
  92.     DefinePropertyPage with the class id of the page.  For example,
  93.       DefinePropertyPage(Class_MonthCalendarXPage); }
  94. end;
  95.  
  96. procedure TMonthCalendarX.EventSinkChanged(const EventSink: IUnknown);
  97. begin
  98.   FEvents := EventSink as IMonthCalendarXEvents;
  99. end;
  100.  
  101. procedure TMonthCalendarX.InitializeControl;
  102. begin
  103.   FDelphiControl := Control as TMonthCalendar;
  104.   FDelphiControl.OnClick := ClickEvent;
  105.   FDelphiControl.OnDblClick := DblClickEvent;
  106.   FDelphiControl.OnGetMonthInfo := GetMonthInfoEvent;
  107.   FDelphiControl.OnKeyPress := KeyPressEvent;
  108. end;
  109.  
  110. function TMonthCalendarX.ClassNameIs(const Name: WideString): WordBool;
  111. begin
  112.   Result := FDelphiControl.ClassNameIs(Name);
  113. end;
  114.  
  115. function TMonthCalendarX.DrawTextBiDiModeFlags(Flags: Integer): Integer;
  116. begin
  117.   Result := FDelphiControl.DrawTextBiDiModeFlags(Flags);
  118. end;
  119.  
  120. function TMonthCalendarX.DrawTextBiDiModeFlagsReadingOnly: Integer;
  121. begin
  122.   Result := FDelphiControl.DrawTextBiDiModeFlagsReadingOnly;
  123. end;
  124.  
  125. function TMonthCalendarX.Get_AutoSize: WordBool;
  126. begin
  127.   Result := FDelphiControl.AutoSize;
  128. end;
  129.  
  130. function TMonthCalendarX.Get_BiDiMode: TxBiDiMode;
  131. begin
  132.   Result := Ord(FDelphiControl.BiDiMode);
  133. end;
  134.  
  135. function TMonthCalendarX.Get_Cursor: Smallint;
  136. begin
  137.   Result := Smallint(FDelphiControl.Cursor);
  138. end;
  139.  
  140. function TMonthCalendarX.Get_Date: Double;
  141. begin
  142.   Result := Double(FDelphiControl.Date);
  143. end;
  144.  
  145. function TMonthCalendarX.Get_DoubleBuffered: WordBool;
  146. begin
  147.   Result := FDelphiControl.DoubleBuffered;
  148. end;
  149.  
  150. function TMonthCalendarX.Get_DragCursor: Smallint;
  151. begin
  152.   Result := Smallint(FDelphiControl.DragCursor);
  153. end;
  154.  
  155. function TMonthCalendarX.Get_DragMode: TxDragMode;
  156. begin
  157.   Result := Ord(FDelphiControl.DragMode);
  158. end;
  159.  
  160. function TMonthCalendarX.Get_Enabled: WordBool;
  161. begin
  162.   Result := FDelphiControl.Enabled;
  163. end;
  164.  
  165. function TMonthCalendarX.Get_EndDate: Double;
  166. begin
  167.   Result := Double(FDelphiControl.EndDate);
  168. end;
  169.  
  170. function TMonthCalendarX.Get_FirstDayOfWeek: TxCalDayOfWeek;
  171. begin
  172.   Result := Ord(FDelphiControl.FirstDayOfWeek);
  173. end;
  174.  
  175. function TMonthCalendarX.Get_Font: IFontDisp;
  176. begin
  177.   GetOleFont(FDelphiControl.Font, Result);
  178. end;
  179.  
  180. function TMonthCalendarX.Get_ImeMode: TxImeMode;
  181. begin
  182.   Result := Ord(FDelphiControl.ImeMode);
  183. end;
  184.  
  185. function TMonthCalendarX.Get_ImeName: WideString;
  186. begin
  187.   Result := WideString(FDelphiControl.ImeName);
  188. end;
  189.  
  190. function TMonthCalendarX.Get_MaxDate: Double;
  191. begin
  192.   Result := Double(FDelphiControl.MaxDate);
  193. end;
  194.  
  195. function TMonthCalendarX.Get_MaxSelectRange: Integer;
  196. begin
  197.   Result := FDelphiControl.MaxSelectRange;
  198. end;
  199.  
  200. function TMonthCalendarX.Get_MinDate: Double;
  201. begin
  202.   Result := Double(FDelphiControl.MinDate);
  203. end;
  204.  
  205. function TMonthCalendarX.Get_MultiSelect: WordBool;
  206. begin
  207.   Result := FDelphiControl.MultiSelect;
  208. end;
  209.  
  210. function TMonthCalendarX.Get_ParentFont: WordBool;
  211. begin
  212.   Result := FDelphiControl.ParentFont;
  213. end;
  214.  
  215. function TMonthCalendarX.Get_ShowToday: WordBool;
  216. begin
  217.   Result := FDelphiControl.ShowToday;
  218. end;
  219.  
  220. function TMonthCalendarX.Get_ShowTodayCircle: WordBool;
  221. begin
  222.   Result := FDelphiControl.ShowTodayCircle;
  223. end;
  224.  
  225. function TMonthCalendarX.Get_Visible: WordBool;
  226. begin
  227.   Result := FDelphiControl.Visible;
  228. end;
  229.  
  230. function TMonthCalendarX.Get_WeekNumbers: WordBool;
  231. begin
  232.   Result := FDelphiControl.WeekNumbers;
  233. end;
  234.  
  235. function TMonthCalendarX.GetControlsAlignment: TxAlignment;
  236. begin
  237.  Result := TxAlignment(FDelphiControl.GetControlsAlignment);
  238. end;
  239.  
  240. function TMonthCalendarX.IsRightToLeft: WordBool;
  241. begin
  242.   Result := FDelphiControl.IsRightToLeft;
  243. end;
  244.  
  245. function TMonthCalendarX.UseRightToLeftAlignment: WordBool;
  246. begin
  247.   Result := FDelphiControl.UseRightToLeftAlignment;
  248. end;
  249.  
  250. function TMonthCalendarX.UseRightToLeftReading: WordBool;
  251. begin
  252.   Result := FDelphiControl.UseRightToLeftReading;
  253. end;
  254.  
  255. function TMonthCalendarX.UseRightToLeftScrollBar: WordBool;
  256. begin
  257.   Result := FDelphiControl.UseRightToLeftScrollBar;
  258. end;
  259.  
  260. procedure TMonthCalendarX._Set_Font(const Value: IFontDisp);
  261. begin
  262.   SetOleFont(FDelphiControl.Font, Value);
  263. end;
  264.  
  265. procedure TMonthCalendarX.AboutBox;
  266. begin
  267.   ShowMonthCalendarXAbout;
  268. end;
  269.  
  270. procedure TMonthCalendarX.FlipChildren(AllLevels: WordBool);
  271. begin
  272.   FDelphiControl.FlipChildren(AllLevels);
  273. end;
  274.  
  275. procedure TMonthCalendarX.InitiateAction;
  276. begin
  277.   FDelphiControl.InitiateAction;
  278. end;
  279.  
  280. procedure TMonthCalendarX.Set_AutoSize(Value: WordBool);
  281. begin
  282.   FDelphiControl.AutoSize := Value;
  283. end;
  284.  
  285. procedure TMonthCalendarX.Set_BiDiMode(Value: TxBiDiMode);
  286. begin
  287.   FDelphiControl.BiDiMode := TBiDiMode(Value);
  288. end;
  289.  
  290. procedure TMonthCalendarX.Set_Cursor(Value: Smallint);
  291. begin
  292.   FDelphiControl.Cursor := TCursor(Value);
  293. end;
  294.  
  295. procedure TMonthCalendarX.Set_Date(Value: Double);
  296. begin
  297.   FDelphiControl.Date := TDate(Value);
  298. end;
  299.  
  300. procedure TMonthCalendarX.Set_DoubleBuffered(Value: WordBool);
  301. begin
  302.   FDelphiControl.DoubleBuffered := Value;
  303. end;
  304.  
  305. procedure TMonthCalendarX.Set_DragCursor(Value: Smallint);
  306. begin
  307.   FDelphiControl.DragCursor := TCursor(Value);
  308. end;
  309.  
  310. procedure TMonthCalendarX.Set_DragMode(Value: TxDragMode);
  311. begin
  312.   FDelphiControl.DragMode := TDragMode(Value);
  313. end;
  314.  
  315. procedure TMonthCalendarX.Set_Enabled(Value: WordBool);
  316. begin
  317.   FDelphiControl.Enabled := Value;
  318. end;
  319.  
  320. procedure TMonthCalendarX.Set_EndDate(Value: Double);
  321. begin
  322.   FDelphiControl.EndDate := TDate(Value);
  323. end;
  324.  
  325. procedure TMonthCalendarX.Set_FirstDayOfWeek(Value: TxCalDayOfWeek);
  326. begin
  327.   FDelphiControl.FirstDayOfWeek := TCalDayOfWeek(Value);
  328. end;
  329.  
  330. procedure TMonthCalendarX.Set_Font(const Value: IFontDisp);
  331. begin
  332.   SetOleFont(FDelphiControl.Font, Value);
  333. end;
  334.  
  335. procedure TMonthCalendarX.Set_ImeMode(Value: TxImeMode);
  336. begin
  337.   FDelphiControl.ImeMode := TImeMode(Value);
  338. end;
  339.  
  340. procedure TMonthCalendarX.Set_ImeName(const Value: WideString);
  341. begin
  342.   FDelphiControl.ImeName := TImeName(Value);
  343. end;
  344.  
  345. procedure TMonthCalendarX.Set_MaxDate(Value: Double);
  346. begin
  347.   FDelphiControl.MaxDate := TDate(Value);
  348. end;
  349.  
  350. procedure TMonthCalendarX.Set_MaxSelectRange(Value: Integer);
  351. begin
  352.   FDelphiControl.MaxSelectRange := Value;
  353. end;
  354.  
  355. procedure TMonthCalendarX.Set_MinDate(Value: Double);
  356. begin
  357.   FDelphiControl.MinDate := TDate(Value);
  358. end;
  359.  
  360. procedure TMonthCalendarX.Set_MultiSelect(Value: WordBool);
  361. begin
  362.   FDelphiControl.MultiSelect := Value;
  363. end;
  364.  
  365. procedure TMonthCalendarX.Set_ParentFont(Value: WordBool);
  366. begin
  367.   FDelphiControl.ParentFont := Value;
  368. end;
  369.  
  370. procedure TMonthCalendarX.Set_ShowToday(Value: WordBool);
  371. begin
  372.   FDelphiControl.ShowToday := Value;
  373. end;
  374.  
  375. procedure TMonthCalendarX.Set_ShowTodayCircle(Value: WordBool);
  376. begin
  377.   FDelphiControl.ShowTodayCircle := Value;
  378. end;
  379.  
  380. procedure TMonthCalendarX.Set_Visible(Value: WordBool);
  381. begin
  382.   FDelphiControl.Visible := Value;
  383. end;
  384.  
  385. procedure TMonthCalendarX.Set_WeekNumbers(Value: WordBool);
  386. begin
  387.   FDelphiControl.WeekNumbers := Value;
  388. end;
  389.  
  390. procedure TMonthCalendarX.ClickEvent(Sender: TObject);
  391. begin
  392.   if FEvents <> nil then FEvents.OnClick;
  393. end;
  394.  
  395. procedure TMonthCalendarX.DblClickEvent(Sender: TObject);
  396. begin
  397.   if FEvents <> nil then FEvents.OnDblClick;
  398. end;
  399.  
  400. procedure TMonthCalendarX.GetMonthInfoEvent(Sender: TObject;
  401.   Month: Cardinal; var MonthBoldInfo: Cardinal);
  402. var
  403.   TempMonthBoldInfo: Integer;
  404. begin
  405.   TempMonthBoldInfo := Integer(MonthBoldInfo);
  406.   if FEvents <> nil then FEvents.OnGetMonthInfo(Integer(Month), TempMonthBoldInfo);
  407.   MonthBoldInfo := Cardinal(TempMonthBoldInfo);
  408. end;
  409.  
  410. procedure TMonthCalendarX.KeyPressEvent(Sender: TObject; var Key: Char);
  411. var
  412.   TempKey: Smallint;
  413. begin
  414.   TempKey := Smallint(Key);
  415.   if FEvents <> nil then FEvents.OnKeyPress(TempKey);
  416.   Key := Char(TempKey);
  417. end;
  418.  
  419. initialization
  420.   TActiveXControlFactory.Create(
  421.     ComServer,
  422.     TMonthCalendarX,
  423.     TMonthCalendar,
  424.     Class_MonthCalendarX,
  425.     18,
  426.     '{695CDB61-02E5-11D2-B20D-00C04FA368D4}',
  427.     0,
  428.     tmApartment);
  429. end.
  430.