📄 poommaster.cpp
字号:
// ************************************************************
// POOMMASTER.CPP
//
// Implementation of application entry point and top-level processing
//
// Copyright 1986-2003 Microsoft Corporation, All Rights Reserved
//
//
// Defines
#define INITGUID
#define MAX_LOADSTRING 100
#define MAX_LISTVIEW_ITEMS 32
#define FT_BOLD 0x1
#define FT_STRIKE 0x2
// Includes
#include <windows.h>
#include <pimstore.h>
#include <aygshell.h>
#include "PoomMaster.h"
// Global Variables:
HINSTANCE g_hInst; // The current instance
HWND g_hwndCB; // The command bar handle
HWND g_hwndLV; // The ListView control
HFONT g_hfBaseFont;
HWND g_hwndMain;
static int listcount = 0;
static SHACTIVATEINFO s_sai;
int g_nCurrFolder = olFolderTasks;
// Forward declarations of functions included in this code module:
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
HWND CreateRpCommandBar(HWND, int);
HWND CreateListView(HWND hwndParent);
void RefreshListView(HWND hwndLV);
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow);
HFONT BuildFont(HDC hDC, HFONT hBaseFont, DWORD dwFlags);
// **************************************************************************
// Function Name: WinMain
//
// Purpose: Application entry point
//
// Arguments:
// IN HINSTANCE hInstance - handle to application instance
// IN HINSTANCE hPrevInstance - not used
// IN LPTSTR lpCmdLine - command line string, not used
// IN int nCmdShow - not used
//
// Return Values:
// int
// Application exit code
//
// Description:
// This function defines the standard application entry point. It starts
// initialization and creates the main application dialog box
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
HACCEL hAccelTable;
// Perform application initialization:
INITCOMMONCONTROLSEX comctrex = { 0 };
comctrex.dwSize = sizeof(INITCOMMONCONTROLSEX);
comctrex.dwICC = ICC_DATE_CLASSES;
InitCommonControls();
InitCommonControlsEx(&comctrex);
g_hInst = hInstance;
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_POOMMASTER);
DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, (DLGPROC)WndProc);
return 0;
}
// **************************************************************************
// Function Name: InitInstance
//
// Purpose: Checks for existing instance of the app and activates it if existing
//
// Arguments:
// none
//
// Return Values:
// BOOL
// returns TRUE if there is no previously existing instance, FALSE otherwise
//
// Description:
// This function tries to find an existing instance of the application window.
// This is a simple check, looking only for the name "PoomMaster" and does not
// check for the window class. If the window is found, it is brought to the
// foreground
BOOL InitInstance(HINSTANCE hInstance,
int nCmdShow)
{
HWND hWnd = NULL;
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
g_hInst = hInstance; // Store instance handle in our global variable
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
//If it is already running, then focus on the window
hWnd = FindWindow(NULL, szTitle);
if (hWnd)
{
// set focus to foremost child window
// The "| 0x01" is used to bring any owned windows to the foreground and
// activate them.
//SetForegroundWindow((HWND)((ULONG) hWnd | 0x00000001));
return FALSE;
}
return TRUE;
}
// **************************************************************************
// Function Name: WndProc
//
// Purpose: Processes messages for the main dialog window
//
// Arguments:
// IN HWND hDlg - handle to the dialog window
// IN UINT message - indentifier for message to be processed
// IN WPARAM wParam - message parameter
// IN LPARAM lParam - message parameter
//
// Return Values:
// LRESULT
// The return value is the result of the message processing and depends on
// the message sent.
//
// Description:
// This is a standard dialog window message processing function. It handles
// the following:
// WM_COMMAND - menu events
// WM_INITDIALOG - dialog initialization
// WM_DESTROY - window cleanup
// WM_ACTIVATE - shell activation notification
// WM_SETTINGCHANGE - system wide setting change notification
// WM_DRAWITEM - owner-drawn painting of listview control
// WM_MEASUREITEM - owner-drawn sizing of listview items
LRESULT CALLBACK WndProc(HWND hWnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
HDC hdc;
LPDRAWITEMSTRUCT lpdis;
LPMEASUREITEMSTRUCT lpmi;
switch (message)
{
case WM_COMMAND:
// Parse the menu selections:
switch (LOWORD(wParam))
{
case IDOK:
case IDM_QUIT:
EndDialog(hWnd, 0);
break;
case IDM_NEWITEM:
switch (g_nCurrFolder)
{
case olFolderTasks:
if (DialogBox(g_hInst, (LPCTSTR)IDD_NEWTASK, hWnd, (DLGPROC)NewTaskProc) == IDOK)
{
RefreshListView(g_hwndLV);
}
break;
case olFolderContacts:
if (DialogBox(g_hInst, (LPCTSTR)IDD_NEWCONTACT, hWnd, (DLGPROC)NewContactProc) == IDOK)
{
RefreshListView(g_hwndLV);
}
break;
case olFolderCalendar:
if (DialogBox(g_hInst, (LPCTSTR)IDD_NEWAPPNTMNT, hWnd, (DLGPROC)NewAppntmntProc) == IDOK)
{
RefreshListView(g_hwndLV);
}
break;
}
break;
case IDM_MODE_CONTACTS:
g_nCurrFolder = olFolderContacts;
RefreshListView(g_hwndLV);SetWindowText(hWnd, _T("POOM Contacts"));
break;
case IDM_MODE_TASKS:
g_nCurrFolder = olFolderTasks;
RefreshListView(g_hwndLV);
SetWindowText(hWnd, _T("POOM Tasks"));
break;
case IDM_MODE_CALENDAR:
g_nCurrFolder = olFolderCalendar;
RefreshListView(g_hwndLV);
SetWindowText(hWnd, _T("POOM Calendar"));
break;
}
break;
case WM_INITDIALOG:
SHINITDLGINFO shidi;
shidi.dwMask = SHIDIM_FLAGS;
shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
shidi.hDlg = hWnd;
SHInitDialog(&shidi);
g_hwndMain = hWnd;
g_hwndCB = CreateRpCommandBar(hWnd, IDM_MAINMENU);
// Initialize the shell activate info structure
memset (&s_sai, 0, sizeof (s_sai));
s_sai.cbSize = sizeof (s_sai);
if (InitPoom(hWnd))
{
// Create the ListView control
g_hwndLV = CreateListView(hWnd);
// populate the main listview display
RefreshListView(g_hwndLV);
SetWindowText(hWnd, _T("POOM Tasks"));
// save our default starting font
hdc = GetDC(g_hwndLV);
g_hfBaseFont = (HFONT)GetCurrentObject(hdc, OBJ_FONT);
ReleaseDC(g_hwndLV, hdc);
}
else
{
//POOM could not initialize
MessageBox(hWnd, _T("Cannot start POOM session"), _T("COM Error"), MB_OK);
EndDialog(hWnd, IDOK);
}
return TRUE;
case WM_DESTROY:
// logout of POOM session
ShutdownPoom();
CommandBar_Destroy(g_hwndCB);
break;
case WM_ACTIVATE:
// Notify shell of our activate message
SHHandleWMActivate(hWnd, wParam, lParam, &s_sai, FALSE);
break;
case WM_SETTINGCHANGE:
SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai);
break;
case WM_DRAWITEM:
// redraw a listview item...called for each item
lpdis = (LPDRAWITEMSTRUCT)lParam;
if (lpdis->CtlType == ODT_LISTVIEW)
{
TCHAR buf[64];
HBRUSH hbrBkColor;
HBRUSH hbrSEL;
COLORREF crOldBkColor;
COLORREF crOldTextColor;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -