---
title: "在Windows Mobile 中最小化，显示图标再任务栏上(2)"
author: "guowee"
date: "2008-10-04T12:09:55Z"
tags: []
slug: "windows-mobile-2"
draft: false
lastmod: "2008-10-04T12:09:55Z"
id: 248826
url: "https://guowee.iteye.com/blog/248826"
---

上一篇文章中提到了如何在Windows mobile中显示一个Notification。但是，由一个问题，就是如何处理在Notification中按钮的响应事件问题。

 

我想再用户点击按钮的时候做相应的操作：这样的话就需要再设置SHNOTIFICATIONDATA 的hwndSink属性。

**sn.hwndSink = this-&gt;m\_hWnd;**

 

然后再MFC类中的OnCommand方法中根据HTML button cmd值进行消息处理。

 

&lt;html&gt;&lt;body&gt;&lt;form method=\\"POST\\" action=&gt;&lt;p&gt;The main window was minilized.Click &lt;font color=\\"#0000FF\\"&gt;&lt;b&gt;Show Window&lt;/b&gt;&lt;/font&gt; to display the main window. &lt;/p&gt;&lt;p align=right&gt;&lt;input type=button name='**cmd:20** ' value='Show Window'&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;

 

 

BOOL SampleDlg::OnCommand(WPARAM wParam, LPARAM lParam)  
{  
    UINT nID = LOWORD( wParam );  
    switch(nID)  
    {  
        case 20:  
            {  
                this-&gt;ShowWindow(SW\_SHOW);  
                return true;  
            }  
            break;  
    }  
    return CWnd::OnCommand(wParam,lParam);  
}

 

当然如果是再Windows程序中也可以用如下的方式写：

在WinMain函数中设置回调函数。

int WINAPI WinMain(  
    HINSTANCE hInstance,  
    HINSTANCE hPrevInstance,  
    LPTSTR lpCmdLine,     
    int nCmdShow  
    )  
{  
    g\_hInst = hInstance;

    SHInitExtraControls();

    // just call a dialog box, system will handle messaging, painting, etc...  
    DialogBox(hInstance,(LPCTSTR)IDD\_NOTIFYMAIN, NULL,(DLGPROC)**NotifyMain** );  
    return 0;  
}

 

在回调函数中处理：

LRESULT CALLBACK NotifyMain(  
    HWND hDlg,  
    UINT message,  
    WPARAM wParam,  
    LPARAM lParam  
    )  
{

      switch(message)

    {

          case WM\_COMMAND:

            {

                 switch(LOWORD(wParam))

                 {

                      **case 10:**

                       **{Your operation}**

                       **Break;**

                 }

            }

     }

}

 

参考文章：http://blog.csdn.net/seamanjiang/archive/2005/10/16/504855.aspx