VB2DELPHI(50分)

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

aflower

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟刚从VB转学DELPHI,现有一程序要从VB转成DELPHI,
请大家帮忙。先谢了!
下面的程序可以返回一个主窗口的文本框的文字。
有两个函数,EditInfo用来找到文本框的hwnd,
涉及到递归和动态数组, windowtext返回文本框文字。
Public Function EditInfo(window_hwnd As Long) As String
Dim txt As String
Dim buf As String
Dim buflen As Long
Dim child_hwnd As Long
Dim children() As Long
Dim num_children As Integer
Dim i As Integer
' Get the class name.
buflen = 256
buf = Space$(buflen - 1)
buflen = GetClassName(window_hwnd, buf, buflen)
buf = Left$(buf, buflen)

' See if we found an Edit object.
If buf = "Edit" then
EditInfo = WindowText(window_hwnd)
Exit Function
End If

' It's not an Edit object. Search the children.
' Make a list of the child windows.
num_children = 0
child_hwnd = GetWindow(window_hwnd, GW_CHILD)
do
While child_hwnd <> 0
num_children = num_children + 1
ReDim Preserve children(1 To num_children)
children(num_children) = child_hwnd

child_hwnd = GetWindow(child_hwnd, GW_HWNDNEXT)
Loop

' Get information on the child windows.
For i = 1 To num_children
txt = EditInfo(children(i))
If txt <> "" then
Exit For
Next i
EditInfo = txt
End Function
' ************************************************
' Return the text associated with the window.
' ************************************************
Public Function WindowText(window_hwnd As Long) As String
Dim txtlen As Long
Dim txt As String
WindowText = ""
If window_hwnd = 0 then
Exit Function

txtlen = SendMessage(window_hwnd, WM_GETTEXTLENGTH, 0, 0)
If txtlen = 0 then
Exit Function

txtlen = txtlen + 1
txt = Space$(txtlen)
txtlen = SendMessage(window_hwnd, WM_GETTEXT, txtlen, ByVal txt)
WindowText = Left$(txt, txtlen)
End Function
 
有个程序叫VB2DELPHI,做的就是这个事。
 
to xwolf :那里有下?
 
只要转EditInfo就行,windowtext我自己会转换。
btw: 这是我第一次在这里提问。
<pre><FONT COLOR=RED><B>Public</B></FONT> <FONT
COLOR=RED><B>Function</B></FONT> EditInfo<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd <FONT COLOR=RED><B>As</B></FONT> <FONT COLOR=RED><B>Long</B></FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=RED><B>As</B></FONT> <FONT
COLOR=RED><B>String</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> txt <FONT COLOR=RED><B>As</B></FONT> <FONT COLOR=RED><B>String</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> buf <FONT COLOR=RED><B>As</B></FONT> <FONT
COLOR=RED><B>String</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> buflen <FONT COLOR=RED><B>As</B></FONT> <FONT COLOR=RED><B>Long</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> child_hwnd <FONT
COLOR=RED><B>As</B></FONT> <FONT COLOR=RED><B>Long</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> children<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=RED><B>As</B></FONT> <FONT
COLOR=RED><B>Long</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> num_children <FONT COLOR=RED><B>As</B></FONT> <FONT COLOR=RED><B>Integer</B></FONT>
<FONT COLOR=RED><B>Dim</B></FONT> i <FONT COLOR=RED><B>As</B></FONT>
<FONT COLOR=RED><B>Integer</B></FONT>
<FONT COLOR=GREEN><I>' Get the class name.
</I></FONT> buflen <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT
COLOR=BROWN>256</FONT>
buf <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> Space$<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>buflen <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>-</FONT></FONT> <FONT
COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
buflen <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> GetClassName<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,
</B></FONT> buf<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> buflen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
buf <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> Left$<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>buf<FONT
COLOR=BLUE SIZE=+1><B>,</B></FONT> buflen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>

<FONT COLOR=GREEN><I>' See if we found an Edit object.
</I></FONT> <FONT COLOR=RED><B>If</B></FONT> buf
<FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT COLOR=PURPLE>"Edit"</FONT> <FONT COLOR=RED><B>then
</B></FONT>
EditInfo <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT>
WindowText<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
<FONT COLOR=RED><B>Exit</B></FONT> <FONT COLOR=RED><B>Function</B></FONT>
<FONT
COLOR=RED><B>End</B></FONT> <FONT COLOR=RED><B>If</B></FONT>

