//-------------------------------------------------------------------------
void CDlgColours::OnDrawItem( int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	COLORREF 	crButton = m_oColor.Get( m_id_map[ nIDCtl ] );
	CDC dc;
	CBrush 		brush( crButton );

	dc.Attach( lpDrawItemStruct->hDC );
	dc.SelectStockObject( BLACK_PEN );
	dc.SelectObject( &brush );
	dc.Rectangle( &lpDrawItemStruct->rcItem );
	dc.Detach();
	
	super::OnDrawItem( nIDCtl, lpDrawItemStruct );
}
void CColorSelector::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    // TODO: Add your message handler code here and/or call default
    CDC omDc;
    omDc.Attach(lpDrawItemStruct->hDC);
	UINT unButtonState  = lpDrawItemStruct->itemState;
	int nPushState = ((unButtonState & ODS_SELECTED) ? DFCS_PUSHED : 0) |
					 ((unButtonState & ODS_DISABLED) ? DFCS_INACTIVE : 0);

    CRect omItemRect    = lpDrawItemStruct->rcItem;
    
	
    
	CRect omArrowRect;
    omArrowRect.left = max(0, omItemRect.Width()- GetSystemMetrics(SM_CXHTHUMB) - 3 );
    omArrowRect.right = max(0, omItemRect.Width()-3);
    omArrowRect.top = 3;
    omArrowRect.bottom = max(omItemRect.Height()-3, GetSystemMetrics(SM_CYVTHUMB)-3);
    
	
    omDc.DrawFrameControl(&omArrowRect, DFC_SCROLL, DFCS_SCROLLDOWN  | nPushState);

    // Create backgroung brush
    CBrush brush( m_omColorBkg);
    omDc.SelectStockObject(BLACK_PEN);
    omDc.DrawEdge(&lpDrawItemStruct->rcItem, EDGE_RAISED, BF_RECT);
    CRect omButtonRect;
    
    omButtonRect.left = lpDrawItemStruct->rcItem.left+5;
    omButtonRect.top = lpDrawItemStruct->rcItem.top+5;
    omButtonRect.right = lpDrawItemStruct->rcItem.right - omArrowRect.Width()-5;// - omArrowRect.Width() ;
    omButtonRect.bottom = lpDrawItemStruct->rcItem.bottom - 5;
    
    //omButtonRect.DeflateRect(3, 3);
    omDc.FillRect(omButtonRect, &brush);
    // Select Old Brush
    omDc.SelectObject(brush);
    
    omButtonRect.DeflateRect(-1, -1);
    
    omDc.Rectangle(omButtonRect);

    if (unButtonState & ODS_FOCUS) 
    {
        omButtonRect.DeflateRect(1,1);
        omDc.DrawFocusRect(omButtonRect);
    }
}
示例#3
0
BOOL CEdRptDoc::PrintAuto(CPrintDialog *pPntDlg)
{
	// 严禁在不使用省却打印机情况下不指定打印机
	ASSERT(m_bDefaultPrint || pPntDlg);
	
	// get default print
	CPrintDialog defaultDlg (FALSE, PD_RETURNDC );
	AfxGetApp()->GetPrinterDeviceDefaults( &defaultDlg.m_pd );	

	if (!pPntDlg)
		pPntDlg = &defaultDlg;
	
	HDC hdc = pPntDlg->CreatePrinterDC();
	ASSERT(hdc);
	CDC dc;
	dc.Attach( hdc );
	
    dc.m_bPrinting = TRUE;
	
    CString strTitle = m_szTitle;
	if (strTitle.IsEmpty())
		strTitle.LoadString(AFX_IDS_APP_TITLE);
		
    DOCINFO di;                                 // Initialise print doc details
    memset(&di, 0, sizeof (DOCINFO));
    di.cbSize = sizeof (DOCINFO);
    di.lpszDocName = strTitle;
	
    BOOL bPrintingOK = dc.StartDoc(&di);        // Begin a new print job
	
    CPrintInfo Info;
    Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));
	
    m_Grid.OnBeginPrinting(&dc, &Info);                // Initialise printing
	m_Grid.SetFocus();
    for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
    {
        dc.StartPage();                         // begin new page
        Info.m_nCurPage = page;
        m_Grid.OnPrint(&dc, &Info);                    // Print page
        bPrintingOK = (dc.EndPage() > 0);       // end page
    }
    m_Grid.OnEndPrinting(&dc, &Info);                  // Clean up after printing
	
    if (bPrintingOK)
        dc.EndDoc();                            // end a print job
    else
        dc.AbortDoc();                          // abort job.
	
    dc.Detach();                                // detach the printer DC
	
	DeleteDC(hdc);

	return TRUE;
}
示例#4
0
void CChartCtrl::Print(const TChartString& strTitle, CPrintDialog* pPrntDialog)
{
	CDC dc;
    if (pPrntDialog == NULL)
    {
        CPrintDialog printDlg(FALSE);
        if (printDlg.DoModal() != IDOK)         // Get printer settings from user
            return;

		dc.Attach(printDlg.GetPrinterDC());     // attach a printer DC
    }
    else
		dc.Attach(pPrntDialog->GetPrinterDC()); // attach a printer DC
    dc.m_bPrinting = TRUE;
	
    DOCINFO di;                                 // Initialise print doc details
    memset(&di, 0, sizeof (DOCINFO));
    di.cbSize = sizeof (DOCINFO);
	di.lpszDocName = strTitle.c_str();

    BOOL bPrintingOK = dc.StartDoc(&di);        // Begin a new print job

    CPrintInfo Info;
    Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));

    OnBeginPrinting(&dc, &Info);                // Initialise printing
    for (UINT page = Info.GetMinPage(); page <= Info.GetMaxPage() && bPrintingOK; page++)
    {
        dc.StartPage();                         // begin new page
        Info.m_nCurPage = page;
        OnPrint(&dc, &Info);                    // Print page
        bPrintingOK = (dc.EndPage() > 0);       // end page
    }
    OnEndPrinting(&dc, &Info);                  // Clean up after printing

    if (bPrintingOK)
        dc.EndDoc();                            // end a print job
    else
        dc.AbortDoc();                          // abort job.

    dc.Detach();                                // detach the printer DC
}
示例#5
0
BOOL CWinApp::CreatePrinterDC(CDC& dc)
{
	HDC hDC = AfxCreateDC(m_hDevNames, m_hDevMode);
	if (hDC != NULL)
	{
		dc.DeleteDC();
		VERIFY(dc.Attach(hDC));
		return TRUE;
	}
	return FALSE;
}
// CMyODListBox is my owner-drawn list box derived from CListBox. This 
// example draws an item's text centered vertically and horizontally. The 
// list box control was created with the following code:
//   m_myODListBox.Create(
//      WS_CHILD|WS_VISIBLE|WS_BORDER|WS_HSCROLL|WS_VSCROLL|
//      LBS_SORT|LBS_MULTIPLESEL|LBS_OWNERDRAWVARIABLE|LBS_WANTKEYBOARDINPUT,
//      CRect(10,250,200,450), pParentWnd, IDC_MYODLISTBOX);
//
void CMyODListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   ASSERT(lpDrawItemStruct->CtlType == ODT_LISTBOX);
   LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
   ASSERT(lpszText != NULL);
   CDC dc;

   dc.Attach(lpDrawItemStruct->hDC);

   // Save these value to restore them when done drawing.
   COLORREF crOldTextColor = dc.GetTextColor();
   COLORREF crOldBkColor = dc.GetBkColor();

   // If this item is selected, set the background color 
   // and the text color to appropriate values. Also, erase
   // rect by filling it with the background color.
   if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
      (lpDrawItemStruct->itemState & ODS_SELECTED))
   {
      dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
      dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
      dc.FillSolidRect(&lpDrawItemStruct->rcItem, 
         ::GetSysColor(COLOR_HIGHLIGHT));
   }
   else
   {
      dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor);
   }

   // If this item has the focus, draw a red frame around the
   // item's rect.
   if ((lpDrawItemStruct->itemAction | ODA_FOCUS) &&
      (lpDrawItemStruct->itemState & ODS_FOCUS))
   {
      CBrush br(RGB(255, 0, 0));
      dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
   }

   // Draw the text.
   dc.DrawText(
      lpszText,
      (int)_tcslen(lpszText),
      &lpDrawItemStruct->rcItem,
      DT_CENTER|DT_SINGLELINE|DT_VCENTER);

   // Reset the background color and the text color back to their
   // original values.
   dc.SetTextColor(crOldTextColor);
   dc.SetBkColor(crOldBkColor);

   dc.Detach();
}
示例#7
0
//
// Show a help balloon on screen
// Parameters:
//    strTitle    |  Title of balloon
//    strContent  |  Content of balloon
//    ptAnchor    |  point tail of balloon will be "anchor"ed to
//    szIcon      |  One of:
//                   IDI_APPLICATION
//                   IDI_INFORMATION IDI_ASTERISK (same)
//                   IDI_ERROR IDI_HAND (same)
//                   IDI_EXCLAMATION IDI_WARNING (same)
//                   IDI_QUESTION
//                   IDI_WINLOGO
//                   NULL (no icon)
//    unOptions   |  One or more of:
//                :     unCLOSE_ON_LBUTTON_UP   |  closes window on WM_LBUTTON_UP
//                :     unCLOSE_ON_MBUTTON_UP   |  closes window on WM_MBUTTON_UP
//                :     unCLOSE_ON_RBUTTON_UP   |  closes window on WM_RBUTTON_UP
//                :     unCLOSE_ON_LBUTTON_DOWN |  closes window on WM_LBUTTON_DOWN
//                :     unCLOSE_ON_MBUTTON_DOWN |  closes window on WM_MBUTTON_DOWN
//                :     unCLOSE_ON_RBUTTON_DOWN |  closes window on WM_RBUTTON_DOWN
//                :     unCLOSE_ON_MOUSE_MOVE   |  closes window when user moves mouse past threshhold
//                :     unCLOSE_ON_KEYPRESS     |  closes window on the next keypress message sent to this thread.  (!!! probably not thread safe !!!)
//                :     unSHOW_CLOSE_BUTTON     |  shows close button in upper right
//                :     unSHOW_INNER_SHADOW     |  draw inner shadow in balloon
//                :     unSHOW_TOPMOST          |  place balloon above all other windows
//                :     unDISABLE_FADE          |  disable the fade-in/fade-out effects (overrides system and user settings)
//                :     unDISABLE_FADEIN        |  disable the fade-in effect
//                :     unDISABLE_FADEOUT       |  disable the fade-out effect
//    pParentWnd  |  Parent window.  If NULL will be set to AfxGetMainWnd(), and anchor to screen
//    strURL      |  If not empty, when the balloon is clicked ShellExecute() will
//                |  be called, with strURL passed in.
//    unTimeout   |  If not 0, balloon will automatically close after unTimeout milliseconds.
//
void CBalloonHelp::LaunchBalloon(const CString& strTitle, const CString& strContent, 
								 const CPoint& ptAnchor, 
								 LPCTSTR szIcon /*= IDI_EXCLAMATION*/,
								 unsigned int unOptions /*= unSHOW_CLOSE_BUTTON*/,
								 CWnd* pParentWnd /*= NULL*/,
								 const CString strURL /*= ""*/,
								 unsigned int unTimeout /*= 10000*/)
{
	CBalloonHelp* pbh = new CBalloonHelp;
	if ( NULL != szIcon )
	{
		HICON hIcon = (HICON)::LoadImage(NULL, szIcon, IMAGE_ICON, 16,16, LR_SHARED);
		if (NULL != hIcon)
		{
			// Use a scaled standard icon (looks very good on Win2k, XP, not so good on Win9x)
			CDC dc;
			CDC dcTmp1;
			CDC dcTmp2;
			CBitmap bmpIcon;
			CBitmap bmpIconSmall;
			dc.Attach(::GetDC(NULL));
			dcTmp1.CreateCompatibleDC(&dc);
			dcTmp2.CreateCompatibleDC(&dc);
			bmpIcon.CreateCompatibleBitmap(&dc, 32,32);
			bmpIconSmall.CreateCompatibleBitmap(&dc, 16,16);
			::ReleaseDC(NULL, dc.Detach());
			
			// i now have two device contexts and two bitmaps.
			// i will select a bitmap in each device context,
			// draw the icon into the larger one,
			// scale it into the smaller one,
			// and set the small one as the balloon icon.
			// This is a rather long process to get a small icon,
			// but ensures maximum compatibility between different
			// versions of Windows, while producing the best possible
			// results on each version.
			CBitmap* pbmpOld1 = dcTmp1.SelectObject(&bmpIcon);
			CBitmap* pbmpOld2 = dcTmp2.SelectObject(&bmpIconSmall);
			dcTmp1.FillSolidRect(0,0,32,32, pbh->m_crBackground);
			::DrawIconEx(dcTmp1, 0,0,hIcon,32,32,0,NULL,DI_NORMAL);
			dcTmp2.SetStretchBltMode(HALFTONE);
			dcTmp2.StretchBlt(0,0,16,16,&dcTmp1, 0,0,32,32,SRCCOPY);
			dcTmp1.SelectObject(pbmpOld1);
			dcTmp2.SelectObject(pbmpOld2);
			
			pbh->SetIcon(bmpIconSmall, pbh->m_crBackground);
		}
	}
	
	pbh->Create(strTitle, strContent, ptAnchor, unOptions|unDELETE_THIS_ON_CLOSE, 
		pParentWnd, strURL, unTimeout, NULL);
}
示例#8
0
void CProgressStatusBar::DrawItem(LPDRAWITEMSTRUCT pDIS)
{
    //TRACE("CProgressStatusBar::DrawItem: %d percent!\n", m_Percent);
    CDC dc;
    dc.Attach(pDIS->hDC);
    CRect rc(pDIS->rcItem);
    CRect rc2(rc);
    rc.right = rc.left + MulDiv(rc.Width(), m_Percent, 100);
    rc2.left = rc.right;
    dc.FillSolidRect(&rc, GetSysColor(COLOR_BTNTEXT));
    dc.FillSolidRect(&rc2, GetSysColor(COLOR_BTNFACE));
    dc.Detach();
}
示例#9
0
文件: kguipc.cpp 项目: CarlHuff/kgui
void kGUISystemWin::GetPrinterInfo(const char *name,int *pw,int *ph,int *ppih,int *ppiv)
{
	HDC printerHDC;
	CDC dc;

	CreateHDC(name,1,&printerHDC);
	dc.Attach (printerHDC);
	pw[0] = dc.GetDeviceCaps(HORZRES);
	ph[0] = dc.GetDeviceCaps(VERTRES);
    ppih[0] = dc.GetDeviceCaps(LOGPIXELSX);
    ppiv[0] = dc.GetDeviceCaps(LOGPIXELSY);
	dc.Detach();
}
void CShareFilesCountStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// TODO:  添加您的代码以绘制指定项
	CDC	dc;
	dc.Attach(lpDrawItemStruct->hDC);

	CRect	rect = lpDrawItemStruct->rcItem;
	DrawBk(&dc, rect);
	rect.DeflateRect(8, 3);
	DrawText(&dc, rect);

	dc.Detach();
}
示例#11
0
void CTabpageBorrow::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// TODO: Add your message handler code here and/or call default
	if (nIDCtl == IDC_RADIO_PASS || nIDCtl == IDC_RADIO_FAIL)
	{
		CDC dc;
		RECT rc;
		dc.Attach(lpDrawItemStruct->hDC);
		dc.SetTextColor(RGB(255, 255, 255));
		dc.Detach();
	}
	CDialogEx::OnDrawItem(nIDCtl, lpDrawItemStruct);
}
示例#12
0
void CPlayerToolBar::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMTBCUSTOMDRAW pTBCD = reinterpret_cast<LPNMTBCUSTOMDRAW>(pNMHDR);
    LRESULT lr = CDRF_DODEFAULT;
    switch (pTBCD->nmcd.dwDrawStage) {
        case CDDS_PREERASE:
            m_volctrl.Invalidate();
            lr = CDRF_DODEFAULT;
            break;
        case CDDS_PREPAINT: {
            // paint the control background, this is needed for XP
            CDC dc;
            dc.Attach(pTBCD->nmcd.hdc);
            RECT r;
            GetClientRect(&r);
            dc.FillSolidRect(&r, ::GetSysColor(COLOR_BTNFACE));
            dc.Detach();
        }
        lr |= CDRF_NOTIFYITEMDRAW;
        break;
        case CDDS_ITEMPREPAINT:
            // notify we want to paint after the system's paint cycle
            lr |= CDRF_NOTIFYPOSTPAINT;
            lr |= CDRF_NOTIFYITEMDRAW;
            break;
        case CDDS_ITEMPOSTPAINT:
            // paint over the duplicated separator
            CDC dc;
            dc.Attach(pTBCD->nmcd.hdc);
            RECT r;
            GetItemRect(11, &r);
            dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
            dc.Detach();
            lr |= CDRF_SKIPDEFAULT;
            break;
    }

    *pResult = lr;
}
示例#13
0
void CMDITabsDialogBar::DrawItem(LPDRAWITEMSTRUCT pdis)
{
    CRect rc = pdis->rcItem;
    int nTabIndex = pdis->itemID;
    bool fSelected = (nTabIndex == GetCurSel());
    ODA_DRAWENTIRE;
	char label[64];
	TCITEM tci;
	tci.mask = TCIF_TEXT | TCIF_PARAM;
	tci.pszText = label;
	tci.cchTextMax = ARRAYSIZE(label);
	if (GetItem(nTabIndex, &tci))
    {
        CMDITabChildWnd *pActive = reinterpret_cast<CMDITabChildWnd*>(tci.lParam);

        CDC dc;
        dc.Attach(pdis->hDC);

        int iIndex = _GetBitmapIndex(pActive->GetTabType());
        CExtBitmap &bitmapToUse = fSelected ? _tabBitmap[iIndex] : _tabBitmapNS[iIndex];
        CRect rcSrc(CPoint(0, 0), bitmapToUse.GetSize());
        //CRect rcPadding(2, 2, 2, 2);
        CRect rcPadding(0, 0, 0, 0);
        bitmapToUse.AlphaBlendSkinParts(pdis->hDC, rc, rcSrc, rcPadding, /*__EXT_BMP_FLAG_PREMULTIPLIED_RGB_CHANNELS |*/ CExtBitmap::__EDM_STRETCH, true, true, 0xFF);

        // Use a different font decoration depending on if this is the most recent version of this item.
        bool fNotMostRecent = false;
        CDocument *pDocAny = pActive->GetActiveDocument();
        if (pDocAny && pDocAny->IsKindOf(RUNTIME_CLASS(CResourceDocument)))
        {
            CResourceDocument *pDoc = static_cast<CResourceDocument*>(pDocAny);
            fNotMostRecent = !theApp._resourceRecency.IsResourceMostRecent(pDoc);
        }
        if (fNotMostRecent)
        {
            // Draw a diagonal line across the thing.
            dc.MoveTo(rc.TopLeft());
            dc.LineTo(rc.BottomRight());
        }

        rc.OffsetRect(4, 1); // indent
        COLORREF crText = RGB(0, 0, 0); // g_PaintManager->PAINTPUSHBUTTONDATA::m_clrForceTextNormal; // green in release, black in debug!
        int nOldText = dc.SetTextColor(crText);
        int nOldBk = dc.SetBkMode(TRANSPARENT);
        dc.DrawText(tci.pszText, -1, &rc, DT_SINGLELINE);
        dc.SetBkMode(nOldBk);
        dc.SetTextColor(nOldText);

        dc.Detach();
    }
}
示例#14
0
BOOL WriteWindow2Mem(BYTE* buf, int W, int H, HDC hDC)
{
	CBitmap 	bitmap;
	CDC 		memDC;
	CRect		rect;

	CDC dc;
	dc.Attach(hDC);
	CDC* pDC = &dc;

	bitmap.CreateCompatibleBitmap(pDC, W,H );

	CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);

	memDC.BitBlt(0, 0, W,H, pDC, 0, 0, SRCCOPY);

	// Create logical palette if device support a palette
	CPalette pal;
	if( pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE )
	{
		UINT nSize = sizeof(LOGPALETTE) + (sizeof(PALETTEENTRY) * 256);
		LOGPALETTE *pLP = (LOGPALETTE *) new BYTE[nSize];
		pLP->palVersion = 0x300;

		pLP->palNumEntries =
			::GetSystemPaletteEntries( *pDC, 0, 255, pLP->palPalEntry );

		// Create the palette
		pal.CreatePalette( pLP );

		delete[] pLP;
	}

	memDC.SelectObject(pOldBitmap);

	// Convert the bitmap to a DIB
	HANDLE hDIB = DDBToDIB( bitmap, BI_RGB, &pal );

	if( hDIB == NULL )
		return FALSE;

	// Write it to file
	WriteDIB2Mem(hDIB, W, H, buf);

	// Free the memory allocated by DDBToDIB for the DIB
	GlobalFree( hDIB );

	dc.Detach();

	return TRUE;
}
示例#15
0
void CUIDesignerView::OnDraw(CDC* pDrawDC)
{
	CUIDesignerDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	if (!pDoc)
		return;

	// TODO: 在此处为本机数据添加绘制代码
	CMemDC memDC(*pDrawDC, this);
	CDC* pDC = &memDC.GetDC();

	CRect rectClient;
	GetClientRect(rectClient);
	CPoint point=GetScrollPosition();
	rectClient.OffsetRect(point);
	pDC->FillSolidRect(rectClient,RGB(255, 255, 255));

	CSize szForm=m_LayoutManager.GetForm()->GetInitSize();
	CSize szFormOffset(FORM_OFFSET_X,FORM_OFFSET_Y);
	CDC hCloneDC;
	HBITMAP hNewBitmap;
	hCloneDC.CreateCompatibleDC(pDC);
	hNewBitmap=::CreateCompatibleBitmap(pDC->GetSafeHdc(),szForm.cx,szForm.cy);
	HBITMAP hOldBitmap=(HBITMAP)hCloneDC.SelectObject(hNewBitmap);

	if (m_brHatch.m_hObject){
		CDC cloneDC;
		cloneDC.Attach(hCloneDC);
		CRect rcTemp = rectClient;
		rcTemp.top= rcTemp.top>=20 ? rcTemp.top-20 : 0;
		rcTemp.left= rcTemp.left>=20 ? rcTemp.left-20 : 0;
		//rcTemp.right  = max(rcTemp.right , m_pScrollHelper->GetDisplaySize().cx);
		//rcTemp.bottom = max(rcTemp.bottom, m_pScrollHelper->GetDisplaySize().cy);
		m_brHatch.UnrealizeObject();
		CPoint pt(0, 0);
		cloneDC.LPtoDP(&pt);
		pt = cloneDC.SetBrushOrg(pt.x % 8, pt.y % 8);
		CBrush* old = cloneDC.SelectObject(&m_brHatch);
		cloneDC.FillRect(&rcTemp, &m_brHatch);
		cloneDC.SelectObject(old);
		cloneDC.Detach();
	}

	m_LayoutManager.Draw(&hCloneDC);
	pDC->BitBlt(szFormOffset.cx,szFormOffset.cy,szForm.cx,szForm.cy,&hCloneDC,0,0,SRCCOPY);
	hCloneDC.SelectObject(hOldBitmap);
	::DeleteDC(hCloneDC);
	::DeleteObject(hNewBitmap);

	m_MultiTracker.Draw(pDC,&szFormOffset);
}
示例#16
0
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{ 
	CDC dc;
	dc.Attach(lpDrawItemStruct->hDC);
    
	CDC MemDC;
	MemDC.CreateCompatibleDC(&dc);
	
	CBitmap bitmap;
	if (lpDrawItemStruct->itemAction == ODA_SELECT || lpDrawItemStruct->itemState == ODS_DISABLED)
	{

		bitmap.LoadBitmap(IDB_BITMAP7);
		MemDC.SelectObject(bitmap);
		this->EnableWindow(FALSE);

	}
	else
	{
		bitmap.LoadBitmap(IDB_BITMAP4);
		MemDC.SelectObject(bitmap);
	}
	
	
	dc.BitBlt(0, 0, 18, 18, &MemDC, 0, 0, SRCCOPY); 
	dc.Detach();
	
	//   UINT uStyle = DFCS_BUTTONPUSH;
	//   
	//   // This code only works with buttons.
	//   ASSERT(lpDrawItemStruct->CtlType == ODT_BUTTON);
	//   
	//   // If drawing selected, add the pushed style to DrawFrameControl.
	//   if (lpDrawItemStruct->itemState & ODS_SELECTED)
	//     uStyle |= DFCS_PUSHED;
	//   
	//   // Draw the button frame.
	//   ::DrawFrameControl(lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, 
	//     DFC_BUTTON, uStyle);
	//   
	//   // Get the button's text.
	//   CString strText;
	//   GetWindowText(strText);
	//   
	//   // Draw the button text using the text color red.
	//   COLORREF crOldColor = ::SetTextColor(lpDrawItemStruct->hDC, RGB(255,0,0));
	//   ::DrawText(lpDrawItemStruct->hDC, strText, strText.GetLength(), 
	//     &lpDrawItemStruct->rcItem, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
	//   ::SetTextColor(lpDrawItemStruct->hDC, crOldColor);
	
}
示例#17
0
void CMyToolBar::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	LPNMTBCUSTOMDRAW pTBCD = (LPNMTBCUSTOMDRAW) pNMHDR;

	if (pTBCD->nmcd.dwDrawStage == CDDS_PREPAINT)
	{
		*pResult = CDRF_NOTIFYITEMDRAW;
		return;
	}

	if (pTBCD->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
	{
		if (m_controls.find(pTBCD->nmcd.dwItemSpec) != m_controls.end())
		{
			*pResult = CDRF_SKIPDEFAULT;
			return;
		}

		for (size_t nLabel = 0; nLabel < m_labels.size(); ++nLabel)
		{
			if (pTBCD->nmcd.dwItemSpec == m_labels[nLabel].nID)
			{
				Label& label = m_labels[nLabel];

				CDC dc;
				dc.Attach(pTBCD->nmcd.hdc);

				CFont* pOldFont = dc.SelectObject(label.pFont);
				COLORREF crTextColor = dc.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT));
				int nBkMode = dc.SetBkMode(TRANSPARENT);

				UINT nFlags = DT_LEFT | DT_NOPREFIX | DT_VCENTER | DT_SINGLELINE;
				CRect rect(pTBCD->nmcd.rc);
				rect.left += 3;
				dc.DrawText(label.strText, rect, nFlags);

				dc.SetTextColor(crTextColor);
				dc.SetBkMode(nBkMode);
				dc.SelectObject(pOldFont);

				dc.Detach();

				*pResult = CDRF_SKIPDEFAULT;
				return;
			}
		}
	}

	*pResult = 0;
}
示例#18
0
LRESULT OperaColorsPage::onDrawItem(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled)
{
	if (PropertiesDlg::g_needUpdate)
	{
		SendMessage(WM_DESTROY, 0, 0);
		SendMessage(WM_INITDIALOG, 0, 0);
		PropertiesDlg::g_needUpdate = false;
	}
	bHandled = FALSE;
	DRAWITEMSTRUCT* dis = (DRAWITEMSTRUCT*)lParam;
	if (dis->CtlType == ODT_STATIC)
	{
		bHandled = TRUE;
		CDC dc;
		dc.Attach(dis->hDC);
		CRect rc(dis->rcItem);
		if (dis->CtlID == IDC_SETTINGS_ODC_MENUBAR_COLOR)
		{
			if (getCheckbox(IDC_SETTINGS_ODC_MENUBAR_USETWO))
				OperaColors::FloodFill(dc, rc.left, rc.top, rc.right, rc.bottom, crMenubarLeft, crMenubarRight, getCheckbox(IDC_SETTINGS_ODC_MENUBAR_BUMPED));
			else
				dc.FillSolidRect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, crMenubarLeft);
			dc.SetTextColor(OperaColors::TextFromBackground(crMenubarLeft));
		}
		else if (dis->CtlID == IDC_PROGRESS_COLOR_DOWN_SHOW || dis->CtlID == IDC_PROGRESS_COLOR_UP_SHOW)
		{
			COLORREF clr = getCheckbox(IDC_PROGRESS_OVERRIDE) ? ((dis->CtlID == IDC_PROGRESS_COLOR_DOWN_SHOW) ? crProgressDown : crProgressUp) : GetSysColor(COLOR_HIGHLIGHT);
			int textcolor;
			if (odcStyle)
			{
				COLORREF a, b;
				OperaColors::EnlightenFlood(clr, a, b);
				OperaColors::FloodFill(dc, rc.left, rc.top, rc.right, rc.bottom, a, b, getCheckbox(IDC_PROGRESS_BUMPED));
			}
			else   // not stealthyStyle or odcStyle
			{
				CBarShader statusBar(rc.bottom - rc.top, rc.right - rc.left);
				statusBar.SetFileSize(16);
				statusBar.FillRange(0, 16, clr);
				statusBar.Draw(dc, rc.top, rc.left, hloubka);
			}
			textcolor = getCheckbox(IDC_PROGRESS_OVERRIDE2) ? ((dis->CtlID == IDC_PROGRESS_COLOR_DOWN_SHOW) ? crProgressTextDown : crProgressTextUp) : OperaColors::TextFromBackground(clr);
			dc.SetTextColor(textcolor);
		}
		const wstring l_text = TSTRING(SETTINGS_MENUHEADER_EXAMPLE);
		dc.DrawText(l_text.c_str(), l_text.length(), rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
		dc.Detach();
	} // if (dis->CtlType == ODT_STATIC) {
	return S_OK;
}
示例#19
0
void CvSqlQueryLowerView::DoFilePrint()
{
	CDC dc;
	CPrintDialog printDlg(FALSE);

	if (printDlg.DoModal() == IDCANCEL)         // Get printer settings from user
		return;

	dc.Attach(printDlg.GetPrinterDC());         // Attach a printer DC
	dc.m_bPrinting = TRUE;

	CString strTitle;                           // Get the application title
	strTitle.LoadString(AFX_IDS_APP_TITLE);

	DOCINFO di;                                 // Initialise print document details
	::ZeroMemory (&di, sizeof (DOCINFO));
	di.cbSize = sizeof (DOCINFO);
	di.lpszDocName = strTitle;

	BOOL bPrintingOK = dc.StartDoc(&di);        // Begin a new print job
	// Get the printing extents and store in the m_rectDraw field of a  CPrintInfo object
	CPrintInfo Info;
	Info.m_rectDraw.SetRect(0,0, dc.GetDeviceCaps(HORZRES), dc.GetDeviceCaps(VERTRES));
	Info.m_bPreview = TRUE;

	OnBeginPrinting(&dc, &Info);                // Call your "Init printing" funtion
	if (m_nPageWidth > Info.m_rectDraw.Width())
		m_nPageWidth = Info.m_rectDraw.Width();
	if (m_nPageHeight > Info.m_rectDraw.Height())
		m_nPageHeight = Info.m_rectDraw.Height();

	while (bPrintingOK)
	{
		dc.StartPage();                         // begin new page
		PrintPageHeader(&dc, Info.m_nCurPage);  // updates m_nHeaderHeight
		PrintPageFooter(&dc, Info.m_nCurPage);  // updates m_nFooterHeight

		ASSERT (m_nHeaderHeight >= 0);
		ASSERT (m_nFooterHeight >= 0);

		PrintPage(&dc, Info.m_nCurPage);
		Info.m_nCurPage++;
		dc.EndPage();
		bPrintingOK = ((int)Info.m_nCurPage > m_nbPrintPage) ? FALSE: TRUE;
	}

	OnEndPrinting(&dc, &Info);
	dc.EndDoc();
	dc.Detach();
}
示例#20
0
void CFavMenu::DrawItem(LPDRAWITEMSTRUCT pds)
{
	CDC dc;	dc.Attach(pds->hDC);
	CRect& rc = (CRect)pds->rcItem;
	int delta;
	CStringArray& data = GetData(pds->itemData, delta);
	CString& str = data.ElementAt(pds->itemData - delta);
	COLORREF bkcolor;	COLORREF textcolor;
	if (pds->itemState & ODS_SELECTED)
	{
		textcolor = GetSysColor(COLOR_HIGHLIGHTTEXT);
		bkcolor = GetSysColor(COLOR_HIGHLIGHT);
	}
	else
	{
		bkcolor = GetSysColor(COLOR_MENU);
		textcolor = GetSysColor(COLOR_MENUTEXT);
	}

	int	topmargin = (rc.Height() - 16) / 2;
	dc.FillSolidRect(rc, bkcolor);
#if defined(_COMBO_)
	int iimg = (str[0] == 'd' ? 3 : (str[0] == 's' ? 4 : (str[0] == 'w' ? 8 : -1)));
#else
	int iimg = (str[0] == 'd' ? 3 : (str[0] == 's' ? 4 : -1));
#endif
	CMainFrame* mainfrm = (CMainFrame*)AfxGetMainWnd();
	ImageList_Draw(mainfrm->img_icons, iimg, dc.m_hDC,
				   rc.left + 2, rc.top + topmargin,
				   ILD_NORMAL | ILD_TRANSPARENT);
	rc.left += 24;

	dc.SetBkMode(TRANSPARENT);
	HGDIOBJ fold = SelectObject(dc.m_hDC, menu_font);

	if (pds->itemState & ODS_GRAYED)
		textcolor = GetSysColor(COLOR_3DSHADOW);

	dc.SetTextColor(textcolor);
	rc.right -= 8;
#if defined(_COMBO_)
	dc.DrawText(LPCTSTR(str) + 1, (iimg != 4 && iimg != 8) ? str.GetLength() - 1 : str.Find('\t') - 1,
				rc, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_EXPANDTABS);
#else
	dc.DrawText(LPCTSTR(str) + 1, (iimg != 4) ? str.GetLength() - 1 : str.Find('\t') - 1,
				rc, DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_EXPANDTABS);
#endif
	SelectObject(dc.m_hDC, fold);
	dc.Detach();
}
//This virtual function is called to draw the individual columns. In the case of
// non-CBS_HASSTRINGS this has to be implimented in derived classes
void COXMultiComboBox::DrawColumnItem(HDC hDC, int nIndex, int nColIndex, const CRect& rectColumn, int ItemState)
// --- In  : hDC : the DC into which to draw the column
//			 nIndex : The row index
//			 nColIndex : The Column Index
//			 rectColumn : The rectangle into which we can draw
//			 ItemState : Gives the state of the item(Selected or not)
// --- Out : 
// --- Returns : 
// --- Effect : The column text is drawn in the case of CBS_HASSTRINGS
{
	ASSERT(GetStyle()&CBS_HASSTRINGS);

	CDC dc;
	dc.Attach(hDC);
	// Sets the foreground color of the text based on its selection state
	COLORREF clrOldForeground = dc.SetTextColor(::GetSysColor(IsWindowEnabled() ? 
		(ItemState&ODS_SELECTED ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT) : 
		COLOR_GRAYTEXT)); 

	COLORREF clrBackground = ::GetSysColor(IsWindowEnabled() ? (ItemState & ODS_SELECTED ? 
COLOR_HIGHLIGHT : COLOR_WINDOW) : COLOR_BTNFACE); 

	// Sets the background color of text based on selection state
	COLORREF clrOldBackground = dc.SetBkColor( clrBackground);

	// Gets  the column text to draw
	CString strText;
	if(nIndex!=-1)
		GetLBText(nIndex,nColIndex,strText);
	else
		strText.Empty();

	CRect cellRect(rectColumn);
	dc.FillSolidRect(cellRect, clrBackground);

	// give left margin
	cellRect.left +=  LOWORD(GetDialogBaseUnits()) / 2;
	// Draw text
	dc.DrawText(strText, cellRect, DT_NOPREFIX | DT_SINGLELINE |
		DT_VCENTER | DT_END_ELLIPSIS);

	// Seperators are drawn in list boxe between columns and rows
	DrawColumnBorder(&dc,rectColumn,ItemState);

	// Reset the actual DC colors
	dc.SetTextColor(clrOldForeground); 
	dc.SetBkColor(clrOldBackground); 
	dc.Detach();
}
示例#22
0
//*************************************************************************************
void CBCGPKeyMapDlg::PrintKeyMap ()
{
	CWaitCursor WaitCursor;
	
	int nItem = -1;
	int nFlag = (m_KeymapList.GetSelectedCount () > 0)  ?  LVNI_SELECTED : LVNI_ALL;
	
	CPrintDialog dlgPrint (FALSE, PD_ALLPAGES | PD_RETURNDC | PD_NOSELECTION, NULL);
	if (dlgPrint.DoModal() != IDOK)
	{
		return;
	}
	
	// Obtain a handle to the device context.
	HDC hdcPrn = dlgPrint.GetPrinterDC ();
	if (hdcPrn == NULL)
	{
		ASSERT (FALSE);
		return;
	}

	CDC dc;
	dc.Attach (hdcPrn);

	CSize szPage (dc.GetDeviceCaps (HORZRES), dc.GetDeviceCaps (VERTRES));

	dc.StartDoc(_T("BCGKeyMapDlg"));  // begin a new print job
	dc.StartPage ();
	
	int nPage = 1;
	int y = OnPrintHeader (dc, nPage, szPage.cx);

	while ((nItem = m_KeymapList.GetNextItem (nItem, nFlag)) >= 0)
	{
		int nItemHeight = OnPrintItem (dc, nItem, y, szPage.cx, TRUE /* Calc height */);
		if (y + nItemHeight > szPage.cy)
		{
			dc.EndPage();

			dc.StartPage ();
			y = OnPrintHeader (dc, ++nPage, szPage.cx);
		}

		y += OnPrintItem (dc, nItem, y, szPage.cx, FALSE /* Draw */);
	}
	
	dc.EndPage();
	dc.EndDoc();
}
示例#23
0
void CMyButton3::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	// TODO: Add your code to draw the specified item
	CDC dc;
	dc.Attach(lpDrawItemStruct->hDC);//得到绘制的设备环境CDC
	VERIFY(lpDrawItemStruct->CtlType==ODT_BUTTON);

	// 得当Button上文字,这里的步骤是:1,先得到在资源里编辑的按钮的文字,
	//然后将此文字重新绘制到按钮上,
	//同时将此文字的背景色设为透明,这样,按钮上仅会显示文字
	const int bufSize = 512;
	TCHAR buffer[bufSize];
	GetWindowText(buffer, bufSize);
	int size=strlen(buffer);   //得到长度
	DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);   //绘制文字
	SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);   //透明

	if (lpDrawItemStruct->itemState &ODS_SELECTED)  //当按下按钮时的处理
	{//
		//重绘整个控制
		CBrush brush(m_DownColor);  
		dc.FillRect(&(lpDrawItemStruct->rcItem),&brush);//
		//因为这里进行了重绘,所以文字也要重绘
		DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);   
		SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);
	}
	else                     //当按钮不操作或者弹起时
	{
		CBrush brush(m_UpColor);     
		dc.FillRect(&(lpDrawItemStruct->rcItem),&brush);//
		//同上,进行重绘文字
		DrawText(lpDrawItemStruct->hDC,buffer,size,&lpDrawItemStruct->rcItem,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_TABSTOP);    
		SetBkMode(lpDrawItemStruct->hDC,TRANSPARENT);
	}
	if ((lpDrawItemStruct->itemState &ODS_SELECTED)&&(lpDrawItemStruct->itemAction &(ODA_SELECT| ODA_DRAWENTIRE)))
	{   //选中了本控件,高亮边框
		COLORREF fc=RGB(255-GetRValue(m_UpColor),255-GetGValue(m_UpColor), 255-             GetBValue(m_UpColor));//
		CBrush brush(fc);//
		dc.FrameRect(&(lpDrawItemStruct->rcItem),&brush);//
	}
	if (!(lpDrawItemStruct->itemState & ODS_SELECTED) &&(lpDrawItemStruct->itemAction & ODA_SELECT))
	{
		//控制的选中状态结束,去掉边框
		CBrush brush(m_UpColor);
		dc.FrameRect(&lpDrawItemStruct->rcItem,&brush);//
	}
	dc.Detach();//
}
示例#24
0
void CWBButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    CDC xdc;
    xdc.Attach( lpDrawItemStruct->hDC );
    CRect rc;
    GetClientRect(rc);
		NumberShark::CMemDC dc(&xdc,rc);
    
    UINT state = lpDrawItemStruct->itemState ;
    bool IsDisable = false;

	if (state & ODS_FOCUS)
    {
		DrawBitmap( &dc, focus );
		if (state & ODS_SELECTED)
        { 
            DrawBitmap( &dc, select );
            rc.left += 5;
		}
	}
	else if (state & ODS_DISABLED)
    {
        IsDisable = true;
    	DrawBitmap( &dc, disable );

    }else{

        DrawBitmap( &dc, normal );
    }

    int imode = dc.SetBkMode(TRANSPARENT);
    CFont *pOldFnt = dc.SelectObject(m_pFnt);
    COLORREF oldColor;

    if(IsDisable)
      oldColor = dc.SetTextColor( GetSysColor(COLOR_GRAYTEXT) );
    else
      oldColor = dc.SetTextColor( m_pFnt->GetFontColor() );

        CString txt;
        GetWindowText(txt);
        dc.DrawText(txt,rc,DT_CENTER | DT_VCENTER | DT_SINGLELINE);
      
    dc.SetTextColor( oldColor );
    dc.SelectObject(pOldFnt);
    dc.SetBkMode(imode );
	
}
示例#25
0
void CIconSelectMenu::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    // TODO :  指定された項目を描画するためのコードを追加してください。
    MENUITEM* pItem = reinterpret_cast< MENUITEM*>( lpDrawItemStruct->itemData);
    if( NULL != pItem)
    {
        CDC cDC;
        if( cDC.Attach( lpDrawItemStruct->hDC))
        {
            int nSaveID = cDC.SaveDC();

            if( 0 < nSaveID)
            {
                COLORREF clrFore;
                COLORREF clrBack;
                if( ODS_SELECTED & lpDrawItemStruct->itemState)
                {
                    clrFore = ::GetSysColor( COLOR_HIGHLIGHTTEXT);
                    clrBack = ::GetSysColor( COLOR_HIGHLIGHT);
                }
                else
                {
                    clrFore = ::GetSysColor( COLOR_MENUTEXT);
                    clrBack = ::GetSysColor( COLOR_MENU);
                }

                cDC.SetBkColor( clrBack);
                cDC.SetTextColor( clrFore);
                cDC.FillSolidRect( &lpDrawItemStruct->rcItem, clrBack);

                int nXSpace = ::GetSystemMetrics( SM_CXFRAME);

                int nLeft = 12;//( ( lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left) - pItem->nWidth) / 2;

                CDC cMemDC;
                cMemDC.CreateCompatibleDC( &cDC);
                cMemDC.SelectObject( pItem->hBitmap);
                cDC.BitBlt( nLeft + lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top, _ICON_WIDTH, _ICON_HEIGHT, &cMemDC, 0, 0, SRCCOPY);
                cDC.TextOut( nLeft + lpDrawItemStruct->rcItem.left + _ICON_WIDTH + nXSpace, lpDrawItemStruct->rcItem.top, pItem->szItemName);


                cDC.RestoreDC( nSaveID);
            }
            cDC.Detach();
        }
    }
}
示例#26
0
LRESULT CNoteDlg::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	PAINTSTRUCT ps;
	HDC hDC = BeginPaint(&ps);
	ATLASSERT(hDC);
	
	CDC cDC;
	cDC.Attach(hDC);
	
	HPEN hOldPen, hPenLine;
	
	CRect rectDlg; 
	GetClientRect(&rectDlg);
	
	// Create a grey pen
	hPenLine = ::CreatePen(PS_SOLID, 1, GREY);
	ATLASSERT(hPenLine);	
	
	// Select the new pen into the device context
	hOldPen = (HPEN)::SelectObject(hDC, hPenLine);
	ATLASSERT(hOldPen);
	ATLASSERT(hOldPen != HGDI_ERROR);
	
	// Draw the gripper
	cDC.MoveTo(rectDlg.Width() - 15, rectDlg.Height());
	cDC.LineTo(rectDlg.Width(), rectDlg.Height() - 15);
	cDC.MoveTo(rectDlg.Width() - 11, rectDlg.Height());
	cDC.LineTo(rectDlg.Width(), rectDlg.Height() - 11);
	cDC.MoveTo(rectDlg.Width() - 7, rectDlg.Height());
	cDC.LineTo(rectDlg.Width(), rectDlg.Height() - 7);
	cDC.MoveTo(rectDlg.Width() - 3, rectDlg.Height());
	cDC.LineTo(rectDlg.Width(), rectDlg.Height() - 3);
	
	// Draw the horisontal line
	cDC.MoveTo(5, rectDlg.Height() - 15);
	cDC.LineTo(rectDlg.Width() - 5, rectDlg.Height() - 15);
	
	// Clean up
	::SelectObject(hDC, hOldPen);
	::DeleteObject(hPenLine);
	hPenLine = NULL;
	
	cDC.Detach();
	EndPaint(&ps);
	return 0;
}
示例#27
0
BOOL CListViewCtrlEx::_GetSubItemLinkRect( int nItem, int nSubItem, LPCTSTR szText, RECT &rc )
{
    _super::GetSubItemRect( nItem, nSubItem, LVIR_LABEL, &rc );
    HDC hDC = GetWindowDC();
    if(!hDC)
        return FALSE;

    rc.left += LEFT_MARGIN_TEXT_COLUMN;
    CDC dc;
    dc.Attach( hDC );
    HFONT hOldFont = dc.SelectFont(m_fontLink);
    dc.DrawText( szText, -1, &rc, DT_CALCRECT|DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS|DT_VCENTER );
    dc.SelectFont(hOldFont);
    dc.Detach();
    ReleaseDC( hDC );
    return TRUE;
}
void CMemoryDC::CreateDC ()
{
	if (m_DC.GetSafeHdc () != NULL)
	{
		return;
	}

	HDC hDC = ::GetDC (NULL);

	HDC hNewDC = ::CreateCompatibleDC (hDC);
	if (hNewDC != NULL)
	{
		m_DC.Attach (hNewDC);
	}

	::ReleaseDC (NULL, hDC);
}
示例#29
0
//뭔가 그려줘야 할때 호출된다 이거져
//그러니까 얘를 이용해야 데겟져
//기억이 가물가물하네
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect r;
	this->GetWindowRect(&r);
	
	CDC dc;
	//CClientDC dc(this);

	dc.Attach(lpDrawItemStruct->hDC);
	if(lpDrawItemStruct->itemState & ODS_SELECTED) {
			dc.TextOutA(0, 0, "j m lee");
	} else {
			dc.TextOutA(0, 0, "재문리");
	}
	dc.Detach();

}
示例#30
0
void CDrawButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	
	//判断控件类型是否为按钮类型
	if (lpDrawItemStruct->CtlType == ODT_BUTTON)
	{
		CDC dc;

		
		dc.Attach(lpDrawItemStruct->hDC);	//附加设备上下文句柄
		//获取按钮状态
		int nState = lpDrawItemStruct->itemState;
		//获取按钮区域
		CRect btnRC = lpDrawItemStruct->rcItem;
		CString szBtnText;
		GetWindowText(szBtnText);	//获取按钮文本

		CPoint pt;
		GetCursorPos(&pt);
		ScreenToClient(&pt);
		
		COLORREF clrText;	//文本颜色
		clrText = RGB(0, 0, 0);
		COLORREF clrBK = RGB(220, 220, 220);		//背景颜色

		if (nState & ODS_SELECTED || nState & ODS_FOCUS)
		{
			clrBK = RGB(222, 231, 239);
		}
		if (m_nBtnState == 1)
		{
			clrText = RGB(255, 0, 255);
		}
		
		dc.SetTextColor(clrText);

		dc.FillRect(btnRC, &CBrush(clrBK));
		dc.FrameRect(btnRC, &CBrush(RGB(140, 158, 176)));


		dc.SetBkMode(TRANSPARENT);
		dc.DrawText(szBtnText, btnRC, DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		dc.Detach();	//分离句柄
	}	
}