Create Hidden window for drawing?

Hi all,

I am writting a MFC component that will create a hidden window, load a 
bitmap into the hidden window and then save the hidden window to bitmap file. 
However, after I loaded the bitmap into the hidden window and save the window 
into bitmap file using function I found in codeguru 
(http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The 
bitmap file only contain the desktop window instead of the hidden window.

Is it possble to create a hidden window for drawing? Is there any other way 
I could create a hidden area for the program to draw on and save the area to 
file?

I could not draw to the client DC directly as I do not want user to see the 
image at all. All I want to do is create a off screen window area, load a 
bitmap and save that window to a bitmap file.

Thanks.



0
Sam2 (7)
9/11/2006 9:02:02 PM
vc.mfc 33608 articles. 0 followers. Follow

11 Replies
973 Views

Similar Articles

[PageSpeed] 16

Can you explain why you want a hidden window?

Why not just create a memory DC and draw to that? The memory DC will contain 
whatever you draw on it for saving to a file as it will not be overlapped by 
other windows. What is the purpose of the Window?

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
> Hi all,
>
> I am writting a MFC component that will create a hidden window, load a
> bitmap into the hidden window and then save the hidden window to bitmap 
> file.
> However, after I loaded the bitmap into the hidden window and save the 
> window
> into bitmap file using function I found in codeguru
> (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The
> bitmap file only contain the desktop window instead of the hidden window.
>
> Is it possble to create a hidden window for drawing? Is there any other 
> way
> I could create a hidden area for the program to draw on and save the area 
> to
> file?
>
> I could not draw to the client DC directly as I do not want user to see 
> the
> image at all. All I want to do is create a off screen window area, load a
> bitmap and save that window to a bitmap file.
>
> Thanks.
>
>
> 


0
jwood (1292)
9/11/2006 10:32:43 PM
Thanks for your reply Jonathan. 

The reason why I need a hidden window is because my component does not have 
a CClientDC and I could not use the main window's client DC. I will have to 
use its own Client DC. I could create a memory DC if and only if I have a 
client DC right? Thanks.

Sam_2

"Jonathan Wood" wrote:

> Can you explain why you want a hidden window?
> 
> Why not just create a memory DC and draw to that? The memory DC will contain 
> whatever you draw on it for saving to a file as it will not be overlapped by 
> other windows. What is the purpose of the Window?
> 
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 
> 
> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
> news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
> > Hi all,
> >
> > I am writting a MFC component that will create a hidden window, load a
> > bitmap into the hidden window and then save the hidden window to bitmap 
> > file.
> > However, after I loaded the bitmap into the hidden window and save the 
> > window
> > into bitmap file using function I found in codeguru
> > (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The
> > bitmap file only contain the desktop window instead of the hidden window.
> >
> > Is it possble to create a hidden window for drawing? Is there any other 
> > way
> > I could create a hidden area for the program to draw on and save the area 
> > to
> > file?
> >
> > I could not draw to the client DC directly as I do not want user to see 
> > the
> > image at all. All I want to do is create a off screen window area, load a
> > bitmap and save that window to a bitmap file.
> >
> > Thanks.
> >
> >
> > 
> 
> 
> 
0
Sam2 (7)
9/11/2006 11:18:02 PM
Wrong. You can create a DC compatible with the screen. I see no reason for a 
separate window here. In fact, that's what seems to be working against you.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
news:4E308ADD-59F4-4DFD-B959-47121282F7FE@microsoft.com...
> Thanks for your reply Jonathan.
>
> The reason why I need a hidden window is because my component does not 
> have
> a CClientDC and I could not use the main window's client DC. I will have 
> to
> use its own Client DC. I could create a memory DC if and only if I have a
> client DC right? Thanks.
>
> Sam_2
>
> "Jonathan Wood" wrote:
>
>> Can you explain why you want a hidden window?
>>
>> Why not just create a memory DC and draw to that? The memory DC will 
>> contain
>> whatever you draw on it for saving to a file as it will not be overlapped 
>> by
>> other windows. What is the purpose of the Window?
>>
>> -- 
>> Jonathan Wood
>> SoftCircuits Programming
>> http://www.softcircuits.com
>>
>>
>> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
>> news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
>> > Hi all,
>> >
>> > I am writting a MFC component that will create a hidden window, load a
>> > bitmap into the hidden window and then save the hidden window to bitmap
>> > file.
>> > However, after I loaded the bitmap into the hidden window and save the
>> > window
>> > into bitmap file using function I found in codeguru
>> > (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). 
>> > The
>> > bitmap file only contain the desktop window instead of the hidden 
>> > window.
>> >
>> > Is it possble to create a hidden window for drawing? Is there any other
>> > way
>> > I could create a hidden area for the program to draw on and save the 
>> > area
>> > to
>> > file?
>> >
>> > I could not draw to the client DC directly as I do not want user to see
>> > the
>> > image at all. All I want to do is create a off screen window area, load 
>> > a
>> > bitmap and save that window to a bitmap file.
>> >
>> > Thanks.
>> >
>> >
>> >
>>
>>
>> 


0
jwood (1292)
9/11/2006 11:47:28 PM
Could you give me an example to create a Memory DC without using CWnd* nor 
pDC* ? Thanks.

Sam_2

"Jonathan Wood" wrote:

> Wrong. You can create a DC compatible with the screen. I see no reason for a 
> separate window here. In fact, that's what seems to be working against you.
> 
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 
> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
> news:4E308ADD-59F4-4DFD-B959-47121282F7FE@microsoft.com...
> > Thanks for your reply Jonathan.
> >
> > The reason why I need a hidden window is because my component does not 
> > have
> > a CClientDC and I could not use the main window's client DC. I will have 
> > to
> > use its own Client DC. I could create a memory DC if and only if I have a
> > client DC right? Thanks.
> >
> > Sam_2
> >
> > "Jonathan Wood" wrote:
> >
> >> Can you explain why you want a hidden window?
> >>
> >> Why not just create a memory DC and draw to that? The memory DC will 
> >> contain
> >> whatever you draw on it for saving to a file as it will not be overlapped 
> >> by
> >> other windows. What is the purpose of the Window?
> >>
> >> -- 
> >> Jonathan Wood
> >> SoftCircuits Programming
> >> http://www.softcircuits.com
> >>
> >>
> >> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
> >> news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
> >> > Hi all,
> >> >
> >> > I am writting a MFC component that will create a hidden window, load a
> >> > bitmap into the hidden window and then save the hidden window to bitmap
> >> > file.
> >> > However, after I loaded the bitmap into the hidden window and save the
> >> > window
> >> > into bitmap file using function I found in codeguru
> >> > (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). 
> >> > The
> >> > bitmap file only contain the desktop window instead of the hidden 
> >> > window.
> >> >
> >> > Is it possble to create a hidden window for drawing? Is there any other
> >> > way
> >> > I could create a hidden area for the program to draw on and save the 
> >> > area
> >> > to
> >> > file?
> >> >
> >> > I could not draw to the client DC directly as I do not want user to see
> >> > the
> >> > image at all. All I want to do is create a off screen window area, load 
> >> > a
> >> > bitmap and save that window to a bitmap file.
> >> >
> >> > Thanks.
> >> >
> >> >
> >> >
> >>
> >>
> >> 
> 
> 
> 
0
Sam2 (7)
9/12/2006 12:21:02 AM
I have some fairly complex code that I'm not willing to post here.

But basically, you declare a memory DC.

CDC dcMem;

Then call dcMem.CreateCompatibleDC(). Note from the docs that if the 
argument is NULL, a memory device context is created that is compatible with 
the screen.

By default, a DC created this way has a 1x1 black and white bitmap. So you 
need to declare a CBitmap and call CBitmap::CreateCompatibleBitmap() of the 
size you need. Then, you must select the bitmap into dcMem.

At this point, you should be able to draw to the bitmap using dcMem just 
like you would draw to a window.

-- 
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
news:96EFDFFC-F936-4C5A-B871-A7DBD43BA66C@microsoft.com...
> Could you give me an example to create a Memory DC without using CWnd* nor
> pDC* ? Thanks.
>
> Sam_2
>
> "Jonathan Wood" wrote:
>
>> Wrong. You can create a DC compatible with the screen. I see no reason 
>> for a
>> separate window here. In fact, that's what seems to be working against 
>> you.
>>
>> -- 
>> Jonathan Wood
>> SoftCircuits Programming
>> http://www.softcircuits.com
>>
>> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
>> news:4E308ADD-59F4-4DFD-B959-47121282F7FE@microsoft.com...
>> > Thanks for your reply Jonathan.
>> >
>> > The reason why I need a hidden window is because my component does not
>> > have
>> > a CClientDC and I could not use the main window's client DC. I will 
>> > have
>> > to
>> > use its own Client DC. I could create a memory DC if and only if I have 
>> > a
>> > client DC right? Thanks.
>> >
>> > Sam_2
>> >
>> > "Jonathan Wood" wrote:
>> >
>> >> Can you explain why you want a hidden window?
>> >>
>> >> Why not just create a memory DC and draw to that? The memory DC will
>> >> contain
>> >> whatever you draw on it for saving to a file as it will not be 
>> >> overlapped
>> >> by
>> >> other windows. What is the purpose of the Window?
>> >>
>> >> -- 
>> >> Jonathan Wood
>> >> SoftCircuits Programming
>> >> http://www.softcircuits.com
>> >>
>> >>
>> >> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
>> >> news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
>> >> > Hi all,
>> >> >
>> >> > I am writting a MFC component that will create a hidden window, load 
>> >> > a
>> >> > bitmap into the hidden window and then save the hidden window to 
>> >> > bitmap
>> >> > file.
>> >> > However, after I loaded the bitmap into the hidden window and save 
>> >> > the
>> >> > window
>> >> > into bitmap file using function I found in codeguru
>> >> > (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/).
>> >> > The
>> >> > bitmap file only contain the desktop window instead of the hidden
>> >> > window.
>> >> >
>> >> > Is it possble to create a hidden window for drawing? Is there any 
>> >> > other
>> >> > way
>> >> > I could create a hidden area for the program to draw on and save the
>> >> > area
>> >> > to
>> >> > file?
>> >> >
>> >> > I could not draw to the client DC directly as I do not want user to 
>> >> > see
>> >> > the
>> >> > image at all. All I want to do is create a off screen window area, 
>> >> > load
>> >> > a
>> >> > bitmap and save that window to a bitmap file.
>> >> >
>> >> > Thanks.
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >>
>>
>>
>> 


0
jwood (1292)
9/12/2006 12:56:37 AM
Thank you so much, I will give it a try tomorrow. 

Sam_2

"Jonathan Wood" wrote:

> I have some fairly complex code that I'm not willing to post here.
> 
> But basically, you declare a memory DC.
> 
> CDC dcMem;
> 
> Then call dcMem.CreateCompatibleDC(). Note from the docs that if the 
> argument is NULL, a memory device context is created that is compatible with 
> the screen.
> 
> By default, a DC created this way has a 1x1 black and white bitmap. So you 
> need to declare a CBitmap and call CBitmap::CreateCompatibleBitmap() of the 
> size you need. Then, you must select the bitmap into dcMem.
> 
> At this point, you should be able to draw to the bitmap using dcMem just 
> like you would draw to a window.
> 
> -- 
> Jonathan Wood
> SoftCircuits Programming
> http://www.softcircuits.com
> 
> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
> news:96EFDFFC-F936-4C5A-B871-A7DBD43BA66C@microsoft.com...
> > Could you give me an example to create a Memory DC without using CWnd* nor
> > pDC* ? Thanks.
> >
> > Sam_2
> >
> > "Jonathan Wood" wrote:
> >
> >> Wrong. You can create a DC compatible with the screen. I see no reason 
> >> for a
> >> separate window here. In fact, that's what seems to be working against 
> >> you.
> >>
> >> -- 
> >> Jonathan Wood
> >> SoftCircuits Programming
> >> http://www.softcircuits.com
> >>
> >> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
> >> news:4E308ADD-59F4-4DFD-B959-47121282F7FE@microsoft.com...
> >> > Thanks for your reply Jonathan.
> >> >
> >> > The reason why I need a hidden window is because my component does not
> >> > have
> >> > a CClientDC and I could not use the main window's client DC. I will 
> >> > have
> >> > to
> >> > use its own Client DC. I could create a memory DC if and only if I have 
> >> > a
> >> > client DC right? Thanks.
> >> >
> >> > Sam_2
> >> >
> >> > "Jonathan Wood" wrote:
> >> >
> >> >> Can you explain why you want a hidden window?
> >> >>
> >> >> Why not just create a memory DC and draw to that? The memory DC will
> >> >> contain
> >> >> whatever you draw on it for saving to a file as it will not be 
> >> >> overlapped
> >> >> by
> >> >> other windows. What is the purpose of the Window?
> >> >>
> >> >> -- 
> >> >> Jonathan Wood
> >> >> SoftCircuits Programming
> >> >> http://www.softcircuits.com
> >> >>
> >> >>
> >> >> "Sam_2" <Sam2@discussions.microsoft.com> wrote in message
> >> >> news:E60EF98B-8353-406A-B779-D304972193CD@microsoft.com...
> >> >> > Hi all,
> >> >> >
> >> >> > I am writting a MFC component that will create a hidden window, load 
> >> >> > a
> >> >> > bitmap into the hidden window and then save the hidden window to 
> >> >> > bitmap
> >> >> > file.
> >> >> > However, after I loaded the bitmap into the hidden window and save 
> >> >> > the
> >> >> > window
> >> >> > into bitmap file using function I found in codeguru
> >> >> > (http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/).
> >> >> > The
> >> >> > bitmap file only contain the desktop window instead of the hidden
> >> >> > window.
> >> >> >
> >> >> > Is it possble to create a hidden window for drawing? Is there any 
> >> >> > other
> >> >> > way
> >> >> > I could create a hidden area for the program to draw on and save the
> >> >> > area
> >> >> > to
> >> >> > file?
> >> >> >
> >> >> > I could not draw to the client DC directly as I do not want user to 
> >> >> > see
> >> >> > the
> >> >> > image at all. All I want to do is create a off screen window area, 
> >> >> > load
> >> >> > a
> >> >> > bitmap and save that window to a bitmap file.
> >> >> >
> >> >> > Thanks.
> >> >> >
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >>
> >>
> >> 
> 
> 
> 
0
Sam2 (7)
9/12/2006 1:45:02 AM
This seems a rather complex solution to a simple problem.  You don't need a hidden window;
all you need is a memory DC. Because the window is hidden, techniques that capture the
bits from the display will, of course, fail, which is what you are seeing.  

Create a CBitmap of the appropriate size.  SelectObject into a memory DC.  Draw into that
DC.

Given you have already loaded the bitmap, you don't even need to draw it!  You already
have it!  All you have to do is write it to a file!

You seem to think that a DC is always visible; it isn't.  Only a DC associated with a
window is visible.  But if all you want to do is load a bitmap (from what?  A resource?)
and write it out, that's easy.  But if you have a .bmp file as the resource, then
FindResource/LoadResource/LockResource will give you the actual raw bits of the bitmap
resource, which you can just write to a file directly!
					joe

On Mon, 11 Sep 2006 14:02:02 -0700, Sam_2 <Sam2@discussions.microsoft.com> wrote:

>Hi all,
>
>I am writting a MFC component that will create a hidden window, load a 
>bitmap into the hidden window and then save the hidden window to bitmap file. 
>However, after I loaded the bitmap into the hidden window and save the window 
>into bitmap file using function I found in codeguru 
>(http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The 
>bitmap file only contain the desktop window instead of the hidden window.
>
>Is it possble to create a hidden window for drawing? Is there any other way 
>I could create a hidden area for the program to draw on and save the area to 
>file?
>
>I could not draw to the client DC directly as I do not want user to see the 
>image at all. All I want to do is create a off screen window area, load a 
>bitmap and save that window to a bitmap file.
>
>Thanks.
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/12/2006 2:57:12 AM
Hi Joe,

Thanks for your reply.

Actually, what I am trying to do is create a off screen DC, draw some texts, 
add some bitmaps to the DC before I create the finally version of the bitmap. 
So, I couldn't create one memory DC and Bitblt to that memory DC alone.  
Thanks.

Sam_2



"Joseph M. Newcomer" wrote:

> This seems a rather complex solution to a simple problem.  You don't need a hidden window;
> all you need is a memory DC. Because the window is hidden, techniques that capture the
> bits from the display will, of course, fail, which is what you are seeing.  
> 
> Create a CBitmap of the appropriate size.  SelectObject into a memory DC.  Draw into that
> DC.
> 
> Given you have already loaded the bitmap, you don't even need to draw it!  You already
> have it!  All you have to do is write it to a file!
> 
> You seem to think that a DC is always visible; it isn't.  Only a DC associated with a
> window is visible.  But if all you want to do is load a bitmap (from what?  A resource?)
> and write it out, that's easy.  But if you have a .bmp file as the resource, then
> FindResource/LoadResource/LockResource will give you the actual raw bits of the bitmap
> resource, which you can just write to a file directly!
> 					joe
> 
> On Mon, 11 Sep 2006 14:02:02 -0700, Sam_2 <Sam2@discussions.microsoft.com> wrote:
> 
> >Hi all,
> >
> >I am writting a MFC component that will create a hidden window, load a 
> >bitmap into the hidden window and then save the hidden window to bitmap file. 
> >However, after I loaded the bitmap into the hidden window and save the window 
> >into bitmap file using function I found in codeguru 
> >(http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The 
> >bitmap file only contain the desktop window instead of the hidden window.
> >
> >Is it possble to create a hidden window for drawing? Is there any other way 
> >I could create a hidden area for the program to draw on and save the area to 
> >file?
> >
> >I could not draw to the client DC directly as I do not want user to see the 
> >image at all. All I want to do is create a off screen window area, load a 
> >bitmap and save that window to a bitmap file.
> >
> >Thanks.
> >
> >
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm
> 
0
Sam2 (7)
9/12/2006 3:31:02 AM
"Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
news:73BFE462-5F06-4387-A252-09ABE46C75EA@microsoft.com...
> Thank you so much, I will give it a try tomorrow.
>

Search for Keith Rule's CMemDC, available on CodeProject, I think.

-- David


0
dc2983 (3206)
9/12/2006 3:00:28 PM
What do you mean by "add some bitmaps to the DC". DC is not a place holder 
for bitmaps. It is just that DC is a handle to draw on a surface(which could 
be a device surface or a bitmap surface) and there are attributes like 
brush,pen,font,etc which are used when drawing on it.

-- 
Vipin Aravind
http://www.explorewindows.com/Blogs


"Sam_2" <Sam2@discussions.microsoft.com> wrote in message 
news:54E6453E-6613-41A0-B8B7-444096FAF6D1@microsoft.com...
> Hi Joe,
>
> Thanks for your reply.
>
> Actually, what I am trying to do is create a off screen DC, draw some 
> texts,
> add some bitmaps to the DC before I create the finally version of the 
> bitmap.
> So, I couldn't create one memory DC and Bitblt to that memory DC alone.
> Thanks.
>
> Sam_2
>
>
>
> "Joseph M. Newcomer" wrote:
>
>> This seems a rather complex solution to a simple problem.  You don't need 
>> a hidden window;
>> all you need is a memory DC. Because the window is hidden, techniques 
>> that capture the
>> bits from the display will, of course, fail, which is what you are 
>> seeing.
>>
>> Create a CBitmap of the appropriate size.  SelectObject into a memory DC. 
>> Draw into that
>> DC.
>>
>> Given you have already loaded the bitmap, you don't even need to draw it! 
>> You already
>> have it!  All you have to do is write it to a file!
>>
>> You seem to think that a DC is always visible; it isn't.  Only a DC 
>> associated with a
>> window is visible.  But if all you want to do is load a bitmap (from 
>> what?  A resource?)
>> and write it out, that's easy.  But if you have a .bmp file as the 
>> resource, then
>> FindResource/LoadResource/LockResource will give you the actual raw bits 
>> of the bitmap
>> resource, which you can just write to a file directly!
>> joe
>>
>> On Mon, 11 Sep 2006 14:02:02 -0700, Sam_2 
>> <Sam2@discussions.microsoft.com> wrote:
>>
>> >Hi all,
>> >
>> >I am writting a MFC component that will create a hidden window, load a
>> >bitmap into the hidden window and then save the hidden window to bitmap 
>> >file.
>> >However, after I loaded the bitmap into the hidden window and save the 
>> >window
>> >into bitmap file using function I found in codeguru
>> >(http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). 
>> >The
>> >bitmap file only contain the desktop window instead of the hidden 
>> >window.
>> >
>> >Is it possble to create a hidden window for drawing? Is there any other 
>> >way
>> >I could create a hidden area for the program to draw on and save the 
>> >area to
>> >file?
>> >
>> >I could not draw to the client DC directly as I do not want user to see 
>> >the
>> >image at all. All I want to do is create a off screen window area, load 
>> >a
>> >bitmap and save that window to a bitmap file.
>> >
>> >Thanks.
>> >
>> >
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> 


0
vipin (696)
9/12/2006 5:36:27 PM
A DC is not something you "add" bitmaps to, as already pointed out.  A DC is a conduit by
which drawings are done, and in the case of a memory DC is the conduit by which drawing is
done to a bunch of bits in a bitmap.  So you have to just draw what you want, then you can
do something with the bits of the bitmap when you're done.  You can create as many memory
DCs as you want, but I think you would be safest if the bitmap should be selected into no
more than one at a time.
					joe
On Mon, 11 Sep 2006 20:31:02 -0700, Sam_2 <Sam2@discussions.microsoft.com> wrote:

>Hi Joe,
>
>Thanks for your reply.
>
>Actually, what I am trying to do is create a off screen DC, draw some texts, 
>add some bitmaps to the DC before I create the finally version of the bitmap. 
>So, I couldn't create one memory DC and Bitblt to that memory DC alone.  
>Thanks.
>
>Sam_2
>
>
>
>"Joseph M. Newcomer" wrote:
>
>> This seems a rather complex solution to a simple problem.  You don't need a hidden window;
>> all you need is a memory DC. Because the window is hidden, techniques that capture the
>> bits from the display will, of course, fail, which is what you are seeing.  
>> 
>> Create a CBitmap of the appropriate size.  SelectObject into a memory DC.  Draw into that
>> DC.
>> 
>> Given you have already loaded the bitmap, you don't even need to draw it!  You already
>> have it!  All you have to do is write it to a file!
>> 
>> You seem to think that a DC is always visible; it isn't.  Only a DC associated with a
>> window is visible.  But if all you want to do is load a bitmap (from what?  A resource?)
>> and write it out, that's easy.  But if you have a .bmp file as the resource, then
>> FindResource/LoadResource/LockResource will give you the actual raw bits of the bitmap
>> resource, which you can just write to a file directly!
>> 					joe
>> 
>> On Mon, 11 Sep 2006 14:02:02 -0700, Sam_2 <Sam2@discussions.microsoft.com> wrote:
>> 
>> >Hi all,
>> >
>> >I am writting a MFC component that will create a hidden window, load a 
>> >bitmap into the hidden window and then save the hidden window to bitmap file. 
>> >However, after I loaded the bitmap into the hidden window and save the window 
>> >into bitmap file using function I found in codeguru 
>> >(http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4919/). The 
>> >bitmap file only contain the desktop window instead of the hidden window.
>> >
>> >Is it possble to create a hidden window for drawing? Is there any other way 
>> >I could create a hidden area for the program to draw on and save the area to 
>> >file?
>> >
>> >I could not draw to the client DC directly as I do not want user to see the 
>> >image at all. All I want to do is create a off screen window area, load a 
>> >bitmap and save that window to a bitmap file.
>> >
>> >Thanks.
>> >
>> >
>> Joseph M. Newcomer [MVP]
>> email: newcomer@flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> 
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
9/29/2006 8:09:56 PM
Reply:

Similar Artilces:

How to create new lead for existing customer?
We are tracking all new leads, whether it is a new prospect or new lead within an existing customer. But when you enter a new lead, it will not allow you to pull an existing account. You have to rekey all company data. Any thoughts? Seems kind of like a backwards approach (which is why there's no option to do this). I would think you would just create a new contact inside an existing account. -- Brandon IT Director Presentations Direct - Office Equipment & Supplies http://www.presentationsdirect.com "Jan Kratochvil" <Jan Kratochvil@discussions.microsoft.com>...

How do I create an anchor in an newletter?
Im trying to create a business newletter with anchors so clients can click on the anchor and they could go back to the top of the page instead of just scrolling up. Iv tryed using the HTML Fragment box, but I dont seem to understand that. I have followed the instructions publisher has, and I copied and pasted the fragment provided for the "back at top" achor but when I sent it to my email to preview, the html code shows up instead of the link. How do I create a hyperlink or an anchor that leads me back to the top of the page? Bookmarks aka Hyperlinking to a place on a page htt...

Create a rule to forward emails from a certain address
Using Outlook 2003, is it possible to create a rule or other method to forward emails from a certain address to another email address? Thanks in advance, Jon jmcclain <jmcclain@discussions.microsoft.com> wrote: > Using Outlook 2003, is it possible to create a rule or other method to > forward emails from a certain address to another email address? Yes. See Tools>Rules and Alerts. -- Brian Tillman [MVP-Outlook] To all: I have figured this out - was my first time creating a rule in Outlook. "jmcclain" wrote: > Using Outlook 2003, is it possible to create ...

Second window for second excel file
How to open second excel fine in seperate window Hi goto 'Tools - Options - View' and check 'Windows in taskbar' -- Regards Frank Kabel Frankfurt, Germany Murthy wrote: > How to open second excel fine in seperate window ...

WINDOWS 7 NEWSGROUP(s) IS/ARE HERE
Where is 'Windows7" Newsgroup? This question is being asked here (on microsoft.public.windows.vista.general): methodically, weekly (if not more often), so it became a "sticky note" everyone is tired of answering. Some of us feel that the question is repeated by people too lazy to Google or learn for themselves. Let's answer this question once & for ALL, only problem I can't make this Article a "sticky note" also (unlike the question - ironically), let's hope these people can SEARCH & LOCATE my answer, here it goes: ********************...

Mail Message window position
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: pop When opening a mail message it positions itself in the upper left corner of my monitor. Can this be set to a new default postion? This is a multi-part message in MIME format. ------=_NextPart_000_005E_01CA93E5.598E43D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable What Entourage update you have on your Mac? Entourage --> about = Entourage. <19ertim@officeformac.com> wrote in message = news:59bb0bde.-1@webcrossing....

VBA to create series of workbooks need to add code to skip creating a report if no lines meet criteria
Hi All, I need some assistance as where I'm at with this report is far beyond my level of knowledge and I'm hoping that someone can point me in the right direction. I've created a template that creates a report and displays variances based on the "search criteria" which is defined in another worksheet and hides any rows that are equal to Zero and are between the value (>= -5000 AND <= +5000) and what I'm trying to figure out is if there are no rows visible within the report then it should not save the report (that way I don't email a blank works...

Create task and sub-task lists using the calendar
Looking for the best way to organize 10 task subjects. Some having as many as 5 sub-tasks, as well as creating to do lists for 4 employees. I set these up in the Folder List and would like to drag these into the Calendar allowing me to print each person a To Do List. A friend suggested Categorizing ,but I like having the folders all visible in the Outlook Shortcuts. Any help would be appreciated. ...

File info from Windows Explorer to Excel?
I need to create a list of the file information from Windows Explorer to MS Excel. I used to have a dos command to do this. Please advise how this can be done. Thank you Regards I assume you mean the Dir command. This is still possible from the command prompt. Go to Start|Run and enter cmd. -- Ian -- "Wordgeek" <Wordgeek@discussions.microsoft.com> wrote in message news:ACE32060-668D-4A76-B901-1AEB70925A47@microsoft.com... >I need to create a list of the file information from Windows Explorer to MS > Excel. I used to have a dos command to do this. Please advise ho...

Create individual worksheets for selected rows in a table
Hi guys, I hope somebody may be able to help. I want to be able to automate the following procedure Create individual worksheets for selected rows in a table. Many thanks - Batman2002 Batman, If you really want the entirerow, then use this - if you just want the selection, then remove the .EntireRow of the last line: Sub CopySelectioToNewWorksheet() Dim mySheet1 As Worksheet Dim mySheet2 As Worksheet Set mySheet1 = ActiveSheet Set mySheet2 = Sheets.Add(Type:="Worksheet") mySheet1.Activate Selection.EntireRow.Copy mySheet2.Range("A1") End Sub HTH, Bernie "...

How to create my own generic list?
I'm still new at C# or any OO program and my coworkers are all at a seminar this week. How do I create my own "generic list" that implements all the features of the .net generic list<string> plus a method to fill itself from strings in an external file. Is there a simple template somewhere I could start with? Do I just inherit from generic list and add my method? thanks, LJB "LJB" <postmaster@127.0.0.1> wrote in message news:O%23EBRGuuKHA.1796@TK2MSFTNGP02.phx.gbl... > I'm still new at C# or any OO program and my coworkers a...

Prompt to Ask If User Wants to Create a Duplicate Record
For example, let's say there's already a record for Mary Shelly, and I have a new Mary Shelly that I'm trying to add to my database. Can I make it so that Access will prompt me and say "There is already a record matching this description. Do you wish to continue?" Hi Dove, I'm assuming first and last name are in the same field. Create a button or Label and add this code to the On Click event but make the following changes to the code: NAMEFIELD= The name of the field where the name is kept on the form TABLEWITHUSERNAMES = The name of the table where the username i...

ow to create comparison chart using text as value data?
lplease help me. I am trying to set up a comparison chart of 3 computers cost and features! I cannot figure out how to use the features as values on the x or y axis says data range is to complex so cant select rows or columns. I am trying to enter the features as my source data too bungled dont know what to do term project is now overdue and I am stressing out!~ Dont want to fail. please help me!do i have to redo the whole chart or what any suggestions and demonstration would be deeply appreciated. thanks, Dee Johnson The first thing you need to do is think how the chart should look. Wh...

Can you create calendars in Excel from data?
I am looking for a way to use the data entered in Excel to make an actual calendar. Is this possible or does Excel not have this functionality? ...

Can a standard column in MS Project be permanently hidden
We need to hide the Std Rate column in the resource views in MS Project for certain project managers (due to contractual requirements) so we are trying to determine if we can just hide it from everyone. We need to make it so it can't be added back. Even though it would be possible to set up a task and add 1 hour and look at the cost to get the rate, the requirement is that the Std Rate field be hidden. Is this something that is possible? This is for Project Server 2007 SP2 and MS Project Pro 2007 SP2. This is a frequently asked question and I'm afraid the answer is still ...

Windows server 2003 R2
Hi, I'm new to dfs, and I would like to know if it is possible to have under 1 dfs root 4 servers that are in replication ? So you have one dfs root with under it 2 servers in replication and 2 other servers that are also in replication. How should I set this up ? Thanks a lot, GM ...

can't add my True Type Windows Fonts
I have tried loading my Font files to C:/Windows/Fonts, they do appear inside the directory when viewing thru my File Manager, but when using my programs, they don't show up in any of my Font menu pulldowns; only the default fonts that come with the machine. I'm using Windows XP Pro ?? chumley Try loading them via Control Panel > Fonts > File > Install New Fonts. -- Rey "chumley" wrote: > I have tried loading my Font files to C:/Windows/Fonts, they do appear > inside the directory when viewing thru my File Manager, but when using > my...

Workflow and GP10 Install
Hi, I have a Windows 2003 Server that has (according to me) all the pre-requisites installed needed for Dynamics GP 10 Workflow including Windows 2003 Server, IIS, Sharepoint, Web Services e.t.c. The problem I am having is after completing the install screens e.g. specifying web services URL and security admin service URL e.t.c. When I click on Install, it comes up with an error that 'Workflow needs to be installed on a Windows 2003 Server' - which is ludicrous as we are on one. Any ideas please. Thanks Neil Neil, Workflow will only install on the following versions of Windo...

hOW DO I CREATE A TWIN BAR CHART?
...

Newsgroup for Windows 7
Is there a newsgroup for Windows 7? I want to create shortcuts to a program but it doesn't show the program location. I want to change icons for a program but it won't do it. I know this one is for XP, but I can't find a Windows 7 one. -- Steve Hayes from Tshwane, South Africa Web: http://hayesfam.bravehost.com/stevesig.htm Blog: http://methodius.blogspot.com E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk On 14/06/2010 12:16, Steve Hayes wrote: > Is there a newsgroup for Windows 7? > > I want to create shortcuts to a...

Beginner questions about creating a sheet.
Hi all, I am having trouble learning some basic functions. So far all I can do is simple calculations. I have made a tip calculator, and growth preidictor for recruitment numbers. Howerver where can I go to get basic step by step training? I just want to create a simple sheet that contains a stage that a sale is in like (1st, 2nd, 3rd etc), the sale name and the name of the person who is buying or being cultivated. I would also like to create a sheet that has check marks that are not in the form tools. I see how I can insert those, but I also downloaded a template and it has check marks wit...

Create a grid level button in ms CRM 4 using ISV Config.
I have this code in the ISVConfig in my custom entity. it is meant to create a grid level button in the custom entity. When i export the ISVConfig I get the error message "either the file could not be uploaded or this is not a valid customization file. Please help me, what am i doing wrong? <Entity name="new_projects <Grid> <Buttons> <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="alert('test');" Client="Web"> <Titles> <Title LCID="1033" Text="New T...

Create TOC from Section Headers (not headings)
Have a document that requires different headers for various sections of the document. The Headers are unlinked and the headers need to be the 'entries' for the TOC. I cannot seem to create a TOC from the Headers. Even if I select & format the individual headers as "Heading 1", Word doesn't seem to identify the headers as a TOC entry. Questions: 1) Can Headers be used as a TOC entry? 2) Can multiple Headers be identified as individual entries within the TOC? 2) If so, what is the procedure to create/identify a header so that the TOC will populate? ...

Add lookup after the table has been created
Hi there I have created a table and realized that to ease use of adding data, I want to add a lookup column. How do I create a lookup column (either typed in or based on another table) to a field which has already been populated? Thank you Don't do it! You should never be working directly with the tables: you should always use a form. On a form, you can easily bind the field to a combo box. See http://www.mvps.org/access/lookupfields.htm at "The Access Web" for some of the many reasons why lookup fields in tables are not considered to be a good thing...

Windows 7 FTP firewall
Hi, Setup a new client on W7 enterprise on a SBS 2003 ISA 2004 network. When I try to use Filezilla to upload some webpages it times out. Added filezilla to excluded programs on Windows firewall and opened port 21. Tried a different FTP program same problem. No joy. Another client running XP Pro works fine with Filezilla. Any suggestions would be welcomed. Thanks, Lyj Changing the firewall on W7 probably made no difference, since all outbound ports are open by default. Your problem probably lies with ISA. What does the realtime monitoring screen show in ISA? Have you inst...