Alaska Software Inc. - Crash in Activex's modal dialog
Username: Password:
AuthorTopic: Crash in Activex's modal dialog
Peter NagyCrash in Activex's modal dialog
on Wed, 29 May 2019 11:22:24 +0200
Hello,

I implemented a PDF Reader Activex in my Xbase++ program and I created a 
toolbar for that. If I want find text in the PDF document, I need to call 
the PDF Reader Activex's Find  function, this funcion create and show a 
Search dialog (It has a textbox, 2 buttons called Search and Cancel). If I 
click on the Cancel button, it close, and I can show again the search 
dialog. But, If I click on the Search button the program freeze for 2-3 
seconds and the entire program exit (no error message, no error log).

The creator of the PDF Reader Activex said about this problem: maybe the 
parent window style is the problem (I tried oXbpWindow:seVisualStyle=false 
and XbpApplication():enableVisualStyle=false, the visual style changed but 
the crash still happening).

How I do it:
oSorax := XbpActiveXControl():new(oDlg:drawingArea, oDlg,{0,25},
{nWidth,nHeight} )
oSorax:CLSID := "Sorax.Pdf Control.2"
oSorax:create(oDlg:drawingArea, oDlg ,,,nil,.F.)
wDocHandle := oSorax:CallMethod("OpenDoc", cPdf, "", "")
wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
oDlg:drawingArea:getHWND(), 1523) //1523 window uID
oSorax:CallMethod("AttachDoc", wViewHandle, wDocHandle)
wSorax:CallMethod("SetViewLayout", wViewHandle, iif(wsorax_siglepage, 1, 
2)+4+iif(wsorax_hgap, 16, 0)+iif(wsorax_vgap, 32, 0))
wSorax:CallMethod("ShowPage", wViewHandle, wsorax_pagenumber, wsorax_size)

wsorax:CallMethod("Find", wViewHandle) //Show the search dialog, and I 
click on the Search it crash

There is a C# example 
(http://www.soraxsoft.com/pdf/sdk/activex.php#sdk_activex), there the 
parent window of the PDF Reader Activex uses .NET framework's 
System.Windows.Forms.UserControl object. Maybe this could be a problem? 
The Activex calls a non-existent funcion? 
Can you help me solve this problem?
Thank you!

Ervin
Andreas Gehrs-Pahl
Re: Crash in Activex's modal dialog
on Wed, 29 May 2019 09:08:21 -0400
Ervin,

I think the problem might be quite simple.

>oSorax := XbpActiveXControl():new(oDlg:drawingArea, oDlg,{0,25}, 
>{nWidth,nHeight} )
>oSorax:CLSID := "Sorax.Pdf Control.2"
>oSorax:create(oDlg:drawingArea, oDlg ,,,nil,.F.)

You should remove the "oDlg" as the "oParent", and try the following 
instead:

oSorax := XbpActiveXControl():New(oDlg:DrawingArea, , {0, 25}, ;
          {nWidth, nHeight})
oSorax:CLSID := "Sorax.Pdf Control.2"
oSorax:Create()

Also, you should probably use "oDlg:GetHWnd()" in the "CreateView" method, 
instead of "oDlg:DrawingArea:GetHWnd()", like this:

wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, ;
               oDlg:GetHWnd(), 1523)    //1523 window uID

That should fix it,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Peter NagyRe: Crash in Activex's modal dialog
on Wed, 29 May 2019 15:37:23 +0200
Andreas,

Thank you for your reply. I used your code, but it not helped if I removed 
the parent oDlg.

If I use oDlg:GetHWND() the Activex dont show up (its working, but 
invisible). But I can still bring up the Search dialog if I click on my 
toolbar's search icon. And if i want to search still crash.

Andreas Gehrs-Pahl wrote in message 
news:11dz9rmadez74$.149bc55bewmqn.dlg@40tude.net...
>Ervin,
>
>I think the problem might be quite simple.
>
>>oSorax := XbpActiveXControl():new(oDlg:drawingArea, oDlg,{0,25}, 
>>{nWidth,nHeight} )
>>oSorax:CLSID := "Sorax.Pdf Control.2"
>>oSorax:create(oDlg:drawingArea, oDlg ,,,nil,.F.)
>
>You should remove the "oDlg" as the "oParent", and try the following 
>instead:
>
>oSorax := XbpActiveXControl():New(oDlg:DrawingArea, , {0, 25}, ;
>          {nWidth, nHeight})
>oSorax:CLSID := "Sorax.Pdf Control.2"
>oSorax:Create()
>
>Also, you should probably use "oDlg:GetHWnd()" in the "CreateView" 
method, 
>instead of "oDlg:DrawingArea:GetHWnd()", like this:
>
>wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, ;
>               oDlg:GetHWnd(), 1523)    //1523 window uID
>
>That should fix it,
>
>Andreas
Peter NagyRe: Crash in Activex's modal dialog
on Wed, 29 May 2019 15:53:33 +0200
Andreas,

I even tried using the AppDesktop():getHWND()

