---
title: "Program baesd CDialog to be hidden when starting"
author: "guowee"
date: "2008-10-04T12:14:36Z"
tags: []
slug: "program-baesd-cdialog-to-be-hidden-when-starting"
draft: false
lastmod: "2008-10-04T12:14:36Z"
id: 248827
url: "https://guowee.iteye.com/blog/248827"
---

FROM: http://blog.csdn.net/seamanjiang/archive/2005/10/16/504855.aspx

 

have wrote a notification bubble with text input control for user to input there email.(MFC)

**Code:**

#define IDS\_DEFAULTHTMLMESSAGE   \_T("&lt;html&gt;&lt;body&gt;&lt;form id='ads' name='ads' action=''&gt;&lt;p&gt; pls input your email &lt;input type='text' name='email'&gt;&lt;input type='button' name='cmd:10' value='Ok' &gt;&lt;/p&gt;&lt;/form&gt;&lt;/body&gt;&lt;/html&gt;");

   pndAdd = (SHNOTIFICATIONDATA\*)malloc(sizeof(SHNOTIFICATIONDATA));  
   pndAdd-&gt;dwID = 4711;  
   pndAdd-&gt;clsid = guidPPCAlertsApp;  
   pndAdd-&gt;npPriority = SHNP\_INFORM;  
   pndAdd-&gt;csDuration = 20;  
   pndAdd-&gt;hwndSink = this-&gt;m\_hWnd  
   pndAdd-&gt;pszHTML = IDS\_DEFAULTHTMLMESSAGE;  
   pndAdd-&gt;hicon = m\_hNotifactionIcon;  
   pndAdd-&gt;cbStruct = sizeof(SHNOTIFICATIONDATA);  
   pndAdd-&gt;pszTitle = IDS\_DEFAULTTITLE;  
   pndAdd-&gt;grfFlags = SHNF\_FORCEMESSAGE;

   SHNotificationAdd(pndAdd);

   ........

as we known, we use WM\_COMMAND to handle Command Button Click,but when we got the click, how should i do for getting the text that user input in the html control?

**Code:**  
BOOL CPOutlookTestDlg::OnCommand(WPARAM wParam, LPARAM lParam)  
{  
   if(wParam==10){

      SHNotificationRemove(&guidPPCAlertsApp, 4711);

      delete pndAdd;  
      return true;  
   }

   return CPOutlookTestDlg::OnCommand(wParam,lParam);  
}

thanks.

seaman

When you call SHNotificationAdd the call is asynchronous and the return value indicates if the notification was successfully added.

To receive return values from the notification bubble itself there are several ways.

1\. Most bubbles have buttons, as in the example:  
   &lt;input type=button name='cmd:10' value='Ok'&gt;  
In this case when the user clicks the 'OK' button your sink window will receive a WM\_COMMAND with a wParam of 10

2\. Bubbles may also contain links which will send you a WM\_COMMAND as well - from the example:  
   &lt;a href=\\"cmd:11\\"&gt;Test Link&lt;/a&gt;

3\. Finally you can have a form in your HTML and have it submitted back to your sink window. The msdn example doesn't appear to show this properly but here's an example:

&lt;form method='get' action='TestBubble://Test'&gt;&lt;table width=100% cellspacing=0 cellpadding=0&gt;&lt;tr&gt;&lt;td colspan=2&gt;&lt;b&gt;Choose a fruit:&lt;/b&gt;&lt;p&gt;&lt;input type='radio' value='0' id='Apples' checked name='Fruit'&gt;&lt;label for='Apples'&gt;Apples&lt;/label&gt;&lt;br&gt;&lt;input type='radio' value='1' id='Oranges' name='Fruit'&gt;&lt;label for='Oranges'&gt;Oranges&lt;/label&gt;&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;input type='submit' value='Submit' name='Submit'&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td width=42%%&gt;&lt;a href='cmd:12288'&gt;Settings&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;"

When the submit button is pressed your sink window will receive a WM\_NOTIFY with a NMSHN structure:

typedef struct \_NMSHN  
{  
    NMHDR   hdr;  
    LPARAM lParam;  
    DWORD dwReturn;  
    union  
    {  
        LPCTSTR pszLink;  
        BOOL    fTimeout;  
        POINT   pt;  
    };  
} NMSHN;

typedef struct tagNMHDR  
{  
    HWND  hwndFrom;  
    UINT  idFrom;  
    UINT  code;         // NM_ code  
}   NMHDR;  
typedef NMHDR FAR * LPNMHDR;

The hdr.code member will be SHNN\_LINKSEL; the pszLink member will contain the URL encoded form submission - eg "TestBubble://Test?Fruit=Apples" and wParam will contain the dwID of the notification (useful if you have multiple notifications of the same type)

Tim