📄 systeminfo.cpp
字号:
// SystemInfo.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <pimstore.h>
#include <windows.h>
#include <aygshell.h>
#include <commctrl.h>
#include <Todaycmn.h>
#include "resource.h"
#include <Pm.h>
#include <projects.h>
#include "ProgramList.h"
#include "PoomList.h"
#include "SystemInfo.h"
#include <pkfuncs.h>
//#define INITGUID
#include <initguid.h>
DEFINE_GUID(IID_IPOutlookApp, 0x05058F22, 0x20BE, 0x11d2, 0x8F, 0x18, 0x00, 0x00, 0xF8, 0x7A, 0x43, 0x35);
DEFINE_GUID(CLSID_Application, 0x05058F23, 0x20BE, 0x11d2, 0x8F, 0x18, 0x00, 0x00, 0xF8, 0x7A, 0x43, 0x35);
typedef struct tag_mydatetime
{
WORD wYear;
WORD wMonth;
WORD wDay;
WORD wDayOfWeek;
WORD wHour;
WORD wMinute;
WORD wSeconds;
}MYDATETIME,*LPMYDATETIME;
HWND APIENTRY InitializeCustomItem(TODAYLISTITEM *ptli, HWND hwndParent);
BOOL APIENTRY CustomItemOptionsDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam);
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ChildrenWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK ButtonSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
VOID OnHandlePaint(HWND hWnd, HDC hdc);
HWND AddButtons(HWND hWnd,int ix,int iy,int iWidth,int iHeight,UINT uiID,BOOL bOwnerDraw);
HWND AddListView(HWND hWnd,int ix,int iy,int iWidth,int iHeight,UINT uiID,BOOL bOwnerDraw);
HWND AddDateTimePickerControl(HWND hWnd,int ix,int iy,int iWidth,int iHeight,UINT uiID,BOOL bOwnerDraw);
HWND AddStaticControl(HWND hWnd,int ix,int iy,int iWidth,int iHeight,UINT uiID,BOOL bOwnerDraw);
void GetTodayDefaults();
void OnMainCreate(HWND hWnd);
HWND AddChildrenWindows(HWND hWnd,int ix,int iy,int iWidth,int iHeight,UINT uiID = NULL);
BOOL RegisterChildrenClass();
void OnChildrenPaint(HWND hWnd,HDC hdc);
void OnHandleCommand(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnChildrenCreate(HWND hWnd);
void OnChildrenCommand(HWND hWnd,WPARAM wParam,LPARAM lParam);
BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM lParam);
void PaintPage1(HWND hWnd,HDC hdc);
void PaintPage2(HWND hWnd,HDC hdc);
void PaintPage3(HWND hWnd,HDC hdc);
void PaintPage4(HWND hWnd,HDC hdc);
void PaintClock(HWND hWnd,HDC hdc);
//handle on action
void GetProgramMemory(LPDWORD dwTotal,LPDWORD dwAvaiable);
BOOL GetStorageMemory(LPDWORD dwTotal,LPDWORD dwAvaiable);
BOOL GetSDCardMemory(LPDWORD dwTotal,LPDWORD dwAvaiable);
BOOL GetBacklight(LPDWORD dwLevel);
BOOL GetBattery(LPDWORD dwPercent);
BOOL GetLed(LPDWORD dwLed);
BOOL GetVibrate(LPDWORD dwVibrate);
void GetDateTime(LPSYSTEMTIME localTime);
void GetRunningPrograms();
DWORD GetLCDStatus();
BOOL SetLCDStatus(VIDEO_POWER_STATE dwStatus);
BOOL GetTaskAndAppointment();
void OnChildrenTimer(HWND hWnd,WPARAM wParam);
void OnChildrenNotify(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnChildrenContext(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnHandleChildrenDown(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnHandlePage4Down(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnHandlePage1Down(HWND hWnd,WPARAM wParam,LPARAM lParam);
void OnHandleClockDown(HWND hWnd,WPARAM wParam,LPARAM lParam);
DWORD GetProgramIndex(POINT ptPos,LPDWORD dwRow,LPDWORD dwCol);
DWORD GetTaskIndex(POINT ptPos,LPDWORD pdwRow);
DWORD GetApplicationIndex(POINT ptPos,LPDWORD dwRow,LPDWORD dwCol);
void OnHandMenuDrawItem(HWND hWnd,LPDRAWITEMSTRUCT lpDIS);
void OnTaskAdd(HWND hWnd);
void OnTaskDelete(HWND hWnd,int iIndex);
void OnTaskEdit(HWND hWnd,int iIndex);
INT_PTR CALLBACK TaskAddProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
//executable application
BOOL GetDirectoryContents(HWND hwndLV, LPTSTR pszDirectory);
BOOL AddItemToListView(HWND hwndLV,WIN32_FIND_DATA findData);
INT CALLBACK ApplicationProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
void OnHandleListViewContext(HWND hDlg,WPARAM wParam,LPARAM lParam);
void OnApplicationMarked(HWND hDlg);
//Poom function
BOOL InitPoom(HWND hwnd=NULL);
void ClosePoom();
BOOL GetPoomApp(IPOutlookApp **ppOutApp);
BOOL GetPoomFolder(int nFolder, IFolder ** ppFolder);
HINSTANCE g_hInstance;
HWND g_hWndParent;
HWND m_hMainWnd;
WNDPROC m_fOldProc;
HWND m_hChildren[4];
HWND m_hClock;
DWORD m_dwCurrentForm = 0;
CPoomList *m_pPoom = NULL;
CProgramList *m_pList = NULL;
CProgramList *m_pApplication = NULL;
CProgramList *m_pApplicationMarked = NULL;
PROGRAMDATA *m_pTemp = NULL;
DWORD m_dwIndex = -1,m_dwRow=0,m_dwCol=0;
DWORD m_dwTaskIndex = -1,m_dwTaskRow=0;
DWORD m_dwAppIndex = -1,m_dwAppRow = 0,m_dwAppCol = 0;
//font for used
HFONT m_hNormalTodayFont,m_hBoldTodayFont,m_hSmallTodayFont;
COLORREF m_crTodayText;
HRGN hUpdateRgn;
HRGN hCombineRgn;
HRGN m_hOldRgn,m_hNewRgn;
HRGN m_hOldTaskRgn,m_hTaskRgn;
HRGN m_hOldAppRgn,m_hNewAppRgn;
IPOutlookApp * g_polApp = NULL;
DWORD m_dwPage=0;
DWORD m_dwAppPage = 0;
DWORD m_dwProgramPage = 0;
HBITMAP m_hBmpClock;
HBITMAP m_hBmpHour,m_hBmpMinute,m_hBmpSecond;
HICON m_hIconClock;
#define PI 3.1415926535
#define R 24
#define L1 10
#define L2 15
#define L3 20
#define TASK_MAX 4
#define APP_MAX 8
#define BUTTON_WIDTH 32
#define BUTTON_HEIGHT 32
#define TODAY_HEIGHT 96
#define MAX_LOADSTRING 100
#define ID_PAGE2_TIMER 3000
#define ID_PAGE3_TIMER 3001
#define ID_CLOCK_TIMER 3002
#define ID_OWNERINFO 0x8798
#define ID_DATETIME 0x8799
#define ID_LISTVIEW 0x8800
#define ID_BASE_COMMAND 0x8801
#define ID_DEVICE_COMMAND 0x8900
//#define ID_DEVICE_COMMAND+1 0x8901
//#define ID_DEVICE_COMMAND+2 0x8902
#define ID_POPUPMENU_NAME 0x8903
#define ID_POPUPMENU_ACTIVE 0x8904
#define ID_POPUPMENU_SEP 0x8905
#define ID_POPUPMENU_STOP 0x8906
#define ID_POPUPMENU_STOPALL 0x8907
#define ID_TASKAPP_DETAIL 0x8909
#define ID_TASK_UP 0x8910
#define ID_TASK_DOWN 0x8911
#define ID_TASK_ADD 0x8912
#define ID_TASK_DELETE 0x8913
#define ID_TASK_EDIT 0x8914
#define ID_APP_LEFT 0x8915
#define ID_APP_RIGHT 0x8916
#define ID_POPUPAPP_NAME 0x8917
#define ID_POPUPAPP_RUN 0x8918
#define ID_POPUPAPP_REMOVE 0x8919
#define ID_POPUPAPP_REMOVEALL 0x8920
#define ID_POPUPAPP_SEP 0x8921
#define ID_POPUPAPP_ADD 0x8922
/**********************************************
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
***************************************************/
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH :
g_hInstance = (HINSTANCE) hModule;
break;
case DLL_PROCESS_DETACH :
break;
}
return TRUE;
}
BOOL APIENTRY CustomItemOptionsDlgProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
SHINITDLGINFO shidi;
switch (message)
{
case WM_INITDIALOG:
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hDlg;
SHInitDialog(&shidi);
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
default:
return DefWindowProc(hDlg, message, wParam, lParam);
}
return 0;
}
HWND APIENTRY InitializeCustomItem(TODAYLISTITEM *ptli,HWND hwndParent)
{
WNDCLASS wc;
HWND hWnd = NULL;
if (ptli->fEnabled==0)
return NULL; //Return NULL if we are not enabled.
g_hInstance = ptli->hinstDLL; //Store instance handle in our global variable
//Create our window class
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
wc.lpszMenuName = 0;
wc.lpszClassName = TEXT("LoyisToday");
RegisterClass(&wc);
m_hMainWnd = hWnd = CreateWindow(TEXT("LoyisToday"), TEXT("LoyisTodayScreen"), WS_VISIBLE | WS_CHILD,
CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hwndParent, NULL, g_hInstance, NULL);
g_hWndParent = hwndParent;
GetTodayDefaults();
return hWnd;
}
//Our main WndProc. Does everything after initialization.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
TODAYDRAWWATERMARKINFO dwi;
HICON hIcon;
DWORD dwIndex;
switch (message)
{
case WM_CREATE:
{
//AddButtons(hWnd,10,10,BUTTON_WIDTH,BUTTON_WIDTH,0x8801,TRUE);
OnMainCreate(hWnd);
}
break;
case WM_ERASEBKGND:
//We return true here since we handle our own background painting.
{
hdc = (HDC)wParam;
TODAYDRAWWATERMARKINFO dwi;
dwi.hdc = hdc;
GetClientRect(m_hMainWnd, &dwi.rc);
dwi.hwnd = m_hMainWnd;
SendMessage(g_hWndParent, TODAYM_DRAWWATERMARK, 0,(LPARAM)&dwi);
}
return TRUE;
case WM_TODAYCUSTOM_CLEARCACHE :
//We have no cache to clear so we ignore this message.
break;
case WM_TODAYCUSTOM_QUERYREFRESHCACHE:
//If the cyp member is set to 0 then you must set it to your windows height.
//This makes sure the shell gives you a certain amout of room for your painting.
if (((TODAYLISTITEM*)wParam)->cyp == 0)
{
((TODAYLISTITEM*)wParam)->cyp = TODAY_HEIGHT; //the shell draws a line at the bottom of our window.
return 1;
}
break;
case WM_PAINT:
//Paint like you would in any other application.
hdc = BeginPaint(hWnd, &ps);
OnHandlePaint(hWnd,hdc);
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONUP:
break;
case WM_DESTROY:
{
if(m_hNormalTodayFont)
{
DeleteObject(m_hNormalTodayFont);
m_hNormalTodayFont = NULL;
}
if(m_hBoldTodayFont)
{
DeleteObject(m_hBoldTodayFont);
m_hBoldTodayFont = NULL;
}
}
break;
case WM_DRAWITEM:
LPDRAWITEMSTRUCT lpdis;
lpdis = (LPDRAWITEMSTRUCT)lParam;
dwi.hdc = lpdis->hDC;
GetClientRect(lpdis->hwndItem, &dwi.rc);
dwi.hwnd = lpdis->hwndItem;
SendMessage(g_hWndParent, TODAYM_DRAWWATERMARK, 0,(LPARAM)&dwi);
if (lpdis->CtlType == ODT_BUTTON)
{
dwIndex = lpdis->CtlID - ID_BASE_COMMAND;
if ((lpdis->itemAction | ODA_SELECT) && (lpdis->itemState & ODS_SELECTED))
{
hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_PAGE1+dwIndex));
}
else
{
hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_PAGE1+dwIndex));
}
DrawIcon(lpdis->hDC,3,3,hIcon);
if(hIcon)
DestroyIcon(hIcon);
}
return (INT_PTR)TRUE;
break;
case WM_MEASUREITEM:
LPMEASUREITEMSTRUCT lpmi;
lpmi = (LPMEASUREITEMSTRUCT)lParam;
if (lpmi->CtlType == ODT_BUTTON)
{
lpmi->itemWidth = BUTTON_WIDTH;
lpmi->itemHeight = BUTTON_HEIGHT;
}
else if (lpmi->CtlType == ODT_LISTVIEW)
{
lpmi->itemHeight = (BUTTON_HEIGHT>>1);
}
return (INT_PTR)TRUE;
break;
case WM_SETTINGCHANGE:
if( SETTINGCHANGE_RESET == wParam)
{
}
break;
case WM_SIZE:
break;
case WM_COMMAND:
OnHandleCommand(hWnd,wParam,lParam);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
void GetTodayDefaults()
{
LOGFONT lf;
HFONT hSysFont;
// Default today item font color
m_crTodayText = SendMessage(g_hWndParent, TODAYM_GETCOLOR, (WPARAM)TODAYCOLOR_TEXT, NULL);
// Default today fonts
hSysFont = (HFONT)GetStockObject(SYSTEM_FONT);
GetObject(hSysFont, sizeof(LOGFONT), &lf);
_tcscpy(lf.lfFaceName, _T("Tahoma"));
lf.lfHeight = -11;
// Normal text
lf.lfWeight = FW_NORMAL;
m_hNormalTodayFont = CreateFontIndirect(&lf);
// Bold text
lf.lfWeight = FW_BOLD;
m_hBoldTodayFont = CreateFontIndirect(&lf);
//small text
lf.lfHeight = -9;
lf.lfWeight = FW_THIN;
m_hSmallTodayFont = CreateFontIndirect(&lf);
}
VOID OnHandlePaint(HWND hWnd, HDC hdc)
{
RECT rect;
GetClientRect(hWnd,&rect);
//SystemParametersInfo(SPI_GETWORKAREA, NULL, &rect, FALSE);
/* //draw the main icon
HICON hIcon;
hIcon = LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_MAIN));
DrawIcon(hdc,0,0,hIcon);
DestroyIcon(hIcon);*/
/*
//draw the text
HFONT hFontOld;
COLORREF crOld;
SIZE size;
TCHAR szText[MAX_LOADSTRING];
LoadString(g_hInstance,IDS_MAIN,szText,MAX_LOADSTRING);
hFontOld = (HFONT)SelectObject(hdc, m_hBoldTodayFont);
GetTextExtentPoint32(hdc, szText, _tcslen(szText), &size);
rect.left = 29;
rect.top = 3;
rect.right = rect.left + size.cx;
rect.bottom = rect.top + size.cy;
SetBkMode(hdc,TRANSPARENT);
SetTextColor(hdc,m_crTodayText);
DrawText(hdc, szText, -1, &rect, DT_LEFT);
SelectObject(hdc, hFontOld);*/
HPEN hPen,hPenOld;
hPen = CreatePen(PS_SOLID,0,GetSysColor(COLOR_HIGHLIGHT));
hPenOld = (HPEN)SelectObject(hdc,hPen);
for(int i=0;i<3;i++)
{
MoveToEx(hdc,0,23+i*24,NULL);
LineTo(hdc,24,23+i*24);
}
MoveToEx(hdc,0,95,NULL);
LineTo(hdc,rect.right,95);
switch(m_dwCurrentForm)
{
case 0:
MoveToEx(hdc,24,23,NULL);
LineTo(hdc,24,96);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -