PUBLIC oform1
oform1=NEWOBJECT("form1")
oform1.Show
RETURN
DEFINE CLASS form1 AS form
DoCreate = .T.
Caption = "Form1"
Name = "Form1"
WindowState = 2
ADD OBJECT olecontrol1 AS olecontrol WITH ;
Top = 0, ;
Left = 0, ;
Height = 204, ;
Width = 375, ;
Anchor = 15, ;
Name = "Olecontrol1", ;
OleClass = "Shell.Explorer.2"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 215, ;
Left = 276, ;
Height = 27, ;
Width = 84, ;
Anchor = 12, ;
Caption = "Find", ;
Name = "Command1"
PROCEDURE olecontrol1.Init
this.navigate("[URL unfurl="true"]http://www.sweetpotatosoftware.com/spsblog")[/URL]
ENDPROC
PROCEDURE command1.Click
LOCAL loDoc
loDoc = THISFORM.Olecontrol1.object.Document
loDoc.focus() && document must have focus
*!* Use API calls to simulate CTRL + F
#DEFINE KEYEVENTF_KEYUP 0x02
#DEFINE VK_CONTROL 0x11
DECLARE INTEGER keybd_event IN Win32API ;
INTEGER, INTEGER, INTEGER, INTEGER
DOEVENTS && make sure everything else is done
keybd_event(VK_CONTROL, 0, 0, 0)
keybd_event(0x46, 0, 0, 0) && 0x46 is 'f'
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
DOEVENTS && make sure it sends the keys right now
CLEAR DLLS "keybd_event"
*!* Keyboard doesn't work here
*!* KEYBOARD '{CTRL+F}'
*!* We could have used Windows Script instead though
*!* WshShell = CreateObject("WScript.Shell")
*!* WshShell.SendKeys("^f")
*!* OTHER DEV NOTES OF INTEREST *!*
*!* ExecWB throws the following exception:
*!* 'OLE Error code Trying to revoke a drop target that has not been registered'
*!* THISFORM.Olecontrol1.ExecWB(42,0)
*!* For some reason Microsoft didn't implement
*!* the find dialog for execCommand
*!* List of supported command identifiers can be found at:
*!* [URL unfurl="true"]http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/commandids.asp[/URL]
*!* loDoc.execCommand("Find") && this doesn't work, but others will
ENDPROC
ENDDEFINE