Re: Help for hDC and textcontrol.com's ActiveX Control

From: Fred Taylor (ftaylor_at_mvps.org!REMOVE)
Date: 02/16/05


Date: Wed, 16 Feb 2005 08:08:08 -0700

Fox Controls are not "real" Windows controls, in that they don't have a
Windows handle or anything like that. You're picturebox control would need
to be an ActiveX control and if it is, you may need to reference the
property as thisform.picture1.object.hDC.

-- 
Fred
Microsoft Visual FoxPro MVP
"Tom Clark" <tjclark@pc-enable.com> wrote in message 
news:1116jlasqavki8d@corp.supernews.com...
> Hi All,
>
> I posted this in the wrong thread.  Sorry for the repost.
>
> Eric den Doop suggested I take a look at TextControl.com's ActiveX control
> for print previewing MS-Word or RTF documents.  I downloaded the trial
> version and I am having a problem with the code.
>
> According to the Help File:
>
> "Text Control's PrintPage method can not only be used with printers, but
> also with any control that has a hDC property. For instance. a PictureBox
> can be used as a print preview window. This is done by simply assigning 
> its
> hDC Property to Text Control's PrintDevice Property. When calling 
> PrintPage,
> Text Control will print to the Picture Box instead of to the printer.
>
> This code snippet will print page 1 to a picture box named Picture1. You 
> can
> use the PrintZoom Property to scale down the printout if the picture box 
> is
> smaller than a full printer page:
>
> TXTextControl1.PrintDevice = Picture1.hDC
> TXTextControl1.PrintZoom = 25 ' scale down to 25%
> TXTextControl1.PrintPage 1"
>
> The MDIDemo sample program contains a sophisticated print preview form 
> that
> works like this. Its source code is contained in the Samples\VB6\MDI
> folder."
>
> Well I have adapted that example as best I could with the following code:
>
> cDoc = "c:\pcenable\rtf\jdis2.doc"
> thisform.oTxt.Load(cDoc,,9,)
> thisform.oTxt.PrintDevice = Picture1.hDC
> thisform.oTxt.PrintZoom = 25 && scale down to 25%
> thisform.oTxt.PrintPage(1)
>
> The code generates the following run time error "Alias 'Picture1' is not
> found."
>
> I have named the image control to "Picture1" but I realize that my problem
> is that I have no idea what hDC is!  Any help would be appreciated.
>
> TIA,
> Tom Clark
>
> Bernhard Sander replied:
>
> "If your "Picture1" is on the same form then the above line should read:
>  thisform.oTxt.PrintDevice = THISFORM.Picture1.hDC"
>
> Which I tried and the new error is "Property hDC not found."
>
> MSDN says the following in regards to Visual BASIC:
>
> Syntax
> object.hDC
> The object placeholder represents an object expression that evaluates to 
> an object in the Applies To list.
> Remarks
> This property is a Windows operating environment device context handle. 
> The Windows operating environment manages the system display by assigning 
> a device context for the Printer object and for each form and PictureBox 
> control in your application. You can use the hDC property to refer to the 
> handle for an object's device context. This provides a value to pass to 
> Windows API calls.
> With a CommonDialog control, this property returns a device context for 
> the printer selected in the Print dialog box when the cdlReturnDC flag is 
> set or an information context when the cdlReturnIC flag is set.
> Note   The value of the hDC property can change while a program is 
> running, so don't store the value in a variable; instead, use the hDC 
> property each time you need it.
> The AutoRedraw property can cause the hDC property setting to change. If 
> AutoRedraw is set to True for a form or PictureBox container, hDC acts as 
> a handle to the device context of the persistent graphic (equivalent to 
> the Image property). When AutoRedraw is False, hDC is the actual hDC value 
> of the Form window or the PictureBox container. The hDC property setting 
> may change while the program is running regardless of the AutoRedraw 
> setting.
> If the HasDC property is set to False, a new device context will be 
> created by the system and the value of the hDC property will change each 
> time it is called.
> 


Relevant Pages

  • Re: Help for hDC and textcontrol.coms ActiveX Control
    ... Microsoft Picture Clip Control v6 and the new error in both ... You're picturebox control would ... >> hDC Property to Text Control's PrintDevice Property. ... >> a device context for the Printer object and for each form and PictureBox ...
    (microsoft.public.fox.programmer.exchange)
  • Help for hDC and textcontrol.coms ActiveX Control
    ... Eric den Doop suggested I take a look at TextControl.com's ActiveX control ... hDC Property to Text Control's PrintDevice Property. ... This property is a Windows operating environment device context handle. ... device context for the Printer object and for each form and PictureBox ...
    (microsoft.public.fox.programmer.exchange)
  • Re: fastest (non bit-blitting) way to move a large bitmap around ?
    ... for the visible portion so this is pretty quick. ... as PictureBox from offscreen the portion to be drawn will be painted more ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... But I am curious if the Opaque control style set to true ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Transparent Picturebox
    ... You can't do this with PictureBox. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ... Answer those GDI+ questions with the GDI+ FAQ ... other control underneath it can show through, ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • RE: Creating a watermark for a form
    ... In Windows, the control has a depth parameter, which is called z-order. ... we can also control the control z-order. ... PictureBox.SendToBack method to keep the picturebox at the background. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)

Loading