⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icontact.cpp

📁 This code is Address book code for Windows Mobile. This source code support windows mobile 5.0 over.
💻 CPP
📖 第 1 页 / 共 5 页
字号:

    EndPaint (hWnd, &ps);

    return 0;
}

//-----------------------------------------------------------------------------
// DoActivate - Process WM_ACTIVATE message for window
//
LRESULT DoActivate (HWND hWnd, UINT wMsg, WPARAM wParam,
                    LPARAM lParam) {

    DWORD dwState;
    RECT rc;

    if (wParam == WA_CLICKACTIVE || wParam == WA_ACTIVE) {
        // To switch to full screen mode, first hide all of the shell parts.
        dwState = (SHFS_HIDETASKBAR 
            | SHFS_HIDESTARTICON 
            | SHFS_HIDESIPBUTTON);

        SHFullScreen(hWnd, dwState);

        // Next resize the main window to the size of the screen.
        SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), 
            GetSystemMetrics(SM_CYSCREEN));
        MoveWindow(hWnd, rc.left, rc.top, rc.right-rc.left, 
            rc.bottom-rc.top, TRUE);

        ShowWindow(hWnd, SW_SHOWNORMAL);
    }

    // The window is being deactivated... restore it to non-fullscreen
    else {
        // To switch to normal mode, first show all of the shell parts.
        dwState = (SHFS_SHOWTASKBAR 
            | SHFS_SHOWSTARTICON 
            | SHFS_SHOWSIPBUTTON);

        SHFullScreen(hWnd, dwState);

        // Next resize the main window to the size of the work area.
        SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE);

        MoveWindow(hWnd, rc.left, rc.top, rc.right-rc.left,
            rc.bottom-rc.top, TRUE);
    }

    return DefWindowProc (hWnd, wMsg, wParam, lParam);
}

//-----------------------------------------------------------------------------
// DoTitlebarCallback - Process WM_TITLEBAR message for window
//
LRESULT DoTitlebarCallback (HWND hWnd, UINT wMsg, WPARAM wParam,
                    LPARAM lParam) {
    RefreshTitlebar(lParam);
    InvalidateRect(hWnd, &rTitlebar, false);
    return 0;
}

//-----------------------------------------------------------------------------
// DoSize - Process WM_SIZE message for window
//
LRESULT DoSize (HWND hWnd, UINT wMsg, WPARAM wParam,
                LPARAM lParam) {

	InitSurface(hWnd);

    return DefWindowProc (hWnd, wMsg, wParam, lParam);
}

//-----------------------------------------------------------------------------
// DoLButtonDown - Process WM_LBUTTONDOWN message for window
//
LRESULT DoLButtonDown (HWND hWnd, UINT wMsg, WPARAM wParam,
                       LPARAM lParam) {

	LastX = ptMouseDown.x = LOWORD(lParam);
	LastY = ptMouseDown.y = HIWORD(lParam);
    tStartTime = ::GetTickCount();

    if (bScrolling) {
        KillTimer(hWnd, IDT_TIMER_SCROLL);
        KillTimer(hWnd, IDT_TIMER_SCROLL_TO);
        Velocity = 0;
        bScrolling = false;
    }

    if (bDisplayingPopup || bTransitioning) {
        return 0;
    }

    if (stScreenType == stList 
        && LastX > rList.right - 20 
        && LastY >= rHeader.bottom 
        && LastY < rMenubar.top) {

        bScrolling = true;
        ScrollBar(LastY);
        InvalidateRect(hWnd, &rList, false);
        UpdateWindow(hWnd);
    }

    return 0;
}

