Ejemplo n.º 1
0
void CVisualSynanView::OnFonts() 
{
	CFontDialog dlgFonts;	

	if( dlgFonts.DoModal() != IDOK)
		return;

	LOGFONT lfOldFont;
	LogFontCpy(&lfOldFont, m_LogFontForWords);
	dlgFonts.GetCurrentFont(&m_LogFontForWords);
	CString str = dlgFonts.GetFaceName();
	CClientDC dc(this);
	EnumFontFamiliesEx(dc.m_hDC, &m_LogFontForWords, &TestIfTrueTypeEx,(LPARAM)this,0);
	if( !m_bExistUsefulFont )
	{
		::AfxMessageBox(IDS_NOT_TRUE_TYPE);
		LogFontCpy(&m_LogFontForWords,lfOldFont);
		return;
	}
	if(!(m_LogFontForWords.lfCharSet & RUSSIAN_CHARSET) )
	{
		::AfxMessageBox(IDS_NOT_RUSSIAN_CHARSET);
		LogFontCpy(&m_LogFontForWords,lfOldFont);
		return;
	};

	// m_LogFontForWords has changed!!
	UpdateFontsFromLogFont();

	CClientDC clDC(this);
	Recalculate(clDC);
	Invalidate();
}
Ejemplo n.º 2
0
//界面绘画函数
void CButtonEx::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	//定义变量
	CRect rcClient;
	GetClientRect(&rcClient);
	bool bDisable=((lpDrawItemStruct->itemState&ODS_DISABLED)!=0);
	bool bButtonDown=((lpDrawItemStruct->itemState&ODS_SELECTED)!=0);

	CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	//获取文字
	CString strText;
	GetWindowText(strText);
	
	//绘制父窗口背景
	CRect rcWindow;
	CClientDC clDC(GetParent());

	GetWindowRect(rcWindow);
	GetParent()->ScreenToClient(rcWindow);

	CDC dcParent;
	CBitmap bmp,*pOldBitmap;
	dcParent.CreateCompatibleDC(&clDC);
	bmp.CreateCompatibleBitmap(&clDC,rcClient.Width(),rcClient.Height());
	pOldBitmap = dcParent.SelectObject(&bmp);
	dcParent.BitBlt(0,0,rcClient.Width(),rcClient.Height(),&clDC,rcWindow.left,rcWindow.top,SRCCOPY);
	bmp.DeleteObject();

	//加载背景图
	if ( !m_ImageBack.IsNull() )
	{
		//计算位图位置
		int nWidth=m_ImageBack.GetWidth()/4,nDrawPos=0;
		if (bDisable) nDrawPos=nWidth*3;
		else if (bButtonDown) nDrawPos=nWidth*2;
		else if (m_bHovering) nDrawPos=nWidth*1;

		//绘画背景图
		if (m_bExpand==false) m_ImageBack.DrawImage(pDC,0,0,rcClient.Width(),rcClient.Height(),nDrawPos,0);
		else m_ImageBack.DrawImage(pDC,0,0,rcClient.Width(),rcClient.Height(),nDrawPos,0,nWidth,m_ImageBack.GetHeight());
	}
	else
	{
		//绘画默认界面
		pDC->FillSolidRect(&rcClient,GetSysColor(COLOR_BTNFACE));
		if (bButtonDown) pDC->Draw3dRect(&rcClient,GetSysColor(COLOR_WINDOWFRAME),GetSysColor(COLOR_3DHILIGHT));
		else pDC->Draw3dRect(&rcClient,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_WINDOWFRAME));
	}

	//绘画字体
	rcClient.top+=1;
	pDC->SetBkMode(TRANSPARENT);
	if (bDisable) pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
	else pDC->SetTextColor(m_crTextColor);
	pDC->DrawText(strText,strText.GetLength(),rcClient,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

	return;
}
Ejemplo n.º 3
0
void CVisualSynanView::OnSize(UINT nType, int cx, int cy) 
{
			
	ResizeScroll();
	CView::OnSize(nType, cx, cy);	
	CClientDC clDC(this);
	Recalculate(clDC);
	Invalidate();


}
Ejemplo n.º 4
0
void CButtonST::PaintBk(CDCHandle pDC)
{
	CWindow		parent = GetParent();
	CClientDC	clDC(parent);
	CRect		rect;
	CRect		rect1;

	GetClientRect(rect);
	GetWindowRect(rect1);
	parent.ScreenToClient(rect1);
	if (m_dcBk == 0)
		{
		m_dcBk.CreateCompatibleDC(clDC);
		m_bmpBk.CreateCompatibleBitmap(clDC, rect.Width(), rect.Height());
		m_pbmpOldBk = m_dcBk.SelectBitmap(m_bmpBk);
		m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), clDC, rect1.left, rect1.top, SRCCOPY);
		}
	pDC.BitBlt(0, 0, rect.Width(), rect.Height(), m_dcBk, 0, 0, SRCCOPY);
}
Ejemplo n.º 5
0
void CGdiImageDrawer::Draw(CDC* pScreenDC, CWnd *pWnd, int posX, int posY, bool mouseHover, bool mouseDown, int forceWidth, int forceHeight)
{
	int width = m_pStdImage->m_pBitmap->GetWidth();
	if (forceWidth != INT_MAX)
		width = forceWidth;
	int height = m_pStdImage->m_pBitmap->GetHeight();
	if (forceHeight != INT_MAX)
		height = forceHeight;

	CRect rectWithBorder(posX, posY, posX + width, posY + height);

	int two = theApp.m_metrics.ScaleX(2);
	rectWithBorder.InflateRect(two, two, two, two);

	CDC dcBk;
	CBitmap bmp;
	CClientDC clDC(pWnd);
		
	//Copy the background over the entire area
	dcBk.CreateCompatibleDC(&clDC);
	bmp.CreateCompatibleBitmap(&clDC, 1, 1);
	dcBk.SelectObject(&bmp);
	dcBk.BitBlt(0, 0, 1, 1, &clDC, rectWithBorder.left-1, rectWithBorder.top, SRCCOPY);
	
	bmp.DeleteObject();		

	//Draw the png file
	if (mouseDown)
	{
		int one = theApp.m_metrics.ScaleX(1);
		posX += one;
		posY += one;
	}
	Gdiplus::Graphics graphics(pScreenDC->m_hDC);
	graphics.DrawImage(*m_pStdImage, posX, posY, width, height);	

	//If we are hoving over then draw the border
	if(mouseHover && mouseDown == false)
	{
		pScreenDC->Draw3dRect(rectWithBorder, RGB(255, 255, 255), RGB(255, 255, 255));
	}
}
Ejemplo n.º 6
0
void CButtonST::PaintBk(CDC * pDC)
{
	CClientDC clDC(GetParent());
	CRect rect;
	CRect rect1;

	GetClientRect(rect);

	GetWindowRect(rect1);
	GetParent()->ScreenToClient(rect1);

	if (m_dcBk.m_hDC == NULL)
	{
		m_dcBk.CreateCompatibleDC(&clDC);
		m_bmpBk.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
		m_pbmpOldBk = m_dcBk.SelectObject(&m_bmpBk);
		m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
	}

	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY);
} // End of PaintBk
Ejemplo n.º 7
0
void Engine::InitOpenCL()
{
	cl_init(m_device, m_context, m_queue);
	std::string				clDC(clDreamcaster_Source[0]);
	cl::Program::Sources	clDCSrc = cl::Program::Sources(1, std::make_pair(clDC.c_str(), clDC.size() )  );

	cl::Program	clDCProg(m_context, clDCSrc);
	cl_int error;
	std::vector<cl::Device>	devices; devices.push_back(m_device);
	error = clDCProg.build(devices);//, clOptions);
	if (error != CL_SUCCESS) 
	{
		cl_int error2;
		std::string str = clDCProg.getBuildInfo<CL_PROGRAM_BUILD_LOG>(m_device, &error2);
		itk_clSafeCall( error2 );
		itk_clThrowBuildLog( str );
	}
	itk_clSafeCall(error);

	// create cl kernels
	K_raycast_batch = cl::Kernel(clDCProg, "raycast_batch", &error);
	itk_clSafeCall(error);
}
Ejemplo n.º 8
0
BOOL CButtonST::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default	
    if (m_dcBk.m_hDC == NULL)
    {
		CClientDC clDC(GetParent());
		CRect rect, rect1;
		
		GetClientRect(rect);
		
		GetWindowRect(rect1);
		GetParent()->ScreenToClient(rect1);

        m_dcBk.CreateCompatibleDC(&clDC);
        m_bmpBk.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
        m_pbmpOldBk = m_dcBk.SelectObject(&m_bmpBk);
        m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), 
            &clDC, rect1.left, rect1.top, SRCCOPY);
    }

	return TRUE;
	
