Page 1 of 2

IE ActiveX problem

Posted: Sat Jan 27, 2007 1:30 am
by James Bott
I am trying to view an XML file using IE and activeX. When I call the function using the ON INIT clause of ACTIVATE WINDOW it works fine. But when I call the same function from a button all I get is a blank screen. See my code below.

I have tried putting sysfresh() in several places but that didn't help.

Any ideas?

I am using FWH Sept 2006 build/ xHarbour. You can use any HTML or XML file to test the code.

James

Code: Select all

#include "fivewin.ch"

function main()
   local oWnd, oBar
   define window oWnd
   define buttonbar oBar of oWnd
   define button of oBar action viewXML()  // Doesn't work
   activate window oWnd on init viewXML()  // Does work
return nil

function viewXML(cFile, cPath)

   local oWnd, oActiveX, oBar

   default cPath := (cFilePath( GetModuleFileName( GetInstance() ) ))
   default cFile:= "test.xml"

   DEFINE WINDOW oWnd TITLE "Test XML Report"

   oActiveX = TActiveX():New( oWnd, "Shell.Explorer" )

   oWnd:oClient = oActiveX

   oActiveX:Do( "Navigate", cPath+cFile )

   ACTIVATE WINDOW oWnd

   oActiveX:end()

return nil

Posted: Sat Jan 27, 2007 2:25 am
by Taiwan
Hello

Same as me.
I don't know FWH's ActiveX problem or Compatible problem as code.

Regards,

Richard

Posted: Sat Jan 27, 2007 3:59 am
by Jeff Barnes
Hi James,

I have not yet played with ActiveX but I tried messing aroud with your sample.

Strange but if you REMOVE the:

oActiveX:End()


It will work via the button.

Hope this helps.

Jeff

Posted: Sat Jan 27, 2007 6:17 am
by areang
Hi All !

For any window dialog, please do not put anything after this :

ACTIVATE WINDOW oWnd

>>> oActiveX:end() <<<<
Sometimes get error.

Change to :
ACTIVATE WINDOW oWnd valid ( oActiveX:End(), .t. )

Regards
Areang

Posted: Sat Jan 27, 2007 1:40 pm
by James Bott
Jeff and Areang,

Thanks a lot guys! It works great now. I was pulling my hair out all day trying to solve that. I would have never guessed that the End() call was the problem. It doesn't seem logical.

Antonio, any idea why that is happening?

James

Posted: Sat Jan 27, 2007 2:33 pm
by Enrico Maria Giordano
James Bott wrote:I would have never guessed that the End() call was the problem. It doesn't seem logical.
No, it is logical. Your secondary window is modeless and oActiveX:End() method is therefore called immediatly.

EMG

Posted: Sat Jan 27, 2007 2:48 pm
by James Bott
>No, it is logical. Your secondary window is modeless and oActiveX:End() method is therefore called immediatly.

Duh, I was thinking it was a dialog. I need some sleep--I only had three hours last night...

Hmm, then why doesn't the activeX object get closed when called from the ON INIT clause?

James

Posted: Sat Jan 27, 2007 3:11 pm
by Enrico Maria Giordano
James Bott wrote:Hmm, then why doesn't the activeX object get closed when called from the ON INIT clause?
Probably because the second window is modal if created in the ON INIT clause?

EMG

Posted: Sat Jan 27, 2007 3:16 pm
by James Bott
Enrico,

>Probably because the second window is modal if created in the ON INIT clause?

That would be a good reason.

James

Posted: Sat Jan 27, 2007 5:10 pm
by Antonio Linares
Enrico is right, the main window is modal and others windows are non modal. If ON INIT clause used then the second window is activated as the main one, thus it becomes modal.

Posted: Tue Jul 17, 2007 2:16 am
by cdmmaui
Hello,

How can I make the window visible? When activate the window, it runs minimized and I have to click on application on taskbar for window to appear and allow user to continue.

DEFINE WINDOW oWnd2 FROM 0, 0 TO 40, 85 MENU oMenu
oActiveX = TActiveX():New( oWnd2, "Shell.Explorer" )
oWnd2:oClient = oActiveX
oActiveX:Do( "Navigate2", cAesdd + cHan )
ACTIVATE WINDOW oWnd2 VALID ( oActiveX:End(), .T. )

Thank You,

Posted: Tue Jul 17, 2007 5:54 am
by James Bott
You could try:

ACTIVATE WINDOW oWnd2 VALID ( oActiveX:End(), .T. ) ;
on init BringWindowToTop( oWnd2:hWnd )

James

Posted: Tue Jul 17, 2007 1:53 pm
by cdmmaui
Hi James,

Thank you for your response. Unfortunately that did not work. Can I try something else?

Posted: Tue Jul 17, 2007 3:32 pm
by James Bott
Darrell,

Can you provide us with a working example that we can test?

James

Posted: Tue Jul 17, 2007 4:10 pm
by cdmmaui
Hi James,

Here is my source. Thanks for your help.

// Write HTML...
cText := '<FORM ACTION="https://www.aesdirect.gov/weblink/weblink.cgi" METHOD="POST">' + cEol

cText += '<INPUT TYPE="HIDDEN" NAME="wl_app_ident" VALUE="wlcdm01">' + cEol
cText += '<INPUT TYPE="HIDDEN" NAME="wl_nologin_url" VALUE="window.close()">' + cEol
cText += '<INPUT TYPE="HIDDEN" NAME="wl_nosed_url" VALUE="window.close()">' + cEol
cText += '<INPUT TYPE="HIDDEN" NAME="wl_success_url" VALUE="window.close()">' + cEol

cText += '<input type="submit" name="B1" value="Send to AES" style="background-color: #B8092C; font-weight: normal; font-size: 10px; font-face: tahoma; color: #ffffff; border-style: solid; border-width: 4px; border-color: #B8092C;">'

cText += '</FORM>'

// Create file
hHan = FCREATE( cAesdd + cHan, 0)
IF (hHan == -1)
MsgAlert( "CDM WinFrt cannot create "+ cAesdd + cHan, "Process Aborted" )
RETURN nil
ENDIF
FWRITE( hHan, cText )
FCLOSE( hHan )

DEFINE WINDOW oWnd2 FROM 0, 0 TO 40, 85 ;
MENU oMenu TITLE PA[04] + " - AES Direct Submission - " + ALLTRIM( cFile ) ICON oIcon

oActiveX = TActiveX():New( oWnd2, "Shell.Explorer" )

oWnd2:oClient = oActiveX // To fill the entire window surface

oActiveX:Do( "Navigate2", cAesdd + cHan )

ACTIVATE WINDOW oWnd2 ON INIT BringWindowToTop( oWnd2:hWnd )