请问高手如何将这段VB代码转为Delphi的 ( 积分: 100 )

  • 主题发起人 AI_Player
  • 开始时间
A

AI_Player

Unregistered / Unconfirmed
GUEST, unregistred user!
Private Declare Function WaterInit Lib &quot;waterdll.dll&quot; (ByVal bitmap As Long) As Long<br>Private Declare Function WaterMouseAction Lib &quot;waterdll.dll&quot; (ByVal hdc As _<br> &nbsp; &nbsp;Long, ByVal sx As Long, ByVal sy As Long, ByVal mx As Long, _<br> &nbsp; &nbsp; &nbsp; &nbsp;ByVal my As Long, ByVal half As Long, ByVal deep As Long) As Long<br><br>Private Declare Function WaterTimer Lib &quot;waterdll.dll&quot; (ByVal hdc As Long, ByVal sx As _<br> &nbsp; &nbsp;Long, ByVal sy As Long) As Long<br><br><br><br>Private Sub Form_Load()<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;WaterInit Picture1.Picture.Handle<br> <br>End Sub<br><br>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br><br> &nbsp; &nbsp;WaterMouseAction Form1.hdc, 10, 10, X, Y, 60, 500<br> &nbsp; &nbsp;<br>End Sub<br><br>Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)<br> &nbsp; &nbsp;WaterMouseAction Form1.hdc, 10, 10, X, Y, 5, 80<br>End Sub<br><br>Private Sub Timer1_Timer()<br><br> &nbsp; &nbsp;WaterTimer Form1.hdc, 10, 10<br> &nbsp; &nbsp;<br>End Sub<br>
 
Private Declare Function WaterInit Lib &quot;waterdll.dll&quot; (ByVal bitmap As Long) As Long<br>Private Declare Function WaterMouseAction Lib &quot;waterdll.dll&quot; (ByVal hdc As _<br> &nbsp; &nbsp;Long, ByVal sx As Long, ByVal sy As Long, ByVal mx As Long, _<br> &nbsp; &nbsp; &nbsp; &nbsp;ByVal my As Long, ByVal half As Long, ByVal deep As Long) As Long<br><br>Private Declare Function WaterTimer Lib &quot;waterdll.dll&quot; (ByVal hdc As Long, ByVal sx As _<br> &nbsp; &nbsp;Long, ByVal sy As Long) As Long<br><br><br><br>Private Sub Form_Load()<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;<br> &nbsp; &nbsp;WaterInit Picture1.Picture.Handle<br> <br>End Sub<br><br>Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br><br> &nbsp; &nbsp;WaterMouseAction Form1.hdc, 10, 10, X, Y, 60, 500<br> &nbsp; &nbsp;<br>End Sub<br><br>Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)<br> &nbsp; &nbsp;WaterMouseAction Form1.hdc, 10, 10, X, Y, 5, 80<br>End Sub<br><br>Private Sub Timer1_Timer()<br><br> &nbsp; &nbsp;WaterTimer Form1.hdc, 10, 10<br> &nbsp; &nbsp;<br>End Sub<br>
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, ExtCtrls;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;Timer1: TTimer;<br> &nbsp; &nbsp;procedure FormCreate(Sender: TObject);<br> &nbsp; &nbsp;procedure Timer1Timer(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp; &nbsp;procedure Form_Load;<br> &nbsp; &nbsp;procedure Form_MouseDown(Button:Integer;Shift:Integer;X:integer;Y:integer);<br> &nbsp; &nbsp;procedure Form_MouseMove(Button:Integer;Shift:Integer;X:integer;Y:integer);<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br> &nbsp;function WaterInit(bitmap:longint):longint;stdcall;<br> &nbsp;far;external 'waterdll.dll' name 'WaterInit';<br> &nbsp;function WaterMouseAction(hdc,sx,sy,mx,my,half,deep:longint):longint;stdcall;<br> &nbsp;far;external 'waterdll.dll' name 'WaterMouseAction';<br> &nbsp;function WaterTimer(hdc,sx,sy:longint):longint;stdcall;<br> &nbsp;far;external 'waterdll.dll' name 'WaterTimer';<br><br>implementation<br><br>{$R *.dfm}<br>procedure TForm1.Form_Load;<br>begin<br> WaterInit(Picture1.Picture.Handle);<br>end;<br><br>procedure TForm1.Form_MouseDown(Button:Integer;Shift:Integer;X:integer;Y:integer);<br>begin<br> WaterMouseAction(Form1.hdc, 10, 10, X, Y, 60, 500);<br>end;<br><br>procedure Form_MouseMove(Button:Integer;Shift:Integer;X:integer;Y:integer);<br>begin<br> WaterMouseAction (Form1.hdc, 10, 10, X, Y, 5, 80);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br><br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br>WaterTimer (Form1.hdc, 10, 10);<br>end;<br><br>end.<br><br>FORM1.HDC是什么我就不知道了。如果Button 是控件的话,参数就改成Button:TButton;
 
hdc使用getDC(handle)获得<br>
 
如果给分的话我就告诉你。我有7年的VB经验。<br>不是我太势利,而是我的分太少。[:D]<br>
 
哈哈<br>果然势力<br>不是有VB开发经验就是老大<br>
 
我用 image组件载入一个BMP图片<br>可以用GDI对象<br>DC:=image1.Picture.Bitmap.Handle<br>获得该bmp图片的句柄<br>但是jpg.gif等图片类型就不行<br>DC得到的值是空的<br>有什么办法可以得到图片的句柄
 
接受答案了.
 

Similar threads

I
回复
0
查看
704
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部