//	return CButton::OnEraseBkgnd(pDC);
}
Ejemplo n.º 9
0
void CMainFrame::OnButtonSelectprocess()
{
	CMFCRibbonButton* pButton = (CMFCRibbonButton*)m_wndRibbonBar.FindByID( ID_BUTTON_SELECTPROCESS );
	CRect pos = pButton->GetRect( );
	ClientToScreen( &pos );

	CMenu menu;
	menu.CreatePopupMenu( );

	ClearProcMenuItems( );

	HANDLE ProcessList = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, NULL );
	if (ProcessList != INVALID_HANDLE_VALUE)
	{
		PROCESSENTRY32 ProcInfo;
		ProcInfo.dwSize	= sizeof( PROCESSENTRY32 );
		BOOL rp = Process32First( ProcessList, &ProcInfo );

		bool bSkip = false;

		while( rp == TRUE )
		{
			// Are we filtering out processes

			if ( gbFilterProcesses )
			{
				for ( int i = 0; i < sizeof( CommonProcesses ) / sizeof( CommonProcesses[0] ) ; i ++ )
				{
					if ( strcmp( ProcInfo.szExeFile, CommonProcesses[i].c_str( ) ) == 0 )
					{
						//printf( "True %s\n", ProcInfo.szExeFile );
						bSkip = true;
					}
				}
			}

			if ( bSkip  )
			{
				bSkip = false;
				rp = Process32Next(ProcessList,&ProcInfo);
				continue;
			}

			HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, false, ProcInfo.th32ProcessID );

			if ( hProcess )
			{
				if ( is64bit( hProcess ) )
				{
					char filename[1024];
					DWORD len = sizeof(filename);
					GetModuleFileNameEx(hProcess,NULL,filename,1024);

					SHFILEINFO    sfi;
					SHGetFileInfo(filename,FILE_ATTRIBUTE_NORMAL,&sfi,sizeof(SHFILEINFO),SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);

					CBitmap* pBitmap = new CBitmap;
					CProcessMenuInfo Item;
					Item.ProcessId = ProcInfo.th32ProcessID;
					Item.pBitmap = pBitmap;

					CClientDC clDC(this);
					CDC dc;dc.CreateCompatibleDC(&clDC);
					int cx = 16;int cy = 16;
					pBitmap->CreateCompatibleBitmap(&clDC,cx,cy);
					CBitmap* pOldBmp = dc.SelectObject(pBitmap);
					dc.FillSolidRect(0,0,cx,cy,GetSysColor(COLOR_3DFACE));
					::DrawIconEx(dc.GetSafeHdc(),0,0,sfi.hIcon,cx,cy,0,NULL,DI_NORMAL);
					dc.SelectObject( pOldBmp );
					dc.DeleteDC();

					DWORD MsgID = WM_PROCESSMENU + ProcMenuItems.size();
					menu.AppendMenu( MF_STRING | MF_ENABLED, MsgID , ProcInfo.szExeFile );
					menu.SetMenuItemBitmaps(MsgID, MF_BYCOMMAND,pBitmap,pBitmap);

					ProcMenuItems.push_back(Item);
				}
				CloseHandle(hProcess);
			}
			rp = Process32Next(ProcessList,&ProcInfo);
		}
		CloseHandle(ProcessList);
	}

	menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_HORNEGANIMATION,pos.left,pos.bottom,this);
}
Ejemplo n.º 10
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CButtonBT::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_imgStd.IsValid())
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDCEx memdc(pScreenDC, rect);
		//CGDIPMemDC pDC(pScreenDC, rect);

		//Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{

			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(&memdc);

			//graphics.DrawImage(*m_pStdImage, 0, 0);
			m_imgStd.Draw(memdc.GetSafeHdc());
		
			m_dcStd.CreateCompatibleDC(&memdc);
			bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(&memdc);

				if (m_bISMove)
				{
					//graphics.DrawImage(*m_pStdImage, 1, 1);
					m_imgStd.Draw(memdc.GetSafeHdc(), 1, 1);
				}
				else
				{
					//graphics.DrawImage(*m_pStdImage, 0, 0);
					m_imgStd.Draw(memdc.GetSafeHdc());
				}
				

				m_dcStdP.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgStd;
				imgtemp.ShiftRGB(20,20,20);
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcStdH.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgStd;
				imgtemp.GrayScale();
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcGS.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(&memdc);

			//graphics.DrawImage(*m_pAltImage, 0, 0);
			m_imgAlt.Draw(memdc.GetSafeHdc());
		
			m_dcAlt.CreateCompatibleDC(&memdc);
			bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(&memdc);

				if (m_bISMove)
				{
					//graphics.DrawImage(*m_pAltImage, 1, 1);
					m_imgAlt.Draw(memdc.GetSafeHdc(), 1, 1);
				}
				else
				{
					//graphics.DrawImage(*m_pAltImage, 0, 0);
					m_imgAlt.Draw(memdc.GetSafeHdc());
				}
				
			
				m_dcAltP.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(&memdc);

				CxImage imgtemp = m_imgAlt;
				imgtemp.ShiftRGB(20,20,20);
				imgtemp.Draw(memdc.GetSafeHdc());
				m_dcAltH.CreateCompatibleDC(&memdc);
				bmp.CreateCompatibleBitmap(&memdc, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), &memdc, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		if(m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Ejemplo n.º 11
0
void CMainFrame::OnButtonSelectProcess()
{
	HANDLE hProcess = 0;
	void* pBuffer = NULL;
	ULONG cbBuffer = 0x20000;
	HANDLE hHeap = NULL;
	NTSTATUS Status = STATUS_INFO_LENGTH_MISMATCH;
	bool bHasEnumeratedProcesses = false;
	PSYSTEM_PROCESS_INFORMATION infoP = NULL;

	CMFCRibbonButton* pButton = NULL;
	
	pButton = static_cast<CMFCRibbonButton*>(m_wndRibbonBar.FindByID(ID_BUTTON_SELECTPROCESS));

	CRect pos = pButton->GetRect();
	ClientToScreen(&pos);

	CMenu menu;
	menu.CreatePopupMenu();

	ClearProcMenuItems();

	static HMODULE hNtdll = (HMODULE)Utils::GetLocalModuleHandle("ntdll.dll");
	static tNtQuerySystemInformation fnQSI = (tNtQuerySystemInformation)Utils::GetProcAddress(hNtdll, "NtQuerySystemInformation");

	hHeap = GetProcessHeap();
	Status = STATUS_INFO_LENGTH_MISMATCH;

	while (!bHasEnumeratedProcesses)
	{
		pBuffer = HeapAlloc(hHeap, HEAP_ZERO_MEMORY, cbBuffer);
		if (pBuffer == NULL)
			return;

		Status = fnQSI(SystemProcessInformation, pBuffer, cbBuffer, &cbBuffer);
		if (Status == STATUS_INFO_LENGTH_MISMATCH)
		{
			HeapFree(hHeap, NULL, pBuffer);
			cbBuffer *= 2;
		}
		else if (!NT_SUCCESS(Status))
		{
			HeapFree(hHeap, NULL, pBuffer);
			return;
		}
		else
		{
			bHasEnumeratedProcesses = true;
			infoP = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
			while (infoP)
			{	
				if (infoP->ImageName.Length)
				{
					char pName[256];
					memset(pName, 0, sizeof(pName));
					WideCharToMultiByte(0, 0, infoP->ImageName.Buffer, infoP->ImageName.Length, pName, 256, NULL, NULL);
					// Are we filtering out processes
					if (gbFilterProcesses)
					{
						bool skip = false;
						for (int i = 0; i < sizeof(CommonProcesses) / sizeof(*CommonProcesses); i++) 
						{
							if ( _stricmp( pName, CommonProcesses[ i ] ) == 0 || (DWORD)infoP->UniqueProcessId == GetCurrentProcessId( ) )
							{
								skip = true;
								break;
							}
						}

						if (skip)
						{
							if (!infoP->NextEntryOffset)
								break;
							infoP = (PSYSTEM_PROCESS_INFORMATION)((unsigned char*)infoP + infoP->NextEntryOffset);
							continue;
						}
					}

					hProcess = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, FALSE, (DWORD)infoP->UniqueProcessId);
					if (hProcess)
					{
						#ifdef _WIN64
						if (Utils::GetProcessPlatform(hProcess) == Utils::ProcessPlatformX64)
						#else
						if (Utils::GetProcessPlatform(hProcess) == Utils::ProcessPlatformX86)
						#endif
						{
							TCHAR filename[1024];
							GetModuleFileNameEx(hProcess, NULL, filename, 1024);

							SHFILEINFO sfi;
							SHGetFileInfo(filename, FILE_ATTRIBUTE_NORMAL, &sfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES);

							CBitmap* pBitmap = new CBitmap();
							CProcessMenuInfo Item;
							Item.ProcessId = (DWORD)infoP->UniqueProcessId;
							Item.pBitmap = pBitmap;

							CClientDC clDC(this);
							CDC dc; dc.CreateCompatibleDC(&clDC);

							int size = 16;
							pBitmap->CreateCompatibleBitmap(&clDC, size, size);
							CBitmap* pOldBmp = dc.SelectObject(pBitmap);

							dc.FillSolidRect(0, 0, size, size, GetSysColor(COLOR_3DFACE));
							::DrawIconEx(dc.GetSafeHdc(), 0, 0, sfi.hIcon, size, size, 0, NULL, DI_NORMAL);
							dc.SelectObject(pOldBmp);
							dc.DeleteDC();

							DWORD MsgID = (DWORD)(WM_PROCESSMENU + ProcMenuItems.size());

							CString proccessString;
							proccessString.Format(_T("%hs (%i)"), pName, (DWORD)infoP->UniqueProcessId); 

							menu.AppendMenu(MF_STRING | MF_ENABLED, MsgID, proccessString.GetBuffer());
							menu.SetMenuItemBitmaps(MsgID, MF_BYCOMMAND, pBitmap, pBitmap);

							ProcMenuItems.push_back(Item);
						}

						CloseHandle(hProcess);
					}
				}

				if (!infoP->NextEntryOffset)
					break;
				infoP = (PSYSTEM_PROCESS_INFORMATION)((unsigned char*)infoP + infoP->NextEntryOffset);
			}
		}
	}

	menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_HORNEGANIMATION, pos.left, pos.bottom, this);
	
	return;
}
Ejemplo n.º 12
0
//控件颜色
HBRUSH CPngButton::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if (!m_bHaveBitmaps)
	{
		//验证判断
		if(!m_pStdImage.m_pBitmap)	return NULL; 
	
		//变量声明
		CBitmap bmp,	*pOldBitmap;

		//获取区域
		CRect rect;
		GetClientRect(rect);

		//创建内存DC
		CMemDC2 pDC(pScreenDC,rect);

		Gdiplus::Graphics graphics(pDC->m_hDC);

		//背景DC
		if(m_dcBk.m_hDC==NULL)
		{
			CRect rect1;
			CClientDC clDC(GetParent());

			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC,rect.Width(),rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0,0,rect.Width(),rect.Height(),&clDC,rect1.left,rect1.top,SRCCOPY);
			bmp.DeleteObject();
		}

		//标准按钮
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
			float height = (float)m_pStdImage.m_pBitmap->GetHeight();
			RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

			graphics.DrawImage(m_pStdImage,grect,0,0,width,height,UnitPixel);

			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
			pOldBitmap=m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
			bmp.DeleteObject();

			// 按下状态
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage,grect,width*2,0,width,height,UnitPixel);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC,rect.Width(),rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY);
				bmp.DeleteObject();
			}

			// 盘旋状态  
			if(m_dcStdH.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
					0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
					0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
					0.05f, 0.05f, 0.05f, 0.00f, 1.00f };

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage, grect, width, 0, width, height, UnitPixel, &ia);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// 无效状态   
			if(m_dcGS.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix GrayMat = { 0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
					0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
					0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
					0.00f, 0.00f, 0.00f, 0.00f, 1.00f };

				ImageAttributes ia;
				ia.SetColorMatrix(&GrayMat);

				float width = (float)m_pStdImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pStdImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);
				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}
		// 交替按钮
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{    
			PaintBk(pDC);

			float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5;
			float height = (float)m_pAltImage.m_pBitmap->GetHeight();
			RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

			graphics.DrawImage(m_pAltImage,grect,0,0,width,height,UnitPixel);   

			m_dcAlt.CreateCompatibleDC(pDC);    
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());    
			pOldBitmap = m_dcAlt.SelectObject(&bmp);    
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);    
			bmp.DeleteObject();

			// 按下状态
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )    
			{     
				PaintBk(pDC);

				float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5;
				float height = (float)m_pAltImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;
				
				graphics.DrawImage(m_pAltImage,grect,width*2,0,width,height,UnitPixel);

				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// 盘旋状态
			if(m_dcAltH.m_hDC == NULL)
			{     
				PaintBk(pDC);

				ColorMatrix HotMat = { 1.05f, 0.00f, 0.00f, 0.00f, 0.00f,           
					0.00f, 1.05f, 0.00f, 0.00f, 0.00f,           
					0.00f, 0.00f, 1.05f, 0.00f, 0.00f,           
					0.00f, 0.00f, 0.00f, 1.00f, 0.00f,           
					0.05f, 0.05f, 0.05f, 0.00f, 1.00f };

				ImageAttributes ia;     
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pAltImage.m_pBitmap->GetWidth()/5; 
				float height = (float)m_pAltImage.m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);
				m_dcAltH.CreateCompatibleDC(pDC); 
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp); 
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}   
		}
		if(m_pCurBtn == NULL)   
		{    
			m_pCurBtn = &m_dcStd;  
		}
		m_bHaveBitmaps = TRUE;
	}
	return NULL;
}
Ejemplo n.º 13
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CGdipButtonTile::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_pStdLeftImage || !m_pStdCenterImage || !m_pStdRightImage)
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDCEx pDC(pScreenDC, rect);


		Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{
			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			InterpolationMode  interMode = graphics.GetInterpolationMode();
			graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

			int		nCalPos = 0;
			int		nWidthLeft = m_pStdLeftImage->m_pBitmap->GetWidth();
			int		nWidthRight = m_pStdRightImage->m_pBitmap->GetWidth();
			graphics.DrawImage(*m_pStdLeftImage, 0, 0, nWidthLeft, m_pStdLeftImage->m_pBitmap->GetHeight());
			nCalPos += nWidthLeft;
			graphics.DrawImage(*m_pStdCenterImage, nCalPos, 0, (m_nButtonWidth-nWidthLeft-nWidthRight)*2, m_pStdCenterImage->m_pBitmap->GetHeight());
			nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
			graphics.DrawImage(*m_pStdRightImage, nCalPos, 0, nWidthRight, m_pStdRightImage->m_pBitmap->GetHeight());
			graphics.SetInterpolationMode(interMode);

			// 글자!
			FontFamily fontFamily(L"나눔고딕");
		    Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
			SolidBrush brush(Color(255, 72, 72, 72));
			StringFormat stringFormat;
			stringFormat.SetAlignment(StringAlignmentCenter);
			stringFormat.SetLineAlignment(StringAlignmentCenter);
			PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
			graphics.SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);
			graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);


			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			//m_dcStd.TransparentBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, rect.Width(), rect.Height(), RGB(255,255,255));
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 1;
				graphics.DrawImage(*m_pStdLeftImage, nCalPos, 1, nWidthLeft, m_pStdLeftImage->m_pBitmap->GetHeight());
				nCalPos += nWidthLeft;
				graphics.DrawImage(*m_pStdCenterImage, nCalPos, 1, 2*(m_nButtonWidth-nWidthLeft-nWidthRight), m_pStdCenterImage->m_pBitmap->GetHeight());
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				graphics.DrawImage(*m_pStdRightImage, nCalPos, 1, nWidthRight, m_pStdRightImage->m_pBitmap->GetHeight());
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 0, 0, 255));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_nButtonWidth;
				float height = (float)m_nButtonHeight;

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 0;
				grect.Width = (float)nWidthLeft;
				graphics.DrawImage(*m_pStdLeftImage, grect, 0, 0, (float)nWidthLeft, height, UnitPixel, &ia);
				nCalPos += nWidthLeft;
				grect.X = (float)nCalPos;
				grect.Width = (float)((m_nButtonWidth-nWidthLeft-nWidthRight)*2);
				graphics.DrawImage(*m_pStdCenterImage, grect, 0, 0, 1, height, UnitPixel, &ia);
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				grect.X = (float)nCalPos;
				grect.Width = (float)nWidthRight;
				graphics.DrawImage(*m_pStdRightImage, grect, 0, 0, (float)nWidthRight, height, UnitPixel, &ia);
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 72, 72, 72));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL && m_bHaveAltImage)
			{
				int		nWidthLeft = m_pAltLeftImage->m_pBitmap->GetWidth();
				int		nWidthRight = m_pAltRightImage->m_pBitmap->GetWidth();

				PaintBk(pDC);

				interMode = graphics.GetInterpolationMode();
				graphics.SetInterpolationMode(InterpolationModeNearestNeighbor);

				nCalPos = 1;
				graphics.DrawImage(*m_pAltLeftImage, nCalPos, 1, nWidthLeft, m_pAltLeftImage->m_pBitmap->GetHeight());
				nCalPos += nWidthLeft;
				graphics.DrawImage(*m_pAltCenterImage, nCalPos, 1, 2*(m_nButtonWidth-nWidthLeft-nWidthRight), m_pAltCenterImage->m_pBitmap->GetHeight());
				nCalPos += m_nButtonWidth-nWidthLeft-nWidthRight;
				graphics.DrawImage(*m_pAltRightImage, nCalPos, 1, nWidthRight, m_pAltRightImage->m_pBitmap->GetHeight());
				graphics.SetInterpolationMode(interMode);

				// 글자!
				FontFamily fontFamily(L"나눔고딕");
				Gdiplus::Font font(&fontFamily, 22, FontStyleBold, UnitPixel);
				SolidBrush brush(Color(255, 0, 0, 255));
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				PointF pointF((float)m_nButtonWidth/2, (float)m_nButtonHeight/2);
				graphics.DrawString(m_strText, (INT)wcslen(m_strText), &font, pointF, &stringFormat, &brush);

				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

#if 0
		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(pDC);

		//	graphics.DrawImage(*m_pAltImage, 0, 0);
			graphics.DrawImage(*m_pAltImage, 0, 0, m_pAltImage->m_pBitmap->GetWidth(), m_pAltImage->m_pBitmap->GetHeight());
		
			m_dcAlt.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(pDC);

				// 2012.02.24 frino - Alt 영상이 커지는 문제가 발생하여 수정함
//				graphics.DrawImage(*m_pAltImage, 1, 1);
				graphics.DrawImage(*m_pAltImage, 1, 1, m_pAltImage->m_pBitmap->GetWidth(), m_pAltImage->m_pBitmap->GetHeight());
			
				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pAltImage->m_pBitmap->GetWidth();
				float height = (float)m_pAltImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcAltH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}
