急得不行:关于ActiveX组件属性页的问题(50分)

  • 主题发起人 主题发起人 huxiaoyong
  • 开始时间 开始时间
H

huxiaoyong

Unregistered / Unconfirmed
GUEST, unregistred user!
属性页中怎么控制其中的控件的?

nit cardpp;

interface

uses SysUtils, Windows, Messages, Classes, Graphics, Controls, StdCtrls,
ExtCtrls, Forms, ComServ, ComObj, StdVcl, AxCtrls, Buttons, OleCtrls,
CardXControl1_TLB, Cards;
type
TCardPropPage = class(TPropertyPage)
ValueGroup: TGroupBox;
speedbutton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
SpeedButton9: TSpeedButton;
SpeedButton10: TSpeedButton;
SpeedButton11: TSpeedButton;
SpeedButton12: TSpeedButton;
SuitGroup: TGroupBox;
SpeedButton13: TSpeedButton;
SpeedButton14: TSpeedButton;
SpeedButton15: TSpeedButton;
SpeedButton16: TSpeedButton;
SpeedButton17: TSpeedButton;
Card1: TCard;
procedure PropertyPageCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);


private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
procedure UpdatePropertyPage
override;
procedure UpdateObject
override;
end;

const
Class_CardPropPage: TGUID = '{5F32DE56-4656-472B-973C-10F48AD28D75}';

implementation

{$R *.DFM}

procedure TCardPropPage.UpdatePropertyPage;
var
i: integer;
AValue,Asuit: integer;
begin
//get suit and value
AValue := OleObject.Value;
ASuit := OleObject.Suit;
//set card correctly
Card1.Value := TCardValue(AValue);
Card1.Suit := TCardSuit(ASuit);
//set correct value speedbutton
with ValueGroup do
for i := 0 to ControlCount - 1 do
if (Controls is TSpeedButton) and
(TSpeedButton(Controls).Tag = AValue) then
TSpeedButton(Controls).Down := True;
//set correct suit speedbutton
with suitgroup do
for i:=0 to controlcount -1 do
if (controls is tspeedbutton) and
(tspeedbutton (controls).tag = asuit) then
tspeedbutton(controls).down := true;
end;
{ Update your controls from OleObject }


procedure TCardPropPage.UpdateObject;
var
i: integer;
begin
//set correct value speedbutton
with valuegroup do
for i := 0 to controlcount -1 do
if(controls is tspeedbutton) and tspeedbutton(controls).down then
begin
oleobject.value := tspeedbutton(controls).tag;
break;
end;
//set correct suit speedbutton
with suitgroup do
for i := 0 to controlcount -1 do
if(controls is tspeedbutton) and tspeedbutton(controls).down then
begin
oleobject.suit := tspeedbutton(controls).tag;
break;
end;
end;
{ Update OleObject from your controls }

procedure TCardPropPage.PropertyPageCreate(Sender: TObject);
const
//ordinal values of "suit" characters in symbol font;
ssuits: Pchar = #167#168#169#170;
var
i: integer;
begin
//set up captions of suit speedbuttons using high
//charcters in symbol font
with suitgroup do
for i := 0 to controlcount - 1 do
if controls is tspeedbutton then
tspeedbutton(controls).caption := ssuits;
end;
{下面这一段看不懂}
procedure TCardPropPage.speedbutton1Click(Sender: TObject);
begin
if sender is TSpeedButton then
begin
with TSpeedButton(Sender) do
begin
if Parent = ValueGroup then
Card1.Value := TcardValue(Tag)
else if Parent = SuitGroup then
Card1.Suit := TCardSuit(Tag);
end;
Modified;
end;
end;



initialization
TActiveXPropertyPageFactory.Create(
ComServer,
TCardPropPage,
Class_CardPropPage);
end.



 

Similar threads

A
回复
0
查看
992
Andreas Hausladen
A
S
回复
0
查看
906
SUNSTONE的Delphi笔记
S
S
回复
0
查看
884
SUNSTONE的Delphi笔记
S
A
回复
0
查看
973
Andreas Hausladen
A
后退
顶部