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. General Programming
  3. C / C++ / MFC
  4. AnimateWindow(), problem

AnimateWindow(), problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • M Offline
    M Offline
    MaTrIX2k2
    wrote on last edited by
    #1

    When i use the AnimateWindow my window is animated, but i don't see any control, my OnPaint() is not called, why?

    P 1 Reply Last reply
    0
    • M MaTrIX2k2

      When i use the AnimateWindow my window is animated, but i don't see any control, my OnPaint() is not called, why?

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      If you look at the remarks in the documentation for AnimateWindow, it looks like it is calling WM_PRINT instead. WM_PRINT is basically like a WM_PAINT except that it gives a DC that should be drawn to. So, if you are using the plain windows API, you could do something like this in your windowproc:

      ...
      case WM_PRINT:
      case WM_PAINT:
      {
      HDC hdc;
      PAINTSTRUCT ps;
      //Test if the wPAram already contains the HDC
      if (NULL != wParam)
      {
      // This is the DC that you should use to paint with.
      hdc = (HDC)wParam;
      }
      else
      {
      // OTherwise call begin paint like normal.
      hdc = ::BeginPaint(hWnd, &ps);
      }

      // Your paint code goes here.
      
      if (NULL == wParam)
      {
      // If you called beginpaint, hten you will need to call endpaint.
          ::EndPaint(hWnd, &ps);
      }
      

      }
      break;
      ...

      If you are using MFC, you will simply need to call OnDraw from your OnPrint handler and be sure to pass in the DC that you received from the OnPrint handler. Good Luck


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      M 1 Reply Last reply
      0
      • P Paul M Watt

        If you look at the remarks in the documentation for AnimateWindow, it looks like it is calling WM_PRINT instead. WM_PRINT is basically like a WM_PAINT except that it gives a DC that should be drawn to. So, if you are using the plain windows API, you could do something like this in your windowproc:

        ...
        case WM_PRINT:
        case WM_PAINT:
        {
        HDC hdc;
        PAINTSTRUCT ps;
        //Test if the wPAram already contains the HDC
        if (NULL != wParam)
        {
        // This is the DC that you should use to paint with.
        hdc = (HDC)wParam;
        }
        else
        {
        // OTherwise call begin paint like normal.
        hdc = ::BeginPaint(hWnd, &ps);
        }

        // Your paint code goes here.
        
        if (NULL == wParam)
        {
        // If you called beginpaint, hten you will need to call endpaint.
            ::EndPaint(hWnd, &ps);
        }
        

        }
        break;
        ...

        If you are using MFC, you will simply need to call OnDraw from your OnPrint handler and be sure to pass in the DC that you received from the OnPrint handler. Good Luck


        Build a man a fire, and he will be warm for a day
        Light a man on fire, and he will be warm for the rest of his life!

        M Offline
        M Offline
        MaTrIX2k2
        wrote on last edited by
        #3

        My Window is a CMiniFrameWnd, and i added this, so i don't get anything to be shown, what's wrong?

        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