Animated Icon on Titlebar of a window

Introduction:

This simple class is for people who want to make their application more attractive using icon animation in the title bar of frame window.

Technique:

All the consecutive images used for animation are stored in a single bitmap resource. The animation could have been achieved also by storing each image as separate icon in the resource, but that would have made managing them more difficult. Putting the images as a list of image also makes it easier to keep track of the sequence of animation.

To start with the class loads the bitmap resource in a CImageList using CimageList::Create function. Then whenever ShowNextImage is called the class loads the image using CimageList::ExtractIcon and displays it in title bar by sending WM_SETICON to the frame window.

Usage:

1. Add AnimateIcon.cpp and AnimateIcon.h files in your project.

2. Create a bitmap resource and put all the images (16 pixels x 16 pixels) in the desired sequence.

3. Add #include "AnimateIcon.h" at the beginning of your mainframe.h file.

4. Add the following protected members to your mainframe class


    CAnimateIcon m_animIcon;
    UINT m_timerID;
5. Add the following code in OnCreate member of your frame class

    m_animIcon.SetImageList(IDB_ANIM_IMGLIST,4,RGB(0,0,0));
    m_timerID = this->SetTimer(99,500,NULL);
SetImageList takes 3 parameters pass ID of your bitmap resource created in step 2 as first parameter. The second parameter is the no of (16x16) images in your bitmap, which is 4 in our case. The last parameter is the RGB value of color you want to make transparent. Second line of code sets a new timer. Here I have made it to fire every 500 ms. you can change it to suit your animation speed.

6. Create a OnDestroy()handler for your main frame class and add the following code. This is very important because if you do not kill the timer created you will lose system resources.


    CFrameWnd::OnDestroy();
    if(m_timerID != 0)
        KillTimer(m_timerID);

7. Add WM_TIMERhandler to your frame class and add the following code


    m_animIcon.ShowNextImage();

Compile and run the code. Now you should be able to see your window icon being animated. Note that just adding the above code also would bring up default MFC icon for a moment. If you want to avoid this change the IDR_MAINFRAME icon in the resource.

Note:

The sample project is built using Visual C++ 4.1, and has been tested on Visual C++ versions 4.1 and 6.0. If you directly try to run the .exe in the sample project it may ask for VC 4.1 runtime DLLs.

This version also fixes resources problem reported by few users.

Download demo project - 46 KB

Download source - 2 KB

Date Updated: December 2, 1998



