#2
sych2024-11-12 14:12
PUBLIC oform1
oform1=NEWOBJECT("form1") oform1.Show RETURN DEFINE CLASS form1 AS form Height = 110 Width = 193 ShowWindow = 2 DoCreate = .T. AutoCenter = .T. Caption = "Form1" AlwaysOnTop = .T. Name = "Form1" ADD OBJECT command1 AS commandbutton WITH ; Top = 60, ; Left = 68, ; Height = 25, ; Width = 60, ; Caption = "执行", ; Name = "Command1" ADD OBJECT text1 AS textbox WITH ; Alignment = 3, ; Value = 1, ; Height = 25, ; InputMask = "999", ; Left = 72, ; Top = 24, ; Width = 40, ; Name = "Text1" ADD OBJECT label1 AS label WITH ; Caption = "选择第:", ; Height = 16, ; Left = 24, ; Top = 29, ; Width = 46, ; Name = "Label1" ADD OBJECT label2 AS label WITH ; Caption = "行", ; Height = 16, ; Left = 116, ; Top = 29, ; Width = 46, ; Name = "Label2" PROCEDURE init PUBLIC lnSendHwnd,hwnd ENDPROC PROCEDURE command1.Click #Define EM_SETSEL 0xb1 #Define EM_LINEINDEX 0xbb #Define WM_SYSCOMMAND 0x112 #Define SC_MAXIMIZE 0xF030 TEXT TO prgprg noshow 2343432435 34454t4365t43 ddffergter rwew阿德顺丰到付归属感 谁丰东股份23424递四方速递 23424535 水电费45235 3424 ENDTEXT DECLARE Long FindWindowEx IN WIN32API Long, Long, String, String Declare Integer SendMessage In WIN32API as SendMessages Integer,Integer,Integer,String Declare Integer SendMessage In WIN32API as SendMessagen Integer,Integer,Integer,Integer Declare Integer SendMessageW In WIN32API as SendMsgWn Integer,Integer,Integer,Integer Declare Integer WinExec in kernel32 string, integer hWnd = FindWindowEx( 0, 0, "Notepad", NULL ) if hwnd=0 winexec("NOTEPAD.EXE",5) hWnd = FindWindowEx( 0, 0, "Notepad", NULL ) SendMessages(m.Hwnd,WM_SYSCOMMAND,SC_MAXIMIZE,null) lnSendHwnd=FindWindowEx(m.hwnd,0,"Edit",Null) SendMessages(lnSendHwnd,12,0,prgprg) endif i=thisform.text1.value SendMsgWn(lnSendHwnd, EM_SETSEL ; , SendMsgWn(lnSendHwnd,EM_LINEINDEX,i-1,0) ; , SendMsgWn(lnSendHwnd,EM_LINEINDEX,i,0) ) ENDPROC ENDDEFINE |
上一个问题的延续,不知道大家发现了没有,如果我们多次执行选择行操作,然后记事本一旦获得焦点,选择的行自动切换回我们第一次执行的结果
比如我们第一次选择第2行,然后在随意的操作几次,然后点击记事本的标题栏使记事本窗口获得焦点,我们会发现选中的行自动变成了第2行,也就是我们第一次操作的结果
[此贴子已经被作者于2024-11-12 14:12编辑过]