|
-
Oct 12th, 2002, 03:04 PM
#1
Thread Starter
Fanatic Member
Dc Q!
Hi, Guys.
I have a question about DCs (Longs).
When I want to copy a DC into another DC and I do it like this:
So when I change the FirstDC the SecondDC changes too, and that's not what I wanted. I want to copy it.
Is there an API for this? or just a simple code?
Help please,
Arie.
-
Oct 12th, 2002, 04:37 PM
#2
Good Ol' Platypus
Try FirstDC = VarPtr(SecondDC). I dunno, sounds scary having Pointers in action in VB!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 13th, 2002, 12:33 PM
#3
You cannot duplicate a dc. But you can use the SaveDC API to save the state of a device context, then restore it.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 13th, 2002, 12:33 PM
#4
Sastraxi's code will most likely lead to an access violation.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 13th, 2002, 08:16 PM
#5
Frenzied Member
Use CreateDC to create a new DC, then BitBlt to copy the first onto the second. Do it all the time. Put the code into a function called CopyDC, put it into a module, and away you go.
-
Oct 14th, 2002, 04:29 AM
#6
But that's something different. What he wants is a copy of a screen dc so he can use two sets of settings (at least that's how I understand it), which you cannot. You can save a set of settings and later load it using SaveDC and RestoreDC.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2002, 07:46 AM
#7
Frenzied Member
Originally posted by CornedBee
But that's something different. What he wants is a copy of a screen dc so he can use two sets of settings (at least that's how I understand it), which you cannot. You can save a set of settings and later load it using SaveDC and RestoreDC.
OK THIS is what he asked for:
So when I change the FirstDC the SecondDC changes too, and that's not what I wanted. I want to copy it.
He didn't ask for anything about copying DC settings; just contents...
-
Oct 14th, 2002, 09:21 AM
#8
Good Ol' Platypus
This is all too freaky for me... I'm outta here!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 14th, 2002, 12:14 PM
#9
So when I change the FirstDC the SecondDC changes too, and that's not what I wanted. I want to copy it.
Does he mean the settings of SecondDC change too, or the content (what is displayed) change too?
Because you still cannot copy a DC. The return of CreateCompatibleDC will not draw to the screen, but to a memory location.
He didn't ask for anything about copying DC settings; just contents...
He asked for copying the DC, which is not possible. And maybe he doesn't know it, but to windows a DC is only a bunch of settings and a reference to a device, which stores the actual data (the device might be the screen or a printer or memory location or a DirectDraw surface, but the DC stores no data).
Arie, we need clarification.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2002, 12:22 PM
#10
Frenzied Member
*sigh*
A Device Context stores a pointer to what roughly translates as image data. By using CreateCompatibleDC you can create a NEW DC that points to blank memory that is compatible with the screen DC. Then you copy the screen DC's image (i.e. contents) using BitBlt to the memory DC, and when you are done you copy them back and use DeleteObject on the memory DC.
-
Oct 14th, 2002, 12:45 PM
#11
Yeah, I know, but if you're a tech freak like I am the question means what I said.
Where's Arie anyway?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 14th, 2002, 01:27 PM
#12
Good Ol' Platypus
Wouldn't it be ironic if he solved his problem on his own and just left
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 14th, 2002, 01:52 PM
#13
Frenzied Member
Originally posted by CornedBee
Yeah, I know, but if you're a tech freak like I am the question means what I said.
Where's Arie anyway?
I've talked to dozens of other coders about DCs using the term "copy" to mean Blt'ing the contents. I've never heard anyone use the term like you do
-
Oct 14th, 2002, 02:00 PM
#14
Thread Starter
Fanatic Member
Hey guys, relax.
I wasn't here a few days.
In the meanwhile I figured that what I need is to BitBlt from FirstDC into SecondDC. I needed only the image in it, nothing else.
I'll adapt the way that mlewis suggested.
Thank you all for helping,
Arie.
-
Oct 15th, 2002, 04:23 AM
#15
Ok, ok, I'm shutting up. I surely wouldn't use it that way, but it's now clear.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|