Just try and try again

导航

今日插件消息整理

1.WM_TODAYCUSTOM_RECEIVEDSELECTION
This message is sent to a Today custom item when it is selected. The component also will get WM_ERASEBKGND and WM_PAINT messages, regardless of the Selectability value
WM_TODAYCUSTOM_RECEIVEDSELECTION
    wParam = (WPARAM) nVirtKey;
lParam = (LPARAM) res;

Parameter

Description

nVirtKey

Contains the virtual key code of the keypad button used to navigate to this item.

res

This parameter is not used.

1)     Receiving the Selection Focus
When the user navigates to a Today screen item using the keypad, the plug-in receives a WM_TODAYCUSTOM_RECEIVEDSELECTION message. Also, regardless of the value of Selectability, it receives a WM_ERASEBKGND and a WM_PAINT message so that it can redraw its content. 
Sending the TODAYM_DRAWWATERMARK message to the parent window always draws an unselected background – unless the Today screen item is selected and its Selectability value is one, in which case a highlighted background is drawn. When the value of Selectability is one, no code changes are required to draw the correct background; but if the value is two, the plug-in must draw the background itself. It should use the TODAYCOLOR_HIGHLIGHT color (0x10000022) for its background and the TODAYCOLOR_HIGHLIGHTEDTEXT color (0x10000023) for its foreground – both of which can be found via the 
消息⑩TODAYM_GETCOLOR message. 
WM_TODAYCUSTOM_RECEIVEDSELECTION is defined as (WM_USER + 244). The parameter wParam is set to the virtual key code used to navigate to this item (i.e., either VK_DOWN or VK_UP); lParam is not used. If the plug-in accepts the selection change, then it should return TRUE; otherwise, the Today screen passes the selection along to the next item. The following code example shows the Today screen passing the section along to the next item. 

TODAYM_GETCOLOR

Send this message to get Today color information for the Today screen.

 
TODAYM_GETCOLOR
    wParam = (WPARAM) flag;
    lParam = (LPARAM) res;


 Parameters 
flag 
A flag which indicates the Today color information to be retrieved.
res 
This parameter is reserved for future use; the value of this parameter must be set to 0.


 Return Value 
The value returned is determined by the value of the wParam.
 
COLORREF  crText = SendMessage(GetParent(hwnd), TODAYM_GETCOLOR, (WPARAM) TODAYCOLOR_TEXT, NULL);
 
消息①case WM_TODAYCUSTOM_RECEIVEDSELECTION:
   g_bSelected = TRUE;
   return TRUE;

2) Taking the Selection Focus

A Today screen plug-in can also request the selection focus, such as in response to a user tap. To do so, the plug-in must send a TODAYM_TOOKSELECTION message to its parent window.

消息②TODAYM_TOOKSELECTION

Send this message to the parent window of a Today item to request selection. In response, the component will get a WM_TODAYCUSTOM_RECEIVEDSELECTIONnotification with wParam = 0 if the request was successful

TODAYM_TOOKSELECTION

    wParam = (WPARAM) res1;

    lParam = (LPARAM) res2;

 Parameters

res1

This parameter is not used.

res2

This parameter is not used.

 Return Value

No return value.

TODAYM_TOOKSELECTION is defined as (WM_USER + 102). The wParam is the handle to the plug-in window. The parameter lParam is not used and can be set to zero.

case WM_LBUTTONDOWN:
   PostMessage(GetParent(hwndPlugin), TODAYM_TOOKSELECTION, (WPARAM)hwndPlugin, 0);
   break;

3)Receiving Keypad Presses

Once the Today screen plug-in has the selection focus, each keypad button press causes it to receive a WM_TODAYCUSTOM_USERNAVIGATION message. If the plug-in handles the button press internally, it should return TRUE in response to this message. Otherwise, the Today screen passes the selection on to the next item if either the up or down key was pressed. This can be used to navigate through a series of sub-items.

WM_TODAYCUSTOM_USERNAVIGATION is defined as (WM_USER + 246). The parameter wParam is set to the virtual key code of the keypress (e.g., VK_UP, VK_LEFT, etc); lParam is not used.

The action button is handled differently. If the action button is pressed, the plug-in receives a WM_TODAYCUSTOM_ACTION message, unless the value of Selectability is equal to one, in which case it receives a WM_LBUTTONDOWN and a WM_LBUTTONUP message at coordinates (1, 1), simulating a user tap.

WM_TODAYCUSTOM_ACTION is defined as (WM_USER + 247). The parameter wParam is equal to the virtual key code for the action key (i.e., VK_RETURN); lParam is not used. The return value for this message is ignored. The following code example shows this.

消息③case WM_TODAYCUSTOM_USERNAVIGATION:

   InvalidateRect(hwnd, NULL, FALSE);

 

   if (wParam == VK_UP)   g_nSelectedItem--;

   if (wParam == VK_DOWN) g_nSelectedItem++;

 

   if (g_nSelectedItem < 0 || g_nSelectedItem >= MAX_ITEMS)

   {

      return FALSE; // go to the next plug-in

   }

   else

   {

      return TRUE;  // stay in this plug-in

   }

消息④WM_TODAYCUSTOM_ACTION

    wParam = (WPARAM) nVirtKey;

    lParam = (LPARAM) res;

 Parameters

