
/**/
/**********************************************************************
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)
dii.iBitDepth = GetDeviceCaps(hDevDC,BITSPIXEL);// Bit depth of the output image
dii.lParam = ( LPARAM ) hFile; // User parameter for callback functions
dii.hdc = hCompDC; // HDC to use for retrieving palettes
dii.iScale = 100; // Scale factor (1 - 100)
dii.iMaxWidth = 10000;//nWidth; // Maximum width of the output image
dii.iMaxHeight = 10000;//nHeight; // Maxumum height of the output image
dii.pfnGetData = GetImageData; // Callback function to get image data
dii.pfnImageProgress = ImageProgress; // Callback function to notify caller of progress decoding the image
dii.crTransparentOverride = ( UINT ) -1; // If this color is not (UINT)-1, it will override the
// transparent color in the image with this color. (GIF ONLY)

// Process and decompress the image data
hr = DecompressImageIndirect( &dii );
if(FAILED(hr))
goto error;

//m_gBGLoaded = TRUE;
bRet = TRUE;
goto error;
error:
// Clean up
if(INVALID_HANDLE_VALUE != hFile)
CloseHandle( hFile );
if(NULL != hCompDC)
DeleteDC(hCompDC);
if(NULL != hDevDC)
::ReleaseDC(NULL, hDevDC);
return bRet;

}

/**/
/*********************************************************************
PHExtShowPhoneMsg
Purpose:
Please see phcanvas.h for details
Arguments:
Please see phcanvas.h
Returns:
status
**********************************************************************/
extern
"
C
"
HRESULT PHExtShowPhoneMsg(PH_MSG phmsg, LPCWSTR psz1, LPCWSTR psz2, BOOL fRemove, DWORD dwSupSvcStatus, BOOL
*
pfDial)

...
{
HRESULT hr = E_NOTIMPL;

// To override behavior, return S_OK and insert code here. If you wish
// to let default processing
// still occur after having intercepted the message, return E_NOTIMPL.
return hr;
}

void
GetRect(HWND hWnd)

...
{

DWORD BUTTON[16] = ...{
IDC_DIALBUTTON_ZERO,
IDC_DIALBUTTON_ONE,
IDC_DIALBUTTON_TWO,
IDC_DIALBUTTON_THREE,
IDC_DIALBUTTON_FOUR,
IDC_DIALBUTTON_FIVE,
IDC_DIALBUTTON_SIX,
IDC_DIALBUTTON_SEVEN,
IDC_DIALBUTTON_EIGHT,
IDC_DIALBUTTON_NINE,
IDC_DIALBUTTON_STAR,
IDC_DIALBUTTON_POUND,
IDC_HISTORY,
IDC_TALKEND,
IDC_SPEED,
IDC_ERASE_BUTTON,
};
HWND hd = NULL;
for(int i = 0; i <= 15; i++)

...{
hd = GetDlgItem(hWnd,BUTTON[i]);
::GetClientRect(hd,&distRect[i]);
::GetWindowRect(hd,&WndPosRect[i]);
}
RECT_Mark = TRUE;
}
//
指出点在那个控件上,x_pos横坐标,y_pos纵坐标
DWORD InRect(DWORD x_pos,DWORD y_pos)

...
{

POINT Point = ...{x_pos,y_pos};

RECT Rect = ...{0};
for(DWORD i = 0; i <= 15; i++)

...{
Rect.bottom = WndPosRect[i].bottom - 26;
Rect.top = WndPosRect[i].top - 26;
Rect.left = WndPosRect[i].left;
Rect.right = WndPosRect[i].right;
if(PtInRect(&Rect,Point))

...{
return i;
}
}
return 100;
}

