Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Picture display in VC application

Status
Not open for further replies.

alzomor

Advanced Member level 2
Joined
Jun 9, 2005
Messages
674
Helped
39
Reputation
78
Reaction score
8
Trophy points
1,298
Location
Germany
Activity points
6,406
Hi

How to dispaly a picture in my VC application ?

Salam
Hossam Alzomor
 

by display a picture you mean where?
 

Hi

anywhere in the application window
and I need to display another picture in the same place after some clicks
Do you know how?

Salam
Hossam Alzomor
 

hi,

yes you can display any picture you want in VC++ application window,
it basically depends on what format your picture file is in is it a bmp or a gif ?,
however the basic idea is to load the picture in a device context (CDC) and then bitblt it into the application window's OnPaint method.
please refer to MSDN the api calls such as CDC::BitBlt etc....
let me know if you need a sample program.
 

void CPaintDlg::ShowBitmap(CPaintDC *pdc, CWnd *pWnd)
{
// Convert the pointer to a pointer to the main dialog class
CGraphicsDlg *lpWnd = (CGraphicsDlg*)pWnd;
BITMAP bm;
// Get the loaded bitmap
lpWnd->m_bmpBitmap.GetBitmap(&bm);
CDC dcMem;
// Create a device context to load the bitmap into
dcMem.CreateCompatibleDC(pdc);
// Select the bitmap into the compatible device context
CBitmap* pOldBitmap = (CBitmap*)dcMem.SelectObject
CRect lRect;
// Get the display area available
GetClientRect(lRect);
lRect.NormalizeRect();
// Copy and resize the bitmap to the dialog window
pdc->StretchBlt(10, 10, (lRect.Width() - 20),
(lRect.Height() - 20), &dcMem, 0, 0,
bm.bmWidth, bm.bmHeight, SRCCOPY);
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top