---
title: "在Windows Mobile 中最小化，显示图标再任务栏上(1)"
author: "guowee"
date: "2008-10-03T19:51:16Z"
tags: []
slug: "windows-mobile-1"
draft: false
lastmod: "2008-10-03T19:51:16Z"
id: 248715
url: "https://guowee.iteye.com/blog/248715"
---

最近写了一个小程序，当用户点击最小化按钮的时候，在任务栏上显示一个小图标。类似MSN Mobile。开始的时候看了好多实现。最终还是看了MSN，找到了结果。

 

下面是我的实现代码，其实很简单的。在MFC中实际上只需响应一个函数，然后把下面的代码拷贝过去就可以了。

SHNOTIFICATIONDATA sn  = {0};  
    sn.cbStruct = sizeof(sn);  
    sn.dwID = 1;  
    //SHNP\_ICONIC  
    sn.npPriority = SHNP\_ICONIC;  
    sn.csDuration = 5;  
    sn.hicon = LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI\_MESSAGE));  
    sn.clsid = CLSID\_SHNAPI\_ICON;  
    sn.grfFlags = 0;  
    sn.pszTitle = TEXT("LearnerAgent");  
    sn.pszHTML = TEXT("&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;");  
    sn.rgskn\[0].pszTitle = TEXT("Dismiss");  
    sn.rgskn\[0].skc.wpCmd = 100;  
    sn.pszTodaySK = TEXT("!BC");

    sn.pszHTML = TEXT("&lt;html&gt;&lt;body&gt;&lt;form method=\\"POST\\" action=&gt;&lt;p&gt;The main window was minilized. &lt;font color=\\"#0000FF\\"&gt;&lt;b&gt;minilized&lt;/b&gt;&lt;/font&gt;.&lt;/p&gt;&lt;p align=right&gt;&lt;input type=button name='cmd:10' value='OK'&gt;&nbsp;&lt;input type=button name='cmd:2' value='Show'&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;");  
    sn.npPriority = SHNP\_INFORM;  
    SHNotificationUpdate(SHNUM\_PRIORITY, &sn);  
    SHNotificationUpdate(SHNUM\_HTML,&sn);  
    SHNotificationAdd(&sn);