BOOL PHExtplpfnHook(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

...
{
HWND hd = NULL;
BOOL breturn = FALSE;
int x_pos;
int y_pos;

PHADDACCUMULATOR num = ...{0};
HRESULT hr = S_OK;
int Talk = 0;
int OutGo = 0;
int Held = 0;
int InCom = 0;
DWORD Acc = 1;
int Connect = 0;
DWORD dnum;

SHRGINFO shrg;
if(RECT_Mark == FALSE)

...{
GetRect(hWnd);
}

UINT vkKeyCode[12] = ...{'0','1','2','3','4','5','6','7','8','9','*','#'};
switch(Msg)

...{
case WM_PH_PAINTCHILDBACKGROUND:

...{
switch(GetDlgCtrlID((HWND)wParam))

...{
case IDC_DIALBUTTON_ONE:
case IDC_DIALBUTTON_TWO:
case IDC_DIALBUTTON_THREE:
case IDC_DIALBUTTON_FOUR:
case IDC_DIALBUTTON_FIVE:
case IDC_DIALBUTTON_SIX:
case IDC_DIALBUTTON_SEVEN:
case IDC_DIALBUTTON_EIGHT:
case IDC_DIALBUTTON_NINE:
case IDC_DIALBUTTON_STAR:
case IDC_DIALBUTTON_ZERO:
case IDC_DIALBUTTON_POUND:
case IDC_HISTORY:
case IDC_ERASE_BUTTON:
case IDC_SPEED:
case IDC_TALKEND:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
breturn = TRUE;
break;
case IDC_BRANDING:
PHGetInt(PH_ID_OUTGOING,&Talk);
PHGetInt(PH_ID_TALKING,&OutGo);
PHGetInt(PH_ID_HELD,&Held);
if((Talk > 0)||(OutGo>0))

...{
Draw_Talk(hWnd,TRUE);
}
else if(Held > 0)

...{
Draw_Talk(hWnd,TRUE);
}
break;
case IDC_ACCUMULATOR:
PHGetInt(PH_ID_HELD,&Held);
PHGetDWORD(PH_ID_ACCUMULATOR_EMPTY, &Acc);
if((Held > 0)&&(Acc == 1))

...{
Draw_Talk(hWnd,TRUE);
}
else if((Held > 0)&&(Acc == 0))

...{
Draw(hWnd,BUTTON_TALKEND,FALSE);
}
break;
case IDC_CALLSTATE:
PHGetInt(PH_ID_OUTGOING,&OutGo);
PHGetInt(PH_ID_TALKING,&Talk);
PHGetInt(PH_ID_INCOMING,&InCom);
if((OutGo == 0)&&(Talk == 0)&&(InCom == 0))

...{
Draw(hWnd,BUTTON_TALKEND,FALSE);
}
break;
}
}
break;
case WM_LBUTTONDOWN:

...{
x_pos = (((DWORD)lParam)&0xFFFF);
y_pos = (((DWORD)lParam) >> 16);

dnum = InRect(x_pos,y_pos);

switch(dnum)

...{
case BUTTON_ZERO:
case BUTTON_ONE:
case BUTTON_TWO:
case BUTTON_THREE:
case BUTTON_FOUR:
case BUTTON_FIVE:
case BUTTON_SIX:
case BUTTON_SEVEN:
case BUTTON_EIGHT:
case BUTTON_NINE:
case BUTTON_STAR:
case BUTTON_POUND:
num.vkKeyCode = vkKeyCode[dnum];
num.ksKeyState = PH_KEYSTATE_DOWN;
PHDoVerb(PH_VERB_ADD_ACCUMULATOR ,FALSE,(VPARAM)(&num));
Draw(hWnd,dnum,TRUE);
breturn = TRUE;
break;
case BUTTON_HISTORY:
hd = GetDlgItem(hWnd,IDC_HISTORY);
SendMessage(hd,WM_LBUTTONDOWN,0,0);
Draw(hWnd,dnum,TRUE);
breturn = TRUE;
break;
case BUTTON_TALKEND:
PHGetInt(PH_ID_TALKING,&Talk);
PHGetInt(PH_ID_HELD,&Held);
PHGetDWORD(PH_ID_ACCUMULATOR_EMPTY, &Acc);
PHGetInt(PH_ID_OUTGOING,&OutGo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if(OutGo > 0)

...{
PHDoVerb(PH_VERB_END ,FALSE,0);
Draw_Talk(hWnd,FALSE);
}
else if((Held > 0)&&(Held < Connect))

...{
PHDoVerb(PH_VERB_END ,FALSE,0);
Draw_Talk(hWnd,FALSE);
}
else if((Held > 0)&&(Held == Connect)&&(Acc == 1))

...{
PHDoVerb(PH_VERB_END ,FALSE,0);
Draw_Talk(hWnd,FALSE);
}
else if((Held > 0)&&(Held == Connect)&&(Acc == 0))

...{
PHDoVerb(PH_VERB_TALK ,FALSE,0);
Draw(hWnd,dnum,TRUE);
}
else if((Held == 0)&&(Connect > 0))

...{
PHDoVerb(PH_VERB_END ,FALSE,0);
Draw(hWnd,dnum,TRUE);
}
else

...{
PHDoVerb(PH_VERB_TALK ,FALSE,0);
Draw(hWnd,dnum,TRUE);
}
breturn = TRUE;
break;
case BUTTON_SPEED:
hd = GetDlgItem(hWnd,IDC_SPEED);
SendMessage(hd,WM_LBUTTONDOWN,0,0);
Draw(hWnd,dnum,TRUE);
breturn = TRUE;
break;
case BUTTON_ERASE:
Draw(hWnd,dnum,TRUE);
shrg.cbSize = sizeof(shrg);
shrg.hwndClient = hWnd;
shrg.ptDown.x = LOWORD(lParam);
shrg.ptDown.y = HIWORD(lParam);
shrg.dwFlags = SHRG_RETURNCMD|
SHRG_NOANIMATION;
if (SHRecognizeGesture(&shrg) == GN_CONTEXTMENU)

...{
hr = PHDoVerb(PH_VERB_REMOVE_ACCUMULATOR ,FALSE,TRUE);
}
else

...{
hr = PHDoVerb(PH_VERB_REMOVE_ACCUMULATOR ,FALSE,FALSE);
}
breturn = TRUE;
break;
default:
break;
}
}
break;
case WM_LBUTTONUP:

...{
x_pos = (((DWORD)lParam)&0xFFFF);
y_pos = (((DWORD)lParam) >> 16);
dnum = InRect(x_pos,y_pos);
switch(dnum)

...{
case BUTTON_ZERO:
case BUTTON_ONE:
case BUTTON_TWO:
case BUTTON_THREE:
case BUTTON_FOUR:
case BUTTON_FIVE:
case BUTTON_SIX:
case BUTTON_SEVEN:
case BUTTON_EIGHT:
case BUTTON_NINE:
case BUTTON_STAR:
case BUTTON_POUND:
case BUTTON_HISTORY:
case BUTTON_SPEED:
case BUTTON_ERASE:
Draw(hWnd,dnum,FALSE);
breturn = TRUE;
break;
case BUTTON_TALKEND:
PHGetInt(PH_ID_TALKING,&OutGo);
PHGetInt(PH_ID_HELD,&Held);
PHGetDWORD(PH_ID_ACCUMULATOR_EMPTY, &Acc);
PHGetInt(PH_ID_OUTGOING,&Talk);
PHGetInt(PH_ID_CONNECTED,&Connect);
if(Held > 0)

...{
Draw_Talk(hWnd,TRUE);
}
else

...{
Draw(hWnd,dnum,FALSE);
}
breturn = TRUE;
break;
default:
break;
}
}
break;
default:
break;
}
return breturn;
}
void
GetRect_Pro(HWND hWnd)

...
{

DWORD BUTTON[6] = ...{
IDC_HISTORY_SPEAKER,
IDC_MUTE,
IDC_HOLDSWAP,
IDC_TALKEND,
IDC_CONTACTS,
IDC_NOTEPAD,
};
HWND hd = NULL;
for(int i = 0; i <= 5; i++)

...{
hd = GetDlgItem(hWnd,BUTTON[i]);
::GetClientRect(hd,&disRect_Pro[i]);
::GetWindowRect(hd,&WndPosRect_Pro[i]);
}
RECT_Mark_Pro = TRUE;
}

DWORD InRect_Pro(DWORD x_pos,DWORD y_pos)

...
{

POINT Point = ...{0,0};
Point.x = x_pos;
Point.y = y_pos;

RECT Rect = ...{0};
for(DWORD i = 0; i <= 5; i++)

...{
Rect.bottom = WndPosRect_Pro[i].bottom - 26;
Rect.top = WndPosRect_Pro[i].top - 26;
Rect.left = WndPosRect_Pro[i].left;
Rect.right = WndPosRect_Pro[i].right;
if(PtInRect(&Rect,Point))

...{
return i;
}
}
return 100;
}

BOOL PHExtplpfnHookPro(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

...
{
HWND hd = NULL;
BOOL breturn = FALSE;
DWORD x_pos;
DWORD y_pos;

int Outgo = 0;
int Connect = 0;
DWORD Acc = 1;
DWORD dnum;

DWORD Speaker = 0;
int Held = 0;
int Talk = 0;

if(RECT_Mark_Pro == FALSE)

...{
GetRect_Pro(hWnd);
}

switch(Msg)

...{
case WM_PH_PAINTCHILDBACKGROUND:

...{
switch(GetDlgCtrlID((HWND)wParam))

...{
case IDC_MUTE:
case IDC_CONTACTS:
case IDC_NOTEPAD:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
breturn = TRUE;
break;
case IDC_HISTORY_SPEAKER:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
getRegSPEAKER(&Speaker);
if(Speaker == 0)

...{
Draw_Pro(hWnd,0,TRUE);
}
else

...{
Draw_Pro_SP(hWnd,SP_LIGHT);
}
}
else

...{
Draw_Pro_SP(hWnd,SP_HIS_LIGHT);
}
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
breturn = TRUE;
break;
case IDC_TALKEND:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
}
else

...{
Draw_Pro_Talk(hWnd,TALK_LIGHT);
}
breturn = TRUE;
break;
case IDC_HOLDSWAP:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
breturn = TRUE;
PHGetInt(PH_ID_CONNECTED,&Connect);
PHGetInt(PH_ID_HELD,&Held);
if((Held == 1)&&(Connect == Held))

...{
Draw_Pro_Held(hWnd,HELD_RESUME_LIGHT);
}
else if((Held == 1)&&(Connect > Held))

...{
Draw_Pro_Held(hWnd,HELD_SWAP_LIGHT);
}
else

...{
Draw_Pro_Held(hWnd,HELD_ASH);
}
break;
case IDC_CALLSTATE:
PHGetInt(PH_ID_TALKING,&Talk);
PHGetInt(PH_ID_HELD,&Held);
PHGetDWORD(PH_ID_ACCUMULATOR_EMPTY, &Acc);
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
getRegSPEAKER(&Speaker);
if((Held == 1)&&(Connect == 1))

...{
Draw_Pro_Held(hWnd,HELD_RESUME_LIGHT);
}
else if((Held == 1)&&(Connect > Held))

...{
Draw_Pro_Held(hWnd,HELD_SWAP_LIGHT);
}
else if(Connect == 0)

...{
Draw_Pro_Held(hWnd,HELD_ASH);
}
if((Connect == 0)&&(Outgo == 0))

...{
Draw_Pro_Mute(hWnd, MUTE_ASH);
}
else if(Mute == TRUE)

...{
Draw_Pro(hWnd,BUTTON_MUTE_PRO,TRUE);
}
else

...{
Draw_Pro_Mute(hWnd,MUTE_LIGHT);
}
if((Connect == 0)&&(Outgo == 0))

...{
Draw_Pro_SP(hWnd,SP_HIS_LIGHT);
}
else if(Speaker == 1)

...{
Draw_Pro_SP(hWnd,SP_LIGHT);
}
else

...{
Draw_Pro(hWnd,BUTTON_SPEAKER_PRO,TRUE);
}
if((Outgo == 0)&&(Connect == 0))

...{
Draw_Pro_Talk(hWnd,TALK_LIGHT);
}
else if((Acc == 0)&&(Held == Connect)&&(Outgo == 0))

...{
Draw_Pro_Talk(hWnd, TALK_LIGHT);
}
break;
case IDC_BRANDING:
PHGetInt(PH_ID_TALKING,&Talk);
PHGetInt(PH_ID_HELD,&Held);
PHGetDWORD(PH_ID_ACCUMULATOR_EMPTY, &Acc);
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
getRegSPEAKER(&Speaker);
if((Held == 1)&&(Connect == 1))

...{
Draw_Pro_Held(hWnd,HELD_RESUME_LIGHT);
}
else if((Held == 1)&&(Connect > Held))

...{
Draw_Pro_Held(hWnd,HELD_SWAP_LIGHT);
}
else if(Connect == 0)

...{
Draw_Pro_Held(hWnd,HELD_ASH);
}
if((Connect == 0)&&(Outgo == 0))

...{
Draw_Pro_Mute(hWnd, MUTE_ASH);
}
else if(Mute == TRUE)

...{
Draw_Pro(hWnd,BUTTON_MUTE_PRO,TRUE);
}
else

...{
Draw_Pro_Mute(hWnd,MUTE_LIGHT);
}
if((Connect == 0)&&(Outgo == 0))

...{
Draw_Pro_SP(hWnd,SP_HIS_LIGHT);
}
else if(Speaker == 1)

...{
Draw_Pro_SP(hWnd,SP_LIGHT);
}
else

...{
Draw_Pro(hWnd,BUTTON_SPEAKER_PRO,TRUE);
}

if((Outgo == 0)&&(Connect == 0))

...{
Draw_Pro_Talk(hWnd,TALK_LIGHT);
}
else if((Acc == 0)&&(Held == Connect)&&(Outgo == 0))

...{
Draw_Pro_Talk(hWnd, TALK_LIGHT);
}
break;

case IDC_STATUSAREA:
PHGetInt(PH_ID_HELD,&Held);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Connect == 1)&&(Held == 0))

...{
Draw_Pro(hWnd,BUTTON_HOLDSWAP_PRO,TRUE);
}
break;
}
}
break;
case WM_LBUTTONDOWN:

...{
x_pos = (((DWORD)lParam)&0xFFFF);
y_pos = (((DWORD)lParam) >> 16);

dnum = InRect_Pro(x_pos,y_pos);
switch(dnum)

...{
case BUTTON_SPEAKER_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
getRegSPEAKER(&Speaker);
if(Speaker)

...{
Draw_Pro_SP(hWnd,SP_DARK);
PHDoVerb(PH_VERB_SPEAKERPHONEOFF,FALSE,FALSE);
setRegSPEAKER(0);
}
else

...{
Draw_Pro(hWnd,dnum,FALSE);
PHDoVerb(PH_VERB_SPEAKERPHONEON,FALSE,FALSE);
setRegSPEAKER(1);
}
}
else

...{
Draw_Pro_SP(hWnd,SP_HIS_DARK);
hd = GetDlgItem(hWnd,IDC_HISTORY_SPEAKER);
SendMessage(hd,WM_LBUTTONDOWN,0,0);
}
break;
case BUTTON_MUTE_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
if(Mute)

...{
Draw_Pro(hWnd,dnum,FALSE);
PHDoVerb(PH_VERB_MUTE,FALSE,FALSE);
}
else

...{
Draw_Pro(hWnd,BUTTON_MUTE_PRO,FALSE);
PHDoVerb(PH_VERB_UNMUTE,FALSE,FALSE);
}
}
break;
case BUTTON_HOLDSWAP_PRO:
PHGetInt(PH_ID_CONNECTED,&Connect);
PHGetInt(PH_ID_HELD,&Held);
if((Connect == 1)&&(Held == 0))

...{
Draw_Pro(hWnd,dnum,FALSE);
PHDoVerb(PH_VERB_HOLD,FALSE,FALSE);
}
else if((Connect == 1)&&(Held == 1))

...{
Draw_Pro_Held(hWnd,HELD_RESUME_DARK);
PHDoVerb(PH_VERB_UNHOLD,FALSE,FALSE);
}
else if(Connect >= 2)

...{
Draw_Pro_Held(hWnd,HELD_SWAP_DARK);
PHDoVerb(PH_VERB_SWAP,FALSE,FALSE);
}
break;
case BUTTON_TALKEND_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
Draw_Pro(hWnd,dnum,FALSE);
PHDoVerb(PH_VERB_END ,FALSE,FALSE);
Mute = TRUE;
}
else

...{
Draw_Pro_Talk(hWnd,TALK_DARK);
PHDoVerb(PH_VERB_TALK ,FALSE,FALSE);
}
break;
case BUTTON_CONTACTS_PRO:
hd = GetDlgItem(hWnd,IDC_CONTACTS);
SendMessage(hd,WM_LBUTTONDOWN,0,0);
Draw_Pro(hWnd,dnum,FALSE);
break;
case BUTTON_NOTEPAD_PRO:
hd = GetDlgItem(hWnd,IDC_NOTEPAD);
SendMessage(hd,WM_LBUTTONDOWN,0,0);
Draw_Pro(hWnd,dnum,FALSE);
break;
}
}
break;
case WM_LBUTTONUP:

...{
x_pos = (((DWORD)lParam)&0xFFFF);
y_pos = (((DWORD)lParam) >> 16);
dnum = InRect_Pro(x_pos,y_pos);
switch(dnum)

...{
case BUTTON_SPEAKER_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
getRegSPEAKER(&Speaker);
if(Speaker)

...{
Draw_Pro_SP(hWnd,SP_LIGHT);
}
else

...{
Draw_Pro(hWnd,dnum,TRUE);
}
}
else

...{
Draw_Pro_SP(hWnd,SP_HIS_LIGHT);
}
break;
case BUTTON_MUTE_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
if(Mute)

...{
Draw_Pro_Mute(hWnd,MUTE_LIGHT);
Mute = FALSE;
}
else

...{
Draw_Pro(hWnd,dnum,TRUE);
Mute = TRUE;
}
}
break;
case BUTTON_HOLDSWAP_PRO:
PHGetInt(PH_ID_CONNECTED,&Connect);
PHGetInt(PH_ID_HELD,&Held);
if((Connect == 1)&&(Held == 0))

