C++ Windows Mobile 6 Professional [27.11.2011]

Windows Mobile. ETEN Glofiish X800. , .

, , , , , . . .

Win32 . , , . , . .

X800 . , . , , , , .

Visual Studio 2008 . , MyMobilDial.sln, Rebuild solution. Deploy solution Windows Mobile 6.1, Windows Mobile Professional 6 Emulator. . ( ), .

.

MyMobilDial.cpp

. . .

//
wchar_t* pref[]={L"050", L"066", L"095", L"0990", L"0992",
L"0993", L"0994", L"0995", L"0998", L"0999", //MTS
L"0991", L"0996", L"0997", // MTS
L"067", L"096", L"097", L"098", //
L"063", L"093", //Life
L"068", //Beeline
L"039", //
L"094", //
L"092", //PeopleNet
L"091", //U'tel
NULL};

. . .

//
// ,
//
case WM_LBUTTONDOWN:
xMouseDown = LOWORD(lParam);
yMouseDown = HIWORD(lParam);
break;
case WM_LBUTTONUP:
if(yMouseDown > 0)
{
org.ChangeView(xMouseDown, yMouseDown, LOWORD(lParam), HIWORD(lParam), hWnd);
yMouseDown = 0;
}
break;

. . .

Org.cpp

. . .

#include "phone.h" // ,
//
#include "pimstore.h" // PocketOutlook

extern wchar_t* pref[];

#define LINE_SIZE 65 //
#define FONT_RATIO 0.4 // ,
//
#define INDENT 10 //

. . .


