Click here to Skip to main content
15,920,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: overload resolution in VC 6.0 Pin
Joaquín M López Muñoz26-Oct-01 6:53
Joaquín M López Muñoz26-Oct-01 6:53 
GeneralRe: overload resolution in VC 6.0 Pin
Patrick D Owens26-Oct-01 9:16
Patrick D Owens26-Oct-01 9:16 
GeneralFilling CListCtrl from dll problem... Pin
26-Oct-01 4:39
suss26-Oct-01 4:39 
GeneralRe: Filling CListCtrl from dll problem... Pin
Joaquín M López Muñoz26-Oct-01 7:27
Joaquín M López Muñoz26-Oct-01 7:27 
GeneralAligning text Pin
Andrew Stampor26-Oct-01 3:57
Andrew Stampor26-Oct-01 3:57 
General2-d Graphics Pin
Chambers26-Oct-01 3:52
Chambers26-Oct-01 3:52 
GeneralRe: 2-d Graphics Pin
Remi Morin26-Oct-01 8:33
Remi Morin26-Oct-01 8:33 
GeneralRe: 2-d Graphics Pin
Christian Graus26-Oct-01 11:04
protectorChristian Graus26-Oct-01 11:04 
Hi all, I am trying to make a custom drawing package in an MDI app.

I've done the same thing and pretty much had to learn how to do it as I went. If you're using GDI ( i.e. not GDI+), buy Windows Graphics Programming by Feng Yuan. Hell, buy it anyway, I still refer to it .

I have managed to load a bitmap into the child window using OnDraw and the CDC* pDC.

First things first. Do NOT use CBitmap, it is a device dependant bitmap. In order to be able to edit and save differing bitmap bit depths instead of just ones the same depth as the screen res, use a DIBSection wrapper like the one Chris Maunder wrote which is in the bitmaps section on the site.

I have also managed to get it to draw various lines to the screen when the users chooses the appropriate menu (yay ). However, these lines are drawn onto the CDC* pDC, is this the best way (I am getting flickering upon resizing of the child window)? or can you draw onto the CBitmap itself?

The only way to draw onto a bitmap is through a CDC unless you're planning to access the bits directly. As has been said, you fix the flicker by drawing to a memory DC and then drawing direct to the screen in one blt. I also killed OnEraseBackground because I was drawing over the whole surface myself anyhow, and that goes a long way to killing flicker.

The main focus of my problem is the fact I need to have low-level access to the pixel colours (in Delphi I was using scanline to scan whole lines of them into a PByteArray) so that I can change the ones that interest me, and leave the ones that don`t.

Using a DIBSection solves this problem - you will have access to the underlying bits in order to do whatever you pretty much like. You'll figure this out quickly anyhow, but I'll mention that Windows stores colours in BGR format.

Finally, what would be the best way to go about creating a layered approach, so that when I draw the lines etc. I don`t actually affect the underlying bitmap? would creating a new DC and drawing onto this, before outputting to the screen solve this? Anyway, I appreciate any help you could give on this guys,

In that case you could store the lines drawn in a path and actually draw them to the screen DC instead of the one holding the original bitmap. I did something like this for the line/shape tools ( where you stretch out a shape and it doesn't become a permanent addition until you let go of the mouse ) -> when the mouse button was pressed I started drawing onto the memDC before blting it to the screen, when you lifted the mouse I drew to the DC that held the bitmap, thus making a permanent change.



Christian

After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
GeneralRe: 2-d Graphics Pin
Chambers27-Oct-01 0:07
Chambers27-Oct-01 0:07 
GeneralRe: 2-d Graphics Pin
Christian Graus27-Oct-01 0:32
protectorChristian Graus27-Oct-01 0:32 
GeneralON_UPDATE_COMMAND_UI problem... Pin
Remi Morin26-Oct-01 3:50
Remi Morin26-Oct-01 3:50 
GeneralRe: ON_UPDATE_COMMAND_UI problem... Pin
Tomasz Sowinski26-Oct-01 4:01
Tomasz Sowinski26-Oct-01 4:01 
GeneralRe: ON_UPDATE_COMMAND_UI problem... Pin
Chambers26-Oct-01 4:08
Chambers26-Oct-01 4:08 
GeneralRe: ON_UPDATE_COMMAND_UI problem... Pin
Carlos Antollini26-Oct-01 4:12
Carlos Antollini26-Oct-01 4:12 
GeneralRe: ON_UPDATE_COMMAND_UI problem... Pin
Carlos Antollini26-Oct-01 4:17
Carlos Antollini26-Oct-01 4:17 
GeneralDate and Time Picker Control Pin
Steve Thresher26-Oct-01 3:43
Steve Thresher26-Oct-01 3:43 
GeneralListview Custom Draw Pin
Paul C26-Oct-01 1:11
Paul C26-Oct-01 1:11 
GeneralRe: Listview Custom Draw Pin
#realJSOP26-Oct-01 1:24
professional#realJSOP26-Oct-01 1:24 
GeneralRe: Listview Custom Draw Pin
Paul C26-Oct-01 1:32
Paul C26-Oct-01 1:32 
GeneralRe: Listview Custom Draw Pin
#realJSOP26-Oct-01 3:35
professional#realJSOP26-Oct-01 3:35 
GeneralRe: Listview Custom Draw Pin
Paul C26-Oct-01 4:04
Paul C26-Oct-01 4:04 
GeneralRe: Listview Custom Draw Pin
Tomasz Sowinski26-Oct-01 2:38
Tomasz Sowinski26-Oct-01 2:38 
GeneralRe: Listview Custom Draw Pin
Paul C26-Oct-01 3:12
Paul C26-Oct-01 3:12 
GeneralRe: Listview Custom Draw Pin
Tomasz Sowinski26-Oct-01 3:35
Tomasz Sowinski26-Oct-01 3:35 
GeneralRe: Listview Custom Draw Pin
Paul C26-Oct-01 4:07
Paul C26-Oct-01 4:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.