...{
Draw_Pro_Held(hWnd,HELD_RESUME_LIGHT);
}
else if((Connect == 1)&&(Held == 1))

...{
Draw_Pro(hWnd,dnum,TRUE);
}
else if(Connect >= 2)

...{
Draw_Pro_Held(hWnd,HELD_SWAP_LIGHT);
}
break;
case BUTTON_TALKEND_PRO:
PHGetInt(PH_ID_OUTGOING,&Outgo);
PHGetInt(PH_ID_CONNECTED,&Connect);
if((Outgo > 0)||(Connect > 0))

...{
Draw_Pro(hWnd,dnum,TRUE);
}
else

...{
Draw_Pro_Talk(hWnd,TALK_LIGHT);
}
break;
case BUTTON_CONTACTS_PRO:
Draw_Pro(hWnd,dnum,TRUE);
break;
case BUTTON_NOTEPAD_PRO:
Draw_Pro(hWnd,dnum,TRUE);
break;
}
}
break;
}
return breturn;
}


void
GetRect_In(HWND hWnd)

...
{
::GetWindowRect(hWnd,&WndPosRect_In[10]);

HWND hd = NULL;
hd = GetDlgItem(hWnd,IDC_BRANDING);
::GetClientRect(hd,&disRect_In[0]);
::GetWindowRect(hd,&WndPosRect_In[0]);

hd = GetDlgItem(hWnd,IDC_STATUSICONS);
::GetClientRect(hd,&disRect_In[1]);
::GetWindowRect(hd,&WndPosRect_In[1]);

hd = GetDlgItem(hWnd,IDC_LINEUI);
::GetClientRect(hd,&disRect_In[2]);
::GetWindowRect(hd,&WndPosRect_In[2]);

hd = GetDlgItem(hWnd,IDC_INCOMINGCALL_TEXT);
::GetClientRect(hd,&disRect_In[3]);
::GetWindowRect(hd,&WndPosRect_In[3]);

hd = GetDlgItem(hWnd,IDC_CALERTCONTACT);
::GetClientRect(hd,&disRect_In[4]);
::GetWindowRect(hd,&WndPosRect_In[4]);

hd = GetDlgItem(hWnd,IDC_CALERTLAYOUTHELPER);
::GetClientRect(hd,&disRect_In[5]);
::GetWindowRect(hd,&WndPosRect_In[5]);

hd = GetDlgItem(hWnd,IDC_CALERTCONTACTPICTURE);
::GetClientRect(hd,&disRect_In[6]);
::GetWindowRect(hd,&WndPosRect_In[6]);

hd = GetDlgItem(hWnd,IDC_GSM);
::GetClientRect(hd,&disRect_In[7]);
::GetWindowRect(hd,&WndPosRect_In[7]);

hd = GetDlgItem(hWnd,IDC_COMIN);
::GetClientRect(hd,&disRect_In[8]);
::GetWindowRect(hd,&WndPosRect_In[8]);

hd = GetDlgItem(hWnd,IDC_NUM);
::GetClientRect(hd,&disRect_In[9]);
::GetWindowRect(hd,&WndPosRect_In[9]);


RECT_Mark_In = TRUE;
}
BOOL PHExtplpfnHookIn(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

...
{
BOOL miao = FALSE;
if(RECT_Mark_In == FALSE)

...{
GetRect_In(hWnd);
}
HWND hd = NULL;
HDC hDC = NULL;
//HWND HWND = NULL;

TCHAR text[MAX_PATH]=...{0};
switch(Msg)

...{
case WM_PH_PAINTCHILDBACKGROUND:

...{
switch(GetDlgCtrlID((HWND)wParam))

...{
case IDC_BRANDING:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
case IDC_STATUSICONS:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
case IDC_LINEUI:
break;
case IDC_INCOMINGCALL_TEXT:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
case IDC_CALERTCONTACT:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
case IDC_CALERTLAYOUTHELPER:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
case IDC_CALERTCONTACTPICTURE:
hd = (HWND)wParam;
ShowWindow(hd,FALSE);
break;
default:
break;
}
}
break;
case WM_ERASEBKGND:
Draw_In(hWnd);
miao = TRUE;
break;

case WM_CTLCOLORSTATIC:
switch(GetDlgCtrlID((HWND)lParam))

...{
case IDC_GSM:
hd = GetDlgItem(hWnd, IDC_BRANDING);
SendMessage(hd,WM_GETTEXT,MAX_PATH,(LPARAM)(LPCTSTR)text);
//SetBkMode((HDC)wParam, TRANSPARENT);
SetBkColor((HDC)wParam,RGB(255,0,0));
ExtTextOut((HDC)wParam,0,0,ETO_OPAQUE,&disRect_In[7],text,wcslen(text),0);
miao = TRUE;
break;
case IDC_COMIN:
hd = GetDlgItem(hWnd, IDC_INCOMINGCALL_TEXT);
//SetBkMode((HDC)wParam, TRANSPARENT);
SendMessage(hd,WM_GETTEXT,MAX_PATH,(LPARAM)(LPCTSTR)text);
SetBkColor((HDC)wParam,RGB(255,0,0));
ExtTextOut((HDC)wParam,0,0,ETO_OPAQUE,&disRect_In[8],text,wcslen(text),0);
miao = TRUE;
break;
case IDC_NUM:
hd = GetDlgItem(hWnd, IDC_CALERTCONTACT);
SendMessage(hd,WM_GETTEXT,MAX_PATH,(LPARAM)(LPCTSTR)text);
//SetBkMode((HDC)wParam, TRANSPARENT);
SetBkColor((HDC)wParam,RGB(255,0,0));
ExtTextOut((HDC)wParam,0,0,ETO_OPAQUE,&disRect_In[9],text,wcslen(text),0);
miao = TRUE;
break;
}
break;
}
return miao;
}

void
Draw_In(HWND hWnd)

...
{
HBITMAP hBmpOwn = NULL;
HDC hDC = NULL;
HDC hCompDC = NULL;
HDC hScreenDC = NULL;
RECT distRect_draw;
//RECT WndPosRect_draw;
BOOL nResult = TRUE;
HWND hd = NULL;

hDC = ::GetDC(hWnd);
hCompDC = CreateCompatibleDC(hDC);
hScreenDC = CreateCompatibleDC(::GetDC(NULL));

distRect_draw = WndPosRect_In[10];

SelectObject(hScreenDC, hBmp_In);

hBmpOwn = CreateBitmap (distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
1,
32,
NULL);
SelectObject(hCompDC,hBmpOwn);

nResult = BitBlt(hDC,
0,
0,
distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
hScreenDC,
0,
0,
SRCCOPY);

DeleteDC(hCompDC);
DeleteDC(hScreenDC);
}

void
Draw_In_IDC(HWND hWnd,DWORD dnum)

...
{
HBITMAP hBmpOwn = NULL;
HDC hDC = NULL;
HDC hCompDC = NULL;
HDC hScreenDC = NULL;
RECT distRect_draw;
RECT WndPosRect_draw;
BOOL nResult = TRUE;
HWND hd = NULL;

hDC = ::GetDC(hWnd);
hCompDC = CreateCompatibleDC(hDC);
hScreenDC = CreateCompatibleDC(::GetDC(NULL));

distRect_draw = disRect_In[dnum];
distRect_draw.top = distRect_draw.top + WndPosRect_In[dnum].top-165;
distRect_draw.bottom = distRect_draw.bottom + WndPosRect_In[dnum].top-165;
distRect_draw.left = distRect_draw.left + WndPosRect_In[dnum].left;
distRect_draw.right = distRect_draw.right + WndPosRect_In[dnum].left;

WndPosRect_draw = WndPosRect_In[dnum];
WndPosRect_draw.top = WndPosRect_draw.top-165;

SelectObject(hScreenDC, hBmp_In);
hBmpOwn = CreateBitmap (distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
1,
32,
NULL);
SelectObject(hCompDC,hBmpOwn);

nResult = BitBlt(hDC,
0,
0,
distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
hScreenDC,
WndPosRect_draw.left,
WndPosRect_draw.top,//-220,
SRCCOPY);
DeleteDC(hCompDC);
DeleteDC(hScreenDC);
}

void
Draw(HWND hWnd,DWORD dnum,BOOL Mark)

...
{
HBITMAP hBmpOwn = NULL;
HDC hDC = NULL;
HDC hCompDC = NULL;
HDC hScreenDC = NULL;
RECT distRect_draw;
RECT WndPosRect_draw;
BOOL nResult = TRUE;
HWND hd = NULL;

hDC = ::GetDC(hWnd);
hCompDC = CreateCompatibleDC(hDC);
hScreenDC = CreateCompatibleDC(::GetDC(NULL));

distRect_draw = distRect[dnum];
distRect_draw.top = distRect_draw.top + WndPosRect[dnum].top - 26;
distRect_draw.bottom = distRect_draw.bottom + WndPosRect[dnum].top - 26;
distRect_draw.left = distRect_draw.left + WndPosRect[dnum].left;
distRect_draw.right = distRect_draw.right + WndPosRect[dnum].left;

WndPosRect_draw = WndPosRect[dnum];
WndPosRect_draw.top = WndPosRect_draw.top-26;

if(Mark)

...{
SelectObject(hScreenDC, hBmp);
}
else

...{
SelectObject(hScreenDC, hBmp_Inv);
}
hBmpOwn = CreateBitmap (distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
1,
32,
NULL);
SelectObject(hCompDC,hBmpOwn);
nResult = BitBlt(hDC,
distRect_draw.left,
distRect_draw.top,
distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
hScreenDC,
WndPosRect_draw.left,
WndPosRect_draw.top,
SRCCOPY);
DeleteDC(hCompDC);
DeleteDC(hScreenDC);
}

void
Draw_Pro(HWND hWnd,DWORD dnum,BOOL Mark)

...
{
HBITMAP hBmpOwn = NULL;
HDC hDC = NULL;
HDC hCompDC = NULL;
HDC hScreenDC = NULL;
RECT distRect_draw;
RECT WndPosRect_draw;
BOOL nResult = TRUE;
HWND hd = NULL;

hDC = ::GetDC(hWnd);
hCompDC = CreateCompatibleDC(hDC);
hScreenDC = CreateCompatibleDC(::GetDC(NULL));

distRect_draw = disRect_Pro[dnum];
distRect_draw.top = distRect_draw.top + WndPosRect_Pro[dnum].top - 26;
distRect_draw.bottom = distRect_draw.bottom + WndPosRect_Pro[dnum].top - 26;
distRect_draw.left = distRect_draw.left + WndPosRect_Pro[dnum].left;
distRect_draw.right = distRect_draw.right + WndPosRect_Pro[dnum].left;

WndPosRect_draw = WndPosRect_Pro[dnum];
WndPosRect_draw.top = WndPosRect_draw.top-26;
if(Mark)

...{
SelectObject(hScreenDC, hBmp_Pro);
}
else

...{
SelectObject(hScreenDC, hBmp_Inv_Pro);
}
hBmpOwn = CreateBitmap (distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
1,
32,
NULL);
SelectObject(hCompDC,hBmpOwn);

nResult = BitBlt(hDC,
distRect_draw.left,
distRect_draw.top,
distRect_draw.right-distRect_draw.left,
distRect_draw.bottom-distRect_draw.top,
hScreenDC,
WndPosRect_draw.left,
WndPosRect_draw.top,
SRCCOPY);
DeleteDC(hCompDC);
DeleteDC(hScreenDC);
}


//
替换通话的界面(TRUE是亮的,FALSE是暗的)
void
Draw_Talk(HWND hWnd,BOOL Mark)

...
{
HBITMAP hButton = NULL;

RECT distRect_button = distRect[BUTTON_TALKEND];
RECT WndPosRec_button = WndPosRect[BUTTON_TALKEND];

if(Mark)

...{
hButton = hBmp_Talk;
}
else

...{
hButton = hBmp_Inv_Talk;
}
Draw_Button(hWnd,distRect_button,WndPosRec_button,hButton);
}


//
替换通话的界面(TRUE是亮的,FALSE是暗的)
void
Draw_Pro_Talk(HWND hWnd,BOOL Mark)

...
{
HBITMAP hButton = NULL;

RECT distRect_button = disRect_Pro[BUTTON_TALKEND_PRO];
RECT WndPosRec_button = WndPosRect_Pro[BUTTON_TALKEND_PRO];

if(Mark)

...{
hButton = hBmp_Pro_Talk;
}
else

...{
hButton = hBmp_Inv_Pro_Talk;
}
Draw_Button(hWnd,distRect_button,WndPosRec_button,hButton);
}

void
Draw_Pro_Mute(HWND hWnd, DWORD Mark)

...
{
HBITMAP hButton = NULL;

RECT distRect_button = disRect_Pro[BUTTON_MUTE_PRO];
RECT WndPosRec_button = WndPosRect_Pro[BUTTON_MUTE_PRO];

if(Mark == 1)

...{
hButton = hBmp_Pro_Mute;
}
else if(Mark == 2)

...{
hButton = hBmp_Inv_Pro_Mute;
}
else

...{
hButton = hBmp_Un_Pro_Mute;
}
Draw_Button(hWnd,distRect_button,WndPosRec_button,hButton);
}

//
扬声器按钮
void
Draw_Pro_SP(HWND hWnd, DWORD Mark)

...
{
HBITMAP hButton = NULL;

RECT distRect_button = disRect_Pro[BUTTON_SPEAKER_PRO];
RECT WndPosRec_button = WndPosRect_Pro[BUTTON_SPEAKER_PRO];

if(Mark == 1)

...{
hButton = hBmp_Pro_SP;
}
else if(Mark == 2)

...{
hButton = hBmp_Inv_Pro_SP;
}
else if(Mark == 3)

...{
hButton = hBmp_Pro_His;
}
else

...{
hButton = hBmp_Inv_Pro_His;
}
Draw_Button(hWnd,distRect_button,WndPosRec_button,hButton);
}
void
Draw_Pro_Held(HWND hWnd, DWORD Mark)

...
{
HBITMAP hButton;
RECT distRect_button = disRect_Pro[BUTTON_HOLDSWAP_PRO];
RECT WndPosRec_button = WndPosRect_Pro[BUTTON_HOLDSWAP_PRO];

if(Mark == 1)

...{
hButton = hBmp_Pro_Held;
}
else if(Mark == 2)

...{
hButton = hBmp_Inv_Pro_Held;
}
else if(Mark == 3)

...{
hButton = hBmp_Pro_Swap;
}
else if(Mark == 4)

...{
hButton = hBmp_Inv_Pro_Swap;
}
else

...{
hButton = hBmp_Un_Pro_Held;
}

Draw_Button(hWnd,distRect_button,WndPosRec_button,hButton);
}

void
Draw_Button(HWND hWnd, RECT distRect_button, RECT WndPosRec_button, HBITMAP hButton)

...
{
HBITMAP hBmpOwn = NULL;
HDC hDC = NULL;
HDC hCompDC = NULL;
HDC hScreenDC = NULL;
BOOL nResult = TRUE;
HWND hd = NULL;

hDC = ::GetDC(hWnd);
hCompDC = CreateCompatibleDC(hDC);
hScreenDC = CreateCompatibleDC(::GetDC(NULL));

SelectObject(hScreenDC, hButton);

hBmpOwn = CreateBitmap (distRect_button.right-distRect_button.left,
distRect_button.bottom-distRect_button.top,
1,
32,
NULL);
SelectObject(hCompDC,hBmpOwn);
distRect_button.top = distRect_button.top + WndPosRec_button.top - 26;
distRect_button.bottom = distRect_button.bottom + WndPosRec_button.top - 26;
distRect_button.left = distRect_button.left + WndPosRec_button.left;
distRect_button.right = distRect_button.right + WndPosRec_button.left;

nResult = BitBlt(hDC,
distRect_button.left,
distRect_button.top,
distRect_button.right-distRect_button.left,
distRect_button.bottom-distRect_button.top,
hScreenDC,
0,
0,
SRCCOPY);
DeleteDC(hCompDC);
DeleteDC(hScreenDC);
}


BOOL setRegSPEAKER(DWORD Speaker)
//

...
{
LONG lRet = 0;
HKEY hkey = NULL;
LPDWORD lpDword = NULL;
LPWSTR lpszSubKey = REG_SPEAKER;
DWORD tValue = Speaker;
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,REG_SPEAKER,0,0,&hkey);

if(lRet != ERROR_SUCCESS) ...{
lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,lpszSubKey,0,lpszSubKey,REG_OPTION_NON_VOLATILE,0,NULL,&hkey,lpDword);
if(lRet != ERROR_SUCCESS)

...{
MessageBox(NULL,_T("Error"),_T("注册表不可写!"),MB_OK);
return FALSE;
}
}
lRet = RegSetValueEx(hkey,lpszSubKey,0,REG_DWORD,(LPBYTE)(&tValue),sizeof(DWORD));
if(lRet != ERROR_SUCCESS)