//-----------------------------------------------------------------------------
// DoMouseMove - Process WM_MOUSEMOVE message for window
//
LRESULT DoMouseMove (HWND hWnd, UINT wMsg, WPARAM wParam,
                     LPARAM lParam) {

	int x = LOWORD(lParam);
	int y = HIWORD(lParam);
    int t = ::GetTickCount();

    if (bDisplayingPopup || bTransitioning) {
        return 0;
    }

    if (stScreenType == stList && ptMouseDown.y >= rMenubar.top) {
        return 0;
    }

    if (ptMouseDown.y < rHeader.bottom) {
        return 0;
    }

    // "back" button in header bar
    //TODO: back to categories from stScreenType == stList
    if (ptMouseDown.y < rHeader.top + HeaderClickHeight 
        && ptMouseDown.x <= HeaderClickHeight
        && stScreenType == stDetails) {

        return 0;
    }

    // "+" button in header bar, or * in detail view
    if (ptMouseDown.y < rHeader.top + HeaderClickHeight 
        && ptMouseDown.x >= rList.right - HeaderClickHeight 
        && (
            stScreenType == stList && pListData->CanAdd()
            || stScreenType == stDetails && pListData->CanFavorite()
        ) ) {

        return 0;
    }

	if (bScrolling) {
        ScrollBar(y);
        InvalidateRect(hWnd, &rList, false);
        UpdateWindow(hWnd);
		return 0;
	}

	if (abs(y - ptMouseDown.y) > SCROLL_THRESHOLD) {
        if (stScreenType == stList)
            pListData->UnselectItem();
        else if (stScreenType == stDetails)
            pListData->SelectDetail(-1);
        bDragging = true;
	}

    // SCROLL
    Scrolled = Scrolled - y + LastY;
	LastY = y;
	LastX = x;

    Velocity = (double)(LastY - ptMouseDown.y) / (t - tStartTime);
    tEndTime = t;

    InvalidateRect(hWnd, 
        (stScreenType == stDetails ? &rContent : &rList), false);

    UpdateWindow(hWnd);

	return 0;
}

