Re: Clip capture
- From: "ProfitMaxTrading.com" <nospam@xxxxxxxxxxxxxx>
- Date: Wed, 30 Nov 2005 09:42:14 -0600
Hi Mike.
All the code that I did have was in one post called - modules. Anyway,
progress is being made.
"does the picture box on the separate Form
*definitely* have its Autoredraw property set to True?"
Most definitely. This is set at design time, however.
"when you say you are "getting a negative number on the hDC" do you
mean that the hDC itself is a negative number"
Yes. The hDC itself. Big number, like -27364574. But from what you say this
is not the problem.
I assumed it was when I replaced it with the source pic window's hDC that
was positive and it worked (though not want I want to do of course).
"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."
Ths is good to know! I can just leave the form show line off then.
"Is the ScaleMode of the Form in which the picture box "libves" set to
pixels?"
Is. Everything in this program has been set to vbPixels (3). And I'm also
aware that Form.width and .height are standard vbTwips and cannot be
changed. So when sizing the output form to contain the output pic, I must
convert pixels using screen.twipsperpixel (something like that).
"And does your code set up the picture box to the size of the blit *and* do
a PictureBox.Cls *before* you perform the blit? (see below)."
No it does not. So this brings up a new question.
I've got this to work where you now see a picture in the output form pic
obj. Do I need to do a pic.cls in order for the outpic pic size to match
the orig pic size? I'm assuming that my output bitblt sizes are just wrong.
NOTE: The only code elsewhere in my program is just to draw the Rect.
Nothing more. This one routine does the whole copy and paste thing. It's all
here now.
Public Sub CreateClipRoutine()
'Copy Rect
frmChart.picTemp.width = fRect.right - fRect.left + 1
frmChart.picTemp.Height = fRect.bottom - fRect.top + 1
'Copy from frmChart.pctChart to frmChart.picTemp
BitBlt frmChart.picTemp.hdc, 0, 0, (fRect.right - fRect.left),
fRect.bottom - fRect.top, _
frmChart.pctChart.hdc, fRect.left, fRect.top, vbSrcCopy
frmChart.picTemp.Refresh
DrawFocusRect frmChart.pctChart.hdc, fRect
'Copy to clipboard for pasting into paint program in order to convert to
GIF for webposting.
Clipboard.Clear
Clipboard.SetData frmChart.picTemp.Image, vbCRFBitmap
'Paste to frmClipScreen1.pctClip
BitBlt frmClipScreen1.pctClip.hdc, 0, 0, fRect.right - fRect.left,
fRect.bottom - fRect.top, _
frmChart.picTemp.hdc, 0, 0, vbSrcCopy
frmClipScreen1.width = screen.TwipsPerPixelX *
frmClipScreen1.pctClip.ScaleWidth
frmClipScreen1.Height = screen.TwipsPerPixelY *
frmClipScreen1.pctClip.ScaleHeight
frmClipScreen1.Show
gbClipToolActive = False
frmChart.pctChart.MousePointer = vbDefault
End Sub
I removed the frmClipScreen1.show line that was here before I read your
message.
Thanks for commenting Mike.
:-)
Rick
"mike williams" <mike@xxxxxxxxxxxxxxxxx> wrote in message
news:dmju4n$m74$1@xxxxxxxxxxxxxxxxxxxxxx
> "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
>
>
>
.
- Follow-Ups:
- Re: Clip capture
- From: Mike Williams
- Re: Clip capture
- Prev by Date: Radial text on inside of path
- Next by Date: memory
- Previous by thread: Radial text on inside of path
- Next by thread: Re: Clip capture
- Index(es):
Relevant Pages
|