...{
RegCloseKey(hkey);
MessageBox(NULL,_T("Error"),_T("注册表不可写!"),MB_OK);
return FALSE;
}
RegCloseKey(hkey);
return TRUE;
}
BOOL getRegSPEAKER(DWORD
*
Speaker)

...
{
LONG lRet = 0;
HKEY hkey = NULL;
DWORD dwType = 0;
DWORD tValue = 0;
DWORD cbData = sizeof(DWORD);
DWORD temp = 1;
//取模式,动作
lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,REG_SPEAKER,0,0,&hkey);
if(lRet != ERROR_SUCCESS)

...{
temp = 1;
*Speaker = temp;
return TRUE;
}
lRet = RegQueryValueEx(hkey,REG_SPEAKER,NULL,&dwType,(LPBYTE)(&tValue),&cbData);
if(lRet == ERROR_SUCCESS)

...{
*Speaker = tValue;
RegCloseKey(hkey);
return TRUE;
}
else

...{
RegCloseKey(hkey);
return FALSE;
}
}
extern
"
C
"
HRESULT PHExtGetPhoneViewInfo(PH_VIEW view, HINSTANCE
*
phInstance, PH_VIEWINFOFLAGS
*
pvif, LPPHONEVIEWHOOKPROC
*
plpfnHook, LPCTSTR
*
plpTemplateName)