//-----------------------------------------------------------------------------
// DoLButtonUp - Process WM_LBUTTONUP message for window
//
LRESULT DoLButtonUp (HWND hWnd, UINT wMsg, WPARAM wParam,
                       LPARAM lParam) {

    POINT pt;

    if (bTransitioning) {
        return 0;
    }

    if (bScrolling) {
        bScrolling = false;
        InvalidateRect(hWnd, &rList, FALSE);
        UpdateWindow(hWnd);
        return 0;
    }

	pt.x = LOWORD(lParam);
	pt.y = HIWORD(lParam);
    
    int minScroll = 0;
    int maxScroll = ListHeight > rListHeight ? ListHeight - rListHeight : 0;


    // They clicked on the popup, no matter what screen
    if (bDisplayingPopup) {
        StartTransition(hWnd, ttKeyboardShrink, SHRINK_KEYBOARD_PERIOD);

        int keyboardIndex = (pt.y / GroupHeight) 
            * (rScreen.right - rScreen.left) / GroupWidth 
            + (pt.x - rScreen.left) / GroupWidth;
        if (keyboardIndex < nKeyboardLetters) {
            pListData->UnselectItem();
            ScrollTo(hWnd, GroupPosition[keyboardIndex]);
        }
    }


    // They clicked in the titlebar
    // no matter what the screen type is
	else if (PtInRect(&rTitlebar, ptMouseDown) && PtInRect(&rTitlebar, pt)) {
        if (pSettings->doExitOnMinimize) {
            DestroyWindow(hWnd);
        }
        else {
            ShowWindow(hWnd, SW_MINIMIZE);
        }
	}


    // They clicked in the bottom menus (in list screen)
    else if (stScreenType == stList 
        && PtInRect(&rMenubar, ptMouseDown) && PtInRect(&rMenubar, pt)) {
        int tab = pt.x * 5 / (rMenubar.right - rMenubar.left);

        // we're assuming, here, that 
        // CMD_SHOW_FAVORITES ... CMD_SHOW_KEYBOARD are sequential
        SendNotifyMessage(hWnd, WM_COMMAND, CMD_GOTO_FAVORITES + tab, NULL);
    }


    // They scrolled the screen up too far
    else if (bDragging && Scrolled < minScroll) {
        bDragging = false;
        ScrollTo(hWnd, minScroll);
    }


    // They scrolled the screen down too far
    else if (bDragging && Scrolled > maxScroll) {
        bDragging = false;
        ScrollTo(hWnd, maxScroll);
    }


    // now we're scrolling
    else if (bDragging) {
        SetTimer(hWnd, IDT_TIMER_SCROLL, 
            REFRESH_RATE, (TIMERPROC) NULL);
        bScrolling = true;
        bDragging = false;
        return 0;
    } 

    else {
        int pos = 0;

        // This is the normal *click* event
        switch (stScreenType) {
            case stList:

                // "back" button in header bar
                if (pt.y >= rHeader.top 
                    && pt.y < rHeader.top + HeaderClickHeight 
                    && pt.x <= HeaderClickHeight) {

                    //TODO: back to categories
                }

                // "+" button in header bar
                else if (pt.y >= rHeader.top 
                    && pt.y < rHeader.top + HeaderClickHeight 
                    && pt.x >= rList.right - HeaderClickHeight 
                    && pListData->CanAdd()) {

			        pListData->AddItem();

                    // This will refresh the data in the current tab
                    SwitchTab(hWnd, nCurrentTab);
		        }

                // Clicked a list item
                else if (pt.y >= rList.top) {
                    pos = pt.y + Scrolled - rList.top;

                    pListData->SelectItem(GetPixelToItem(pos));
                    StartTransition(hWnd, ttSlideLeft, EXPAND_DETAILS_PERIOD);
                }
                break;

            case stDetails:

                // "back" button in header bar
                if (pt.y >= rHeader.top 
                    && pt.y < rHeader.top + HeaderClickHeight 
                    && pt.x <= HeaderClickHeight) {

                    // Back to list
                    StartTransition(hWnd, ttSlideRight, EXPAND_DETAILS_PERIOD);
                }

                // "*" button in header bar
                else if (pt.y >= rHeader.top 
                    && pt.y < rHeader.top + HeaderClickHeight 
                    && pt.x >= rList.right - HeaderClickHeight 
                    && pListData->CanFavorite()) {

                    SetCursor(LoadCursor(NULL, IDC_WAIT));
                    pListData->ToggleFavorite();
                    SetCursor(NULL);

                    // Switch back to list of favorites, if they just
                    // de-favorited one of them. Presumably, the one they
                    // just favorited will be missing from the list now.
                    if (nCurrentTab == 0) {
                        SwitchTab(hWnd, 0);
                    }
                    else {
                        pListData->PopulateDetails();
                        InvalidateRect(hWnd, &rHeader, false);
                    }
		        }

                // Clicked a list item
                else if (pt.y >= rList.top) {
			        // HANDLE SUBLIST EVENTS
                    pos = pt.y + Scrolled - rContent.top;
                    int subListIndex = pos / DefaultItemHeight;
                    if (!pListData->SelectDetail(subListIndex))
                        break;

                    InvalidateRect(hWnd, &rContent, false);
                    UpdateWindow(hWnd);

                    // TODO: is this the best way to send SMS?
                    int column = pt.x > rList.right - HeaderClickHeight ? 2 : 1;

                    HRESULT hr = pListData->PerformCurrentDetailAction(column);

                    if (SUCCEEDED(hr)) {
                        if (pSettings->doExitOnAction) {
                            DestroyWindow(hWnd);
                        }
                        else {
                            pListData->PopulateDetails();
                            CalculateHeights();
                        }
                    }
                    else {
                        SwitchTab(hWnd, nCurrentTab);
                    }
    		        InvalidateRect(hWnd, &rScreen, FALSE);
		        }
                if (NULL != pListData)
    		        pListData->SelectDetail(-1);

	            break;
        }
    }

    UpdateWindow(hWnd);

	return 0;
}

//-----------------------------------------------------------------------------
// DoTimer - Process WM_TIMER message for window
//
LRESULT DoTimer (HWND hWnd, UINT wMsg, WPARAM wParam,
                       LPARAM lParam) {

    DWORD t = ::GetTickCount();
    DWORD dt = 0;
    double s = 0.0;

    int minScrolled = 0;
    int maxScrolled = ListHeight <= rListHeight ? 0 : ListHeight - rListHeight;

	switch (wParam)	{

        ///// TIMER for scrolling
	    case IDT_TIMER_SCROLL:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -