ActiveSkin v4.0 程式面板設計簡介 |
|
領航天使
站長 發表:12216 回覆:4186 積分:4084 註冊:2001-07-25 發送簡訊給我 |
ActiveSkin v4.0 程式面板設計簡介
楊志賢 Jack Yung
2001/12/24
~~~Delphi K.Top討論區站長~~~
------
~~~Delphi K.Top討論區站長~~~ |
LYW
一般會員 發表:9 回覆:32 積分:8 註冊:2002-03-08 發送簡訊給我 |
|
tonyplus
初階會員 發表:22 回覆:97 積分:28 註冊:2002-04-13 發送簡訊給我 |
引言:小弟努力的研究activeskin,在交相參考針對BCB寫的電子書和VB的範例程式之後,以下是和電子書內最後的範例一樣,使用FreeForm的原始碼,小弟還把電子書內遺漏的功能補齊,使以下的原始碼,執行起來和ActiveSkin 4.22附帶的VB範例程式一模一樣!如果還有其他問題,請提出來大家一起研究討論吧... unit UFreeForm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, ACTIVESKINLib_TLB, ExtCtrls, StdCtrls,Math; type TForm1 = class(TForm) Edit1: TEdit; Timer1: TTimer; Skin1: TSkin; procedure FormShow(Sender: TObject); procedure Edit1Change(Sender: TObject); procedure Skin1Render(Sender: TObject; const Source: ISkinObject; const ScreenBuffer: ISkinImage; PositionX, PositionY: Integer); procedure Skin1SkinTimer(Sender: TObject; const Source: ISkinObject; SourceHWND, PassedTime: Integer); procedure Skin1Scroll(Sender: TObject; const Source: ISkinObject; NewPos: Integer); procedure Skin1Click(Sender: TObject; const Source: ISkinObject); Procedure ShowSkin; private { Private declarations } public { Public declarations } end; var Form1: TForm1; bars:array[0..10] of single; //宣告陣列,代表音頻等化器上 10 個頻道的強度 Speed:array[0..10] of Single;//宣告陣例,放置 10 個頻道強度變化的速度 flag:Integer = 0; //用來判斷換那一個skin(helen.skn,sputnik.skn) Running:Boolean; implementation {$R *.dfm} procedure TForm1.FormShow(Sender: TObject); begin ShowSkin; end; procedure TForm1.Edit1Change(Sender: TObject); var TextField2:ISkinObject; TextField1:ISkinStatic; Anim:ISkinAnimation; AnimationCount:Integer; i,j,KeyCount:integer; begin I:=0; J:=0; Skin1.GetSkinnedWindow(Handle).FindObject('TextField',TextField2); TextField2.QueryInterface(IID_ISkinStatic,TextField1); TextField1.SetCaption(Edit1.Text); TextField2.QueryInterface(IID_ISkinAnimation,Anim); Anim.GetAnimationCount(AnimationCount); While i < AnimationCount Do begin Anim.GetKeyCount(I,KeyCount); While j < KeyCount Do // 巡行 Animation 中的每個 Key begin Anim.GetKeyObject(i,j,TextField2); TextField2.QueryInterface(IID_ISkinStatic,TextField1); TextField1.SetCaption(Edit1.Text); J:=J 1; end; I:=I 1; end; Anim.StopAnimation; Skin1.StartAnimation(handle,'OnText'); end; procedure TForm1.Skin1Render(Sender: TObject; const Source: ISkinObject; const ScreenBuffer: ISkinImage; PositionX, PositionY: Integer); var SourceName:WideString; visScreen:ISkinVisual; rect:SkinRect; Ib:Integer; Color:SkinARGB; rcItem:SkinRect; begin if Skin1.GetSkinnedWindow(Handle)=nil then exit; Source.GetName(SourceName); if (SourceName <> 'Screen') then Exit; Source.QueryInterface(IID_ISkinVisual,visScreen); visScreen.CalcRelativeRect(Skin1.GetSkinnedWindow(Handle),rect); for ib:=0 to 10 Do begin Color.Alpha:=128; Color.Blue:=0; Color.Red:=255; Color.Green:=0; rcItem := rect; rcItem.left:=round(rect.left (ib-1)*(rect.right-rect.left) / 10); rcItem.right:=round(rect.left ib*(rect.right-rect.left) / 10); rcItem.top:=rcItem.bottom-round(Bars[ib]); ScreenBuffer.Fill(skAlphaBlend,rcItem,color); end; end; procedure TForm1.Skin1SkinTimer(Sender: TObject; const Source: ISkinObject; SourceHWND, PassedTime: Integer); var i:integer; visScreen2:ISkinObject; visScreen1:ISkinVisual; begin for i:=0 to 10 do begin Bars[i]:=Bars[i] Speed[i]; Speed[i]:=Speed[i]-0.15; if (bars[i] < 0) then begin Bars[i]:=0; If Running then Speed[i]:=random*4.5 else Speed[i]:=0; // Speed[i]:=Round(Rnd div 100); end; end; Skin1.GetSkinnedWindow(Handle).findObject('Screen',visScreen2); visScreen2.QueryInterface(IID_ISkinVisual,visScreen1); visScreen1.Refresh; end; procedure TForm1.Skin1Scroll(Sender: TObject; const Source: ISkinObject; NewPos: Integer); begin Skin1.GetImages.SetHue(Newpos,True); end; procedure TForm1.Skin1Click(Sender: TObject; const Source: ISkinObject); var ClickName:widestring; begin Source.GetName(ClickName); If (ClickName = 'ButtonPlay') then begin//按下play Running:=True; Skin1.StartAnimation(handle,'OnPlay'); end; If (ClickName = 'ButtonStop') then begin//按下stop Running:=False; Skin1.StartAnimation(handle,'OnStop');//執行activeskin裡onstop的動作 end; if (clickName = 'ButtonSkin') then begin if (Flag = 0) then begin Flag:=1; ShowSkin; end else begin Flag:=0; ShowSkin; end; end; end; procedure TForm1.ShowSkin; var SkinPath:WideString; vixTextBox1:ISkinvisual;// 取得 "TextBox" 物件的 ISkinVisual 介面 vixTextBox2:ISkinObject; rc:SkinRect; begin If (flag=0) then SkinPath:='D:\Program Files\ActiveSkin 4\Samples\Equalizer\helen.skn' else SkinPath:='D:\Program Files\ActiveSkin 4\Samples\Equalizer\sputnik.skn'; Skin1.LoadSkin(SkinPath); Skin1.ApplySkinByName(Handle,'MainForm'); Skin1.GetSkinnedWindow(Handle).FindObject('TextBox',vixTextBox2); vixTextBox2.QueryInterface(IID_ISkinVisual,vixTextBox1); vixtextBox1.CalcRelativeRect(Skin1.GetSkinnedWindow(handle),rc); // 將 Edit1 設定到名為 TextBox 的 ActiveSkin 物件的範為內 Edit1.Left:=rc.left; Edit1.Top:=rc.top; Edit1.width:=rc.right-rc.left; Edit1.Height:=rc.bottom-rc.top; timer1.Interval:=1; Timer1.Enabled:=True; Running:=True; Skin1.StartAnimation(handle,'OnPlay'); end; end.這本書的內容,是在說明ActiveSkin在BCB上的使用;不是在Delphi上使用的。 [/code] |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |