home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / mswindo / programm / misc / 4477 < prev    next >
Encoding:
Text File  |  1992-12-25  |  2.5 KB  |  64 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!psinntp!panix!rryan
  3. From: rryan@panix.com (Rob Ryan)
  4. Subject: Re: how to animate icon of minimised window ?
  5. Message-ID: <1992Dec25.062010.6731@panix.com>
  6. Date: Fri, 25 Dec 1992 06:20:10 GMT
  7. References: <25DEC199200040150@vms1.iscs.nus.sg>
  8. Organization: Panix, NYC
  9. Lines: 53
  10.  
  11. In <25DEC199200040150@vms1.iscs.nus.sg> nuscss1@vms1.iscs.nus.sg (Vax BULLET-IN-Board SysOps) writes:
  12.  
  13. >    I would like to animate the icon of a minimised window. I guess
  14. >    this can be done by continually changing the hIcon of the
  15. >    window class. So what I did is to set a timer, and upon the
  16. >    reception of WM_TIMER, I check if the window is iconic. If it
  17. >    is, I use SetClassWord to change the hicon.
  18. >
  19. >    problem : the dang thing doesn't seem to be working.
  20. >    can someone give me an idea on how to go about implementing it ?
  21. >    am I on the wrong track ? I've check the API, and there doesn't seem
  22. >    to be a function for this purpose.
  23.  
  24. Are you invalidating your window in your WM_TIMER message?  As well as telling
  25. Windows what the new icon is, you'd probably want to tell it to redraw it (and
  26. you do this by invalidating the appropriate window).
  27.  
  28. Personally, I wouldn't do the SetClassWord(), but rather manually take over
  29. the processing of the paint command.  So, I'd have something like:
  30.  
  31.   1. my WM_TIMER code would invalidate the window for the application and set
  32.      a static, hIcon to be the handle of my new icon; and
  33.   2. have a WM_PAINT (Microsoft doesn't recommend using WM_PAINTICON anymore)
  34.      check to see if IsIconic().  So, I'd have something like:
  35.        case WM_PAINT:
  36.          if (IsIconic(hWnd)) {
  37.              BeginPaint(hWnd, &ps);
  38.              DefWindowProc(hWnd, WM_ICONERASEBKGND, (WORD) ps.hdc, 0L);
  39.              DrawIcon(ps.hdc, 0, 0, hIcon);
  40.              EndPaint(hWnd, &ps);
  41.              return 0;
  42.          } else 
  43.              return DefWindowProc(hWnd, message, wParam, lParam);
  44.        case WM_ERASEBKGND:
  45.          if (IsIconic(hWnd))
  46.              return TRUE;
  47.          else
  48.              return DefWindowProc(hWnd, message, wParam, lParam);
  49.  
  50.   3. Microsoft also recommends taking over the WM_QUERYDRAGICON too:
  51.        case WM_QUERYDRAGICON:
  52.          return (LONG) (WORD) hIcon;
  53.  
  54. The key is that you invalidate the window to instruct Windows to redraw it.
  55. Just changing the icon isn't enough.
  56.  
  57. If you have a copy, see the Fall '92 issue of the Microsoft Develop Network
  58. News on how to deal with the painting of icons.  Notably, they discuss the
  59. disappearance of the WM_PAINTICON.
  60.  
  61. -- 
  62.  Rob Ryan
  63.     rryan@panix.com
  64.