DCPRINT ON Window Parent

This forum is for eXpress++ general support.
Post Reply
Message
Author
ivanvazan
Posts: 21
Joined: Tue May 18, 2010 5:57 am

DCPRINT ON Window Parent

#1 Post by ivanvazan »

Hi Roger,

When using DCPRINT ON to a printer with a large report, there is a page counter window that appears but I can click away and the counter window 'hides' behind my application. How can I set the parent window of the dialog so that I cannot click away.

Ivan

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCPRINT ON Window Parent

#2 Post by rdonnay »

Try making the below change to your _DCPRC.PRG.
It is located in \exp19\source\dclipx folder.
Then rebuild DCLIPX.DLL by running BUILD19.BAT or BUILD19_SL1.BAT.

If this works, I will put this change in the next release.

Code: Select all

898  IF oPrinter:nCurrPage # nPage
899    oPrinter:oStatusText:setCaption(DC_LangMsg(DCMSG_PC_PAGE) + ;
900                                  '  ' + Alltrim(Str(oPrinter:nCurrPage)))
901    nPage := oPrinter:nCurrPage
902    oPrinter:oStatusDlg:toFront()  // <<<<<<<<<<<<<<<<< Add this
903  ENDIF
The eXpress train is coming - and it has more cars.

ivanvazan
Posts: 21
Joined: Tue May 18, 2010 5:57 am

Re: DCPRINT ON Window Parent

#3 Post by ivanvazan »

Hi Roger,
I tried your suggestion and it worked, but only up to certain point. The 'Page Counter' window is modal to the application, so it was popping up in the other application thread windows, which is kind of confusing for the user. The second thing is that since the :tofront() was executed only during the page change, there was always a delay (depending on the amount of printed info) before the 'Page Counter' window re-appeared.
So I started to fiddle around and came up with better solution (at least I think so ;) ). If you allow me to pass oParent to the DCPRINT ON command and make this object a parent of the 'Page Counter' window, all issues would be solved. Temporarily, to prove and test my idea, I set up a PUBLIC variable in my MAIN function and just before the DCPRINT ON is called, I assigned my current window object to this variable. Then I altered your code as follows:

Code: Select all

oPrinter:oStatusDlg := XbpDialog():new(AppDeskTop(),,{0,0},{200,100},,.f.)
oPrinter:oStatusDlg:title := cTitle
oPrinter:oStatusDlg:minButton := .f.
oPrinter:oStatusDlg:maxButton := .f.
IF VALTYPE( oDMIPARENT ) = "O"                                                 // <<<<<<<<<<<<<<<<< Add this
    oPrinter:oStatusDlg:setparent( oDMIPARENT )                          // my temporary PUBLIC variable, to be replaced with passed in oParent
ENDIF
oPrinter:oStatusDlg:create()
IF VALTYPE( oDMIPARENT ) != "O"                                               // <<<<<<<<<<<<<<<<< Add this
    oPrinter:oStatusDlg:setModalState(XBP_DISP_APPMODAL)         // no need to set modality if oParent passed in
ENDIF
oPrinter:oStatusText := XbpStatic():new(oPrinter:oStatusDlg:drawingArea,,{10,40},{250,20},,.t.)
oPrinter:oStatusText:type := XBPSTATIC_TYPE_TEXT
oPrinter:oStatusText:create()
oPrinter:oStatusText:setFontCompoundName('10.Arial Bold')
oXbp := XbpPushButton():new(oPrinter:oStatusDlg:drawingArea,,{10,10},{70,20},,.t.)
oXbp:caption := DC_LangMsg(DCMSG_CANCEL)
oXbp:activate := {||oPrinter:lTerminated := .t.}
oXbp:create()
SetAppFocus(oXbp)
DC_CenterObject(oPrinter:oStatusDlg)

oPrinter:oStatusDlg:show()
IF VALTYPE( oDMIPARENT ) != "O"                                                // <<<<<<<<<<<<<<<<< Add this
    oPrinter:oStatusDlg:setModalState(XBP_DISP_APPMODAL)         // no need to set modality if oParent passed in
ENDIF

DC_ClearEvents()
oPrinter:oStatusDlg:toFront()
DO WHILE !oPrinter:lTerminated .AND. !oPrinter:lDone .AND. !oPrinter:lPreview
  IF oPrinter:nCurrPage # nPage
    oPrinter:oStatusText:setCaption(DC_LangMsg(DCMSG_PC_PAGE) + ;
                                  '  ' + Alltrim(Str(oPrinter:nCurrPage)))
    nPage := oPrinter:nCurrPage
    //oPrinter:oStatusDlg:toFront()                                                  // <<<<<<<<<<<<<<<<< This is not needed
  ENDIF

Please let me know what you think.
Thanks.

User avatar
rdonnay
Site Admin
Posts: 4733
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: DCPRINT ON Window Parent

#4 Post by rdonnay »

Ivan -

I would rather you try another solution first that would prevent the need for more parameters and more documentation.

There is already an OWNER clause that is accepted by the DCPRINT ON command.

It requires only a few small mods to the _DCPRC.PRG to use it for the Cancel Dialog.

Change #1
Line 359:

Code: Select all

IS:

::oOwner := oOwner
IF lPreview
   bKeyboard := {|a,b,o|IIF( a==xbeK_ENTER,PostAppEvent( xbeP_Activate,,,o ),nil)}

WAS:

IF lPreview
  ::oOwner := oOwner 
   bKeyboard := {|a,b,o|IIF( a==xbeK_ENTER,PostAppEvent( xbeP_Activate,,,o ),nil)}
Change #2
Line 876:

Code: Select all

IS:

oPrinter:oStatusDlg := XbpDialog():new(AppDeskTop(), oPrinter:oOwner,{0,0},{200,100},,.f.)

WAS:

oPrinter:oStatusDlg := XbpDialog():new(AppDeskTop(), ,{0,0},{200,100},,.f.)
The eXpress train is coming - and it has more cars.

ivanvazan
Posts: 21
Joined: Tue May 18, 2010 5:57 am

Re: DCPRINT ON Window Parent

#5 Post by ivanvazan »

Roger,

I was in the middle of a major customer upgrade and could not get to this until today. This change worked perfectly. Thanks for all of your help.

Post Reply