Windows Mobile Incoming Call View Custom
Incoming call view custom of Windows Mobile PhoneCanvas
?
關(guān)于WinMobile電話自定義, 在SDK Documents里已經(jīng)有說明 "Phone Canvas Customization"
位置: Shell, GWES, and User Interface > Shell > Shell OS Design Development >
Sample Code: ../WM650/PUBLIC/APPS/OAK/SAMPLES
1. Customizing Controls in the Phone Canvas
Shell > Shell OS Design Development > Phone Canvas Customization >
添加注冊表, 告訴MSFT的程序說我們要自定義電話,? 并說明要加載哪個DLL文件.
2. PHExtGetPhoneViewInfo 函數(shù).? 通過它, 可以調(diào)用自己自定義的對話框,
| Shell > Shell OS Design Development > Phone Canvas Customization > 這里有說明哪些電話對框可以充許自定義 |
下面關(guān)于PHExtGetPhoneViewInfo的例子:
?/*PHExtGetPhoneViewInfo
???
??? Used to provide a new layout for the dialog box representing the phone view
??? specified in parameter "view".? Not all views support this functionality.? See the
??? below table.
??? Either PH_VIF_SQUARE, PH_VIF_PORTRAIT, or PH_VIF_LANDSCAPE will be set in the
??? pvif member indicating the dialog template that the phone application is
??? requesting.? To specify a dialog template, fill in the phInstance parameter
??? and the plpTemplateName.? phInstance identifies a module that
??? contains a dialog box template named by the plpTemplateName parameter.
??? plpTemplateName? is a long pointer to a null-terminated string that names
??? the dialog box template resource in the module identified by the phInstance
??? parameter. This template is substituted for the phone application抯 dialog
??? box template used to create the phone view. For numbered dialog box
??? resources, plpTemplateName can be a value returned by the MAKEINTRESOURCE
??? macro.
??? Additionally, the OEM can provide a plpfnHook hook procedure in the phone
??? view.? The hook procedure can process messages sent to the dialog box
??? representing the phone view.? To enable a hook procedure, add the
??? PH_VIF_ENABLEHOOK flag to the pvif parameter and specify the address of
??? the hook procedure in the plpfnHook parameter.? The hook procedure should
??? return TRUE to indicate that the phone application should not process
??? this message.? A return value of FALSE will cause? the phone application
??? to continue with its default handling of the message.
??? Note that if controls are added and/or removed, their control ids should not
??? coincide with the same id's used in the default layouts.? The phone dialogs
??? may attempt to communicate with these controls via their control id.
??? This function is called by the phone application both when phone
??? view is being created and when the phone view needs to rotate
??? due to a screen orientation change.? This allows the phone application
??? to use different dialog templates for portrait and landscape.
???
??? Table:
??? PH_VIEW_INCOMING????????? // template : incoming call view
??? PH_VIEW_DIALER??????????? // template : PocketPC dialer view
??? PH_VIEW_CALL_PICKER?????? // template : remove a call from a conference (GSM only)
??? PH_VIEW_NETWORK_SELECTION // template : manual network selection (GSM only)
??? PH_VIEW_CALL_HISTORY????? // NA (for PocketPC only, bitmaps can be changed)
??? PH_VIEW_SPEED_DIAL??????? // NA (for PocketPC only, bitmaps can be changed)
??? PH_VIEW_SIM_PIN,????????? // NA (for PocketPC only, bitmaps can be changed)
??? PH_VIEW_PROGRESS????????? // template : call progress or active calls view
???
??? [in]???? view : Any of the PH_VIEW enums.? It indicates which view
????????????????????? the phone application is creating or rotating.? Call history,
????????????????????? speed dial, and the unlock SIM PIN views are not replaceable
????????????????????? by the OEM.? Hence, the phone application will not call
????????????????????? PHExtGetPhoneViewInfo for these views.
??? [in/out] pvif??????????? : PH_VIF_SQUARE, PH_VIF_PORTRAIT, and PH_VIF_LANDSCAPE
?????????????????????????????? are set as input.? The client can add PH_VIF_ENABLEHOOK to
?????????????????????????????? indicate that plpfnHook is valid.
??? [out]??? phInstance????? : see above.
??? [out]??? plpTemplateName : See above.
??? [out]??? plpfnHook?????? : See above.
???
??? returns:
??? S_OK????? : success.
??? E_NOTIMPL : the phone application should use its defaults.*/
extern "C" HRESULT PHExtGetPhoneViewInfo(PH_VIEW view, HINSTANCE* phInstance, PH_VIEWINFOFLAGS* pvif, LPPHONEVIEWHOOKPROC*? plpfnHook, LPCTSTR* plpTemplateName)
{
??? HRESULT hr = E_NOTIMPL;
??? // Specify dialog templates for dialer view
??? switch (view)
??? {
??? // dialer view
??? case PH_VIEW_DIALER:
??? ??? break;
??? // progress view
??? case PH_VIEW_PROGRESS:
??? ??? break;
???
??? // incoming call view
??? case PH_VIEW_INCOMING:
??? ??? switch(*pvif)
??? ??? {
??? ??? case PH_VIF_PORTRAIT:
??? ??? ??? // Specify a calert portrait view dialog template
??? ??? ??? *phInstance = g_MainWnd.m_hInst;
??? ??? ??? *pvif = (PH_VIEWINFOFLAGS) (*pvif | PH_VIF_ENABLEHOOK);? //如果不想HOOK的話,這行和下面那一行可以注釋掉
??? ??? ??? *plpfnHook = (LPPHONEVIEWHOOKPROC)CalertWndProc;??????? //如果不想HOOK的話,本行和上面那一行可以注釋掉
??? ??? ??? *plpTemplateName = MAKEINTRESOURCE(dwIDD_CALERT_PORT);
??? ??? ??? hr = S_OK;
??? ??? ??? break;
??? ??? case PH_VIF_LANDSCAPE:
??? ??? ??? // Specify a calert landscape view dialog template
??? ??? ??? *phInstance = g_MainWnd.m_hInst;
??? ??? ??? *pvif = (PH_VIEWINFOFLAGS) (*pvif | PH_VIF_ENABLEHOOK);
??? ??? ??? *plpfnHook = (LPPHONEVIEWHOOKPROC)CalertWndProc;
??? ??? ??? *plpTemplateName = MAKEINTRESOURCE(dwIDD_CALERT_LAND);
??? ??? ??? hr = S_OK;
??? ??? ??? break;
??? ??? default:
??? ??? ??? break;
??? ??? }
??? ??? break;
??? default:
??? ??? break;
??? }
??? return hr;
}
這樣當有電話進來的時候, 就會調(diào)用CalertWndProc,? 和調(diào)用dwIDD_CALERT_XXX資源對話框了. 我做的是整個來電對話框自己Draw上相關(guān)的來電信息,還有接聽/掛斷按鈕,添加菜單等. 沒用dwIDD_CALERT_XXX資源對話框, 所以沒有試過不用HOOK, 只換Caler資源對框來自定義的情況, 不過文檔上說是可以的...
3. 來電時會調(diào)用CalertWndProc, 這里要添加一些小小的處理. 這個CallBack里的hWnd是最底層的(用Remote SPY 可以看得到), 所以要用兩次GetParent來取得MSFT顯示的來電對話框的handle, 將其它Move出顯示區(qū)域,并對它進行SetWindowLong.
/*********************************************************************
CalertWndProc
Purpose:
The windows procedure for the Calert control
Arguments:
HWND hWnd?????? - handle to the window
UINT uMsg?????? - the message to process
WPARAM wParam?? - additional parameter
LPARAM lParam?? - additional parameter
Returns:
LRESULT lRes 0 = success
**********************************************************************/
LRESULT CALLBACK CalertWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
??? LRESULT lRes = 0;
??? HWND hWndWorker = NULL;
??? switch (uMsg)
??? {
??? case WM_INITDIALOG:
??? ??? m_hWndCalert = hWnd;
??? ??? // to hide and SetWindowLong the MSFT incoming call view main dialog
??? ??? hWndWorker = GetParent(hWnd);
??? ??? if (hWndWorker == NULL)
??? ??? {
??? ??? ??? break;
??? ??? }
??? ??? m_hWndIncomingCall = GetParent(hWndWorker);
??? ??? if (m_hWndIncomingCall != NULL)
??? ??? {
??????????? // 這里我將MSFT的來電對話框Move出去,? 這樣它就不會顯示出來了
??? ??? ??? MoveWindow(m_hWndIncomingCall, -1, -1, 0, 0, FALSE);
??? ??? ??? // set window long for MSFT incoming call view main dialog
??? ??? ??? if (m_OldIncomingCallWndProc == NULL)
??? ??? ??? {
??????????????? // 調(diào)用SetWindowLong, 來到來電對話框的CallBack消息.
??? ??? ??? ??? m_OldIncomingCallWndProc = (WNDPROC)SetWindowLong(m_hWndIncomingCall, GWL_WNDPROC, (LONG)IncomingCallWndProc);
??? ??? ??? ??? if(!m_OldIncomingCallWndProc)
??? ??? ??? ??? {
??? ??? ??? ??? ??? DEBUGMSG(1 , (L"m_OldIncomingCallWndProc == NULL"));
??? ??? ??? ??? }
??? ??? ??? }
??? ??? }
??? ??? break;
??? default:
??? ??? break;
??? }
??? return lRes;
}
4. IncomingCallWndProc 處理. SHBM_SHOW(用Remote SPY 可以看得到)這個就是來電BubbleBox, Show/Hide時的消息
/*********************************************************************
IncomingCallWndProc
Purpose:
The windows procedure for the Incoming Call control
Arguments:
HWND hWnd?????? - handle to the window
UINT uMsg?????? - the message to process
WPARAM wParam?? - additional parameter
LPARAM lParam?? - additional parameter
Returns:
LRESULT lRes 0 = success, else callback default
**********************************************************************/
LRESULT CALLBACK CCalert::IncomingCallWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
??? LRESULT lRet = S_OK;
??? switch (uMsg)
??? {
??? case SHBM_SHOW:
??? ??? // shbox.h: Show/Hide dialog box. wParam == TRUE to Show. wParam == FALSE to Hide. lParam=TRUE to set foreground.
??? ??? if (wParam)
??? ??? {???
??? ??? ??? // 來電對話框 Show
??????????? // 這里用來添加自
??? ??? }
??? ??? // Hide the incoming call dialog box
??? ??? else
??? ??? {
??? ??? ??? // hide the custome incoming call and the default incoming call
??? ??? ??? // 來電對話框 Hide
??? ??? }
??? ??? break;
??? default:
??? ??? return CallWindowProc(m_OldIncomingCallWndProc, hWnd, uMsg, wParam, lParam);
??? ??? break;
??? }
??? return lRet;
}
OK, 這樣當來電的時候就顯示自定義的窗口了...
關(guān)于來電防火墻的處理嘛,就應(yīng)該更簡單了:-<
關(guān)于來電話定義的東西比較多, 這里我先寫點對來電對話框自定義顯示的小結(jié), 等有時間再寫其它的.
轉(zhuǎn)載于:https://www.cnblogs.com/xyzlmn/archive/2010/01/10/3168312.html
總結(jié)
以上是生活随笔為你收集整理的Windows Mobile Incoming Call View Custom的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linq TO SQL 虽好,但不要滥用
- 下一篇: 编程中弹出的提示框