Thread: Looking for hints on "layered" drawing

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    106

    Looking for hints on "layered" drawing

    Hello, I need to create a surface to draw on it. This surface (the upper layer) should ovelap the base "layer", which should be updated with graphic while the upper layer is shown. Note that the size of the upper layer is smaller than the base layer. Note that the upper should be closed after a given event or a timeout.

    My solution is to use a new window (CDialog?) as upper layer, to draw on its DC. The problem with this solution is that I need to show the window immediately, without making it "Modal": this would stop the program until the window is closed.

    Let's have an example (Note: IDD_DIALOG_UPPERLAYER is a resource dialog without title bar and border):
    Code:
    ....
        CDialog *pDialogUpperLayer;
    
        pDialogUpperLayer = new CDialog();
        pDialogUpperLayer ->Create( IDD_DIALOG_UPPERLAYER, (CWnd*)this );
        pDialogUpperLayer ->SetWindowPos( &wndTopMost, 
                                          r.left, 
                                          r.top, 
                                          r.Width(),
                                          r.Height(),  
                                          WP_SHOWWINDOW );
    
        pdc = pDialogUpperLayer ->GetDC();
        //drawing on pdc
    ......
    This example doesn't work correctly because the pDialogUpperLayer dialog is not shown when I call the SetWindowPos() method, but only when the operating system lets the pDialogUpperLayer execute the positioning and showing WM_ message. This results in a grey dialog area (drawn as default WM_PAINT handler??) which overwrites the previusly executed drawings.

    Any suggestion? Thank you all^_^

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    106

    found a first solution

    ...it was obvious: SendMessage( pDialog, WM_PAINT ) make the window to be drawn immediately without making it "modal".

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    The 'layers' are not actual DC layers. Layers could be implemented using a std::vector of display objects or a static array of display objects.

    In my tile editor I use layers and each layer is composed of a tile map. The drawing code then iterates the layers and draws what is on each layer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing HBITMAP into CWnd, Acquired from "screenshot"
    By DeusAduro in forum Windows Programming
    Replies: 6
    Last Post: 07-02-2009, 03:41 PM
  2. Slow drawing code
    By tjpanda in forum Windows Programming
    Replies: 5
    Last Post: 05-09-2008, 05:09 PM
  3. Line Drawing Algorithm
    By Axpen in forum Game Programming
    Replies: 15
    Last Post: 08-01-2005, 06:30 PM
  4. How to do double buffing with win32 drawing?
    By Josh Kasten in forum Windows Programming
    Replies: 2
    Last Post: 03-27-2004, 12:02 AM
  5. drawing minimaps and radar screens.
    By Eber Kain in forum Game Programming
    Replies: 4
    Last Post: 03-08-2002, 11:44 AM