Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / August 2008



Tip: Looking for answers? Try searching our database.

Problems with HDC's

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Farmer - 26 Aug 2008 18:15 GMT
Hi all, I'm trying to remove 2 pictureboxes and do the work with memory
HDC's
This is what is causing my problem, whichever HDC is created first seems to
work fine
but the second HDC is just a black picture.

Sub Setup_HDCs()
   Dim MyBM As StdPicture
   Set MyBM = PictureFromDC(picShown.hDC, 0, 0, picShown.ScaleWidth,
picShown.ScaleHeight)
   HDC_Backup = CreateCompatibleDC(picShown.hDC)
   Call SelectObject(HDC_Backup, MyBM.Handle)
   HDC_Hidden = CreateCompatibleDC(picShown.hDC)
   Call SelectObject(HDC_Hidden, MyBM.Handle)
   Set MyBM = Nothing
End Sub

if I bitblt HDC_Backup I get a the correct picture BUT
if I bitblt HDC_hiddem I get a BLACK picture

If I swap the sub above around its always the second HDC that gives the
black picture.
What am I doing wrong?
Dean Earley - 27 Aug 2008 08:43 GMT
> Hi all, I'm trying to remove 2 pictureboxes and do the work with memory
> HDC's
[quoted text clipped - 19 lines]
> black picture.
> What am I doing wrong?

You can only have one DC selected into a bitmap at a time.
Depending on what you are actually trying to do, you may have to just
duplicate the code.

Signature

Dean Earley (dean.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

Thorsten Albers - 27 Aug 2008 12:55 GMT
Dean Earley <dean.earley@icode.co.uk> schrieb im Beitrag
<O9sfpiBCJHA.3496@TK2MSFTNGP03.phx.gbl>...
> You can only have one DC selected into a bitmap at a time.

Presumably you mean
1. You can only have one bitmap selected into a DC at a time
2. You can only have a bitmap selected into one DC at a time

Signature

----------------------------------------------------------------------
Thorsten Albers                               albers(a)uni-freiburg.de
----------------------------------------------------------------------

Dean Earley - 27 Aug 2008 13:06 GMT
> Dean Earley <dean.earley@icode.co.uk> schrieb im Beitrag
> <O9sfpiBCJHA.3496@TK2MSFTNGP03.phx.gbl>...
[quoted text clipped - 3 lines]
> 1. You can only have one bitmap selected into a DC at a time
> 2. You can only have a bitmap selected into one DC at a time

They're the ones. Sorry for any confusion.

Signature

Dean Earley (dean.earley@icode.co.uk)
i-Catcher Development Team

iCode Systems

Chris Farmer - 27 Aug 2008 13:40 GMT
yes the problem was setting  MYBM to the same stdpicture
instead of using two picture references for the same picture.
set MYBM1 = the picture
set MYBM2 = the picture
Then I can select each of these into the two HDC's

Thanks for you help
Chris

>> Dean Earley <dean.earley@icode.co.uk> schrieb im Beitrag
>> <O9sfpiBCJHA.3496@TK2MSFTNGP03.phx.gbl>...
[quoted text clipped - 5 lines]
>
> They're the ones. Sorry for any confusion.
Thorsten Albers - 27 Aug 2008 20:00 GMT
Chris Farmer <H313AGF@aol.com> schrieb im Beitrag
<utrZOIECJHA.4340@TK2MSFTNGP02.phx.gbl>...
> yes the problem was setting  MYBM to the same stdpicture
> instead of using two picture references for the same picture.
> set MYBM1 = the picture
> set MYBM2 = the picture
> Then I can select each of these into the two HDC's

Is there a reason for the use of a picture object? Since the picture object
'contents' is first retrieved from a DC and later selected into another DC
there is no need for using a picture object - unless the picture object
doesn't get manipulated somewhere else with special picture object methods
of VB.

Signature

----------------------------------------------------------------------
Thorsten Albers                               albers(a)uni-freiburg.de
----------------------------------------------------------------------

Chris Farmer - 28 Aug 2008 23:00 GMT
Yes the picture object is what the user sees in the Picture Box
I'm just using the 2 memory DCs to manipulate regions of this picture and
bitblt it back to the picturebox based on the users interaction.
Its all working fine now, thanks
Chris

> Chris Farmer <H313AGF@aol.com> schrieb im Beitrag
> <utrZOIECJHA.4340@TK2MSFTNGP02.phx.gbl>...
[quoted text clipped - 10 lines]
> doesn't get manipulated somewhere else with special picture object methods
> of VB.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.