股票玩得够劲的,赚不少了。
简单测试,参考上面贴图应该能看得明。
下面4个参数
第一个是窗口句柄,从上面列表选择通达信主窗口,不能选错。
第二个是窗口消息标志,默认是通达信的消息标志。
第三个是证券号,输入
第四个为0,忽略
** test.prg
DECLARE LONG GetWindow IN User32 LONG, LONG
DECLARE LONG GetWindowText IN User32 LONG, STRING@, LONG
DECLARE LONG GetClassName IN User32 LONG, STRING@, LONG
DECLARE LONG IsWindowVisible IN User32 LONG
DECLARE LONG RegisterWindowMessage IN User32 STRING@
DECLARE LONG PostMessage IN User32 LONG, LONG, LONG, LONG
UWM_STOCK = RegisterWindowMessage("Stock")
#DEFINE GW_HWNDNEXT
2
#DEFINE GW_CHILD
5
CREATE CURSOR DGrid1 (hWnd_WText C(50), WClass C(50), hWnd I)
of = CREATEOBJECT("Form1")
of.Show
READ EVENTS
CLOSE DATABASES ALL
CLEAR DLLS
RETURN
DEFINE CLASS Form1 As Form
Height
= 250
Width
= 800
AutoCenter = .T.
ShowWindow = 2
ADD OBJECT Grid1 AS Grid WITH Top=10,Left=10,Height=190,Width=650,AllowCellSelection=.F.,RecordSource="DGrid1"
ADD OBJECT Check1 AS CheckBox WITH Top=10,Left=680,Height=20,Width=100,Caption="可视的窗口",Value=1
ADD OBJECT Check2 AS CheckBox WITH Top=32,Left=680,Height=20,Width=100,Caption="所有子窗口"
ADD OBJECT Command1 AS Commandbutton WITH Top=60,Left=680,Height=32,Width=100,Caption="刷新窗口列表"
ADD OBJECT label1 AS label WITH Top=210,Left=100,Width=500,FontSize=10,;
Caption="hWnd
Msg
wParam
IParam"
ADD OBJECT text1 AS textbox WITH Top=208,Left=130,Width=60,FontSize=10,value=0
ADD OBJECT text2 AS textbox WITH Top=208,Left=228,Width=60,FontSize=10,value=UWM_STOCK
ADD OBJECT text3 AS textbox WITH Top=208,Left=348,Width=60,FontSize=10,value="600000"
ADD OBJECT text4 AS textbox WITH Top=208,Left=466,Width=60,FontSize=10,value=0
ADD OBJECT Command2 AS Commandbutton WITH Top=208,Left=540,Height=22,Width=80,Caption="发送消息"
PROCEDURE UnLoad
CLEAR EVENTS
ENDPROC
PROCEDURE Init
ZAP IN "DGrid1"
_EnumWindows(_VFP.hWnd, (this.Check1.Value==1), (this.Check2.Value==1), 0, 0)
GO TOP IN "DGrid1"
this.Grid1.SetFocus
ENDPROC
PROCEDURE Grid1.Click
thisform.text1.value = DGrid1.hWnd
ENDPROC
PROCEDURE Check1.InteractiveChange
thisform.Init
ENDPROC
PROCEDURE Check2.InteractiveChange
thisform.Init
ENDPROC
PROCEDURE Command1.Click
thisform.Init
ENDPROC
PROCEDURE Command2.Click
code = ALLTRIM(thisform.text3.value) && 证号
code = IIF(LEFT(code,1)=="6","7","6") + code &&上证号前加“7”,其他前加“6”
PostMessage(thisform.text1.value,thisform.text2.value,VAL(code),thisform.text4.value)
ENDPROC
ENDDEFINE
** 枚举窗口
FUNCTION _EnumWindows(dhWnd, blIsVisible, blIsChild, ddCmd, ddLay)
LOCAL cText, cClass
cText
= SPACE(256)
cClass = SPACE(256)
dhWnd = GetWindow(dhWnd, ddCmd)
DO WHILE (dhWnd != 0)
IF !blIsVisible OR (blIsVisible AND (IsWindowVisible(dhWnd) == 1))
GetWindowText(dhWnd, @cText, LEN(cText))
GetClassName(dhWnd, @cClass , Len(cClass))
INSERT INTO DGrid1 VALUES (SPACE(ddLay*2)+TRANSFORM(dhWnd)+" "+ cText, cClass, dhWnd)
IF blIsChild
_EnumWindows(dhWnd, blIsVisible, blIsChild, GW_CHILD, ddLay + 1)
ENDIF
ENDIF
dhWnd = GetWindow(dhWnd, GW_HWNDNEXT)
ENDDO
ENDFUNC