S
shabi
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么有的listView的API管用,有的不管用,是不是我的API参数写法不对,大家帮我看看<br>不管用的:<br> itemNo:= ListView_FindItem(hand,-1,itemInfo);<br>这句话返回的值始终是0,不知道为什么,高手指点.<br><br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,CommCtrl,<br> StdCtrls;<br><br>type<br> TMyShape=(Circle,Heart,screwCurve,normal);<br> TForm1 = class(TForm)<br> Button1: TButton;<br> cbShape: TComboBox;<br> Edit1: TEdit;<br> Label1: TLabel;<br> procedure Button1Click(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br><br>function GetDesktopHand: THandle;<br>var Htemp:THandle;<br>begin<br> Result:=FindWindow('progman',nil);<br> Result:=GetWindow(Result,GW_Child);<br> Result:=GetWindow(Result,GW_Child);<br>end;<br><br>procedure DrawPic(r: integer);<br>var<br> i,j,itemNo, Count, CenterX, CenterY, TempR :integer;<br> Hand: THandle;<br> Radian: double;<br> TempRect: TRect;<br> DesktopHeight,DesktopWidth :integer;<br> X, Y,k : Word;<br> ItemInfo:LV_FINDINFO;<br> mylv:Lv_Item;<br> P:TPoint;<br>begin<br> Hand:=GetDesktopHand;<br> SystemParametersInfo(SPI_GetWorkArea,0,@TempRect,0);<br> DesktopWidth:=TempRect.Right - TempRect.Left;<br> DesktopHeight:= TempRect.Bottom - TempRect.Top;<br> CenterX:=DesktopWidth div 2;<br> CenterY:=DesktopHeight div 2;<br> if CenterX>CenterY then<br> TempR:=CenterY-20<br> else<br> TempR:=CenterX;<br> if r>TempR then r:=TempR;<br> Count:=Listview_GetItemCount(Hand);<br> Radian:=2*3.14159/Count;<br> k:=Trunc(r*0.5);<br> with itemInfo do<br> begin<br> flags:=LVFI_PARTIAL;<br> psz:=pchar('server');<br> end;<br> itemNo:= ListView_FindItem(hand,-1,itemInfo);<br> SendMessage(Hand,LVM_SetItemPosition,ItemNo,MakeLparam(900, 10));<br> i:=-1;<br> for j:=0 to Count-1 do<br> begin<br> i:=i+1;<br> Case TMyShape(form1.cbShape.ItemIndex) of<br> Circle:<br> begin<br> X:=Integer(CenterX+Trunc(r*Sin(i*Radian)));<br> Y:=Integer(CenterY+Trunc(r*Cos(i*Radian)));<br> end;<br> Heart:<br> begin<br> X:=Integer(CenterX+Trunc(r*(1-sin(i*Radian))*Cos(i*Radian)));<br> y:=100-Integer(Trunc(r*(1-sin(i*Radian))*Sin(i*Radian)));<br> end;<br> screwCurve:<br> begin<br> x:=Integer(Trunc(r*radian*i-k*sin(i*radian)));<br> y:=Integer(Centery+Trunc(r-k*cos(i*radian)));<br> end;<br> NorMal:<br> begin<br> x:=(i div 9)*80+20;<br> y:=(i mod 9)*80+20;<br> end;<br> end;<br> SendMessage(Hand,LVM_SetItemPosition,i,MakeLparam(X, y));<br><br> end;<br> // sendMessage(Hand,LVM_ARRANGE,LVA_ALIGNTOP,0);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var r:integer;<br>begin<br> if edit1.text='' then r:=250<br> else r:=strToInt(edit1.text);<br> DrawPic(r);<br>end;<br><br><br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var i:TMyShape;<br>begin<br> cbShape.ItemIndex:=0;<br>end;<br><br>end.<br><br>