Information générale
Catégorie:
Contrôles ActiveX en VFP
Titre:
Focus with TreeView Events
I'm using the FoxTray OLE Control to load a form. I'm having trouble getting giving the new form the focus. If I display a messagebox just after loading the form or in the form's init, the focus is correct. If not, the focus is somewhere else, though I've been unable to determine where.
Compile this code as an EXE to see what I mean. Any ideas? A bandaid is okay here, though I'd like to keep the form as top-level.
*** Code begins here
_Screen.AddProperty("TrayForm",CREATEOBJECT("Form"))
_Screen.TrayForm.addobject("FoxTray","DMTray")
sleep(1000)
READ EVENTS
DEFINE CLASS myform as Form
showwindow = 2
PROCEDURE Init()
thisform.AddObject("txtbox","TextBox")
thisform.txtbox.visible = .T.
thisform.txtbox.setfocus()
* Uncomment the next line and the focus works
* MESSAGEBOX("test")
ENDPROC
PROCEDURE QueryUnload
thisform.Release()
ENDPROC
ENDDEFINE
DEFINE CLASS DMTray As OLEControl
OleClass="FoxTrayCtl.cFoxTray"
PROCEDURE Init
WITH THIS
* Set the default properties
.IconTip = "Test Form"
.ShowIcon()
* Set the menu items
.GetPopupItem(1).Caption = "View Form"
.GetPopupItem(2).Caption = "Exit"
ENDWITH
ENDPROC
PROCEDURE OnPopupItemSelected(item, caption)
DO CASE
CASE item = 1
_Screen.AddProperty("testform",CREATEOBJECT("myform"))
_Screen.testform.show()
CASE item = 2
CLEAR EVENTS
ENDCASE
ENDDEFINE
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement