Teo,
I'm not sure what's happening. I tried:
Procedure Init
ThisForm.AddObject ("oleBrowserWin", "oleControl", "Shell.Explorer.2")
ThisForm.oleBrowserWin.Name = "oleBrowserWin"
ThisForm.oleBrowserWin.Top = 5
ThisForm.oleBrowserWin.Left = 5
ThisForm.oleBrowserWin.Height = 165
ThisForm.oleBrowserWin.Width = 360
ThisForm.oleBrowserWin.Visible = .T.
EndProc
And it worked. But when I add the oleBrowserWin.Init and oleBrowserWin.Refresh methods it gave me the error message
"Unknown member OLEBROWSERWIN.". I don't know the cause of this error, let's hope some of our fellows can help us in this.
Actually I use to add controls to the form by
Add Object (and in this case all is working ok) and not by
AddObject(). Please check and run the complete example below (change the name of the file name to be shown to one of your own).
Fernando
cLoadFileName = "YourImage.jpg"
oImageViewer = CreateObject ("frmImageViewer")
oImageViewer.Show ()
Define Class frmImageViewer as Form
Caption = " Image Viewer Using Explorer Control"
WindowType = 1
Name = "frmImageViewer"
Height = 205
Width = 370
AutoCenter = .T.
Add Object oleBrowserWin as oleControl with Top = 5 , ;
Left = 5 , ;
Height = 165 , ;
Width = 360 , ;
Name = "oleBrowserWin" , ;
OLEClass = "Shell.Explorer.2"
Add Object cmdCancel as CommandButton with Top = 175 , ;
Left = 290 , ;
Height = 25 , ;
Width = 75 , ;
FontName = "Arial" , ;
FontSize = 8 , ;
Cancel = .T. , ;
Caption = "\<Close"
Procedure cmdCancel.Click
ThisForm.Release
EndProc
Procedure ExplorerLoadImage
ThisForm.oleBrowserWin.Navigate (cLoadFileName)
EndProc
Procedure oleBrowserWin.Refresh
NoDefault
EndProc
Procedure oleBrowserWin.Init
This.Navigate (cLoadFileName)
EndProc
Procedure Init
ThisForm.ExplorerLoadImage ()
EndProc
Procedure Resize
ThisForm.LockScreen = .T.
If Thisform.Height < 165
Thisform.Height = 165
endif
If Thisform.Width < 360
Thisform.Width = 360
endif
ThisForm.oleBrowserWin.Height = Thisform.Height - 40
ThisForm.oleBrowserWin.Width = Thisform.Width - 10
ThisForm.cmdCancel.Top = Thisform.Height - 30
ThisForm.cmdCancel.Left = Thisform.Width - 80
ThisForm.LockScreen = .F.
EndProc
Procedure QueryUnload
ThisForm.cmdCancel.Click ()
NoDefault
Return .T.
EndProc
EndDefine