PrinterSetup from Preview has no focus

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

PrinterSetup from Preview has no focus

Postby mcsh » Tue Feb 17, 2009 2:09 pm

situation: VpeControl embedded in C# Form
Code: Select all
vpeControl.ExternalPreview = false;
vpeControl.ToolBar = false;
vpeControl.PageScroller = false;
vpeControl.Rulers = false;


preview is shown with
Code: Select all
vpeControl.PreviewDoc(vpeControl.Left, vpeControl.Top, vpeControl.Right, vpeControl.Bottom, PreviewState.Normal);


own ToolStripBar with Buttons for Printing, Email, ...
when i call
Code: Select all
vpeControl.PrintDoc(true);

the PrinterSetup dialog is shown (and looks like active) but has no focus (no hottracking of buttons, etc), so i have to click 2x on Ok or Cancel (first click to activate the dialog, second click to press the button)
the same happens when i call
Code: Select all
vpeControl.SendKey(KeyFunction.Print);

or
Code: Select all
vpeControl.SetupPrinter(null, PrintDialogControl.Always | PrintDialogControl.Full);


but if i use
Code: Select all
vpeControl.SetupPrinter(null, PrintDialogControl.Always);

the simpler dialog is shown and has regular behavior with full focus and all.

any suggestions?

vpe version 4.0.4.5427
mcsh
 
Posts: 8
Joined: Tue Feb 17, 2009 1:50 pm

Postby IDEAL Software Support » Tue Feb 17, 2009 4:35 pm

This seems to be related to the event handling of your toolbar. Try setting the focus onto the VPE control before calling SetupPrinter().
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby mcsh » Wed Feb 18, 2009 9:07 am

I have tried various ways and combinations, setting Focus to the VpeControl, the VpeControl.ParentForm, the containing Panel, using Framework/VpeControl
Code: Select all
.Focus();
, P/Invoke
Code: Select all
SetFocus(vpeControl.PreviewWindow.Handle;
, each with or without
Code: Select all
DoEvents();
before and/or after...

I really think it is a problem of vpe, because
Code: Select all
int result = vpeControl.SetupPrinter(null, PrintDialogControl.Always & ~PrintDialogControl.Full);
does work correctly, but
Code: Select all
int result = vpeControl.SetupPrinter(null, PrintDialogControl.Always | PrintDialogControl.Full);
does not work (both without any DoEvents() or anything else).

more: vpeControl.Focus(); returns false, but vpeControl.CanFocus is true
mcsh
 
Posts: 8
Joined: Tue Feb 17, 2009 1:50 pm

Postby IDEAL Software Support » Wed Feb 18, 2009 1:39 pm

We checked our source code and you should rather blame Microsoft than us.

In both cases, i.e. with PrintDialogControl.Full or without, we are calling the common dialog API of Windows: PrintDlg(). The only difference is that we specify the flag PD_PRINTSETUP in one of both cases.

As a quick idea, a workaround could be that you post (not send) yourself a message when the toolbar button is clicked. When receiving the posted message, try calling SetupPrinter().

Please let me know if this helps.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby mcsh » Wed Feb 18, 2009 4:12 pm

yes, it seems like it's a M$ problem - see other topic for resolution
mcsh
 
Posts: 8
Joined: Tue Feb 17, 2009 1:50 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: Google [Bot] and 13 guests

cron