Re: Clip capture



"ProfitMaxTrading.com" <nospam@xxxxxxxxxxxxxx> wrote in message
news:7Tbjf.11031$QW2.3552@xxxxxxxxxxxxx

> I copied on purpose a greater height than width picture but
> my output shows width greater than height. So I'm obviously
> truncating my output somewhere.

I wish I could see all your code in one list, instead of seeing little bits
of it piecemeal. For example, where are you declaring the variables you use
and is their scope correct? Also, does the picture box on the separate Form
*definitely* have its Autoredraw property set to True? It needs to be. By
the way, when you say you are "getting a negative number on the hDC" do you
mean that the hDC itself is a negative number or that the returned value
from a blit or other API operation that you use on the hDC returns a
negative number. Which is it? It is possible for a hDC to be a negative
number (especially in Win XP). It's just effectively a memory address. Is
this negative nunmber *just* a negative number, ir is it a specific negative
number that usually has special significance when using API routines (-1)?

If the Autoredraw property of the picture box on the second Form is True
then you can draw into it straight away. If you draw into it when the Form
that contains it is not loaded then VB will load that Form for you. So
whether or not you show or load the form prior to blitting into its
Autoredraw picture box you shouldn't have a problem. Is the ScaleMode of the
Form in which the picture box "libves" set to pixels? And does your code set
up the picture box to the size if the blit *and* do a PictureBox.Cls
*before* you perform the blit? (see below).

When you blit to an Autoredraw picture box the blit will just go into
whatever size bitmap is currently selected into that hDC (being clipped if
the bitmap is smaller than the blit, but with the "extra bitmap area"
remaining as it previously was if the existing bitmap is larger than the
blit). This means that unless you do something about it, the resultant size
of the bitmap can be very different from the size of the blit. If you want
your blit to create a specifically sized bitmap then you *must* set the
width and height of the picture box (assuming it is borderless) to the size
you require *before* you perform the blit. And, of course, the Picture Box's
container must be set to pixels when you do set the size. Also, *and this is
a very important step*, you *must* use Cls on the picture box after you have
set its size to a new value. The Cls method removes the currently existing
bitmap from memory altogether and de-selects it from the device context.
Then, the next time you access the hDC property the system will
automatically create a new bitmap (the same pixel size as the current client
area of the picture box) and will select that new bitmap into the device
context. So, if you want a specifically sized bitmap (and if the size you
want is different from the size of the currently selected bitmap) you must
do:

Height = something
Width = something
Cls
Blit

Mike



.



Relevant Pages

  • Re: Zoom in/ Zoom out images
    ... Picture control in the same dialog. ... As soon as you leave this function the destructor is called and the bitmap object is ... The drawing must be done in the OnPaint handler. ...
    (microsoft.public.vc.mfc)
  • Re: Clip capture
    ... "when you say you are "getting a negative number on the hDC" do you ... "If the Autoredraw property of the picture box on the second Form is True ... "And does your code set up the picture box to the size of the blit *and* do ... > the bitmap is smaller than the blit, but with the "extra bitmap area" ...
    (comp.lang.basic.visual.misc)
  • Re: One Thing I Noticed - Line Too Long
    ... > that creating a VB Autoredraw picture box automatically creates a separate ... > because you said it uses too much memory because it creates two bitmaps. ... > create an otherwise non existent bitmap in video card memory! ...
    (microsoft.public.vb.general.discussion)
  • Re: Graph Plotting - Mike
    ... the main picture box?". ... creates contains a bitmap and all of the details as to how Windows is to ... The device context that it creates is compatible with the device you ... in memory that contains the 'attribute'. ...
    (comp.lang.basic.visual.misc)
  • Re: Zoom in/ Zoom out images
    ... Picture control in the same dialog. ... As soon as you leave this function the destructor is called and the bitmap object is ... The drawing must be done in the OnPaint handler. ...
    (microsoft.public.vc.mfc)