Like this:
oDlg          :=XbpDialog():new(AppDesktop(),,{aScreen[1]/2.4-nWidth/2, 
aScreen[2]/2.4-nHeight/2},{nWidth,nHeight},,.F.)
(...)
wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, 
AppDesktop():getHWND(), 13232324*1233)

Then it made a separate window, and if I want to search with my toolbar's 
search icon, after the search dialog the program still crashes. So I guess 
the problem is not the parent window. And I tried oActivex:UseGuiThread := 
.F. also.
Andreas Gehrs-Pahl
Re: Crash in Activex's modal dialog
on Thu, 30 May 2019 05:14:00 -0400
Ervin,

How about using the handle of the ActiveX object itself?

wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, ;
               oSorax:GetHWnd(), 1523)    //1523 window uID

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC
Peter NagyRe: Crash in Activex's modal dialog
on Thu, 30 May 2019 15:58:11 +0200
Adreas,

oSorax:GetHWND() is 0. So, the CreateView failed, and cant created the pdf 
view.

Ervin

Andreas Gehrs-Pahl wrote in message 
news:1ojwom3yi3nso$.1wtc9qlcw442o.dlg@40tude.net...
>Ervin,
>
>How about using the handle of the ActiveX object itself?
>
>wViewHandle := oSorax:CallMethod("CreateView", 0, 25, 1019, 739, ;
>               oSorax:GetHWnd(), 1523)    //1523 window uID
>
>Andreas
Jim LeeRe: Crash in Activex's modal dialog
on Wed, 29 May 2019 22:51:08 +0200
as i understand you create a new Windows from activeX ?

i'm not sure if this work with Xbase++ activeX as all work in same
GUI-Thread.
have you try to use a own Thread to create new Window ?



---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Peter NagyRe: Crash in Activex's modal dialog
on Thu, 30 May 2019 08:54:34 +0200
Jim,

I create the activex in an XbpDialog. The activex "Find()" function make a 
window (modal dialog) for entering the search data. I created a separate 
thread, with own event loop and it still crash if I want to search.

The thing I realized: After I call the activex "Find()" function, the 
activex's search dialog show up, and my event loop just wait. If i click to 
the cancel It go back normally to my event loop, but if i click on the 
search button it crash and no log data in my eventloop (i wrote to a file 
all the captured events by the AppEvent function).
Jim LeeRe: Crash in Activex's modal dialog
on Sat, 01 Jun 2019 21:58:58 +0200
hi,

i wonder why you need a separte Windows for Find() ... i just send CRTL-F
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-sendinput

INLINE METHOD keybd_event( nVirtKey, nScanCode, dwFlags, dwExtraInfo )
LOCAL oInput := INPUT() :New()
LOCAL nSize  := oInput:_sizeof_()
LOCAL nRet   := 0

   DEFAULT nScanCode TO 0
   DEFAULT dwFlags TO 0
   DEFAULT dwExtraInfo TO 0

   oInput:type := INPUT_KEYBOARD

   oInput:ki:wVk := nVirtKey
   oInput:ki:wScan := nScanCode
   oInput:ki:dwFlags := dwFlags
   oInput:ki:dwExtraInfo := dwExtraInfo

   nRet := @User32:SendInput( 1, oInput, nSize )

RETURN nRet



---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Peter NagyRe: Crash in Activex's modal dialog
on Mon, 03 Jun 2019 10:33:46 +0200
Jim,

I do no create the separate Window for Find(). I use an Activex control to 
show a PDF. The Activex control itself create a Search dialog, not me. And 
sadly, there is no other way to search (no ctrl+F either).

Ervin
Jim LeeRe: Crash in Activex's modal dialog
on Tue, 04 Jun 2019 01:00:08 +0200
> I do no create the separate Window for Find(). I use an Activex control to
> show a PDF. The Activex control itself create a Search dialog, not me. And
> sadly, there is no other way to search (no ctrl+F either).

i might be that your activeX do not accept CRTL-F ... but all Windows Apps 
use CRTL-F for "find".

as i say you can send virtual Key like this

#define VK_CONTROL         0x11     STRG
#define KEYEVENTF_KEYUP    0x02

PROCEDURE ShowSuch(oControl)
    NEED to set Focus to Control
   SetAppFocus(oControl)
    press key
   keybd_event( VK_CONTROL, 0, 0, 0)
   keybd_event( asc("F"), 0, 0, 0)
    release key
   keybd_event( asc("F"), 0, KEYEVENTF_KEYUP, 0)
   keybd_event( VK_CONTROL, 0, KEYEVENTF_KEYUP, 0)
RETURN

it work with Alaska Sample \Source\samples\activex\acrobat\acrobat.exe

! Note : API function "keybd_event" is superseded. Use SendInput instead
with INPUT Structure



---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com
Peter NagyRe: Crash in Activex's modal dialog
on Tue, 11 Jun 2019 12:24:37 +0200
Jim,

It did not worked. The only way to search in the PDF document is via the 
Activex Find dialog. But I cant figure out what is the problem. I checked 
the example software with a debug program, and I saw even the dialogs 
parent/child relations are ok.