...
{
HRESULT hr = E_NOTIMPL;
//win = 0;
if(PH_VIEW_DIALER == view)

...{
switch(*pvif)

...{
case PH_VIF_PORTRAIT:
// Specify a dialer portrait view dialog template
*phInstance = g_hInst;
//enable PHExtplpfnHook
*pvif = (PH_VIEWINFOFLAGS) (*pvif | PH_VIF_ENABLEHOOK);
*plpTemplateName = MAKEINTRESOURCE(IDD_CDIALER_PORT);
*plpfnHook = (LPPHONEVIEWHOOKPROC)PHExtplpfnHook;
LoadImage(&hBmp,L"/Windows/PcvDialerBkP_Inv.bmp");
LoadImage(&hBmp_Inv,L"/Windows/PcvDialerBkP.bmp");
LoadImage(&hBmp_Talk,L"/Windows/PcvDialerEndL.bmp");
LoadImage(&hBmp_Inv_Talk,L"/Windows/PcvDialerEndL_At.bmp");
hr = S_OK;
break;
}
}
if(PH_VIEW_PROGRESS == view)

...{
switch(*pvif)

...{
case PH_VIF_PORTRAIT:
// Specify a dialer portrait view dialog template
*phInstance = g_hInst;
//enable PHExtplpfnHook
*pvif = (PH_VIEWINFOFLAGS) (*pvif | PH_VIF_ENABLEHOOK);
*plpTemplateName = MAKEINTRESOURCE(IDD_CPROG_PORT);
*plpfnHook = (LPPHONEVIEWHOOKPROC)PHExtplpfnHookPro;
LoadImage(&hBmp_Pro,L"/Windows/PcvProgBkP.bmp");
LoadImage(&hBmp_Inv_Pro,L"/Windows/PcvProgBkP_Inv.bmp");
LoadImage(&hBmp_Pro_Talk,L"/Windows/PcvProgTalk.bmp");
LoadImage(&hBmp_Inv_Pro_Talk,L"/Windows/PcvProgTalk_At.bmp");

LoadImage(&hBmp_Pro_Mute,L"/Windows/PcvProgUnmute.bmp");
LoadImage(&hBmp_Inv_Pro_Mute,L"/Windows/PcvProgUnmute_At.bmp");
LoadImage(&hBmp_Un_Pro_Mute,L"/Windows/VbBtnUp_Port.bmp");

LoadImage(&hBmp_Pro_SP,L"/Windows/PcvProgSpeakeroff.bmp");
LoadImage(&hBmp_Inv_Pro_SP,L"/Windows/PcvProgSpeakeroff_At.bmp");
LoadImage(&hBmp_Pro_His,L"/Windows/PcvProgCallhistory.bmp");
LoadImage(&hBmp_Inv_Pro_His,L"/Windows/PcvProgCallhistory_At.bmp");

LoadImage(&hBmp_Pro_Held,L"/Windows/PcvProgUnhold.bmp");
LoadImage(&hBmp_Inv_Pro_Held,L"/Windows/PcvProgUnhold_At.bmp");
LoadImage(&hBmp_Pro_Swap,L"/Windows/PcvProgSwap.bmp");
LoadImage(&hBmp_Inv_Pro_Swap,L"/Windows/PcvProgSwap_At.bmp");
LoadImage(&hBmp_Un_Pro_Held,L"/Windows/VbBtnUp_Port_Held.bmp");


hr = S_OK;
break;
}
}
//只有整个背景换掉了,还有控件的背景没有换掉,所以没有用
if(PH_VIEW_INCOMING == view)

...{

/**//*
switch(*pvif)
{
case PH_VIF_PORTRAIT:
*phInstance = g_hInst;
//enable PHExtplpfnHook
*pvif = (PH_VIEWINFOFLAGS) (*pvif | PH_VIF_ENABLEHOOK);
*plpTemplateName = MAKEINTRESOURCE(IDD_CALERT);
*plpfnHook = (LPPHONEVIEWHOOKPROC)PHExtplpfnHookIn;
LoadImage(&hBmp_In,L"/Windows/PcvIn.bmp");//亮的
hr = S_OK;
break;
}
*/
}
return hr;
}




实在太长了,一次贴不完
可以实现每个按钮的图片大小,位置自定义,背景也可以自定义,支持横屏
改天发对应的inf和图片定义,source和makefile
发表于 @ 2006年12月06日 19:15:00 | | 编辑| 举报| 收藏