现在的位置: 首页 > 综合 > 正文

wince 拨号界面自定制

2013年05月14日 ⁄ 综合 ⁄ 共 5951字 ⁄ 字号 评论关闭
/**********************************************************************
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Copyright (c) ppcat_001 Corporation. All Rights Reserved.

This code is sample code and is included for illustrative purposes only.
It may not have been designed by the core product team and has not been 
tested to the same standards as product code.  

MODULE:
  custphone.cpp

ABSTRACT:
  Phone Canvas extension code to set skinning settings.
*********************************************************************
*/


#include 
"custphone.h"
#include 
"phcanvas.h"
#include 
"PhoneResources.h"
#include 
<windows.h>
#include 
<imgdecmp.h>
#include 
"miscsvcs.h"
#include 
"winsock2.h"

#define IPPHONE                TEXT("IPPhone")
#define DIALER_PORT    1        //拨号界面
HPHONELISTENER g_idlTapiState 
= INVALID_HPHONELISTENER;

// Phone behavior overriding functions
HRESULT PHExtInitialize(void *pVoid);
HRESULT PHExtShowPhoneMsg(PH_MSG phmsg, LPWSTR psz1, LPWSTR psz2, BOOL fRemove, DWORD dwSupSvcStatus, BOOL 
* pfDial);
HRESULT PHExtDoVerb(PH_VERB verb, BOOL fValidateOnly, VPARAM vp);
HRESULT PHExtGetPhoneViewInfo(PH_VIEW view, HINSTANCE 
* phInstance, PH_VIEWINFOFLAGS * pvif, LPPHONEVIEWHOOKPROC * plpfnHook, LPCTSTR * plpTemplateName);
BOOL PHExtplpfnHook(HWND, UINT, WPARAM, LPARAM);
//主界面的
BOOL PHExtplpfnHookPro(HWND, UINT, WPARAM, LPARAM);//拨号界面的
BOOL PHExtplpfnHookIn(HWND, UINT, WPARAM, LPARAM);//拨号界面的
void Draw(HWND hWnd,DWORD IDC,BOOL Mark);//在指定的位置画图(窗口句柄,画的控件ID,背景是FALSE,按界面之后是TRUE)
void Draw_Talk(HWND hWnd,BOOL Mark);//替换通话界面中的通话部分(换成结束)
void Draw_In(HWND);
void Draw_In_IDC(HWND,DWORD);
void Draw_Button(HWND, RECT, RECT, HBITMAP);

#define REG_SPEAKER    L"ITF_SPEAKER"
//这个没有用扬声器的api,各位可能要改
BOOL setRegSPEAKER(DWORD Speaker);//sP 是当前扬声器是否已经打开]
BOOL getRegSPEAKER(DWORD *Speaker);//sP 是当前扬声器是否已经打开


void Draw_Pro(HWND hWnd,DWORD dnum,BOOL Mark);//同上,但是num为画第几张图
void Draw_Pro_Talk(HWND hWnd,BOOL Mark);
void Draw_Pro_Mute(HWND hWnd,DWORD Mark);//Mark = 1//菲静音亮,Mark = 2,菲静音暗,Mark = 3灰色不可点击
void Draw_Pro_SP(HWND hWnd,DWORD Mark);
void Draw_Pro_Held(HWND hWnd,DWORD Mark);

void GetRect(HWND hWnd);
DWORD InRect(DWORD x_pos,DWORD y_pos);

void GetRect_Pro(HWND hWnd);
DWORD InRect_Pro(DWORD x_pos,DWORD y_pos);

BOOL RECT_Mark 
= FALSE;

