AFX_INLINE BOOL CreateImageListA(CImageList& il, UINT nID,CDC* m_DC, long sizeImage = 16) { il.Create(sizeImage, sizeImage, ILC_MASK|ILC_COLOR24, 0, 0);//4,1 CBitmap bmp; VERIFY(bmp.LoadBitmap(nID)); il.Add(&bmp,RGB(255,0,255)); return TRUE; }
void CServerListCtrl::SetAllIcons() { CImageList iml; iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); iml.Add(CTempIconLoader(_T("Server"))); HIMAGELIST himl = ApplyImageList(iml.Detach()); if (himl) ImageList_Destroy(himl); }
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(); }
void OnDragging( CPoint& point ){ if( m_bDragging ) { CPoint pt(point); ClientToScreen( &pt ); m_pDragImage->DragMove( pt ); m_pDragImage->DragShowNolock( FALSE ); CWnd* pDropWnd = CWnd::WindowFromPoint( pt ); ASSERT(pDropWnd); if( pDropWnd != m_pDropWnd ) { if( m_hDropItem ) { ((CTreeCtrl*)m_pDropWnd)->SelectDropTarget( NULL ); m_hDropItem = NULL; } if( m_nDropIndex != -1 ) { CListCtrl* pList = (CListCtrl*)m_pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); m_nDropIndex = -1; } } m_pDropWnd = pDropWnd; pDropWnd->ScreenToClient( &pt ); if( pDropWnd->IsKindOf(RUNTIME_CLASS(CTreeCtrl)) ) { UINT uFlags; m_hDropItem = ((CTreeCtrl*)pDropWnd)->HitTest( pt, &uFlags ); ((CTreeCtrl*)pDropWnd)->SelectDropTarget( m_hDropItem ); } else if( pDropWnd->IsKindOf(RUNTIME_CLASS(CListCtrl)) ) { UINT uFlags; CListCtrl* pList = (CListCtrl*)pDropWnd; pList->SetItemState( m_nDropIndex, 0, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest( pt, &uFlags ); pList->SetItemState( m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED ); pList->RedrawItems( m_nDropIndex, m_nDropIndex ); pList->UpdateWindow(); } m_pDragImage->DragShowNolock( TRUE ); } }
BOOL CConnectDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here m_listServer.m_nType = CONNECTDLG; // 리스트가 지신의 기능만을 처리할수 있는 타입값 m_nClient = 0; // 라디오박스 m_bViewFolder = TRUE; // 폴더공유 UpdateData(false); m_listServer.InsertColumn(0, "", LVCFMT_CENTER, 22); // 이미지 m_listServer.InsertColumn(1, "Server Name", LVCFMT_LEFT, 116); m_listServer.InsertColumn(2, "Server IP", LVCFMT_LEFT, 110); m_listServer.InsertColumn(3, "User ID", LVCFMT_LEFT, 100); m_listServer.InsertColumn(4, "View Folder", LVCFMT_CENTER, 90); m_listServer.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); // 밑줄나오게 설정 // 256 칼라 이상 적용(icon) CImageList imageList; CBitmap bitmap; bitmap.LoadBitmap(IDB_BITMAP_LIST_LIBRARY_CONNECT); imageList.Create(16, 16, ILC_COLORDDB | ILC_MASK, 16, 1); imageList.Add(&bitmap, RGB(255, 255, 255)); m_listServer.SetImageList(&imageList, LVSIL_SMALL); imageList.Detach(); bitmap.Detach(); /** // listCtrl 에 아이콘 256 칼라 넣기 m_imageList.Create(16, 16, ILC_COLOR8 | ILC_MASK, 16, 1); HICON hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_LIST_LIBRARY_CONNECT), IMAGE_ICON, SM_CXICON, SM_CYICON, LR_SHARED | LR_LOADTRANSPARENT); m_imageList.Add(hIcon); hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_ICON_LIST_LIBRARY_DISCONNECT), IMAGE_ICON, SM_CXICON, SM_CYICON, LR_SHARED | LR_LOADTRANSPARENT); m_imageList.Add(hIcon); m_listServer.SetImageList(&m_imageList, LVSIL_SMALL); **/ // 파일로드 LoadFile(); // 처음에 데이타가 한개라도 있으면 첫번째 데이타를 보이게 if(m_listServer.GetItemCount() > 0){ m_strServerName = m_listServer.GetItemText(0, 1); m_ipAddressServerIP.SetWindowText(m_listServer.GetItemText(0, 2)); m_strUserID = m_listServer.GetItemText(0, 3); m_bViewFolder = (m_listServer.GetItemText(0, 4) == "YES" ? 1 : 0); UpdateData(FALSE); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CDirectoryTreeCtrl::OnDestroy() { // If a treeview control is created with TVS_CHECKBOXES, the application has to // delete the image list which was implicitly created by the control. CImageList *piml = GetImageList(TVSIL_STATE); if (piml) piml->DeleteImageList(); CTreeCtrl::OnDestroy(); }
UINT DllWrapper::GetImage(CImageList & il, UINT nID) { CBitmap bmp; HBITMAP hBitmap = LoadBitmap(m_hInstance,MAKEINTRESOURCE(nID)); CBitmap* pBmp = bmp.FromHandle(hBitmap); int ret = il.Add(pBmp,CXTPImageManager::GetBitmapMaskColor(*pBmp, CPoint(0, 0))); return il.GetImageCount(); }
// @pymethod int|PyCImageList|GetImageCount|Retrieves the number of images in an image list. PyObject *PyCImageList_GetImageCount( PyObject *self, PyObject *args ) { CImageList *pList; if (!(pList=PyCImageList::GetImageList(self))) return NULL; CHECK_NO_ARGS2(args, "GetImageCount"); GUI_BGN_SAVE; int rc = pList->GetImageCount(); GUI_END_SAVE; return Py_BuildValue("i", rc); }
BOOL CEmptyProjectTemplateItem::InitItem(LPCTSTR lpszPath, CImageList &ImageList32, CImageList &ImageList16) { UNUSED_ALWAYS(lpszPath); //add image to image list and remember index HICON hIcon = theApp.LoadIcon(IDR_LATEXDOCTYPE); m_nImageIndex = hIcon ? ImageList32.Add(hIcon) : -1; ImageList16.Add(hIcon); return TRUE; }
BOOL CFileWindow::InitDirectoryImageList( CImageList & imglst ) { SHFILEINFO shFinfo; HIMAGELIST hImageList = NULL; hImageList = (HIMAGELIST)SHGetFileInfo( "C:\\", 0, &shFinfo, sizeof( shFinfo ), SHGFI_SYSICONINDEX | SHGFI_SMALLICON ); if ( ! hImageList ) return FALSE; if( imglst.Detach() ) AfxMessageBox( "This should not occur!"); imglst.Attach( hImageList ); return TRUE; }
void CTaskSwitcher32Dlg::FilterList() { m_windowList2.DeleteAllItems(); window_list *list = window_item::get_window_list(); CImageList *pImageList = new CImageList(); pImageList->Create( 16, 16, ILC_COLOR32 | ILC_MASK | ILC_PERITEMMIRROR, 0, 10); m_windowList2.SetImageList( pImageList, LVSIL_SMALL); int default_idx = pImageList->Add( m_hIcon ); for ( unsigned int i = 0; i < list->size(); i++ ) { window_item *item = (*list)[i]; bool ok = true; if ( this->search.length() > 0 ) { int pos = item->get_lower_title().find( this->search ) ; int pos2 = item->get_process_name().find( this->search ); if ( pos == std::string::npos && pos2 == std::string::npos ) ok = false; } if ( ok ) { HWND hwnd = item->get_handle(); HICON hIcon = NULL; SendMessageTimeout(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon); if (!hIcon) SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon); if (!hIcon) SendMessageTimeout(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&hIcon); if (!hIcon) hIcon = (HICON)GetClassLong(hwnd, GCL_HICON); if (!hIcon) hIcon = (HICON)GetClassLong(hwnd, GCL_HICONSM); int imageidx = -1; if ( hIcon != NULL ) { HICON iconCopy = CopyIcon( hIcon ); imageidx = pImageList->Add( iconCopy ); DestroyIcon( iconCopy ); } else { imageidx = 1; } int idx = m_windowList2.InsertItem( 0, item->get_title().c_str(), imageidx ); m_windowList2.SetItem( idx, 1, LVIF_TEXT | LVIF_IMAGE, item->get_process_name().c_str(), imageidx, 0, 0, 0 ); m_windowList2.SetItemData( idx, (DWORD_PTR) item ); } } m_windowList2.SetItemState( 0, LVIS_SELECTED, LVIS_SELECTED ); m_windowList2.SetSelectionMark( 0 ); }
// @pymethod int|PyCImageList|Add|Adds an image to the list. PyObject *PyCImageList_Add( PyObject *self, PyObject *args ) { PyObject *obbmp1, *obbmp2; int mask; CImageList *pList = PyCImageList::GetImageList(self); int rc; if (!pList) return NULL; if (PyArg_ParseTuple(args, "(OO)", &obbmp1, &obbmp2)) {// @pyparm (int,int)|bitmap, bitmapMask||2 Bitmaps to use (primary and mask) HBITMAP bmp1, bmp2; if (!PyWinObject_AsHANDLE(obbmp1, (HANDLE *)&bmp1) || !PyWinObject_AsHANDLE(obbmp2, (HANDLE *)&bmp2)) return NULL; if (!IsGdiHandleValid(bmp1) || !IsGdiHandleValid(bmp2)) RETURN_ERR("One of the bitmap handles is invalid"); GUI_BGN_SAVE; rc = pList->Add(CBitmap::FromHandle(bmp1), CBitmap::FromHandle(bmp2)); GUI_END_SAVE; } else { PyErr_Clear(); HBITMAP bmp1; if (PyArg_ParseTuple(args, "Oi", &obbmp1, // @pyparmalt1 int|bitmap||Bitmap to use &mask)) { // @pyparmalt1 int|color||Color to use for the mask. if (!PyWinObject_AsHANDLE(obbmp1, (HANDLE *)&bmp1)) return NULL; if (!IsGdiHandleValid(bmp1)) RETURN_ERR("The bitmap handle is invalid"); GUI_BGN_SAVE; rc = pList->Add(CBitmap::FromHandle(bmp1), (COLORREF)mask); GUI_END_SAVE; } else { PyErr_Clear(); PyObject *obIcon; if (PyArg_ParseTuple(args, "O", &obIcon)) {// @pyparmalt2 int|hIcon||Handle of an icon to add. HICON hIcon; if (!PyWinObject_AsHANDLE(obIcon, (HANDLE *)&hIcon)) return NULL; GUI_BGN_SAVE; rc = pList->Add(hIcon); GUI_END_SAVE; } else { PyErr_Clear(); RETURN_ERR("Add requires '(hbitmap, hbitmap)', 'hbitmap, color' or 'hicon'"); } } } if (rc==-1) RETURN_ERR("Add failed"); return Py_BuildValue("i", rc); // @rdesc Zero-based index of the first new image. }
LRESULT IdentifyView::onCreate(LPCREATESTRUCT createStruct) { RECT myRect = { 0, 0, createStruct->cx, createStruct->cy }; //RECT identRect = { 0, 0, 250, createStruct->cy }; //RECT gridRect = { 250, 0, createStruct->cx, createStruct->cy }; DWORD splitterStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; // Create child windows m_splitter.Create(m_hWnd, myRect, NULL, splitterStyle); m_splitter.SetSplitterExtendedStyle(0); m_splitter.SetDlgCtrlID(IDW_SPLITTER); DWORD gridStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA; m_identifyList->Create(m_splitter.m_hWnd, rcDefault, NULL, gridStyle, WS_EX_CLIENTEDGE); m_identifyList->SetDlgCtrlID(IDW_IDENTLIST); m_datagrid->Create(m_splitter.m_hWnd, rcDefault, NULL, gridStyle, WS_EX_CLIENTEDGE); m_datagrid->SetDlgCtrlID(IDW_DATAGRID); m_splitter.SetSplitterPanes(m_identifyList->m_hWnd, m_datagrid->m_hWnd); m_splitter.SetActivePane(SPLIT_PANE_LEFT); m_splitter.SetSplitterPos(250); // Assign a datamodel to the list of identifyables. m_identifyListModel.reset(new IdentifyListDataModel(m_db)); m_identifyList->setModel(m_identifyListModel); m_identifyList->autosizeColumnsUseData(); DlgResize_Init(false, false); // Build the toolbar TBBUTTON buttons[1]; buttons[0].iBitmap = 0; buttons[0].idCommand = ID_HELP; buttons[0].fsState = TBSTATE_ENABLED; buttons[0].fsStyle = TBSTYLE_BUTTON | BTNS_SHOWTEXT | BTNS_AUTOSIZE; buttons[0].dwData = NULL; buttons[0].iString = (INT_PTR)_T("Help"); CImageList imageList; imageList.CreateFromImage(IDB_IDENTIFY_VIEW, 16, 1, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION | LR_DEFAULTSIZE); m_toolbar.Create(GetTopLevelWindow(), NULL, _T("IdentifyViewToolBar"), ATL_SIMPLE_TOOLBAR_PANE_STYLE | TBSTYLE_LIST, TBSTYLE_EX_MIXEDBUTTONS); m_toolbar.SetButtonStructSize(); m_toolbar.SetImageList(imageList); m_toolbar.AddButtons(ARRAYSIZE(buttons), buttons); m_toolbar.AutoSize(); return 0; }
BOOL CEmoticonDlg::OnInitDialog() { CDialog::OnInitDialog(); CImageList* pImageList = new CImageList(); pImageList->Create(32, 32, ILC_COLOR16, 0, 1); m_listEmoticon.SetImageList(pImageList, LVSIL_NORMAL); LoadEmoticons(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void AddQuestion(HIMAGELIST hmyImageList) { CImageList imgList; // Attach the image list handle to the CImageList object. imgList.Attach(hmyImageList); // Add a new icon to the image list. imgList.Add(AfxGetApp()->LoadStandardIcon(IDI_QUESTION)); // Detach the handle from the CImageList object. imgList.Detach(); }
///////////////////////////////////////////////////////////////////////////// // CMyTreeCtrl message handlers void CMyTreeCtrl::OnDestroy() { CImageList *pimagelist; pimagelist = GetImageList(TVSIL_NORMAL); if( pimagelist ) pimagelist->DeleteImageList(); delete pimagelist; pimagelist = GetImageList(TVSIL_STATE); if( pimagelist ) pimagelist->DeleteImageList(); delete pimagelist; }
LRESULT CSHeaderCtrl::OnSetImageList(WPARAM, LPARAM lParam) { CImageList* pImageList; pImageList = CImageList::FromHandle((HIMAGELIST)lParam); IMAGEINFO info; if (pImageList->GetImageInfo(0, &info)) { m_sizeImage.cx = info.rcImage.right - info.rcImage.left; m_sizeImage.cy = info.rcImage.bottom - info.rcImage.top; } return Default(); }
void CIrcWnd::SetAllIcons() { CImageList iml; iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); iml.Add(CTempIconLoader(_T("Smiley_Smile"))); iml.Add(CTempIconLoader(_T("Bold"))); iml.Add(CTempIconLoader(_T("Underline"))); iml.Add(CTempIconLoader(_T("Colour"))); iml.Add(CTempIconLoader(_T("ResetFormat"))); CImageList* pImlOld = m_wndFormat.SetImageList(&iml); iml.Detach(); if (pImlOld) pImlOld->DeleteImageList(); }
void CEditDelayed::OnInit(CHeaderCtrl* pColumnHeader) { SetEditRect(false); CRect rectWindow; GetClientRect(rectWindow); m_pctrlColumnHeader = pColumnHeader; m_hCursor = LoadCursor(NULL, IDC_ARROW); m_nCurrentColumnIdx = 0; CImageList* pImageList = new CImageList(); pImageList->Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); pImageList->SetBkColor(CLR_NONE); if (pColumnHeader != NULL) pImageList->Add(CTempIconLoader(_T("SEARCHEDIT"))); else pImageList->Add(CTempIconLoader(_T("KADNODESEARCH"))); m_iwColumn.SetImageList(pImageList); m_iwColumn.Create(_T(""), WS_CHILD | WS_VISIBLE, CRect(0, 0, ICON_LEFTSPACE, rectWindow.bottom), this, 1); pImageList = new CImageList(); pImageList->Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1); pImageList->SetBkColor(CLR_NONE); pImageList->Add(CTempIconLoader(_T("FILTERCLEAR1"))); pImageList->Add(CTempIconLoader(_T("FILTERCLEAR2"))); m_iwReset.SetImageList(pImageList); m_iwReset.Create(_T(""), WS_CHILD , CRect(0, 0, ICON_LEFTSPACE, rectWindow.bottom), this, 1); ShowColumnText(true); }
BOOL CMainFrame::CreateShortcutsBar () { CMFCOutlookBarTabCtrl::EnableAnimation (); const int nInitialWidth = 150; const CString strCaption = _T("Shortcuts"); // <snippet2> // int nInitialWidth // CString strCaption if (!m_wndShortcutsBar.Create (strCaption, this, CRect (0, 0, nInitialWidth, nInitialWidth), ID_VIEW_OUTLOOKBAR, WS_CHILD | WS_VISIBLE | CBRS_LEFT)) { TRACE0("Failed to create outlook bar\n"); return FALSE; // fail to create } // </snippet2> CMFCOutlookBarTabCtrl* pShortcutsBarContainer = DYNAMIC_DOWNCAST (CMFCOutlookBarTabCtrl, m_wndShortcutsBar.GetUnderlyingWindow ()); if (pShortcutsBarContainer == NULL) { TRACE0("Cannot get outlook bar container\n"); return FALSE; } // <snippet4> CImageList images; images.Create (IDB_SHORTCUTS, 32, 0, RGB (255, 0, 255)); // Create first page: m_wndShortcutsPane1.Create (&m_wndShortcutsBar, AFX_DEFAULT_TOOLBAR_STYLE, ID_SHORTCUTS_PANE_1); // The this pointer points to a CMainFrame class which extends the CFrameWnd class m_wndShortcutsPane1.SetOwner (this); m_wndShortcutsPane1.EnableTextLabels (); m_wndShortcutsPane1.EnableDocking (CBRS_ALIGN_ANY); m_wndShortcutsPane1.EnablePageScrollMode(); m_wndShortcutsPane1.SetBackColor(RGB(0,255,0)); m_wndShortcutsPane1.AddButton (images.ExtractIcon (0), _T("View 1"), ID_SHORTCUT_1); m_wndShortcutsPane1.AddButton (images.ExtractIcon (1), _T("View 2"), ID_SHORTCUT_2); m_wndShortcutsPane1.AddButton (images.ExtractIcon (2), _T("View 3"), ID_SHORTCUT_3); m_wndShortcutsPane1.AddButton (images.ExtractIcon (3), _T("View 4"), ID_SHORTCUT_4); // </snippet4> pShortcutsBarContainer->AddTab (&m_wndShortcutsPane1, _T("Views"), (UINT)-1, FALSE); return TRUE; }
BOOL CuDlgMain::OnInitDialog() { CDialog::OnInitDialog(); m_hIconOpen = theApp.LoadIcon (IDI_OPEN); m_hIconSave = theApp.LoadIcon (IDI_SAVE); m_hIconNode = theApp.LoadIcon (IDI_NODE); m_cButtonSc2Save.SetIcon(m_hIconSave); m_cButtonSc2Open.SetIcon(m_hIconOpen); m_cButtonSc1Save.SetIcon(m_hIconSave); m_cButtonSc1Open.SetIcon(m_hIconOpen); VERIFY (m_cListCheckBox.SubclassDlgItem (IDC_LIST1, this)); m_ImageListNode.Create(IDB_NODES, 16, 1, RGB(255, 0, 255)); m_ImageListUser.Create(IDB_USER, 16, 1, RGB(255, 0, 255)); m_ImageListDatabase.Create(IDB_DATABASE, 16, 1, RGB(255, 0, 255)); UINT narrayImage[3] = {IDB_INGRESOBJECT3_16x16, IDB_DATABASE_DISTRIBUTED, IDB_DATABASE_COORDINATOR}; for (int i = 0; i<3; i++) { CImageList im; if (im.Create(narrayImage[i], 16, 1, RGB(255, 0, 255))) { HICON hIconBlock = im.ExtractIcon(0); if (hIconBlock) { m_ImageListDatabase.Add (hIconBlock); DestroyIcon (hIconBlock); } } } m_cComboNode1.SetImageList(&m_ImageListNode); m_cComboNode2.SetImageList(&m_ImageListNode); m_cComboDatabase1.SetImageList(&m_ImageListDatabase); m_cComboDatabase2.SetImageList(&m_ImageListDatabase); m_cComboUser1.SetImageList(&m_ImageListUser); m_cComboUser2.SetImageList(&m_ImageListUser); HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); m_cListCheckBox.SendMessage(WM_SETFONT, (WPARAM)hFont); m_cCheckIgnoreOwner.SetCheck(1); m_vsdaCtrl.SetSessionStart(500); m_vsdaCtrl.SetSessionDescription(_T("Ingres Visual Database Objects Differences Analyzer (vsda.ocx)")); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL CTrueColorToolBar::SetTrueColorToolBar(UINT uToolBarType, UINT uToolBar, int nBtnWidth) { CImageList cImageList; CBitmap cBitmap; BITMAP bmBitmap; CSize cSize; int nNbBtn; if (!cBitmap.Attach(LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(uToolBar), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_CREATEDIBSECTION)) || !cBitmap.GetBitmap(&bmBitmap)) return FALSE; cSize = CSize(bmBitmap.bmWidth, bmBitmap.bmHeight); nNbBtn = cSize.cx/nBtnWidth; RGBTRIPLE* rgb = (RGBTRIPLE*)(bmBitmap.bmBits); COLORREF rgbMask = RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue); if (!cImageList.Create(nBtnWidth, cSize.cy, ILC_COLOR24|ILC_MASK, nNbBtn, 0)) return FALSE; if (cImageList.Add(&cBitmap, rgbMask) == -1) return FALSE; /* if (uToolBarType == TB_SETIMAGELIST) GetToolBarCtrl().SetImageList(&cImageList); else if (uToolBarType == TB_SETHOTIMAGELIST) GetToolBarCtrl().SetHotImageList(&cImageList); else if (uToolBarType == TB_SETDISABLEDIMAGELIST) GetToolBarCtrl().SetDisabledImageList(&cImageList); else return FALSE; */ SendMessage(uToolBarType, 0, (LPARAM)cImageList.m_hImageList); cImageList.Detach(); cBitmap.Detach(); return TRUE; }
void CToolsHelper::AppendToolsToToolbar(const CUserToolArray& aTools, CToolBar& toolbar, UINT nCmdAfter) { // remove tools first RemoveToolsFromToolbar(toolbar, nCmdAfter); // then re-add if (aTools.GetSize()) { // figure out if we want the large or small images CSize sizeBtn(toolbar.GetToolBarCtrl().GetButtonSize()); sizeBtn -= CSize(7, 7); // btn borders from BarTool.cpp CSysImageList sil((sizeBtn.cx > 16)); VERIFY(sil.Initialize()); // start adding after the pref button int nStartPos = toolbar.CommandToIndex(nCmdAfter) + 1; int nAdded = 0; for (int nTool = 0; nTool < aTools.GetSize(); nTool++) { const USERTOOL& tool = aTools[nTool]; HICON hIcon = GetToolIcon(sil, tool); if (hIcon) { CImageList* pIL = toolbar.GetToolBarCtrl().GetImageList(); int nImage = pIL->Add(hIcon); TBBUTTON tbb = { nImage, nTool + m_nStartID, 0, TBSTYLE_BUTTON, 0, 0, (UINT)-1 }; if (toolbar.GetToolBarCtrl().InsertButton(nStartPos + nAdded, &tbb)) nAdded++; else // remove image pIL->Remove(nImage); // cleanup ::DestroyIcon(hIcon); } } // add a separator if any buttons added if (nAdded) { TBBUTTON tbb = { -1, 0, 0, TBSTYLE_SEP, 0, 0, (UINT)-1 }; toolbar.GetToolBarCtrl().InsertButton(nStartPos, &tbb); } } }
void CHelperDlg::DrawGripSize(void) { static CImageList s_ilGripSize; if(s_ilGripSize.m_hImageList == 0) { s_ilGripSize.Create(IDB_BITMAP_GRIP_SIZE, 12, 1, RGB(255, 0, 255)); } CRect rect; GetWindowRect(&rect); CDC *dc = GetWindowDC(); ImageList_Draw(s_ilGripSize.m_hImageList, 0, dc->m_hDC, rect.Width()-12-3, rect.Height()-12-3, ILD_NORMAL); ::ReleaseDC(m_hWnd, dc->m_hDC); }
void CListOptionCtrl::InitListBox() { m_bHighlightOnlyText=m_listBoxEx.GetHighlightOnlyText(); m_clrListBoxBack=m_listBoxEx.GetBkColor(); UpdateData(FALSE); // set image list to be displayed static CImageList imageList; imageList.Create(IDB_IL_LISTBOXCHK,16,0,RGB(192,192,192)); m_listBoxEx.SetImageList(&imageList); // fonts for items static CFont g_fontHeader; VERIFY(g_fontHeader.CreatePointFont(150,_T("Arial"))); static CFont g_fontFamily; VERIFY(g_fontFamily.CreatePointFont(140,_T("Times New Roman"))); // hierarchial items AddItem(_T("Simpsons"),0,0,RGB(0,0,0), _T("Reside in Springfield, USA"),&g_fontHeader); AddItem(_T("Homer"),0,20,RGB(0,0,255),_T("Still has hair"),&g_fontFamily); AddItem(_T("Marge"),0,20,RGB(0,0,255),_T(""),&g_fontFamily); AddItem(_T("Bart"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("Lisa"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("Maggie"),0,40,RGB(0,128,0),_T(""),&g_fontFamily); AddItem(_T("GrandPa"),0,20,RGB(128,128,128),_T(""),&g_fontFamily); for(int nIndex=0; nIndex<m_listBoxEx.GetCount(); nIndex++) { CFont* pFont=new CFont; m_arrFonts.Add(pFont); } m_listBoxEx.SetCurSel(0); OnSelChangeListBoxEx(); //GetParentFrame()->RecalcLayout(); //ResizeParentToFit(); }
void ProgressImages::InitializeProgressImages(CImageList& img, RgbPixel32 background, RgbPixel32 filled, RgbPixel32 unfilled) { m_background = background; m_unfilled = unfilled; m_filled = filled; m_diameter = 14; m_radius = 7; m_pieBlurringSize = 2; m_perimeter = static_cast<int>(GetPI() * m_diameter); m_background = background; m_images.clear(); m_images.reserve(m_perimeter+1); // add 1 for complete coverage, to be on the safe side. m_angles.Resize(m_radius + 1, static_cast<float>(m_perimeter), 0);// the values returned from m_angles will be in the range 0-perimeter, or in other words, 0-m_images.size(). for(m_i = 0; m_i < m_perimeter; m_i ++) { m_bmp = new AnimBitmap<32>(); m_bmp->SetSize(16, 16); m_bmp->Fill(m_background); FilledCircleAAG(8, 8, m_radius, this, &ProgressImages::DrawHLine, this, &ProgressImages::DrawAlphaPixel); // add it to the imagelist. HBITMAP hbm = m_bmp->DetachHandle(); m_images.push_back(img.Add(hbm)); DeleteObject(hbm); delete m_bmp; m_bmp = 0; } }
//填充列表 WORD __cdecl CUserFaceRes::FillImageList(CImageList & ImageList) { //设置资源 AfxSetResourceHandle(GetModuleHandle(USER_FACE_DLL_NAME)); //加载头像 CBitmap Image; Image.LoadBitmap(IDB_FACE_NORMAL); ImageList.Create(NOR_FACE_WIDTH,NOR_FACE_HEIGHT,ILC_COLOR16|ILC_MASK,0,0); ImageList.Add(&Image,RGB(255,0,255)); //设置资源 AfxSetResourceHandle(GetModuleHandle(NULL)); return m_wCount; }
bool CToolWindow::TryToIntegrate(HWND hWnd) { if (m_hWnd) return true; // this is singleton, integrate only first time CFindWnd finder(hWnd, TOOLBARCLASSNAME); // TODO: do it safer if (!finder.m_hWnd) return false; SubclassWindow(finder.m_hWnd); if (!::IsWindow(this->m_hWnd)) return true; // HACK CImageList il = GetImageList(); m_IconBase = il.GetImageCount(); il.AddIcon(LoadIcon(GetBaseModule().GetModuleInstance(), MAKEINTRESOURCE(IDI_XREFRESHA))); il.AddIcon(LoadIcon(GetBaseModule().GetModuleInstance(), MAKEINTRESOURCE(IDI_XREFRESHZ))); return true; }
// @pymethod |PyCImageList|SetBkColor|Sets the background color for an Image List. PyObject *PyCImageList_SetBkColor( PyObject *self, PyObject *args ) { CImageList *pList; if (!(pList=PyCImageList::GetImageList(self))) return NULL; int col; // @pyparm int|color||The new background color. if (!PyArg_ParseTuple( args, "i:SetBkColor", &col)) return NULL; GUI_BGN_SAVE; BOOL ok = pList->SetBkColor(col); GUI_END_SAVE; if (!ok) RETURN_ERR("SetBkColor failed"); RETURN_NONE; }
BOOL CDeleteMasterApp::InitInstance() { // LOGFONT lf; HANDLE hMapping; BOOL bPrevInstance = FALSE; CString csError,csCaption; csCaption.LoadString (IDS_DM_ERROR); hMapping = CreateFileMapping((HANDLE)0xffffffff, NULL, PAGE_READONLY, 0, 32, _T("YGDM2003MAP")); if(hMapping) { if( GetLastError() == ERROR_ALREADY_EXISTS ) bPrevInstance = TRUE; } else { // Some other error; handle error. csError.LoadString(IDS_APP_INIT_ERR); ::MessageBox(NULL,csError,csCaption,MB_OK|MB_ICONSTOP); ExitProcess(1); } if(!bPrevInstance) { if(!IsUserAdmin()) { csError.LoadString(IDS_NOT_ADMIN); ::MessageBox(NULL,csError,csCaption,MB_OK|MB_ICONSTOP); return FALSE; } if(!RegClass()) return FALSE; g_imgList_BOX.Create(IDB_BOX,16,0,RGB(255,255,255)); g_imgList_LIST.Create(IDB_LIST,16,0,RGB(255,255,255)); g_pFixDiskInfo = NULL; g_nDelMothed = 0; g_nWipeMothed = 0; g_bVerify = FALSE; g_bFormat = FALSE; g_dwMaxTry = 10; m_pMainWnd = new CMain(); m_pMainWnd->ShowWindow(SW_SHOW); } return TRUE; }