Also be aware that the exposed graphics object will let you accomplish what BitBlt used to be used for. In fact, most GDI functions are much easier to work with from managed .NET objects.
Main Topics
Browse All TopicsHi All,
I am trying to render an API image to a background (image) memory location then use that image as a source for a BitBlt API call.
In my former life as a VB6 programmer I could simply render the image to a PictureBox (located off screen) with AutoRedraw = True.
I realize that this wasn't 'technically' rendering to memory but it served the purpose of giving me an 'off screen' intermediate memory location that had a HDC handle so I could use the hidden image as a source for BitBit.
I now find myself in the .NET - C# (C sharp) world trying to accomplish this same feat.
I can render from the EM_Message to an intermediate picture box but if it is not located in a visable area of the screen, it will not render. This method acts like the old VB6 PictureBox with AutoRedrw = False.
I made a stab it it below....
1st I create a memory bitmap called intImage...
Bitmap intImage = new Bitmap(533, 165);
then get a handle to it...
IntPtr memHDC = intImage.GetHbitmap();
I have a feeling that maybe I am not creating a 'Graphic' but I am unsure how to do that?
Or maybe I just missing something simple that would allow me to render an API painted image in the background.
FYI - Note: I am using EM_FORMATRANGE (below) to render the initial image and it works fine when rendered to a PictureBox.
//Render the selected RTF text into the tempPicBox hdc (from FORMATRANGE structure)
res = SendMessage(Handle, EM_FORMATRANGE, wparam, lparam);
Thank You in advance for your time and kind assistance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Yeah...see his last PAQ:
http://www.experts-exchang
He's trying to draw a RichTextBox to a Bitmap and it wasn't playing nicely as it's an exception to the rule. =\
Business Accounts
Answer for Membership
by: Idle_MindPosted on 2009-08-27 at 08:28:07ID: 25199342
I think you need to get a Graphics first and then get an hDC from that:
e);
Bitmap intImage = new Bitmap(533, 165);
Graphics G = Graphics.FromImage(intImag
IntPtr memHDC = G.GetHdc();
// ... use "memHDC" ...
G.ReleaseHdc(memHDC);
G.Dispose();