nVirtKey

Contains the virtual key code for the action key (VK_RETURN).

res

This parameter is not used.

 Return Value

The return value is ignored.

 

case  WM_TODAYCUSTOM_ACTION:

   OnAction();

   break;

4) Losing the Selection Focus

When the plug-in loses focus, it receives a WM_TODAYCUSTOM_LOSTSELECTION message. Regardless of the value of the Selectability registry key, the plug-in also receives WM_ERASEBKGND and WM_PAINT messages so that it can redraw its content.

Note   The plug-in must call InvalidateRect when it receives the WM_TODAYCUSTOM_LOSTSELECTION message to ensure that it will be refreshed correctly while scrolling.

WM_TODAYCUSTOM_LOSTSELECTION is defined as (WM_USER + 245). The parameters wParam and lParam are not used, and the return value is ignored. For example:

消息⑤WM_TODAYCUSTOM_LOSTSELECTION

    wParam = (WPARAM) res1;

    lParam = (LPARAM) res2;

 Parameters

res1

This parameter is not used.

res2

This parameter is not used.

 Return Value

The return value is ignored.

 

case WM_TODAYCUSTOM_LOSTSELECTION:

   g_bSelected = FALSE;

   break;

InvalidateRect

This function adds a rectangle to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn.

BOOL InvalidateRect(

  HWND hWnd,

  const RECT* lpRect,

  BOOL bErase

);

 Parameters

hWnd

Handle to the window whose update region has changed.

If you pass a NULL value for this parameter InvalidateRect takes no action and returns FALSE.

lpRect

Long pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region.

If this parameter is NULL, the entire client area is added to the update region.

bErase

Boolean that specifies whether the background within the update region is to be erased when the update region is processed.

If this parameter is TRUE, the background is erased when the BeginPaint function is called.

If this parameter is FALSE, the background remains unchanged.

5) Drawing the Today Screen Watermark

When a Today screen plug-in sends a TODAYM_DRAWWATERMARK message to its parent window, the Today screen, the Today screen will draw the appropriate watermark, if there is any. The lParam parameter of the message is a pointer to a TODAYDRAWWATERMARKINFO structure that can be found in the todaycmn.h header file.

消息⑥TODAYM_DRAWWATERMARK

Send this message to ask the Shell to draw a portion of the background (watermark) bitmap.

TODAYM_DRAWWATERMARK

    wParam = (WPARAM) res;

    lParam = (LPARAM) lpdwi;

 Parameters

Parameter

Description

res

This parameter is reserved for future use; the value of this parameter must be set to 0.

lpdwi

[in] A pointer to a TODAYDRAWWATERMARKINFO structure.

 Return Value

Returns TRUE if the request to draw the watermark was successful, otherwise FALSE.

 

In a plug-in, this message can be used in the WndProc via a message that handles:

case WM_ERASEBKGND:

{

  TODAYDRAWWATERMARKINFO twm;

  twm.hdc = (HDC)wParam;

  twm.hwnd = hWnd;

 

  GetClientRect(hWnd, &(twm.rc));

  SendMessage(GetParent(hWnd), TODAYM_DRAWWATERMARK, 0, (LPARAM)&twm);

}

break;

消息⑦WM_TODAYCUSTOM_QUERYREFRESHCACHE

This message is sent to a Today custom item's window to determine whether the data pertaining to the item has been updated or not.

WM_TODAYCUSTOM_QUERYREFRESHCACHE

    wParam = (WPARAM) lptli;

    lParam = (LPARAM) res;

 Parameters

lptli

A pointer to a TODAYLISTITEM structure.

res

This parameter is reserved for future use; the value of this parameter must be set to 0.

 Return Value

Returns TRUE if the item needs to be updated, otherwise FALSE. If the item needs updating, the cyp member of the structure will be set to the height of the item.

 Remarks

This message is also used for the item to set the cyp member of the TODAYLISTITEMstructure (which is initialized to 0) to the appropriate height. The item should set the height and return TRUE the first time the message is received and return FALSE after that.

消息⑧WM_TODAYCUSTOM_CLEARCACHE

This message is sent to a Today custom item's window to indicate that it is about to be unloaded.

WM_TODAYCUSTOM_CLEARCACHE

    wParam = (WPARAM) lptli;

    lParam = (LPARAM) res;

 Parameters

lptli

A pointer to the TODAYLISTITEMstructure for the item.

res

This parameter is reserved for future use; the value of this parameter must be set to 0.

 Return Value

No return value.

 

消息⑨TODAYM_REQUESTREFRESH

Send this message to ask the Windows Mobile Shell to start polling Today custom items for changes (send each custom item a WM_TODAYCUSTOM_QUERYREFRESHCACHE message.)

 Syntax

TODAYM_REQUESTREFRESH

    wParam = (WPARAM) res1;

    lParam = (LPARAM) res2;

 Parameters

res1

This parameter is not used.

res2

This parameter is not used.

 Return Value

Returns 0 if the Shell processed the message; the return value does not indicate that the screen was refreshed, only that the message was processed.

 

posted on 2009-03-21 16:37  梦幻石头  阅读(654)  评论(0编辑  收藏  举报