Click here to Skip to main content
15,902,189 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGetting the back ground colour of a Dialog Pin
Shibu.V.Nair10-Jul-02 0:00
Shibu.V.Nair10-Jul-02 0:00 
GeneralRe: Getting the back ground colour of a Dialog Pin
Dov Sherman10-Jul-02 0:46
Dov Sherman10-Jul-02 0:46 
GeneralBeginner's Template question! Pin
Wayne Jin9-Jul-02 23:40
Wayne Jin9-Jul-02 23:40 
GeneralRe: Beginner's Template question! Pin
Terry Denham10-Jul-02 3:41
Terry Denham10-Jul-02 3:41 
GeneralRe: Beginner's Template question! Pin
Anonymous10-Jul-02 6:37
Anonymous10-Jul-02 6:37 
GeneralSetting the number of lines to scroll in Windows98 ... urgent....helppppp... Pin
Alek9-Jul-02 23:33
Alek9-Jul-02 23:33 
GeneralLoadBitmap in rectangle Pin
slah9-Jul-02 23:31
slah9-Jul-02 23:31 
GeneralRe: LoadBitmap in rectangle Pin
Dov Sherman10-Jul-02 0:45
Dov Sherman10-Jul-02 0:45 
I generally make a CStatic box with a border and then create a new class which is a child of CStatic. For example, class CBitmapViewBox : public CStatic

I add a member variable of type CBitmapViewBox to my main dialog and, in the OnInitDialog() event, I do this...

<br />
	m_BitmapViewBox.SubclassDlgItem(IDC_SBITMAPDISPLAY, this);<br />
	m_BitmapViewBox.Init();<br />


To load and display the bitmap, I do this...

<br />
void CBitmapViewBox::OnPaint() <br />
{<br />
	CPaintDC dc(this); // device context for painting<br />
	CMainViewDlg *pWnd = (CMainViewDlg *)GetParent();<br />
	<br />
	if(pWnd != NULL)<br />
	{<br />
		if(m_bValid)<br />
		{<br />
			CRect lRect;<br />
			GetClientRect(lRect);<br />
			lRect.NormalizeRect();<br />
			<br />
			BITMAP bm;<br />
			m_BMP.GetBitmap(&bm);<br />
			CBitmap *pOldBitmap = dcMem.SelectObject(&m_BMP);<br />
<br />
			dc.BitBlt(0, 0, lRect.Width(), lRect.Height(), &dcMem, 0, 0, SRCCOPY);<br />
				<br />
			dc.SelectObject(pOldBitmap);<br />
		}<br />
		else<br />
		{<br />
			dc.DrawText("Not a valid BMP file", -1, lRect, DT_CENTER | DT_VCENTER | DT_WORDBREAK);<br />
		}<br />
	}<br />
<br />
	CStatic::OnPaint();<br />
}<br />
<br />
BOOL CBitmapViewBox::UpdateBMP(LPCTSTR lpszName)<br />
{<br />
	CMainViewDlg *pFrameWnd = (CMainViewDlg *)GetParent();<br />
	HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), lpszName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);<br />
<br />
	m_bValid = TRUE;<br />
<br />
	// Get rid of other bitmap<br />
	if(m_BMP.DeleteObject())<br />
		m_BMP.Detach();<br />
<br />
	if(!hBitmap)<br />
	{<br />
		m_bValid = FALSE;<br />
		UpdateSize(m_iMaxWidth, m_iMaxHeight);<br />
		Invalidate(TRUE);<br />
		return FALSE;<br />
	}<br />
<br />
	m_bValid = TRUE;<br />
<br />
	m_BMP.Attach(hBitmap);<br />
}<br />

GeneralWINAPI Book Pin
S van Leent9-Jul-02 22:48
S van Leent9-Jul-02 22:48 
GeneralRe: WINAPI Book Pin
slah9-Jul-02 23:35
slah9-Jul-02 23:35 
GeneralRe: WINAPI Book Pin
Christian Graus10-Jul-02 3:23
protectorChristian Graus10-Jul-02 3:23 
GeneralRe: WINAPI Book Pin
Anonymous10-Jul-02 0:06
Anonymous10-Jul-02 0:06 
GeneralRe: WINAPI Book Pin
S van Leent10-Jul-02 3:40
S van Leent10-Jul-02 3:40 
GeneralRe: WINAPI Book Pin
Anonymous10-Jul-02 14:29
Anonymous10-Jul-02 14:29 
Generalpassing the memDC from view to ActiveX control Pin
nar_shilpa9-Jul-02 21:33
nar_shilpa9-Jul-02 21:33 
Generalunable to capture components outside screen area Pin
nar_shilpa9-Jul-02 21:30
nar_shilpa9-Jul-02 21:30 
QuestionResize in a hybrid dialog? Pin
chen9-Jul-02 20:26
chen9-Jul-02 20:26 
QuestionRemove OK button in Pocket PC program? Pin
Anonymous9-Jul-02 20:11
Anonymous9-Jul-02 20:11 
GeneralFile Copy Pin
Shibu.V.Nair9-Jul-02 19:03
Shibu.V.Nair9-Jul-02 19:03 
GeneralRe: File Copy Pin
Michael Dunn9-Jul-02 19:18
sitebuilderMichael Dunn9-Jul-02 19:18 
Generaldialog based Pin
Anonymous9-Jul-02 18:59
Anonymous9-Jul-02 18:59 
GeneralRe: dialog based Pin
Christian Graus9-Jul-02 19:08
protectorChristian Graus9-Jul-02 19:08 
GeneralRe: dialog based Pin
Anonymous9-Jul-02 19:14
Anonymous9-Jul-02 19:14 
GeneralRe: dialog based Pin
Christian Graus9-Jul-02 19:17
protectorChristian Graus9-Jul-02 19:17 
GeneralRe: dialog based Pin
Anonymous9-Jul-02 19:31
Anonymous9-Jul-02 19:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.