Comments

  • budget-priced clarisonic can renovate your skin

    Posted by iouwanzi on 06/06/2013 08:33am

    [url=http://www.miaclarisonicaustralia.org/clarisonic-pro]clarisonic pro[/url] our bikini fluo avec des chandails effet de perspective au crochet, plus la féminité très sexy se tailler grosses boucles, mais pas simple. Sexy niveau populaire, tant de belles femmes a eu à envier. En fait, voulez vous débarrasser d’enfantin, d’augmenter féminin, approprié propres cheveux bouclés, mais très sculpté points de Oh! Un beau bébé et Miranda Kerr d’Australie mérite d’être un modèle de Freaky, les occasions formelles ou la rue tous les jours a attiré l’attention du public. Bien que chaque forme est différente, mais pas difficile à trouver, la plupart des enfants peuvent préférer cette exclusion boucles. [url=http://www.miaclarisonicaustralia.org/clarisonic-classic]clarisonic classic[/url] Un fabuleux produit saisonnier qui devrait satisfaction à peu près toutes les fashionistas à long terme et de créer par lui-même comme l’un des principaux programmes de cette année ou plus. Katy Perry expose « Écarlate », la dernière collection de tout poil frisé de compagnie ghd.Au moment encore une fois, une plus importante marque de ghd cheveux crépus loin un sensationnel fer plat important qui aidera à obtenir plus d’un du plus prouvé utile ainsi que semble en vogue à l’époque. [url=http://www.miaclarisonicaustralia.org/]clarisonic mia[/url] modestes caractéristiques consistent non pas un mais deux défini guides mise en page talents Deco, simultanément disponible ce sont unique. Toute la galerie Scarlet comprend un sac soie cramoisi tolérant à chaleur merveilleuse lesoù aider à stocker le fer à lisser vos plaques ghd IV Styler cheveux pour s’assurer vous rose profond, par le biais de non pas un mais deux trucs cheveux sauvages dont une instance appropriée.Écrit à l’intérieur d’une boîte commune inflammed inanité habilitée par période de Style déco, tous le groupe écarlate fantaisie ghd styler intemporelle métal jaune comprend une alimentation réduite option rouge et en outre une mallette de rangement, un voyage fabuleux crinière sèche-cheveux ghd, couple de crinière de films et en outre un important carton satiné résistant à la chaleur.

    Reply
  • Technological requirements seeking inauguration of the Joomla! theme directorate system.

    Posted by carpitnvg on 04/16/2013 09:24am

    Irrevocably, no overview of clothing hazards would be consummate without [url=http://www.hollistercovfrance.fr]hollister france[/url] acknowledging the corset. Transfer for hundreds of years, the corset has been worn to bearing or accentuate the heartfelt curves of a frail's [url=http://www.abercrombiesfrancevparise.fr]abercrombie[/url], or debar's, body. With whalebone or metal boning and tight-lacing, the body-binders prompted medical professionals, mostly in the 1800s, to sample to deportment an termination to their ingest, explaining that they [url=http://www.airjordanfrpaschera.fr]air jordan[/url] hindered muscle event, mobility and, indisputably, the skate to breathe. The doctors were on to something, but, as was the action with strained feet, mixed women weren't psyched up to incitement up the body-shaper because, they, or friendship, preferred the [url=http://www.abercrombieufrancersoldes.fr]abercrombie france[/url] corseted prepare greater than their unexceptional one. The aughts haven’t at rest receded into the divided late, [url=http://www.airjordanspasuchera.fr]air jordan pas cher[/url] but already we’re rationalization forth what we’ll look change to tailpiece from on and associate with the prime decade of the 21st century. Not national ago, the [url=http://www.hollisterfrancevmagusin.fr]hollister france[/url] Chic York Times published, “What Will-power We Fail to victual When It’s 2033,” a species of available assessment of the music, urbanity and smartness we’ll associate with 1999 to 2009, name-checking the unity [url=http://www.abercrombiexandfitchuke.co.uk]abercrombie uk[/url] from Gwyneth Paltrow to the Lowering Eyed Peas to “Contemplate Runway” to angular haircuts, flared jeans and trucker hats [url=http://www.monclerfranceumagasinsfr.com]doudoune moncler[/url]. Underneath that we’ve shared Dani + Dominic’s breathtaking position photos, [url=http://www.airjordanzchaussuren.com]air jordan pas cher[/url] it’s circumstance to dividend their blending! I pleasure that Dani + Dom made verging on the whole seeking their day. Dani is wearing story of my most favorite dresses from [url=http://www.michaelukorsua.com]michael kors outlet[/url] BHLDN and her bridesmaids all wore refulgent dresses from Not busy People. They did all things unfold untraditional including calling dick a week in head and changing the metre of their merging! The two [url=http://www.hollisterucoboutiques.fr]hollister[/url] of them disposition going on lane trips and because of their divers nights on the up in the wind roads, “Undo” before Zach Brown Gang became their anthem and foremost bound at a bargain quotation a stir [url=http://patrimoine.agglo-troyes.fr/BAM/louboutinpascher.html]louboutin[/url].

    Reply
  • Sa kimono est fabriquee a partir de guipure et caracteristiques degrader la coloration et finition festonnee.

    Posted by kkhyfhevv on 03/22/2013 08:34am

    Tes Drollery de la marque ont toujours eu une following de critiques et controverses. La plupart des slogans sont considerees comme degradantes filles [url=http://www.hollistercoefrance.fr]hollister france[/url] (fair exemple, ?Je ne suis pas autorise a ce jour, sauf si vous etes chaud?). Ils montrent aussi arrogants messages ou slogans irrespectueux (?Je ferai de toi une select dram persuade sur la marche de la honte?). Ils sont anti-slogans [url=http://www.abercrombiefrancevparis.fr]abercrombie france[/url] cultivation ainsi: ?Je Faites vos devoirs, mais je n'ai meme pas faire le mien;? L'ecole est rise rattraper le sommeil ?) chemises filles sont vendues avec des slogans qui generalement mettent en valeur. leur [url=http://www.airjordanfrpascherz.com]jordan[/url] apparence ("Il vaut mieux etre brunette", etc.) Peut-etre le additional controverse de tous etait la ligne de sous-vetements let in cityscape jeunes filles avec les paroles "Clin d'oeil Clin d'oeil" et "Objective Sweets" serigraphie sur eux. [9] Les parents monte vitrine manifestations a l'choler de la lingerie suggestive sexuellement. Recemment, des elements geometriques, l'habillement [url=http://www.abercrombieafranceusolde.fr]abercrombie france[/url] est tres utilise. Appended recemment, les grandes marques commencent a lancer des talons hauts geometriques esthetiques [url=http://www.hollisteruonlineshops.de]hollister[/url] nouvelles. Insouciance a une combinaison de la ligne dans l'esthetique geometrique, il est un classique. Seminar cela, nous vous recommandons sandales a talons hauts Louboutin2012 printemps et serie estivale: du luxe et de la magie [url=http://www.hollisterfranceamagesin.fr]hollister france[/url] de l'esthetique geometrique. Geometrie creee customary les sandales a talons hauts en reptilian, du metal, des lignes geometriques cardiaques together with de femmes. Les scientifiques débattent toujours quand les gens ont commencé à cleaner des vêtements. Ralf Kittler, Manfred Kayser et Assay-mark Stoneking, les anthropologues de l'Institut Max Planck cascade l'anthropologie évolutionnaire, ont procédé à une [url=http://www.abercrombiexandfitchukes.co.uk]abercrombie uk[/url] pooped down génétique de poux de brigade humains qui suggère vêtements origine puff récemment, il ya environ 107.000 années. Les poux de battalion est un indicateur de vêtements à l'usure, puisque la plupart des êtres humains ont des poils [url=http://www.abercrombiesdeutschlandshopu.com]abercrombie[/url] clairsemés, et les poux donc besoin de vêtements de l'homme spew out-moded survivre. Leur recherche suggère l'cock-and-bull story de vêtements peut-être co?ncidé avec la migration vers le nord de l'Homo sapiens moderne loin du climat chaud de l'Afrique, [url=http://www.abercrombiesdeutschlandshopu.com]abercrombie[/url] aurait commencé entre 50.000 et 100.000 ans. Cependant, un deuxième groupe de chercheurs qui utilisent des méthodes similaires génétiques estimer que les vêtements origine autour de 540.000 années auparavant (Reed et al 2004 PLoS Biology 2 (11):.. E340). Release le import, la old-fashioned de l'origine du vêtement n'est toujours pas résolu.

    Reply
  • Thanks

    Posted by Legacy on 07/09/2002 12:00am

    Originally posted by: Code Guy

    Rajesh,

    Thanks for the handy code. It's nice to be able to add a little flair to otherwise drab loooking applications with something like this icon animator.

    -Code Guy

    Reply
  • How to display a text with owner fonts

    Posted by Legacy on 12/10/2001 12:00am

    Originally posted by: Bui

    I don't know How to display a text with owner fonts in
    title bar . Please help me , Thank you very much

    Reply
  • Ref: Request for tech help on VB++

    Posted by Legacy on 06/13/2001 12:00am

    Originally posted by: Shuvro

    I want to Manipulate a Image File which is Scanned from the newspaper Page.
    Image size is in Pixel: Width:-2440
    Height:-3381

    I have developed a Browser with Vb6 using Picture Box Control.
    I have kept all options like Zooming in , Zooming Out and Cropping a selected Portion.
    Sometimes it works and Sometimes it Fails.When it fails it shows an error Message.
    When I make the picture bigger than its Original size and also try to Crop a Selected Part it shows error.Error message is : AutoRedraw cannot Create Image.Err Number is 480
    But I have to work with big Image.

    Reply
  • Quick way to make imagelists...

    Posted by Legacy on 03/15/2000 12:00am

    Originally posted by: Mark Stevens

    A real easy way to manage the bitmaps in an imagelist is to use a toolbar resource. It is actually stored as two separate resources, a regular bitmap resource and a toolbar resource. the nice thing is you can move buttons around and edit/resizing is a piece of cake.

    In your code you just use the toolbar's resource ID as a bitmap and ignore the other part.

    Reply
  • You can use this with CDialog

    Posted by Legacy on 03/09/2000 12:00am

    Originally posted by: Sergey

    Just change the original line:
    HICON hPrevIcon = (HICON)AfxGetMainWnd()->SendMessage(WM_SETICON,TRUE,(LPARAM)hIcon);

    to
    HICON hPrevIcon = (HICON)AfxGetMainWnd()->SetIcon(hIcon, FALSE);

    Thanks

    Reply
  • Nice Code It is But.................

    Posted by Legacy on 07/06/1999 12:00am

    Originally posted by: Nauman Ahmad Khan

    Very simple code is written to animate an icon on the title bar but one problem is there that how to keep all images in the same bitmap resource is not more clear. One way in my mind is that you create an image which holds the small images ( they should be explicitly created ) and include this image as bitmap resource. Thanks and congratulations on such a simple to use code 
    

    Reply
  • How about stop the timer.

    Posted by Legacy on 03/08/1999 12:00am

    Originally posted by: Yuan Songjun

    I have setup an application as what you have shown.
    It works. There is a ever-changing icon in the application's title bar.
    While I want to stop it from the CView derived class, so I call it by ((CFramWnd*) GetParentFrame()->OnDestroy();
    It does not work: the icon is still changina as ever.
    How to stop it from outside?
    Thanks.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

Most Popular Programming Stories

More for Developers

RSS Feeds