#endif

		if (m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Ejemplo n.º 14
0
void CSkinButton2::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{	
	UINT lState = lpDrawItemStruct->itemState;	

	CRect rect;
	GetClientRect(rect);

	CMemDC pDC( CDC::FromHandle(lpDrawItemStruct->hDC), rect);
	Gdiplus::Graphics graphics(pDC->m_hDC);

	// get background
	CBitmap bmp, *pOldBitmap;
	if (m_dcBk.m_hDC == NULL)
	{
		CRect rect1;
		CClientDC clDC(GetParent());
		GetWindowRect(rect1);
		GetParent()->ScreenToClient(rect1);

		m_dcBk.CreateCompatibleDC(&clDC);
		bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
		pOldBitmap = m_dcBk.SelectObject(&bmp);
		m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
		bmp.DeleteObject();
	}
	// paint backGround

	pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &m_dcBk, 0, 0, SRCCOPY);

	if( m_bDisable )
	{
		DrawImage(graphics);
	}
	else
	{
		if (lState & ODS_DISABLED)
		{
			DrawImage(graphics, DRAW_GRAY);
		}
		else
		{
			if (m_bSelected )
			{
				DrawFrame(graphics,rect );
				DrawImage(graphics, DRAW_LIGHT);
			}
			else
			{
				if (lState & ODS_SELECTED)
				{
					DrawFrame(graphics,rect );
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics, DRAW_LIGHT);
					}
				}
				else if (m_bMouseOnButton)
				{
					DrawFrame(graphics,rect );
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics,DRAW_LIGHT);
					}	
				}
				else if (lState & ODS_FOCUS)
				{				
					if( m_enmuDrawType == NO_FRAME_SELECT )
					{
						DrawFrame(graphics,rect );
					}
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics);
					}
				}
				else
				{
					if( m_enmuDrawType == NO_FRAME_SELECT )
					{
						DrawFrame(graphics,rect );
					}
					if( m_enmuDrawType != NO_FRAME_SELECT )
					{
						DrawImage(graphics);
					}
				}
			}
			//graphics
		}
	}

	if( m_strText.GetLength() > 0 && m_pPngImage == NULL )
	{
		Gdiplus::Bitmap bmpText( rect.Width(), rect.Height(), &graphics );
		Graphics* Ptext=Graphics::FromImage(&bmpText);
		//	Ptext->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias);

		//Matrix mx(0.25f,0,0,0.25f,1,1);
		//Ptext->SetTransform(&mx);

		Gdiplus::RectF rc( rect.left, rect.top, rect.Width(), rect.Height() );

		WCHAR   wFile[1024];   
#ifndef   UNICODE   
		MultiByteToWideChar(CP_ACP,   0,   LPCTSTR(m_strText),   -1,   wFile,  1024 );   
#else   
		lstrcpy(wFile,   szFile);   
#endif 

		StringFormat format;
		format.SetAlignment( StringAlignmentCenter );

		Gdiplus::RectF rectText, rectBack;
		rectText.X = rc.X;
		rectText.Y = rc.Y+ ( rc.Height-m_nWidth)/2;
		rectText.Width = rc.Width;
		rectText.Height = m_nWidth + rc.Height/2;

		rectBack.X = rc.X+2;
		rectBack.Y = rc.Y+1+ ( rc.Height-m_nWidth)/2;
		rectBack.Width = rc.Width-2;
		rectBack.Height = m_nWidth + rc.Height/2-1;

		Ptext->DrawString( wFile,-1 ,mp_font,rectBack,&format,&SolidBrush(Color(100,0,0,0)) );
		//graphics.SetInterpolationMode( Gdiplus::InterpolationModeHighQualityBicubic);
		//graphics.SetTextRenderingHint(  Gdiplus::TextRenderingHintAntiAlias);
		graphics.DrawImage(&bmpText,rc,0,0,bmpText.GetWidth(),bmpText.GetHeight(),UnitPixel);
		graphics.DrawString(wFile,-1,mp_font,rectText,&format,&SolidBrush(Color(255,255,255,255)));
	}
}
Ejemplo n.º 15
0
//=============================================================================
//
//	The framework calls this member function when a child control is about to 
//	be drawn.  All the bitmaps are created here on the first call. Every thing
//	is done with a memory DC except the background, which get's it's information 
//	from the parent. The background is needed for transparent portions of PNG 
//	images. An always on top app (such as Task Manager) that is in the way can 
//	cause it to get an incorrect background.  To avoid this, the parent should 
//	call the SetBkGnd function with a memory DC when it creates the background.
//				
//=============================================================================
HBRUSH CGdipButton::CtlColor(CDC* pScreenDC, UINT nCtlColor) 
{
	if(!m_bHaveBitmaps)
	{
		if(!m_pStdImage)
		{
			return NULL; // Load the standard image with LoadStdImage()
		}

		CBitmap bmp, *pOldBitmap;

		CRect rect;
		GetClientRect(rect);

		// do everything with mem dc
		CMemDC pDC(pScreenDC, rect);

		Gdiplus::Graphics graphics(pDC->m_hDC);

		// background
		if (m_dcBk.m_hDC == NULL)
		{

			CRect rect1;
			CClientDC clDC(GetParent());
			GetWindowRect(rect1);
			GetParent()->ScreenToClient(rect1);

			m_dcBk.CreateCompatibleDC(&clDC);
			bmp.CreateCompatibleBitmap(&clDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcBk.SelectObject(&bmp);
			m_dcBk.BitBlt(0, 0, rect.Width(), rect.Height(), &clDC, rect1.left, rect1.top, SRCCOPY);
			bmp.DeleteObject();
		}

		// standard image
		if (m_dcStd.m_hDC == NULL)
		{
			PaintBk(pDC);

			graphics.DrawImage(*m_pStdImage, 0, 0);
		
			m_dcStd.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcStd.SelectObject(&bmp);
			m_dcStd.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// standard image pressed
			if (m_dcStdP.m_hDC == NULL)
			{
				PaintBk(pDC);

				graphics.DrawImage(*m_pStdImage, 1, 1);

				m_dcStdP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdP.SelectObject(&bmp);
				m_dcStdP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// standard image hot
			if(m_dcStdH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcStdH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcStdH.SelectObject(&bmp);
				m_dcStdH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// grayscale image
			if(m_dcGS.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix GrayMat = {	0.30f, 0.30f, 0.30f, 0.00f, 0.00f,
										0.59f, 0.59f, 0.59f, 0.00f, 0.00f,
										0.11f, 0.11f, 0.11f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&GrayMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pStdImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcGS.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcGS.SelectObject(&bmp);
				m_dcGS.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		// alternate image
		if( (m_dcAlt.m_hDC == NULL) && m_bHaveAltImage )
		{
			PaintBk(pDC);

			graphics.DrawImage(*m_pAltImage, 0, 0);
		
			m_dcAlt.CreateCompatibleDC(pDC);
			bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
			pOldBitmap = m_dcAlt.SelectObject(&bmp);
			m_dcAlt.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
			bmp.DeleteObject();

			// alternate image pressed
			if( (m_dcAltP.m_hDC == NULL) && m_bHaveAltImage )
			{
				PaintBk(pDC);

				graphics.DrawImage(*m_pAltImage, 1, 1);
			
				m_dcAltP.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltP.SelectObject(&bmp);
				m_dcAltP.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}

			// alternate image hot
			if(m_dcAltH.m_hDC == NULL)
			{
				PaintBk(pDC);

				ColorMatrix HotMat = {	1.05f, 0.00f, 0.00f, 0.00f, 0.00f,
										0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
										0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
										0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
										0.05f, 0.05f, 0.05f, 0.00f, 1.00f	};

				ImageAttributes ia;
				ia.SetColorMatrix(&HotMat);

				float width = (float)m_pStdImage->m_pBitmap->GetWidth();
				float height = (float)m_pStdImage->m_pBitmap->GetHeight();

				RectF grect; grect.X=0, grect.Y=0; grect.Width = width; grect.Height = height;

				graphics.DrawImage(*m_pAltImage, grect, 0, 0, width, height, UnitPixel, &ia);

				m_dcAltH.CreateCompatibleDC(pDC);
				bmp.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
				pOldBitmap = m_dcAltH.SelectObject(&bmp);
				m_dcAltH.BitBlt(0, 0, rect.Width(), rect.Height(), pDC, 0, 0, SRCCOPY);
				bmp.DeleteObject();
			}
		}

		if(m_pCurBtn == NULL)
		{
			m_pCurBtn = &m_dcStd;
		}

		m_bHaveBitmaps = TRUE;
	}

	return NULL;
}
Ejemplo n.º 16
0
void CVisualSynanView::OnPaint() 
{
	CString S = GetDocument()->m_VisualSentences.m_WorkTimeStr;
	((CFrameWnd*)((CVisualSynanApp*)AfxGetApp())->m_pMainWnd)->SetMessageText(S);
	ASSERT( GetDocument() );


	CClientDC clDC(this);
	CView::OnPaint();

	CRect clientRect;	
	CDC memDC;
	CBitmap bmBmp;
	
	CRect rectDevice;

	//creating memory DC
	GetClientRect(&clientRect);
	rectDevice = clientRect;
	OnPrepareDC(&clDC);
	clDC.DPtoLP(&clientRect);
	bmBmp.CreateCompatibleBitmap(&clDC, rectDevice.right , rectDevice.bottom);
	memDC.CreateCompatibleDC(&clDC);

	CBitmap* pOldBitmap = memDC.SelectObject(&bmBmp);
	CBrush brBackground(::GetSysColor(COLOR_WINDOW));
	memDC.FillRect(&rectDevice, &brBackground);
	memDC.SetBkColor(::GetSysColor(COLOR_WINDOW));

	//selecting choosen font
	CFont* pOldFont;

	if( m_bExistUsefulFont)
	{
		pOldFont = memDC.SelectObject(&m_FontForWords);
	}



	if( m_bFirsTime && !GetDocument()->NoSentences() )
	{
		m_bFirsTime = FALSE;
		GetDocument()->CalculateCoordinates(&memDC,clientRect.right, m_bShowGroups);
	}


	int iOffset = clientRect.top - rectDevice.top;

	//drawing sentences in memory DC
	GetDocument()->PrintSentences(&memDC,clientRect, iOffset);

	//drawing it on the screen
	clDC.BitBlt(0,clientRect.top, rectDevice.right,rectDevice.bottom,&memDC,0,0,SRCCOPY);

	//restoring old bitmap and old font
	memDC.SelectObject(pOldBitmap);
	if( m_bExistUsefulFont)
		memDC.SelectObject(pOldFont);
	memDC.DeleteDC();	
	
	
	ResizeScroll();
}