int COrg::GetData() //
// PocketOutlook
//{05058F23-20BE-11d2-8F18-0000F87A4335}
//
//{05058F22-20BE-11d2-8F18-0000F87A4335}
{
Cleanup();

Init();

IPOutlookApp * polApp;
HRESULT hr = CoCreateInstance(CLSID_Application,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPOutlookApp,
(LPVOID*)&polApp);
if (FAILED(hr)) return FALSE;

if (FAILED(polApp->Logon(NULL))) return FALSE;

IFolder * pFolder;
if (FAILED(polApp->GetDefaultFolder(olFolderContacts, &pFolder))) return FALSE;

IPOutlookItemCollection * polItems;
if (FAILED(pFolder->get_Items(&polItems))) return FALSE;

int count;
if (FAILED(polItems->get_Count(&count))) return FALSE;

IContact * pContact;
BSTR pwszOrg, pwszFirstName, pwszLastName, pwszJob, pwszTel;
for(int i = 1; i <= count; i++)
{
if (FAILED(polItems->Item(i, (IDispatch**)&pContact))) return FALSE;

if (FAILED(pContact->get_CompanyName(&pwszOrg))) return FALSE;
if (FAILED(pContact->get_FirstName(&pwszFirstName))) return FALSE;
if (FAILED(pContact->get_LastName(&pwszLastName))) return FALSE;
if (FAILED(pContact->get_JobTitle(&pwszJob))) return FALSE;

Add(pwszOrg, pwszFirstName, pwszLastName, pwszJob);

// ,
//
//
//
//

if (FAILED(pContact->get_BusinessFaxNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_MobileTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_BusinessTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_HomeTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_Home2TelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_HomeFaxNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_CarTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_AssistantTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_Business2TelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);
if (FAILED(pContact->get_RadioTelephoneNumber(&pwszTel))) return FALSE;
AddTel(pwszTel);

pContact->Release();
}

polItems->Release();
pFolder->Release();
polApp->Logoff();
polApp->Release();

// <>
//

BSTR calls = SysAllocString(TEXT("<>"));
HANDLE hl;
CALLLOGENTRY ce;
ce.cbSize = sizeof(CALLLOGENTRY);
if (FAILED(PhoneOpenCallLog(&hl)))return FALSE;

BSTR name, tel, strtime;
while(S_OK == PhoneGetCallLogEntry(hl, &ce))
{
wchar_t buf[64];
SYSTEMTIME st;
FILETIME ft;
FileTimeToLocalFileTime(&ce.ftStartTime, &ft);
FileTimeToSystemTime(&ft, &st);
wsprintf(buf, TEXT("%2.2u:%2.2u"), st.wHour, st.wMinute);
strtime = SysAllocString(buf);
if(ce.pszName != NULL)
{
name = SysAllocString(ce.pszName);
LocalFree(ce.pszName);
}
else name = SysAllocString(TEXT("noname"));
if(ce.pszNumber != NULL)
{
tel = SysAllocString(ce.pszNumber);
LocalFree(ce.pszNumber);
}
else tel = SysAllocString(TEXT("nonumber"));
if(ce.pszNameType != NULL)LocalFree(ce.pszNameType);
if(ce.pszNote != NULL)LocalFree(ce.pszNote);

Add(calls, strtime, name, tel, TRUE);
AddTel(tel);
}

PhoneCloseCallLog(hl);

return TRUE;
}

. . .


void COrg::Paint(HDC hdc, HWND hwnd)// WM_PAINT
//
{
RECT rect;
GetClientRect(hwnd, &rect);
int sx = rect.right;
int sy = rect.bottom;

Dcount = sy / LINE_SIZE;

HFONT holdFont;

if(pCurOrg == NULL)//
{
holdFont = (HFONT)SelectObject(hdc, hFont);
ORG* ptmp = pBegin;
int i = 0;
while(ptmp != NULL)
{
if(i >= Dstart && i < Dstart + Dcount)
{
rect.top = LINE_SIZE * (i - Dstart);
rect.bottom = LINE_SIZE * (i - Dstart + 1);
rect.left = INDENT;
rect.right = sx - INDENT;

// ,
//
//

DrawText(hdc, ptmp->pwszOrg, -1, &rect, DT_CALCRECT | DT_SINGLELINE);
if(rect.right > sx - INDENT)
{
HFONT hTmpFont = DoFont(LINE_SIZE, double(sx - 2 * INDENT) / (rect.right - rect.left));
SelectObject(hdc, hTmpFont);
rect.right = sx - INDENT;
DrawText(hdc, ptmp->pwszOrg, -1, &rect, DT_NOCLIP | DT_SINGLELINE);
SelectObject(hdc, hFont);
DeleteObject(hTmpFont);
}
else DrawText(hdc, ptmp->pwszOrg, -1, &rect, DT_NOCLIP | DT_SINGLELINE);
}

i++;
ptmp = ptmp->pNext;
}
}
else // ,
{
WCHAR buf[100];
holdFont = (HFONT)SelectObject(hdc, hFont);
NAME* pt = pCurOrg->pName;
int i = 0;
while(pt != NULL)
{
if(i >= pCurOrg->Dstart && i < pCurOrg->Dstart + Dcount)
{
rect.top = LINE_SIZE * (i - pCurOrg->Dstart);
rect.bottom = LINE_SIZE * (i - pCurOrg->Dstart + 1);
rect.left = INDENT;
rect.right = sx - INDENT;
//
wcscpy_s(buf, 99, pt->pwszFirstName);
wcscat_s(buf, 99, TEXT(" "));
wcscat_s(buf, 99, pt->pwszLastName);
wcscat_s(buf, 99, TEXT(" "));
wcscat_s(buf, 99, pt->pwszJob);

// ,
//
//

DrawText(hdc, buf, -1, &rect, DT_CALCRECT | DT_SINGLELINE);
if(rect.right > sx - INDENT)
{
HFONT hTmpFont = DoFont(LINE_SIZE, double(sx - 2 * INDENT) / (rect.right - rect.left));
SelectObject(hdc, hTmpFont);
rect.right = sx - INDENT;
DrawText(hdc, buf, -1, &rect, DT_NOCLIP | DT_SINGLELINE);
SelectObject(hdc, hFont);
DeleteObject(hTmpFont);
}
else DrawText(hdc, buf, -1, &rect, DT_NOCLIP | DT_SINGLELINE);
}

i++;
pt = pt->pNext;
}
}

SelectObject(hdc, holdFont);
}

. . .


void COrg::ChangeView(int x1, int y1, int x2, int y2, HWND hwnd)
{
//
int dy = y2 - y1;
int dx = x2 - x1;

int* pDstart = pCurOrg == NULL ? &Dstart : &(pCurOrg->Dstart);
int oldDstart = *pDstart;
BOOL fUpdate = FALSE;
int elem_count = pCurOrg == NULL ? org_count : pCurOrg->name_count;
// ,
//
// ,
if(dy > LINE_SIZE)
{
*pDstart -= Dcount;
if(*pDstart < 0) *pDstart = 0;
}
else if(dy < -LINE_SIZE)
{
*pDstart += Dcount;
if(*pDstart > elem_count - Dcount) *pDstart = elem_count - Dcount;
if(*pDstart < 0) *pDstart = 0;
}
else if(dx > -LINE_SIZE && dx < LINE_SIZE)
{
// , .
if(pCurOrg == NULL)//
{
int i = y1 / LINE_SIZE + Dstart;
pCurOrg = pBegin;
while(i-- > 0 && pCurOrg != NULL) pCurOrg = pCurOrg->pNext;
if(pCurOrg != NULL) fUpdate = TRUE;
}
else //
{
int i = y1 / LINE_SIZE + *pDstart;
NAME* ptmp = pCurOrg->pName;
while(i-- > 0 && ptmp != NULL) ptmp = ptmp->pNext;
if(ptmp != NULL)
{
wchar_t snd[32];
// 10 pref[]
if(ptmp->indexTel < 10)wcscpy(snd, TEXT("\\Windows\\Default.wav"));
// 14
else if(ptmp->indexTel < 24)wcscpy(snd, TEXT("\\Windows\\msound1.wav"));
//
else wcscpy(snd, TEXT("\\Windows\\msound3.wav"));

PlaySound(snd, NULL, SND_FILENAME | SND_ASYNC | SND_NOWAIT);
//
PHONEMAKECALLINFO phinf;
memset(&phinf, 0, sizeof(PHONEMAKECALLINFO));
phinf.cbSize = sizeof(PHONEMAKECALLINFO);
phinf.dwFlags = PMCF_DEFAULT;
phinf.pszDestAddress = ptmp->pwszTel;

PhoneMakeCall(&phinf);
}
}
}
else if(dx < -LINE_SIZE || dx > LINE_SIZE)
{
//
//
if(pCurOrg != NULL)
{
pCurOrg = NULL;
fUpdate = TRUE;
}
else
{
PlaySound(TEXT("\\Windows\\msound5.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_NOWAIT);
GetData();
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
return;
}
}

if(*pDstart != oldDstart || fUpdate)
{
PlaySound(TEXT("\\Windows\\Splat.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_NOWAIT);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
}
}

. . .

 

www.alvis.com.ua
, ,

m-t.com.ua
, ,

www.rdsrv.org

 -  -  © kuzmin@it.kharkov.ua +380504010794