Application.DOCMD with Visio Drawing Control

P

Phil Hazell

Hi,

I am building a custom app using the drawing control and I have been able to
successfully call most Visio internal functions by referencing the
application object and using DOCMD, but I cannot get this to work for
PrintPreview or emailing.

The command constants I am using are:

PrintPreview: DoCmd(visCmdPrintPreview)
Email: DoCmd(visCmdSendAsMail)

In both cases I get "Requested Operation Is Presently Disabled"

Any suggestions?
 
C

Chris Roth [ Visio MVP ]

The document.PrintOut method looks pretty powerful, but doesn't seem to
offer print preview option.

You can use GetWindowRect, GetViewRect and the Set versions of these
functions to control the zoom of the drawing in the window to simulate a
sort of preview, after all, Visio is supposedly WYSIWYG.

No ideas on the email...

--

Hope this helps,

Chris Roth
Visio MVP
 
M

Mai-lan [MS]

Replied with the following to a duplicate post:

Hi, Phil: You can't get to PrintPreview through the control. Here's a
workaround:
Visio's Print methods target the current printer; use
Application.ActivePrinter to tell you what printer is current. The Visio
object model does not include a PrintPreview method. Here's one approach:
private void menuFilePrintPreview_Click(object sender,
System.EventArgs e)

{

try

{



PrintDocument pd = new PrintDocument(); //Assumes the
default printer



PrintPreviewDialog dlg = new PrintPreviewDialog();

pd.PrintController = new PreviewPrintController();





pd.PrintPage += new
PrintPageEventHandler(this.pd_PrintPage);



dlg.Document = pd;



dlg.ShowDialog();



//pd.Print();



}

catch (Exception exp)

{

Debug.WriteLine( exp.Message );

throw exp;

}

}





private void pd_PrintPage(object sender, PrintPageEventArgs ev)

{



Metafile mf = new Metafile( (IntPtr) visioPage.Picture.Handle,
false );



ev.Graphics.DrawImage( mf, 0, 0 );

}



To simulate Print Preview, you could use an Image control and make some sort
of Draw or Render call using the preview context and pass it a bitmap or
metafile presentation of the control. You can also Page.Picture to get an
enhanced metafile to render as an IPictureDisp.

Thanks,

Mai-lan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top