ctacke/>
Thu Dec 06 08:54:28 PST 2007
My bet is you'll have to fully owner draw the thing as a pure custom window,
setting the ROP operation manually through native interop. I've done it
before, but I I don't know if I have any consumable "samples" that I can
readily publish.
--
Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com
"Simon" <Simon@discussions.microsoft.com> wrote in message
news:EA55DA98-F204-4AD0-BB48-054E2F8E80F5@microsoft.com...
> First off thanks for the reply Chris.
>
> I wasn't implying there are bitmaps hanging around for behind controls but
> I
> was hoping I could do a screen capture via a certain controls handle so
> that
> I could cache a bitmap of what is behind the current control.
>
> I understand what your solution is stating however I am not seeing this
> case
> across the board in NETCF controls. If I recall I tried overriding the
> OnPaintBackground method of Panel and it still renders white even if I
> surpress this from happening.
>
> Something along the lines of this DOES work however as you can imagine, it
> is not smart performance wise, in cases like scrolling, it flickers a ton
> because its invalidating parent.parent.parent etc and eventually
> invalidating
> the Form. However on something where the layout is static, it draws
> perfectly
> as if it was transparent. So that if you have a PictureBox in behind a
> Panel,
> you would see the PictureBox.
>
> Example:
>
> protected override void OnPaintBackground(PaintEventArgs e)
> {
> return;
> }
>
> protected override void OnPaint(PaintEventArgs e)
> {
> if (!isPaintBackgroundComplete)
> {
> this.Visible = false;
> this.Parent.Invalidate(Bounds);
> this.Parent.Update();
> this.Visible = true;
> isPaintBackgroundComplete = true;
>
> return;
> }
> isPaintBackgroundComplete = false;
> }
>
> I am hoping to find a better solution than this because its invalidating a
> whole tree for every transparent control. I would rather do something
> similiar once, cache a bitmap somehow. Or if there is another solution
> entirely that is more efficient.
>
> Simply surpressing OnPaintBackground doesn't achieve the desired results
> you
> would expect.
>
> Again thanks for your help.
>
> Thanks and take care,
> Simon
>
> "<ctacke/>" wrote:
>
>> I think you misunderstand how GDI works and are headed down the wrong
>> path.
>> There is no bitmap of anything behind a control.
>>
>> There is a single frame buffer that represents the current screen that
>> you
>> you are looking at. There aren't bitmaps for every control floating
>> around - that menas there is no bitmap representation of what's behind
>> any
>> control. Rendering is handled by GDI onto that one surface, so that's
>> all
>> there is - you can get a screen shot of it, or any part.
>>
>> Transparency is the act of *not* drawing a region to that buffer, not
>> trying
>> to reclaim what was overwritten.
>>
>> To get a transparency you need to do it at draw time by either custom
>> drawing only what you want (for a panel it would really be just draing
>> the
>> border) or using a ROP operation to set a transparency color so that when
>> it
>> gets rendered, the transparent areas don't get drawn.
>>
>>
>> --
>>
>> Chris Tacke, eMVP
>> Join the Embedded Developer Community
>>
http://community.opennetcf.com
>>
>>
>>
>> "Simon" <Simon@discussions.microsoft.com> wrote in message
>> news:DF001D2D-5DBF-4FBC-BC5B-DD0964972BC7@microsoft.com...
>> > Hey gang.
>> >
>> > I am looking to do some alpha transparency / transparent Panels in
>> > NETCF.
>> > Is
>> > there any PInvoke functions to get a bitmap from a control?
>> >
>> > I am not looking to just get a bitmap from an owner drawn control. I
>> > want
>> > the real image of whats on screen behind a Control somehow. So if I
>> > have a
>> > Button behind a Panel I can paint the image of what is behind the Panel
>> > as
>> > the Panel's BG. Making it seem transparent.
>> >
>> > In NETCF many objects don't support a BackColor = Color.Transparent so
>> > this
>> > is what I am trying to achieve for Panels, Labels etc. So that controls
>> > behind them show through.
>> >
>> > I know in Vista there is a DrawToBitmap API but is there anything I can
>> > do
>> > to achieve something similiar?
>> >
>> > Maybe not force a control to draw to a bitmap but capture the controls
>> > bitmap through a handle or atleast a form then I can crop based on
>> > control
>> > Bounds?
>> >
>> > Any help would be greatly appreciated.
>> >
>> > Thanks and take care.
>>
>>
>>