本文整理汇总了C++中CImageList::GetSafeHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ CImageList::GetSafeHandle方法的具体用法?C++ CImageList::GetSafeHandle怎么用?C++ CImageList::GetSafeHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImageList
的用法示例。
在下文中一共展示了CImageList::GetSafeHandle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Py_BuildValue
// @pymethod int|PyCImageList|GetSafeHandle|Retrieves the HIMAGELIST for the object
PyObject *PyCImageList_GetSafeHandle( PyObject *self, PyObject *args )
{
CImageList *pList;
if (!(pList=PyCImageList::GetImageList(self)))
return NULL;
CHECK_NO_ARGS2(args, "GetSafeHandle");
return Py_BuildValue("i", pList->GetSafeHandle());
}
示例2: OnLvnBegindrag
void CSharedDirsTreeCtrl::OnLvnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)pNMHDR;
*pResult = 0;
CDirectoryItem* pToDrag = (CDirectoryItem*)lpnmtv->itemNew.lParam;
if (pToDrag == NULL || pToDrag->m_eItemType != SDI_UNSHAREDDIRECTORY || FileSystemTreeIsShared(pToDrag->m_strFullPath))
return;
ASSERT( m_pDraggingItem == NULL );
delete m_pDraggingItem;
m_pDraggingItem = pToDrag->CloneContent(); // to be safe we store a copy, as items can be deleted when collapsing the tree etc
CImageList* piml = NULL;
POINT ptOffset;
RECT rcItem;
if ((piml = CreateDragImage(lpnmtv->itemNew.hItem)) == NULL)
return;
/* get the bounding rectangle of the item being dragged (rel to top-left of control) */
if (GetItemRect(lpnmtv->itemNew.hItem, &rcItem, TRUE))
{
CPoint ptDragBegin;
int nX, nY;
/* get offset into image that the mouse is at */
/* item rect doesn't include the image */
ptDragBegin = lpnmtv->ptDrag;
ImageList_GetIconSize(piml->GetSafeHandle(), &nX, &nY);
ptOffset.x = (ptDragBegin.x - rcItem.left) + (nX - (rcItem.right - rcItem.left));
ptOffset.y = (ptDragBegin.y - rcItem.top) + (nY - (rcItem.bottom - rcItem.top));
/* convert the item rect to screen co-ords, for use later */
MapWindowPoints(NULL, &rcItem);
}
else
{
GetWindowRect(&rcItem);
ptOffset.x = ptOffset.y = 8;
}
if (piml->BeginDrag(0, ptOffset))
{
CPoint ptDragEnter = lpnmtv->ptDrag;
ClientToScreen(&ptDragEnter);
piml->DragEnter(NULL, ptDragEnter);
}
delete piml;
/* set the focus here, so we get a WM_CANCELMODE if needed */
SetFocus();
/* redraw item being dragged, otherwise it remains (looking) selected */
InvalidateRect(&rcItem, TRUE);
UpdateWindow();
/* Hide the mouse cursor, and direct mouse input to this window */
SetCapture();
}
示例3: OnCreate
int CShellWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
m_ShellTreeCtrl.Create(WS_CHILD|WS_VISIBLE|TVS_SHOWSELALWAYS|TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT|TVS_TRACKSELECT,
CRect(0,0,0,0), this, 100);
m_ShellTreeCtrl.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
// bring the tooltips to front
CWnd* pTT = m_ShellTreeCtrl.FromHandle((HWND) m_ShellTreeCtrl.SendMessage(TVM_GETTOOLTIPS));
if (pTT != NULL)
pTT->SetWindowPos(&CWnd::wndTopMost, 0, 0, 0, 0,
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
if (!m_fType.Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|CBS_LOWERCASE, CRect(0,0,0,0), this, ID_SHELLWND_COMBO))
{
return -1; // fail to create
}
//m_fType.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
CFont* font = m_ShellTreeCtrl.GetFont();
m_fType.SetFont(font);
m_fType.AddString("*.htm;*.html;*.shtm;*.shtml;*.mht;*.txt;");
m_fType.AddString("*.txt;");
m_fType.AddString("*.htm;*.html;");
m_fType.AddString("*.c;*.cpp;*.h;");
m_fType.AddString("*.bmp;*.jpg;*.gif;*.png;");
m_fType.AddString("*.*");
//
CImageList img;
m_wndRef.CreateEx(this);
img.Create(13, 15, ILC_COLORDDB|ILC_MASK, 1, 1);
HBITMAP hbmp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_REFRESH));
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_wndRef.GetToolBarCtrl().SetImageList(&img);
img.Detach();
m_wndRef.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT|TBSTYLE_TOOLTIPS );
m_wndRef.SetButtonInfo(0, IDOK, TBSTYLE_BUTTON, 0);
m_wndRef.GetToolBarCtrl().GetToolTips()->UpdateTipText(IDS_REFRESH, this, IDOK);
return 0;
}
示例4: CreateCheckboxImageList
///////////////////////////////////////////////////////////////////////////////
//
// CreateCheckboxImageList()
//
// Purpose: Create themed checkbox image list
//
// Parameters: pDC - pointer to device context for drawing
// imagelist - image list to create
// nSize - height and width of images
// crBackground - fill color
//
// Returns: BOOL - TRUE if image list created OK
//
BOOL CreateCheckboxImageList(CDC *pDC,
CImageList& imagelist,
int nSize,
COLORREF crBackground)
{
ASSERT(pDC);
ASSERT(nSize > 0);
BOOL rc = FALSE;
///////////////////////////////////////////////////////////////////////////
//
// CHECKBOX IMAGES
//
// From MSDN: "To indicate that the item has no state image, set the
// index to zero. This convention means that image zero in
// the state image list cannot be used as a state image."
//
// Note that comparable hot image = cold image index OR 8.
// Disabled state = index OR 4.
struct CHECKBOXDRAWDATA
{
TCHAR * pszDesc; // description for debugging
int nStateId; // for DrawThemeBackground
UINT nState; // for DrawFrameControl
}
cbdd[] =
{
// cold -----------------------------------------------------------------------------------
/*0000*/_T("unused"), 0, 0,
/*0001*/_T("unchecked normal"), CBS_UNCHECKEDNORMAL, DFCS_BUTTONCHECK | DFCS_FLAT,
/*0010*/_T("checked normal"), CBS_CHECKEDNORMAL, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT,
/*0011*/_T("tri-state normal"), CBS_MIXEDNORMAL, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT,
/*0100*/_T("unused"), 0, 0,
/*0101*/_T("unchecked disabled"), CBS_UNCHECKEDDISABLED, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT,
/*0110*/_T("checked disabled"), CBS_CHECKEDDISABLED, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
/*0111*/_T("tri-state disabled"), CBS_MIXEDDISABLED, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
// hot ------------------------------------------------------------------------------------
/*1000*/_T("unused"), 0, 0,
/*1001*/_T("unchecked normal"), CBS_UNCHECKEDHOT, DFCS_BUTTONCHECK | DFCS_FLAT,
/*1010*/_T("checked normal"), CBS_CHECKEDHOT, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT,
/*1011*/_T("tri-state normal"), CBS_MIXEDHOT, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT,
/*1100*/_T("unused"), 0, 0,
/*1101*/_T("unchecked disabled"), CBS_UNCHECKEDDISABLED, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT,
/*1110*/_T("checked disabled"), CBS_CHECKEDDISABLED, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
/*1111*/_T("tri-state disabled"), CBS_MIXEDDISABLED, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
NULL, 0, 0 // last entry
};
if (pDC && (nSize > 0))
{
const int nBmpWidth = nSize;
const int nBmpHeight = nSize;
const int nImages = sizeof(cbdd)/sizeof(cbdd[0]);
ASSERT(nImages == 17);
if (imagelist.GetSafeHandle())
imagelist.DeleteImageList();
CBitmap bmpCheckboxes;
if (bmpCheckboxes.CreateCompatibleBitmap(pDC, nBmpWidth * nImages,
nBmpHeight))
{
if (imagelist.Create(nBmpWidth, nBmpHeight, ILC_COLOR32 | ILC_MASK,
nImages, 1))
{
CDC dcMem;
if (dcMem.CreateCompatibleDC(pDC))
{
HTHEME hTheme = NULL;
hTheme = (g_xpStyle.IsThemeActive() &&
g_xpStyle.IsAppThemed()) ?
g_xpStyle.OpenThemeData(NULL, L"BUTTON") : NULL;
CBitmap* pOldBmp = dcMem.SelectObject(&bmpCheckboxes);
dcMem.FillSolidRect(0, 0, nBmpWidth*nImages, nBmpHeight,
crBackground);
int nImageWidth = nBmpWidth - 2; // allow 2 for border
int nImageHeight = nBmpHeight - 2;
int nImageLeft = (nBmpWidth - nImageWidth) / 2;
int nImageTop = (nBmpHeight - nImageHeight) / 2;
CRect rectImage(nImageLeft,
//.........这里部分代码省略.........
示例5: OnInitDialog
BOOL CSetProxy::OnInitDialog()
{
CDialog::OnInitDialog();
CString str;
m_tmpProxyCategory = new CProxyCategory(((CMainFrame*)pMainFrame)->m_aProxyCategories);
// TODO: Add extra initialization here
//load proxy list
/* POSITION pos = ((CMainFrame*)pMainFrame)->m_astrProxy.GetHeadPosition();
POSITION pos1 = ((CMainFrame*)pMainFrame)->m_aProxySpeed.GetHeadPosition();
POSITION pos2 = ((CMainFrame*)pMainFrame)->m_astrProxyName.GetHeadPosition();
*/ CRect rect;
int i=0;
m_ProxyList.GetWindowRect(rect);
m_ProxyList.InsertColumn(0,"Name");
m_ProxyList.SetColumnWidth(0, 110);
m_ProxyList.InsertColumn(1,"Proxy");
m_ProxyList.SetColumnWidth(1, rect.Width()-175);
m_ProxyList.InsertColumn(2,"Speed");
m_ProxyList.SetColumnWidth(2, 45);
//image
CImageList img;
img.Create(9, 9, ILC_COLORDDB|ILC_MASK, 2, 1);
HBITMAP hbmp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP10));
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
m_CateList.SetImageList(&img, LVSIL_SMALL);
img.Detach();
//m_ProxyList.SetExtendedStyle(m_ProxyList.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
//fill with the default proxy list
//category list
m_nList = m_nSelProxyList;
int icon;
for(i=0; i<=m_tmpProxyCategory->m_ProxyCategory.GetUpperBound(); i++)
{
if(m_tmpProxyCategory->m_ProxyCategory.ElementAt(i)->m_bIsWebProxy)
icon=0;
else
icon=1;
m_CateList.InsertItem(i, m_tmpProxyCategory->m_ProxyCategory.ElementAt(i)->m_strCategoryName, icon);
}
CProxyList* pl=NULL;
if(m_nList>=0 && m_nList<i)
pl=m_tmpProxyCategory->m_ProxyCategory.GetAt(m_nList);
if(pl!=NULL)
{
for(i=0; i<=pl->m_Proxies.GetUpperBound(); i++)
{
m_ProxyList.InsertItem(i, pl->m_Proxies.ElementAt(i)->m_strProxyName);
m_ProxyList.SetItemText(i, 1, pl->m_Proxies.ElementAt(i)->m_strProxy);
if(m_SelProxy == pl->m_Proxies.ElementAt(i)->m_strProxy)
m_ProxyList.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
str.LoadString(IDS_SP_INVALID + pl->m_Proxies.ElementAt(i)->m_nProxySpeed);
m_ProxyList.SetItemText(i, 2, str);
}
m_ByPass.SetWindowText(pl->m_strProxyByPass);
}
m_CateList.SetItemState(m_nList, LVIS_SELECTED, LVIS_SELECTED);
m_bUnUpdateProxy = TRUE;
//load web proxy
/* pos = ((CMainFrame*)pMainFrame)->m_astrWebProxy.GetHeadPosition();
pos1 = ((CMainFrame*)pMainFrame)->m_aWebProxySpeed.GetHeadPosition();
pos2 = ((CMainFrame*)pMainFrame)->m_astrWebProxyName.GetHeadPosition();
i=0;
m_WebProxyList.GetWindowRect(rect);
m_WebProxyList.InsertColumn(0,"Name");
m_WebProxyList.SetColumnWidth(0, 75);
m_WebProxyList.InsertColumn(1,"Web Proxy");
m_WebProxyList.SetColumnWidth(1, rect.Width()-130);
m_WebProxyList.InsertColumn(2,"Speed");
m_WebProxyList.SetColumnWidth(2, 45);
m_WebProxyList.SetExtendedStyle(m_WebProxyList.GetExtendedStyle() | LVS_EX_FULLROWSELECT);
//select web proxy
m_SelWebProxy.MakeLower();
m_SelWebProxy.TrimLeft();
m_SelWebProxy.TrimRight();
while(pos!=NULL && pos1!=NULL && pos2 != NULL)
{
m_WebProxyList.InsertItem(i, ((CMainFrame*)pMainFrame)->m_astrWebProxyName.GetAt(pos2));
((CMainFrame*)pMainFrame)->m_astrWebProxyName.GetNext(pos2);
str = ((CMainFrame*)pMainFrame)->m_astrWebProxy.GetAt(pos);
str.MakeLower();
str.TrimLeft();
str.TrimRight();
m_WebProxyList.SetItemText(i, 1, str);
//.........这里部分代码省略.........
示例6: OnInitDialog
BOOL CWebFileOpenDlg::OnInitDialog()
{
#ifdef _WRITE_LNG_FILE_
_WriteDlgString(this,"DialogOpenFile");
this->OnCancel();
return TRUE;
#endif
LOADDLG("DialogOpenFile");
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CImageList img;
img.Create(16, 16, ILC_COLORDDB|ILC_MASK, 2, 1);
HBITMAP hbmp = pmf->GetBitmap("FavBar.bmp");
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_conAddress.SetImageList(&img);
img.Detach();
m_conAddress.SetExtendedStyle(0, m_conAddress.GetExtendedStyle()|CBES_EX_NOSIZELIMIT);
//auto complete
HINSTANCE hIns = LoadLibrary("shlwapi.dll");
if(hIns != NULL)
{
LPFNDLLFUNC1 lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hIns, "SHAutoComplete");
if(lpfnDllFunc1!=NULL)
lpfnDllFunc1(m_conAddress.GetEditCtrl()->m_hWnd, 0xe);
FreeLibrary(hIns);
}
//typed urls
TCHAR sz[MAX_PATH];
HKEY hKey;
DWORD dwSize;
TCHAR id[9] = "url";
int i = 1;
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\TypedUrls"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Typed URLs not found\n");
return TRUE;
}
dwSize = MAX_PATH-1;
itoa(i, id+3, 10);
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
item.iImage = 1;
item.iSelectedImage = 1;
dwSize = sizeof(sz);
while(RegQueryValueEx(hKey, _T(id), NULL, NULL, (LPBYTE)sz, &dwSize) == ERROR_SUCCESS)
{
item.iItem = i-1;
item.pszText = (LPTSTR)(LPCTSTR)sz;
m_conAddress.InsertItem(&item);
i++;
itoa(i, id+3, 10);
dwSize = MAX_PATH - 1;
}
RegCloseKey(hKey);
if (m_bDirectOpenFile)
{
OnBrowse();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例7: OnInitDialog
BOOL CCustomizeToolbar::OnInitDialog()
{
CDialog::OnInitDialog();
//must after OnInitDialog, for the combo string
LOADDLG("DialogCustomize");
m_avabtn.SetExtendedStyle(m_avabtn.GetExtendedStyle()| LVS_EX_FULLROWSELECT);
m_curbtn.SetExtendedStyle(m_curbtn.GetExtendedStyle()| LVS_EX_FULLROWSELECT);
int n=0;
CImageList img;
img.Create(24, 24, ILC_COLORDDB|ILC_MASK, 40, 1);
HBITMAP hbmp = pmf->GetBitmap("MainTool24.bmp");
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_avabtn.SetImageList(&img, LVSIL_SMALL);
img.Detach();
LOADSTR(str ,IDS_SEPARATOR);
CRect rect;
m_avabtn.InsertColumn(0,"");
m_avabtn.GetWindowRect(rect);
m_avabtn.SetColumnWidth(0, rect.Width()-25);
m_avabtn.InsertItem(0, str, -1);
m_avabtn.SetItemData(0, 1);
int nMaxBtn = BUTTON_COUNT;//sizeof(g_nToolBarID)/sizeof(UINT);
n=1;
for(int i=0; i<nMaxBtn; i++)
{
if(g_nToolBarID[i]!=0)
{
LOADSTR(str ,g_nToolBarText[i]);
m_avabtn.InsertItem(n, str.Right(str.GetLength()-str.Find('\n')-1), g_nToolBarImg[i]);
m_avabtn.SetItemData(n, i);
n++;
}
}
img.Create(24, 24, ILC_COLORDDB|ILC_MASK, 40, 1);
hbmp = pmf->GetBitmap("MainTool24.bmp");
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_curbtn.SetImageList(&img, LVSIL_SMALL);
img.Detach();
m_curbtn.InsertColumn(0,"");
m_curbtn.GetWindowRect(rect);
m_curbtn.SetColumnWidth(0, rect.Width()-25);
int ids[50], idx=0, id;
char tmp[6]; tmp[0]='B';
id=0;idx=0;
while(idx<nMaxBtn && id!=-1)
{
itoa(idx,tmp+1,10);
id = (int)AfxGetApp()->GetProfileInt("ToolBar", tmp, -5);
if(id==-5)
ids[idx] = idx;
else if(id>=nMaxBtn)
ids[idx] = 1;//add a seprate
else
ids[idx]=id;
idx++;
}
LVFINDINFO info;
int index;
n=0;
for(i=0; i<idx; i++)
{
itoa(i,tmp+1,10);
id = ids[i];
if(id>=0 && id<nMaxBtn)
{
if(g_nToolBarText[id]>0)
{
LOADSTR(str ,g_nToolBarText[id]);
m_curbtn.InsertItem(n, str.Right(str.GetLength()-str.Find('\n')-1), g_nToolBarImg[id]);
m_curbtn.SetItemData(n, id);
//delete from available list
info.flags = LVFI_PARAM;
info.lParam = id;
index=m_avabtn.FindItem(&info);
if(index != -1)
{
m_avabtn.DeleteItem(index);
}
}
else
{
LOADSTR(str ,IDS_SEPARATOR);
m_curbtn.InsertItem(n, str, -1);
m_curbtn.SetItemData(n, 1);
}
n++;
}
else if(id>=nMaxBtn)
continue;
else
//.........这里部分代码省略.........
示例8: DrawItemEntry
void CXTPSkinObjectHeader::DrawItemEntry(CDC* pDC, int nIndex, CRect rcItem, int nState)
{
CXTPSkinManagerClass* pClass = GetSkinClass();
CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)this;
CImageList* pImageList = CImageList::FromHandle((HIMAGELIST)
::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETIMAGELIST, 0, 0L));
// Set up the header item order array.
HD_ITEM hdi;
::ZeroMemory(&hdi, sizeof(HD_ITEM));
hdi.fmt = HDF_STRING | HDF_IMAGE;
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM;
// Get the header item text and format
CString strCaption;
LPTSTR pszText = strCaption.GetBuffer(256);
pszText[0] = 0;
hdi.pszText = pszText;
hdi.cchTextMax = 255;
BOOL bResult = pHeaderCtrl->GetItem(nIndex, &hdi);
strCaption.ReleaseBuffer();
#ifdef _UNICODE
if (!bResult)
{
char tText[256];
tText[0] = 0;
HD_ITEMA hdia;
::ZeroMemory(&hdia, sizeof(HD_ITEMA));
hdia.fmt = HDF_STRING | HDF_IMAGE;
hdia.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM;
// Get the header item text and format
hdia.pszText = tText;
hdia.cchTextMax = 255;
::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETITEMA, nIndex, (LPARAM)&hdia);
strCaption = tText;
hdi.fmt = hdia.fmt;
hdi.iImage = hdia.iImage;
hdi.lParam = hdia.lParam;
}
#else
bResult;
#endif
if (hdi.fmt & HDF_OWNERDRAW)
{
DRAWITEMSTRUCT dis;
dis.CtlType = ODT_HEADER;
dis.CtlID = (UINT)GetDlgCtrlID();
dis.itemID = nIndex;
dis.itemAction = ODA_DRAWENTIRE;
dis.itemState = (nState == HIS_PRESSED) ? ODS_SELECTED : 0;
dis.hwndItem = m_hWnd;
dis.hDC = pDC->GetSafeHdc();
dis.rcItem = rcItem;
dis.itemData = hdi.lParam;
// Now send it off to my parent...
if (GetParent()->SendMessage(WM_DRAWITEM, dis.CtlID,
(LPARAM)(DRAWITEMSTRUCT*)&dis))
{
return;
}
}
CRect rcText(rcItem);
if (pImageList && (hdi.fmt & HDF_IMAGE) && hdi.iImage >= 0 && hdi.iImage < pImageList->GetImageCount())
{
int iBitmapMargin = (int)SendMessage(HDM_GETBITMAPMARGIN);
if (iBitmapMargin == 0)
iBitmapMargin = GetMetrics()->m_cxEdge * 3;
int cxBitmap = 16, cyBitmap = 16;
ImageList_GetIconSize(pImageList->GetSafeHandle(), &cxBitmap, &cyBitmap);
CPoint pt(rcItem.left + iBitmapMargin, (rcItem.bottom + rcItem.top - cyBitmap) / 2);
if (hdi.fmt & HDF_BITMAP_ON_RIGHT)
{
CSize sz = pDC->GetTextExtent(strCaption);
pt.x += sz.cx + iBitmapMargin + 9;
if (pt.x + cxBitmap > rcItem.right - 3)
pt.x = max(rcItem.left + 6, rcItem.right - 3 - cxBitmap);
if (nState == HIS_PRESSED)
pt.x ++;
pImageList->Draw(pDC, hdi.iImage, pt, ILD_TRANSPARENT);
rcText.right = pt.x + 6;
}
//.........这里部分代码省略.........
示例9: OnInitDialog
BOOL CCollectorDlg::OnInitDialog()
{
#ifdef _WRITE_LNG_FILE_
_WriteDlgString(this,"DialogCollector");
this->OnCancel();
return TRUE;
#endif
LOADDLG("DialogCollector");
CDialog::OnInitDialog();
m_txt.SetLimitText(MAX_COLLECTOR);
m_output.SetLimitText(MAX_COLLECTOR);
m_script.SetLimitText(MAX_COLLECTOR);
if (!m_ToolBar.CreateEx(this))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// set up toolbar properties
CImageList img;
img.Create(16, 16, ILC_COLORDDB|ILC_MASK, 8, 1);
HBITMAP hbmp = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_COLLECTOR_TOOL));
ImageList_AddMasked(img.GetSafeHandle(), hbmp, RGB(255,0,255));
DeleteObject(hbmp);
m_ToolBar.GetToolBarCtrl().SetImageList(&img);
img.Detach();
//
m_ToolBar.SetButtons(NULL, 12);
m_ToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT| TBSTYLE_TOOLTIPS );
m_ToolBar.ModifyStyleEx(0, WS_EX_TOOLWINDOW);
m_ToolBar.SetBarStyle(m_ToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
// set up each toolbar button
CString str;
LOADSTR(str ,ID_COLLECTOR_TXT);
m_ToolBar.SetButtonInfo(0, ID_COLLECTOR_TXT, TBSTYLE_BUTTON, 0);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_TXT);
LOADSTR(str ,ID_COLLECTOR_OUTPUT);
m_ToolBar.SetButtonInfo(1, ID_COLLECTOR_OUTPUT, TBSTYLE_BUTTON, 1);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_OUTPUT);
LOADSTR(str ,ID_COLLECTOR_SCRIPT);
m_ToolBar.SetButtonInfo(2, ID_COLLECTOR_SCRIPT, TBSTYLE_BUTTON, 2);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_SCRIPT);
m_ToolBar.SetButtonInfo(3, 0, TBSTYLE_SEP, 0);
LOADSTR(str ,ID_COLLECTOR_SAVE);
m_ToolBar.SetButtonInfo(4, ID_COLLECTOR_SAVE, TBSTYLE_BUTTON, 4);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_SAVE);
LOADSTR(str ,ID_COLLECTOR_CLEAR);
m_ToolBar.SetButtonInfo(5, ID_COLLECTOR_CLEAR, TBSTYLE_BUTTON, 3);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_CLEAR);
m_ToolBar.SetButtonInfo(6, 0, TBSTYLE_SEP, 0);
LOADSTR(str ,ID_COLLECTOR_TRANS);
m_ToolBar.SetButtonInfo(7, ID_COLLECTOR_TRANS, TBSTYLE_BUTTON, 5);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_COLLECTOR_TRANS);
m_ToolBar.SetButtonInfo(8, 0, TBSTYLE_SEP, 0);
LOADSTR(str ,ID_RUN_SCRIPT);
m_ToolBar.SetButtonInfo(9, ID_RUN_SCRIPT, TBSTYLE_BUTTON, 6);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_RUN_SCRIPT);
LOADSTR(str ,ID_OPEN_SELECTED_TEXT);
m_ToolBar.SetButtonInfo(10, ID_OPEN_SELECTED_TEXT, TBSTYLE_BUTTON, 7);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_OPEN_SELECTED_TEXT);
LOADSTR(str ,ID_OPEN_CURSOR_LINE);
m_ToolBar.SetButtonInfo(11, ID_OPEN_CURSOR_LINE, TBSTYLE_BUTTON, 8);
m_ToolBar.GetToolBarCtrl().GetToolTips()->UpdateTipText(str, &m_ToolBar, ID_OPEN_CURSOR_LINE);
m_nOldMode = 255;
if (pmf->m_nCollectorTrans<255)
CollectorTrans(pmf->m_nCollectorTrans);
m_edit = 0;
OnCollectorTxt();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例10: OnBeginDrag
void SmartListCtrl::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
if ( !eventHandler_ )
return;
LPNMLISTVIEW info = (LPNMLISTVIEW)pNMHDR;
std::string text;
int image;
getData( info->iItem, text, image );
POINT pt;
GetCursorPos( &pt );
if ( dragImgList_ )
{
delete dragImgList_;
dragImgList_ = 0;
}
int pos = GetNextItem( -1, LVNI_SELECTED );
bool isFirst = true;
int xoff = 0;
int yoff = 0;
int xstep = 0;
int ystep = 0;
IMAGEINFO imf;
int maxDragWidth = 400;
int maxDragHeight = 350;
while ( pos != -1 ) {
if ( isFirst ) {
dragImgList_ = CreateDragImage( pos, &pt );
dragImgList_->GetImageInfo( 0, &imf );
xstep = imf.rcImage.right - imf.rcImage.left;
ystep = imf.rcImage.bottom - imf.rcImage.top;
yoff = imf.rcImage.bottom;
isFirst = false;
}
else
{
if ( yoff + ystep > maxDragHeight && xoff + xstep > maxDragWidth )
generateDragListEndItem_ = true; // reached the max, so generate a 'more...' item in GetData
CImageList* oneImgList = CreateDragImage( pos, &pt );
generateDragListEndItem_ = false;
CImageList* tempImgList = new CImageList();
tempImgList->Attach(
ImageList_Merge(
dragImgList_->GetSafeHandle(),
0, oneImgList->GetSafeHandle(), 0, xoff, yoff ) );
delete dragImgList_;
delete oneImgList;
dragImgList_ = tempImgList;
dragImgList_->GetImageInfo( 0, &imf );
yoff += ystep;
if ( yoff > maxDragHeight )
{
xoff += xstep;
if ( xoff > maxDragWidth )
break;
yoff = 0;
}
}
pos = GetNextItem( pos, LVNI_SELECTED );
}
if ( dragImgList_ )
{
CPoint offset( thumbWidthCur_ + 16 , max( 16, thumbHeightCur_ - 14 ) );
dragImgList_->SetBkColor( GetBkColor() );
dragImgList_->SetDragCursorImage( 0, offset );
dragImgList_->BeginDrag( 0, offset );
dragImgList_->DragEnter( 0, pt );
}
if ( delayedSelectionPending_ )
{
// if a selection timer is pending, force it
delayedSelectionNotify();
}
dragging_ = true;
eventHandler_->listStartDrag( info->iItem );
}
示例11: setStyle
void SmartListCtrl::setStyle( ViewStyle style )
{
style_ = style;
static CImageList dummyImgList;
static const int IMGLIST_FORMAT = ILC_COLOR24|ILC_MASK;
thumbnailManager_->resetPendingRequests( this );
if ( !dummyImgList.GetSafeHandle() )
{
dummyImgList.Create( 1, 1, IMGLIST_FORMAT, 0, 0 );
dummyImgList.SetBkColor( GetBkColor() );
}
// delete previous image list
SetImageList( &dummyImgList, LVSIL_NORMAL );
SetImageList( &dummyImgList, LVSIL_SMALL );
SetImageList( &dummyImgList, LVSIL_STATE );
CImageList* imgListPtr = 0;
// set thumbnail size according to list style
DWORD wstyle = GetWindowLong( GetSafeHwnd(), GWL_STYLE );
// hack: have to force change the list view style so tooltip cache resets.
SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_REPORT );
wstyle = GetWindowLong( GetSafeHwnd(), GWL_STYLE );
if ( style_ == BIGICONS )
{
SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_ICON );
listViewIcons_ = true;
thumbWidthCur_ = thumbWidth_;
thumbHeightCur_ = thumbHeight_;
listCache_ = &listCacheBig_;
listCache_->setMaxItems( maxItems_ );
imgListPtr = &imgListBig_;
}
else if ( style_ == SMALLICONS )
{
SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_LIST );
listViewIcons_ = true;
thumbWidthCur_ = thumbWidthSmall_;
thumbHeightCur_ = thumbHeightSmall_;
// Since small icons take less space, up the max cache items (by 16 if
// big thumbs are 64x64 and small thumbs are 16x16, for example) to
// take advantage of the same memory space.
int memoryMultiplier =
( thumbWidth_ * thumbHeight_ ) /
( thumbWidthSmall_ * thumbHeightSmall_ );
listCache_ = &listCacheSmall_;
listCache_->setMaxItems( maxItems_ * memoryMultiplier );
imgListPtr = &imgListSmall_;
}
else
{
SetWindowLong( GetSafeHwnd(), GWL_STYLE, (wstyle & ~LVS_TYPEMASK) | LVS_LIST );
listViewIcons_ = false;
thumbWidthCur_ = 0;
thumbHeightCur_ = 0;
imgListPtr = &dummyImgList;
}
// create image list if the style requires it
if ( style_ != LIST )
{
if ( !imgListPtr->GetSafeHandle() )
{
imgListPtr->Create( thumbWidthCur_, thumbHeightCur_, IMGLIST_FORMAT, 0, 32 );
imgListPtr->SetBkColor( GetBkColor() );
imgListPtr->Add( AfxGetApp()->LoadIcon( IDI_UALFILE ) );
// clear cache
listCache_->init( imgListPtr, 1 );
}
}
// set the image list
if ( style_ == BIGICONS )
SetImageList( imgListPtr, LVSIL_NORMAL );
else if ( style_ == SMALLICONS )
SetImageList( imgListPtr, LVSIL_SMALL );
// clear and start
SetItemCount( 0 );
if ( provider_ )
SetTimer( SMARTLIST_LOADTIMER_ID, SMARTLIST_LOADTIMER_MSEC, 0 );
}