Announcement

Collapse
No announcement yet.

Popping the Screen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Popping the Screen

    In DOS I used to draw the screen and then pop it to the forefront. Is there a way to do this in Windows? I am using PB/DLL 6.0.

    Thanks.



    [This message has been edited by Shawn Tartaglia (edited March 27, 2000).]

  • #2
    It is definately possible, and there are various techniques to do it - they are very different to how you would do it in DOS however.

    Because drawing should only ever occur in response to a %WM_PAINT message, there are a couple of approaches you can take - draw whenever the window receives a %WM_PAINT message, or, in advance, draw the image onto a bitmap in a 'hidden' Device Context (DC) and just copy the bitmap into the DC when a %WM_PAINT message is received. The first approach is quite straight forward, but the second can make for much faster updates. The choice depends on what your application is going to do.

    The following is a brief overview of the process (going from my memory!) - errors an omissions excepted!

    The 1st technique works like this:
    1. When you receive a %WM_PAINT message, get the DC of the window or control you want to draw on (or if it is the client area of the actual window or dialog, call BeginPaint())
    2. Using the DC, use the API drawing functions like LineTo(), MoveToEx(), Rectangle(), PolyLine(), TextOut(), etc.
    3. Release the DC or call EndPaint() depending on how you got the DC to begin with.
    You are done. To force a repaint if you want to change the content of the window, call InvalidateRect() followed by UpdateWindow().

    The second technique is similar to the first, but involves a lot more work. It is less useful if the image is to change frequently.
    1. Get the DC of the window you eventually want the image to appear within.
    2. Create a compatible DC using, you guessed it, CreateCompatibleDC() - this gives you a "hidden" or "memory" DC.
    3. Create a bitmap using this DC
    4. Select the bitmap into the memory DC.
    5. Use the drawing function as in #2 in the 1st technique.
    6. When your app receives a %WM_PAINT message, use the BltBit() API to copy the image from the memory DC into the DC of the Window you want the drawing into.
    7. When the app terminates, release all of the objects (bitmap and memory DC, etc)

    I hope this gives you an idea. If you want real code to do this, then the Source Code forum may have a few examples - however, the best way to learn this is to read a book such as Petzold or Rector/Newcomer. See the FAQ forum for more info on these books.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment

    Working...
    X