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

📄 poommaster.cpp

📁 使用poom api新建或获得ppc上的PIM data
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				COLORREF crRed = RGB(255,0,0);
				DWORD dwFontFlags =0;
				HFONT hCustomFont = 0;
				
				hdc = lpdis->hDC;
				
				// save the current text and background colors
				crOldTextColor = GetTextColor(hdc);
				crOldBkColor = GetBkColor(hdc);
				
				
				hbrBkColor = CreateSolidBrush (crOldBkColor);
				hbrSEL = CreateSolidBrush (GetSysColor(COLOR_HIGHLIGHT));
				// make sure standard font is the default
				SelectObject(hdc, g_hfBaseFont);
				
				// if this item is selected, draw the highlight box
				if ((lpdis->itemAction | ODA_SELECT) && (lpdis->itemState & ODS_SELECTED))
				{
					SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
					FillRect(hdc, &lpdis->rcItem,hbrSEL);
				}
				// otherwise fill with standard background color and draw a rectangle around the item
				else
				{
					RECT r;
					
					FillRect(hdc, &lpdis->rcItem,hbrBkColor);
					r = lpdis->rcItem;
					Rectangle(hdc, r.left-1, r.top-1, r.right, r.bottom);
					
				}
				
				DeleteObject (hbrSEL);
				DeleteObject (hbrBkColor);
				
				ListView_GetItemText(g_hwndLV, lpdis->itemID, 0, buf, 64);
				// if viewing tasks, set some font properties
				if (g_nCurrFolder == olFolderTasks)
				{
					if (GetTaskPriority(lpdis->itemID) == olImportanceHigh)
					{
						// color text red to denote high importance
						SetTextColor(hdc, crRed);
						dwFontFlags |= FT_BOLD;
					}

					if (TaskIsComplete(lpdis->itemID))
					{
						// cross out if task is complete
						dwFontFlags |= FT_STRIKE;
						
					}
					
					// Build and select the font
					hCustomFont = BuildFont(hdc, g_hfBaseFont, dwFontFlags);
					SelectObject(hdc, hCustomFont) ;
				}
				
				// Draw the item's text
				DrawText(hdc, buf, _tcslen(buf),&lpdis->rcItem , DT_LEFT| DT_WORDBREAK |DT_TOP); 
				
				// Reset the background color and the text color back to their
				// original values.
				SetTextColor(hdc, crOldTextColor);
				SetBkColor(hdc, crOldBkColor);
			
				if (hCustomFont != 0)
				{
					DeleteObject(hCustomFont);
				}
				
				ReleaseDC (g_hwndLV, hdc);
			}
			
			return TRUE;
			
		case WM_MEASUREITEM:
			// set the height for each item box
			lpmi = (LPMEASUREITEMSTRUCT)lParam;
			lpmi->itemHeight= 36;
			
			return TRUE;
		
   }
   return FALSE;
}

// **************************************************************************
// Function Name: CreateRpCommandBar
// 
// Purpose: Creates a Rapier shell command bar
//
// Arguments:
//	 IN HWND hwnd - handle to parent window
//	 IN int nMenu - Resource ID of menu resource
//
// Return Values:
//    HWND
//    handle of created command bar
// 
// Description:  
//  This function creates a shell-specific menu bar specified by the given
//	resource ID. 
HWND CreateRpCommandBar(HWND hwnd, 
						int nMenu)
{
	SHMENUBARINFO mbi;
	
	memset(&mbi, 0, sizeof(SHMENUBARINFO));
	mbi.cbSize     = sizeof(SHMENUBARINFO);
	mbi.hwndParent = hwnd;
	mbi.nToolBarId = nMenu;
	mbi.hInstRes   = g_hInst;
	mbi.nBmpId     = 0;
	mbi.cBmpImages = 0;
	
	if (!SHCreateMenuBar(&mbi)) 
		return NULL;
	
	return mbi.hwndMB;
}



// **************************************************************************
// Function Name: CreateListView
// 
// Purpose: Create a listview control suitable for listing POOM items
//
// Arguments:
//	 IN HWND hwnd - handle to parent window
//
// Return Values:
//    HWND
//    handle of created list view control
// 
// Description:  
//  This function creates an owner-drawn listview control with a single column. 
//	All drawing is handled in the WM_DRAWITEM handler in WndProc. The list items are 
//	sized via the WM_MEASUREITEM handler.
HWND CreateListView(HWND hwndPrnt)
{
	HWND hwndRet = NULL;
	
    LV_COLUMN lvColumn;
	RECT mainRect;
	// Get the main rect
	GetClientRect (hwndPrnt, &mainRect);
	
	
	// Create ListView
	hwndRet = CreateWindow (WC_LISTVIEW, NULL,WS_CHILD | WS_VISIBLE | 
		LVS_REPORT | LVS_SINGLESEL | LVS_EDITLABELS | LVS_OWNERDRAWFIXED | LVS_NOCOLUMNHEADER, 
		0, 0, mainRect.right - mainRect.left, mainRect.bottom - mainRect.top, 
		hwndPrnt, NULL, g_hInst, 0);
	
	ListView_SetItemCount(hwndRet, MAX_LISTVIEW_ITEMS);
	
	// set column width to screen width
	lvColumn.mask = LVCF_WIDTH;
	lvColumn.cx = mainRect.right - mainRect.left;
	
	ListView_InsertColumn(hwndRet, 0, &lvColumn);
	
	return hwndRet;
}
// **************************************************************************
// Function Name: InitNewItemDlg
// 
// Purpose: Common intialization routine for new item dialogs
// Arguments:
//	 IN HWND hDlg - handle new dialog box
//
// Return Values:
//    BOOL
//    TRUE if initialization succeeds, FALSE otherwise
// 
// Description:  
//	This function supplies a common initialization implementation for all of the
//	apps New Item dialog boxes (New Contact, New Task, New Appointment). It provides
//  each dialog with the same shell properties and menu.  
BOOL InitNewItemDlg(HWND hDlg)
{
	
	SHINITDLGINFO shidi;
	
	
	shidi.dwMask = SHIDIM_FLAGS;
	shidi.dwFlags =  SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
	shidi.hDlg = hDlg;
	if (!SHInitDialog(&shidi))
	{
		return FALSE;
	}
	
	return IsWindow(CreateRpCommandBar(hDlg, IDM_NEWITEMMENU));
	
}

// **************************************************************************
// Function Name: RefreshListView
// 
// Purpose: Create a listview control suitable for listing POOM items
//
// Arguments:
//	 IN HWND hwnd - handle to listview control
//
// Return Values:
//  none
// 
// Description:  
//  This function deletes and repopulates the the listview items with POOM 
//	data and sets the first item as selected.
void RefreshListView(HWND hwndLV)
{
	listcount = 0;
	ListView_DeleteAllItems (hwndLV);
	PopulateList(g_nCurrFolder);	
	ListView_SetItemState(hwndLV, 0, LVIS_SELECTED, LVIS_SELECTED);
}
// **************************************************************************
// Function Name: AddToList
// 
// Purpose: Add text to a listview item, then insert the item into the list
//
// Arguments:
//	 IN TCHAR * tszTxt - ptr to a string containing text to add to listview item
//
// Return Values:
//  none
// 
// Description:  
//	This function simply creates a listview item with text content, then adds it 
//	to the list. It also sets the item order (0 based) and sort parameter (1 based).
//	See LVITEM documentation for details 
void AddToList(TCHAR * tszTxt)
{
	LVITEM lv = {0};
	lv.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM | LVIF_IMAGE;
	lv.iItem = listcount++;
	lv.lParam = listcount;
	lv.pszText = tszTxt;
	ListView_InsertItem (g_hwndLV, &lv);		
}
// **************************************************************************
// Function Name: GetCtrlText
// 
// Purpose: Get the displayed text from a given control
//
// Arguments:
//	 IN HWND hDlg - control's parent hwnd
//	 IN int nCtrlId - resource ID of the control
//	 OUT BSTR * pbstrTxt - length-prefixed buffer for returned string. Must be
//		freed (SysFreeString) by calling code
//
// Return Values:
//  none
// 
// Description:  
//  This function retrieves the specified control's window text and stores it in
// an newly allocated BSTR which is rerturned via output parameter. The allocated
// string must be be freed by the calling code with SysFreeString
void GetCtrlBstr(HWND hDlg, 
					 int nCtrlId, 
					 BSTR * pbstrTxt)
{
	int nLen = 0;
	
	nLen = GetWindowTextLength(GetDlgItem(hDlg, nCtrlId));
	(*pbstrTxt) = SysAllocStringLen(NULL, nLen+1);
	GetWindowText(GetDlgItem(hDlg, nCtrlId), *pbstrTxt, nLen+1);
	
}

HFONT BuildFont(HDC hDC, HFONT hBaseFont, DWORD dwFlags)
{
	LOGFONT lf;
	HFONT hFont = NULL;
	
	memset(&lf, 0, sizeof(LOGFONT));
	
	GetObject(hBaseFont, sizeof(lf), (LOGFONT*)&lf);
	
	if (dwFlags & FT_BOLD)
		lf.lfWeight=FW_BOLD;
	if (dwFlags & FT_STRIKE)
		lf.lfStrikeOut=TRUE;	
	
	return CreateFontIndirect(&lf);
}

⌨️ 快捷键说明

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