Click here to Skip to main content
16,011,611 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Running a batch file Pin
Camron20-Sep-05 5:49
Camron20-Sep-05 5:49 
GeneralRe: Running a batch file Pin
David Crow20-Sep-05 6:04
David Crow20-Sep-05 6:04 
AnswerRe: Running a batch file Pin
bugDanny20-Sep-05 7:16
bugDanny20-Sep-05 7:16 
AnswerRe: Running a batch file Pin
Christopher Lloyd20-Sep-05 12:47
Christopher Lloyd20-Sep-05 12:47 
AnswerRe: Running a batch file Pin
Johann Gerell20-Sep-05 19:41
Johann Gerell20-Sep-05 19:41 
QuestionCListCtrl custom draw problem Pin
followait20-Sep-05 4:48
followait20-Sep-05 4:48 
AnswerRe: CListCtrl custom draw problem Pin
Alexander M.,20-Sep-05 8:35
Alexander M.,20-Sep-05 8:35 
QuestionHow to show the Bitmap at top ? Pin
Amarelia20-Sep-05 4:22
Amarelia20-Sep-05 4:22 
Hi I am showing a bitmap in my dialog based MFC programm.
I have also put some Static Control and that goes overlapped to the bitmap I want to saw.

Is there any way to show bitmap at forground and static control in background so that we can see the bitmap still overlapping the static control

My code is as follow :

MyDlg.cpp
=========
BOOL MyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
OnInitBitmap();

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

return TRUE;
}
void CMyDlg::OnInitBitmap()
{
//Give the path and name of bitmap file to the given Bitmap variable
m_sBitmap = "C:\\Test.bmp";

HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);

if(hBitmap)
{
if (m_bmpBitmap.DeleteObject())
m_bmpBitmap.Detach();
m_bmpBitmap.Attach(hBitmap);
}
return;
}
void MyDlg::ShowBitmap(CPaintDC *pdc)
{
BITMAP bm;
int iStartX,iStartY, iHeight, iWidth;
HWND hWnd;
bool bRes;
CRect myRect;

hWnd = ::GetDesktopWindow();
bRes = ::GetWindowRect(hWnd,myRect);
ClientToScreen(myRect);

m_bmpBitmap.GetBitmap(&bm);
CDC dcMem;

dcMem.CreateCompatibleDC(pdc);
CBitmap *pOldBitmap = (CBitmap *) dcMem.SelectObject(m_bmpBitmap);

CRect lRect;
GetClientRect(lRect);
lRect.NormalizeRect();

iStartX = m_BorderWidth;
iStartY = myRect.Height();
iHeight = bm.bmHeight-20;
pdc->StretchBlt(iStartX,iStartY,iWidth, iHeight, &dcMem, 0,0, bm.bmWidth,bm.bmHeight, SRCCOPY);

return;
}

void MyDlg::OnPaint()
{
CPaintDC dc(this);
ShowBitmap(&dc);

if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
CDialog::OnPaint();
}

Amarelia Maehsh
Gujarat
India

AnswerRe: How to show the Bitmap at top ? Pin
Eytukan20-Sep-05 4:40
Eytukan20-Sep-05 4:40 
GeneralRe: How to show the Bitmap at top ? Pin
ThatsAlok20-Sep-05 20:02
ThatsAlok20-Sep-05 20:02 
AnswerRe: How to show the Bitmap at top ? Pin
Neagoe Gabriel20-Sep-05 5:40
Neagoe Gabriel20-Sep-05 5:40 
QuestionOCX link to DLL Pin
honae20-Sep-05 4:01
honae20-Sep-05 4:01 
QuestionCode To Terminate Application Using Key ? Pin
Amarelia20-Sep-05 3:44
Amarelia20-Sep-05 3:44 
AnswerRe: Code To Terminate Application Using Key ? Pin
BlackDice20-Sep-05 4:22
BlackDice20-Sep-05 4:22 
AnswerRe: Code To Terminate Application Using Key ? Pin
Neagoe Gabriel20-Sep-05 5:49
Neagoe Gabriel20-Sep-05 5:49 
QuestionHow to color the dialog leaving some user defined border? Pin
Amarelia20-Sep-05 3:30
Amarelia20-Sep-05 3:30 
AnswerRe: How to color the dialog leaving some user defined border? Pin
Neagoe Gabriel20-Sep-05 5:45
Neagoe Gabriel20-Sep-05 5:45 
QuestionMFC help and tutorials Pin
bugDanny20-Sep-05 3:26
bugDanny20-Sep-05 3:26 
AnswerRe: MFC help and tutorials Pin
toxcct20-Sep-05 3:41
toxcct20-Sep-05 3:41 
GeneralRe: MFC help and tutorials Pin
bugDanny20-Sep-05 4:16
bugDanny20-Sep-05 4:16 
General*off topic* Pin
Eytukan20-Sep-05 4:35
Eytukan20-Sep-05 4:35 
GeneralRe: *off topic* Pin
toxcct20-Sep-05 4:40
toxcct20-Sep-05 4:40 
GeneralRe: *off topic* Pin
Eytukan20-Sep-05 4:52
Eytukan20-Sep-05 4:52 
GeneralRe: MFC help and tutorials Pin
Trollslayer20-Sep-05 4:59
mentorTrollslayer20-Sep-05 4:59 
GeneralRe: MFC help and tutorials Pin
toxcct20-Sep-05 5:02
toxcct20-Sep-05 5:02 

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.