RECT  distRect[
16= {0};
RECT  WndPosRect[
16= {0};

BOOL RECT_Mark_Pro 
= FALSE;

RECT  disRect_Pro[
6= {0};
RECT  WndPosRect_Pro[
6= {0};

BOOL RECT_Mark_In 
= FALSE;
RECT WndPosRect_In[
11= {0};
RECT disRect_In[
10= {0};

BOOL Mute 
= TRUE;

HINSTANCE g_hInst 
= NULL;
HWND g_hWnd;


HBITMAP hBmp 
= NULL;
HBITMAP hBmp_Inv 
= NULL;
HBITMAP hBmp_Talk 
= NULL;
HBITMAP hBmp_Inv_Talk 
= NULL;

HBITMAP hBmp_Pro 
= NULL;
HBITMAP hBmp_Inv_Pro 
= NULL;

HBITMAP hBmp_Pro_Talk 
= NULL;
HBITMAP hBmp_Inv_Pro_Talk 
= NULL;

HBITMAP hBmp_Pro_Mute 
= NULL;
HBITMAP hBmp_Inv_Pro_Mute 
= NULL;
HBITMAP hBmp_Un_Pro_Mute 
= NULL;

HBITMAP hBmp_Pro_SP 
= NULL;
HBITMAP hBmp_Inv_Pro_SP 
= NULL;
HBITMAP hBmp_Pro_His 
= NULL;
HBITMAP hBmp_Inv_Pro_His 
= NULL;

HBITMAP hBmp_Pro_Held 
= NULL;
HBITMAP hBmp_Inv_Pro_Held 
= NULL;
HBITMAP hBmp_Pro_Swap 
= NULL;
HBITMAP hBmp_Inv_Pro_Swap 
= NULL;
HBITMAP hBmp_Un_Pro_Held 
= NULL;

HBITMAP hBmp_In 
= NULL;



extern "C" BOOL WINAPI DllMain(HANDLE hinstDll, DWORD dwReason, LPVOID lpReserved)
{    
    
switch (dwReason)
    
{
        
case DLL_PROCESS_ATTACH:
            g_hInst 
= (HINSTANCE)hinstDll;
            
break;
    }


    
return TRUE;
}





/*********************************************************************
 PHExtInitialize
  
 Purpose:
  Please see phcanvas.h for details
    
 Arguments:
  Please see phcanvas.h
 
 Returns:
  status
  
*********************************************************************
*/

extern "C" HRESULT PHExtInitialize(void *pVoid)
{
    UNREFERENCED_PARAMETER(pVoid);
    
    
return S_OK;
}


/*********************************************************************
 PHExtDoVerb
 
 Purpose:
  Please see phcanvas.h for details
   
 Arguments:
  Please see phcanvas.h

 Returns:
  status
 
*********************************************************************
*/

extern "C" HRESULT PHExtDoVerb(PH_VERB verb, BOOL fValidateOnly, VPARAM vp)
{
    HRESULT hr 
= E_NOTIMPL;
    
return hr;
}





DWORD CALLBACK GetImageData(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam )
{
    DWORD dwNumberOfBytesRead;

    
if ( (HANDLE)lParam == INVALID_HANDLE_VALUE )
        
return 0;

    ReadFile( (HANDLE)lParam, szBuffer, dwBufferMax, 
&dwNumberOfBytesRead, NULL );

    
// Return number of bytes read
    return dwNumberOfBytesRead;
}

void CALLBACK ImageProgress(IImageRender *pRender, BOOL bComplete, LPARAM lParam )
{
    
if( bComplete )
    
{
        
// (Optional) add code here for completion processing
    }

}



BOOL LoadImage(HBITMAP 
* lpBmp, LPCWSTR lpPath)
{
    HRESULT hr 
= 0;
    DecompressImageInfo    dii;
    BYTE    szBuffer[
4096= {0};
    HDC        hCompDC, hDevDC;
    HANDLE    hFile;
    BOOL    bRet 
= FALSE;

    hFile 
= CreateFile(lpPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
    DWORD miao 
= GetLastError();
    
if (hFile == INVALID_HANDLE_VALUE)
    
{
        
goto error;
    }


    hDevDC 
= ::GetDC(NULL);
    
if(!hDevDC)
        
goto error;
    hCompDC 
= CreateCompatibleDC(hDevDC);
    
if(NULL == hCompDC)
    
{
        
goto error;
    }

    
// Fill in the 'DecompressImageInfo' structure
    dii.dwSize = sizeof( DecompressImageInfo );        // Size of this structure
    dii.pbBuffer = szBuffer;                        // Pointer to the buffer to use for data
    dii.dwBufferMax = sizeof(szBuffer);                // Size of the buffer
    dii.dwBufferCurrent = 0;                        // The amount of data which is current in the buffer
    dii.phBM = lpBmp;                                // Pointer to the bitmap returned (can be NULL)
    dii.ppImageRender = NULL;                        // Pointer to an IImageRender object (can be NULL)

抱歉!评论已关闭.