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

📄 memwatcher.cpp

📁 在Windows Mobile 5.0 Pocket PC下
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            rcMyBounds.left = rcMyBounds.left + DRA::SCALEX(28);
            DrawText(hDC, TEXT("Storage:"), -1, &rcMyBounds, DT_LEFT);
            
            // draw the program item text
            rcMyBounds.top += DRA::SCALEX(20);
            DrawText(hDC, TEXT("Program:"), -1, &rcMyBounds, DT_LEFT);
            
            // draw the program item % text
            rcMyBounds.left = DRA::SCALEX(210);
            wsprintf(szTextBuffer, TEXT("%i%%"), g_ProgramMemUsed);
            DrawText(hDC, szTextBuffer, -1, &rcMyBounds, DT_LEFT);
            
            // draw the storage item % text
            rcMyBounds.top = DRA::SCALEY(2);
            wsprintf(szTextBuffer, TEXT("%i%%"), g_StorageMemUsed);
            DrawText(hDC, szTextBuffer, -1, &rcMyBounds, DT_LEFT);
            
        }
        else
        {
            // if only show program memory is checked
            if(g_fShowProgram)
            {
                // update and paint program status bar
                SendMessage(g_hProgramProgressBar, PBM_SETPOS, g_ProgramMemUsed, NULL);
                SetWindowPos(g_hProgramProgressBar, g_hWnd, DRA::SCALEX(85), DRA::SCALEY(4), DRA::SCALEX(120), DRA::SCALEY(10), SWP_SHOWWINDOW);
                
                // draw the program item text
                rcMyBounds.left = rcMyBounds.left + DRA::SCALEX(28);
                DrawText(hDC, TEXT("Program:"), -1, &rcMyBounds, DT_LEFT);
                
                // draw the program item % text
                rcMyBounds.left = DRA::SCALEX(210);
                wsprintf(szTextBuffer, TEXT("%i%%"), g_ProgramMemUsed);
                DrawText(hDC, szTextBuffer, -1, &rcMyBounds, DT_LEFT);
            }
            // if only show storage memory is checked
            else
            {
                // update and paint storage status bar
                SendMessage(g_hStorageProgressBar, PBM_SETPOS, g_StorageMemUsed, NULL);
                SetWindowPos(g_hStorageProgressBar, g_hWnd, DRA::SCALEX(85), DRA::SCALEX(4), DRA::SCALEX(120), DRA::SCALEX(10), SWP_SHOWWINDOW);
                
                // draw the storage item text
                rcMyBounds.left = rcMyBounds.left + DRA::SCALEX(28);
                DrawText(hDC, TEXT("Storage:"), -1, &rcMyBounds, DT_LEFT);
                
                // draw the storage item % text
                rcMyBounds.left = DRA::SCALEX(210);
                wsprintf(szTextBuffer, TEXT("%i%%"), g_StorageMemUsed);
                DrawText(hDC, szTextBuffer, -1, &rcMyBounds, DT_LEFT);
            }
        }
        
        // Select the previous font back into the device context
        SelectObject(hDC, hFontOld);

        DeleteObject(hFont);

        EndPaint(hwnd, &ps);
        return 0;
        
    case WM_DESTROY :          
        return 0 ;
        
    // this fills in the background with the today screen image
    case WM_ERASEBKGND:
        TODAYDRAWWATERMARKINFO dwi;
        dwi.hdc = (HDC)wParam;
        GetClientRect(hwnd, &dwi.rc);
        
        dwi.hwnd = hwnd;
        SendMessage(GetParent(hwnd), TODAYM_DRAWWATERMARK, 0,(LPARAM)&dwi);
        return TRUE;
    }

    return DefWindowProc (hwnd, uimessage, wParam, lParam) ;
}


/*************************************************************************/
/* Create and register our window class for the today item                 */
/*************************************************************************/
INT InitializeClasses()
{
    WNDCLASS         wc; 
    memset(&wc, 0, sizeof(wc));
    
    wc.style         = 0;                   
    wc.lpfnWndProc     = (WNDPROC) WndProc;
    wc.hInstance     = g_hInst;
    wc.hIcon         = 0;
    wc.hCursor         = 0;
    wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
    wc.lpszClassName = (LPCTSTR)LoadString(g_hInst, IDS_TODAY_STORAGE_APPNAME,0,0);
    
    //register our window
    if(!RegisterClass(&wc))
    { 
        return 0 ;
    }
    return 1;
}