<FONT COLOR=GREEN><I>' It's not an Edit object. Search the children.
</I></FONT> <FONT COLOR=GREEN><I>' Make a list of the
child windows.
</I></FONT> num_children <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> <FONT COLOR=BROWN>0</FONT>
child_hwnd <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE
SIZE=+1>=</FONT></FONT> GetWindow<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> GW_CHILD<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
<FONT COLOR=RED><B>Do</B></FONT> <FONT
COLOR=RED><B>While</B></FONT> child_hwnd <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;lt;</FONT></FONT><FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;gt;</FONT></FONT> <FONT COLOR=BROWN>0</FONT>
num_children
<FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> num_children <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>+</FONT></FONT> <FONT COLOR=BROWN>1</FONT>
<FONT COLOR=RED><B>ReDim</B></FONT> Preserve
children<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=BROWN>1</FONT> <FONT COLOR=RED><B>To</B></FONT> num_children<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
children<FONT COLOR=BLUE
SIZE=+1><B>(</B></FONT>num_children<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> child_hwnd

child_hwnd <FONT COLOR=BLUE SIZE=+1><FONT
COLOR=BLUE SIZE=+1>=</FONT></FONT> GetWindow<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>child_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> GW_HWNDNEXT<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
<FONT
COLOR=RED><B>Loop</B></FONT>

<FONT COLOR=GREEN><I>' Get information on the child windows.
</I></FONT> <FONT COLOR=RED><B>For</B></FONT> i <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE
SIZE=+1>=</FONT></FONT> <FONT COLOR=BROWN>1</FONT> <FONT COLOR=RED><B>To</B></FONT> num_children
txt <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> EditInfo<FONT COLOR=BLUE
SIZE=+1><B>(</B></FONT>children<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>i<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
<FONT COLOR=RED><B>If</B></FONT> txt <FONT COLOR=BLUE SIZE=+1><FONT
COLOR=BLUE SIZE=+1>&amp;lt;</FONT></FONT><FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>&amp;gt;</FONT></FONT> <FONT COLOR=PURPLE>""</FONT> <FONT COLOR=RED><B>then
</B></FONT> <FONT COLOR=RED><B>Exit</B></FONT> <FONT
COLOR=RED><B>For</B></FONT>
<FONT COLOR=RED><B>Next</B></FONT> i
EditInfo <FONT COLOR=BLUE SIZE=+1><FONT COLOR=BLUE SIZE=+1>=</FONT></FONT> txt
<FONT
COLOR=RED><B>End</B></FONT> <FONT COLOR=RED><B>Function</B></FONT></pre>
 
http://qlion.163.net/software/Vb2d21.rar
转控件可能不太好用,但转这些程序代码应该没问题
 
<pre><FONT COLOR=RED><B>unit</B></FONT> ieaddress<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>interface</B></FONT>
<FONT COLOR=RED><B>uses</B></FONT>
Windows<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Messages<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> SysUtils<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Classes<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Graphics<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Controls<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Forms<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> Dialogs<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT>
StdCtrls<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>type</B></FONT>
TForm1 <FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=RED><B>class</B></FONT><FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>TForm<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT>
lblAddress<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TLabel<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
Button1<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TButton<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
Edit1<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TEdit<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>procedure</B></FONT> Button1Click<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>Sender<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TObject<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>private</B></FONT>
<FONT COLOR=GREEN><I>{ Private declarations }</I></FONT>
<FONT COLOR=RED><B>public</B></FONT>
<FONT COLOR=GREEN><I>{ Public declarations }</I></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>function</B></FONT> WindowText<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> <FONT COLOR=RED><B>var</B></FONT> window_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>function</B></FONT> EditInfo<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> <FONT COLOR=RED><B>var</B></FONT> window_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>var</B></FONT>
Form1<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TForm1<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
lblAddress<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TLabel<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
blEditVisible<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT>boolean<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>implementation</B></FONT>
<FONT COLOR=GREEN><I>{$R *.DFM}</I></FONT>
<FONT COLOR=RED><B>function</B></FONT> EditInfo<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> <FONT COLOR=RED><B>var</B></FONT> window_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> integer <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>var</B></FONT>
txt <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
buf <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
buflen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
child_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
children <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> Variant <FONT COLOR=GREEN><I>{array}</I></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
num_children <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> integer<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
i <FONT COLOR=BLUE SIZE=+1><B>,</B></FONT>intchildren<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> integer<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
children <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> VarArrayCreate<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>[</B></FONT><FONT COLOR=BROWN>0</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT>0<FONT COLOR=BLUE SIZE=+1><B>]</B></FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> varInteger <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=GREEN><I>// Get the class name.
</I></FONT> buflen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=BROWN>255</FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
buf <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> StringOfChar<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>' '</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> buflen <FONT COLOR=BLUE SIZE=+1>-</FONT> <FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
buflen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> GetClassName<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> pchar<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>buf<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> buflen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
buf <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> Copy<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>buf<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> <FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> buflen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=GREEN><I>// See if we found an Edit object.
</I></FONT> <FONT COLOR=RED><B>if</B></FONT> buf <FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=PURPLE>'Edit'</FONT> <FONT COLOR=RED><B>then
</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
Result <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> WindowText<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
blEditVisible <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> IsWindowVisible<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
exit<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT> <FONT COLOR=GREEN><I>{ EXIT FUNCTION }</I></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=GREEN><I>// It's not an Edit object. Search the children.
</I></FONT> <FONT COLOR=GREEN><I>// Make a list of the child windows.
</I></FONT> num_children <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=BROWN>0</FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
child_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> GetWindow<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> GW_CHILD<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>while</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> child_hwnd <FONT COLOR=BLUE SIZE=+1>&amp;lt;</FONT><FONT COLOR=BLUE SIZE=+1>&amp;gt;</FONT> <FONT COLOR=BROWN>0</FONT> <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=RED><B>do</B></FONT> <FONT COLOR=GREEN><I>{ begin
do
..WHILE }</I></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
num_children <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> num_children <FONT COLOR=BLUE SIZE=+1>+</FONT> <FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
VarArrayRedim<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> children<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> num_children <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
children<FONT COLOR=BLUE SIZE=+1><B>[</B></FONT>num_children<FONT COLOR=BLUE SIZE=+1><B>]</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> child_hwnd<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
child_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> GetWindow<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>child_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> GW_HWNDNEXT<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT> <FONT COLOR=GREEN><I>{ ENDdo
..WHILE }</I></FONT>
<FONT COLOR=GREEN><I>// Get information on the child windows.
</I></FONT> <FONT COLOR=RED><B>for</B></FONT> i <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=BROWN>1</FONT> <FONT COLOR=RED><B>to</B></FONT> num_children <FONT COLOR=RED><B>do</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
intchildren<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT>children<FONT COLOR=BLUE SIZE=+1><B>[</B></FONT>i<FONT COLOR=BLUE SIZE=+1><B>]</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txt <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> EditInfo<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>intchildren<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>if</B></FONT> txt <FONT COLOR=BLUE SIZE=+1>&amp;lt;</FONT><FONT COLOR=BLUE SIZE=+1>&amp;gt;</FONT> <FONT COLOR=PURPLE>''</FONT> <FONT COLOR=RED><B>then
</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
break<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT> <FONT COLOR=GREEN><I>{ EXIT FOR }</I></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
Result <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> txt<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=GREEN><I>// ************************************************
</I></FONT> <FONT COLOR=GREEN><I>// Return the text associated with the window.
</I></FONT> <FONT COLOR=GREEN><I>// ************************************************
</I></FONT><FONT COLOR=RED><B>function</B></FONT> WindowText<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT> <FONT COLOR=RED><B>var</B></FONT> window_hwnd <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint <FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>var</B></FONT>
txtlen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> longint<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txt <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> <FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
Result <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=PURPLE>''</FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>if</B></FONT> window_hwnd <FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=BROWN>0</FONT> <FONT COLOR=RED><B>then
</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
exit<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT> <FONT COLOR=GREEN><I>{ EXIT FUNCTION }</I></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txtlen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> SendMessage<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> WM_GETTEXTLENGTH<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> <FONT COLOR=BROWN>0</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> <FONT COLOR=BROWN>0</FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT> <FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>if</B></FONT> txtlen <FONT COLOR=BLUE SIZE=+1>=</FONT> <FONT COLOR=BROWN>0</FONT> <FONT COLOR=RED><B>then
</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
exit<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT> <FONT COLOR=GREEN><I>{ EXIT FUNCTION }</I></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txtlen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> txtlen <FONT COLOR=BLUE SIZE=+1>+</FONT> <FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txt <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> StringOfChar<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT><FONT COLOR=PURPLE>' '</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> txtlen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
txtlen <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> SendMessage<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>window_hwnd<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> WM_GETTEXT<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> txtlen<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> integer<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>txt<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
Result <FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT> Copy<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>txt<FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> <FONT COLOR=BROWN>1</FONT><FONT COLOR=BLUE SIZE=+1><B>,</B></FONT> txtlen<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>procedure</B></FONT> TForm1<FONT COLOR=BLUE SIZE=+1><B><FONT COLOR=BLUE SIZE=+1><B>.</B></FONT></B></FONT>Button1Click<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>Sender<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT> TObject<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>var</B></FONT>
a<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=RED><B>string</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
b<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT>integer<FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>begin
</B></FONT>
b<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT>strtoint<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>edit1<FONT COLOR=BLUE SIZE=+1><B><FONT COLOR=BLUE SIZE=+1><B>.</B></FONT></B></FONT>text<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
lblAddress<FONT COLOR=BLUE SIZE=+1><B><FONT COLOR=BLUE SIZE=+1><B>.</B></FONT></B></FONT>caption<FONT COLOR=BLUE SIZE=+1><B>:</B></FONT><FONT COLOR=BLUE SIZE=+1>=</FONT>EditInfo<FONT COLOR=BLUE SIZE=+1><B>(</B></FONT>b<FONT COLOR=BLUE SIZE=+1><B>)</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B>;</B></FONT>
<FONT COLOR=RED><B>end</B></FONT><FONT COLOR=BLUE SIZE=+1><B><FONT COLOR=BLUE SIZE=+1><B>.</B></FONT></B></FONT></pre>
 
xWolf,温柔一刀,能否给我vb2delphi,收到后给100分,发过来就给分
email:harbinlss@21cn.com
 

Similar threads

A
回复
0
查看
932
Andreas Hausladen
A
A
回复
0
查看
805
Andreas Hausladen
A
S
回复
0
查看
688
SUNSTONE的Delphi笔记
S
S
回复
0
查看
683
SUNSTONE的Delphi笔记
S
后退
顶部