Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Smooth drawing for a window ?(win CE)

Smooth drawing for a window ?(win CE)

Scheduled Pinned Locked Moved Mobile
graphicshelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nguyenvodich
    wrote on last edited by
    #1

    When you move a dialog (or a CWnd object) your dialog's background will be repainted. It make some unsmooth effects when you have to move your Window too much times (for example you build a drop down window). Have any solutions for this problem ?

    Nothing Is Impossible !

    M 1 Reply Last reply
    0
    • N nguyenvodich

      When you move a dialog (or a CWnd object) your dialog's background will be repainted. It make some unsmooth effects when you have to move your Window too much times (for example you build a drop down window). Have any solutions for this problem ?

      Nothing Is Impossible !

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      This isn't an easy question to answer, because it depends on how your application is structured. Fundamentally, you need to minimize the amount of painting you do. If you implement a WM_PAINT handler to paint the dialog's surface yourself, you should look into the GetUpdateRect or GetUpdateRgn functions to determine the area of the surface which actually needs to be repainted, and only perform painting operations that affect this area. (Windows clips painting to this area anyway, so any painting operations which go outside this area simply waste time). You can find out whether a rectangle will be drawn using the RectVisible function. Alternatively, use IntersectRect to find out if any part of one rectangle is within another (and the area that is within both), RectInRegion to find out if any part of a rectangle is in that region, or PtInRect and PtInRegion to check whether a point is in the rectangle or region. If doing your own painting, it may be better to do as much painting as possible with one set of graphics objects rather than constantly swapping between different objects (for example, if you want two black lines and a red line, select a black pen, draw the two black lines, then select a red pen and draw the red line, rather than drawing the red line in between the two black ones). If you're overpainting the entire background of the window, consider implementing a handler for WM_ERASEBKGND and returning TRUE. This prevents some flicker generated by Windows painting the window background with the default background brush, then your painting code painting the actual desired result over the top. If you're not doing your own painting, consider reducing the number of controls on your dialog. When Windows has an invalid region on the screen, it has to generate a WM_PAINT for every window that intersects the invalid region. The overhead can cause the overall painting operation to take a long time. You should ensure that any controls that aren't visible because another control is obscuring them are actually hidden (call ShowWindow with the SW_HIDE flag). If these are controls that are part of the dialog template, hide any controls not initially active in the template.

      Stability. What an interesting concept. -- Chris Maunder

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups