`
guowee
  • 浏览: 173096 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

在Windows Mobile 中最小化,显示图标再任务栏上(2)

阅读更多

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

 

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

sn.hwndSink = this->m_hWnd;

 

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

 

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

 

 

BOOL SampleDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
    UINT nID = LOWORD( wParam );
    switch(nID)
    {
        case 20:
            {
                this->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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics