C
cncharles
Unregistered / Unconfirmed
GUEST, unregistred user!
//以下是核心代码.<br>type<br> PRSAction_List=^TRSActionList;<br> TRSAction_List=array of TAction;<br><br>procedure TMainform.Button1Click(Sender: TObject);<br>var<br> RSActionList:TRSActionList;<br>begin<br> SetLength(RSActionList,4);<br> RSActionList[0]:=acOpen;<br> RSActionList[1]:=acEdit;<br> RSActionList[2]:=acSave;<br> RSActionList[3]:=acCancel;<br> //ShowMessage('Low='+IntToStr(Low(RSActionList))+ 'High='+IntToStr(High(rsActionList)));<br> PostMessage(Application.Handle,rsMsg,rs_ToolCaption,Integer(@RSActionList));<br>end;<br><br>procedure TMainform.apevt1Message(var Msg: tagMSG; var Handled: Boolean);<br><br>begin<br> if Msg.message=rsMsg then<br> case Msg.wParam of<br> rs_ToolCaption:begin<br> SetToolBar(PRSActionList(Msg.lParam)^);<br> Handled:=True;<br> end;<br> end;<br>end;<br><br><br>procedure TMainform.SetToolBar(RSActionList:TRSActionList);<br>{功能:这个过程用来设置 Toobar<br>}<br>var<br> SI:SmallInt;<br> strTB:string;<br> Comp:TComponent;<br>begin<br> Comp:=nil;<br> ShowMessage('Low='+IntToStr(Low(RSActionList))+ ' High='+IntToStr(High(rsActionList)));<br> //显示Low=0,High=-1为什么??????????<br> for SI:=Low(RSActionList) to High(rsActionList) do begin<br> strTB:='tb'+trim(IntToStr(SI+1));<br> Comp:=FindComponent(strTB);<br> if Comp<>nil then begin<br> (Comp as TToolButton).Action:=rsActionList[SI];<br> (Comp as TToolButton).Visible:=True;<br> end;<br> end;<br><br>end;