/*************************************************************************/
/* Initialize the DLL by creating a new window                             */
/*************************************************************************/
HWND InitializeCustomItem(TODAYLISTITEM *ptli, HWND hwndParent) 
{
    LPCTSTR appName = (LPCTSTR)LoadString(g_hInst,IDS_TODAY_STORAGE_APPNAME,0,0);
    
    //create a new window
    g_hWnd = CreateWindow(appName,appName,WS_VISIBLE | WS_CHILD,
        CW_USEDEFAULT,CW_USEDEFAULT,240,0,hwndParent, NULL, g_hInst, NULL) ;
    
    // create the storage space progress bar
    g_hStorageProgressBar = CreateWindow(PROGRESS_CLASS, TEXT("Storage Progress Bar"), 
        WS_CHILD | PBS_SMOOTH, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT
        ,g_hWnd, NULL, g_hInst, NULL);
    
    // adjust the step to be in 1% increments
    SendMessage(g_hStorageProgressBar,PBM_SETSTEP,1,NULL); 
    
    // create the program memory progress bar
    g_hProgramProgressBar = CreateWindow(PROGRESS_CLASS, TEXT("Program Progress Bar"), 
        WS_CHILD | PBS_SMOOTH, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT
        ,g_hWnd, NULL, g_hInst, NULL);
    
    
    // adjust the step to be in 1% increments
    SendMessage(g_hProgramProgressBar,PBM_SETSTEP,1,NULL); 
    
    
    // attach our winproc to the newly created window
    SetWindowLong(g_hWnd, GWL_WNDPROC, (LONG) WndProc);
    
    //display the window
    ShowWindow (g_hWnd, SW_SHOWNORMAL);
    UpdateWindow (g_hWnd) ;  
    
    return g_hWnd;
}

/*************************************************************************/
/* Message Handler for the options dialog                                 */
/*************************************************************************/
LRESULT WINAPI CustomItemOptionsDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    static TODAYLISTITEM *s_ptliItem = NULL;

    switch (message)
    {
    case WM_INITDIALOG:
        {
            SHINITDLGINFO shidi;
            BOOL fShowStorage, fShowProgram;

            // Create a Done button and size it.  
            shidi.dwMask = SHIDIM_FLAGS;
            shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
            shidi.hDlg = hDlg;
            SHInitDialog(&shidi);

            // get a pointer to the item structure that Settings passes us
            s_ptliItem = (TODAYLISTITEM*)lParam;

            // the flags are used to store the user choice of what to show
            // (beyond that, further settings could be stored in the registry)

            if (NULL != s_ptliItem)
            {
                // get the selection stored in grfFlags
                fShowStorage = !(s_ptliItem->grfFlags & FLAGS_HIDE_STORAGE);
                fShowProgram = !(s_ptliItem->grfFlags & FLAGS_HIDE_PROGRAM);
            }
            else
            {
                // something went wrong, check both
                fShowStorage = fShowProgram = TRUE;
            }

            if (fShowStorage && fShowProgram)
            {
                CheckRadioButton(hDlg, IDC_PROGRAM, IDC_STORAGE, IDC_BOTH);
            }
            else if (fShowStorage)
            {
                CheckRadioButton(hDlg, IDC_PROGRAM, IDC_STORAGE, IDC_STORAGE);
            }
            else
            {
                CheckRadioButton(hDlg, IDC_PROGRAM, IDC_STORAGE, IDC_PROGRAM);
            }
        }
        return TRUE; 
        
    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK) 
        {
            HWND hCurrentRadioButton;
            BOOL fShowStorage, fShowProgram;

            // check to see if both is checked
            hCurrentRadioButton = GetDlgItem(hDlg, IDC_BOTH);
            if(BST_CHECKED == SendMessage(hCurrentRadioButton, BM_GETCHECK, NULL, NULL))
            {
                fShowStorage = TRUE;
                fShowProgram = TRUE;
            }
            
            // check to see if only program is checked
            hCurrentRadioButton = GetDlgItem(hDlg, IDC_PROGRAM);
            if(BST_CHECKED == SendMessage(hCurrentRadioButton, BM_GETCHECK, NULL, NULL))
            {
                fShowStorage = FALSE;
                fShowProgram = TRUE;
            }
            
            // check to see if only storage is checked
            hCurrentRadioButton = GetDlgItem(hDlg, IDC_STORAGE);
            if(BST_CHECKED == SendMessage(hCurrentRadioButton, BM_GETCHECK, NULL, NULL))
            {
                fShowStorage = TRUE;
                fShowProgram = FALSE;
            }
            
            s_ptliItem->grfFlags = (fShowStorage ? 0 : FLAGS_HIDE_STORAGE) |
                (fShowProgram ? 0 : FLAGS_HIDE_PROGRAM);
            
            EndDialog(hDlg, LOWORD(wParam));
            return TRUE;
        }
        break;

    case WM_DESTROY:
        // reset this - the Settings instance is closing
        s_ptliItem = NULL;
        break;

    }

    return FALSE;
}

⌨️ 快捷键说明

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