Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to close a user created message box without effecting the parent window

Good Evening... My query is......

After user selects PRINT menu one message box(usr created)will appear.
The message box consists of 2 command button controls.
one is OK and the other is CANCEL.
If the user presses OK it should take snapshot of the background (BACKGROUND contains ACTIVEX CONTROLS) and should create a BITMAP IMAGE without the message box. That means IMAGE shouldn't contain the message box. For this I am calling EndDialog() function. But now the problem message box is creating some empty space in the background and IMAGE is coming with that empty space. But it shouldn't come.
The code is as folows.

After selecting PRINT menu it will execute the following code.... i.e.,
**************************************************************************8
CSwissMessage m_objMsg;
m_objMsg.m_strMSG = "\n\n\nPress Print to Print the Screen or Cancel To Quit";
m_objMsg.DoModal();
****************************************************************************
Know the message box will appear. If the user selects PRINT button it will execute the following code.....
****************************************************************************
void CSwissMessage::OnClickCmdbtnPrint()
{
CSwissMessage::EndDialog(10);
snap();
}
****************************************************************************
void CSwissMessage::snap()
{
CWnd* pWnd = AfxGetApp()->m_pMainWnd;

if (windowtobmp("ShipStatus.bmp",pWnd)==FALSE)
{
MessageBox("ERROR");
}
}
*******************************************************************************************
BOOL CSwissMessage::windowtobmp(CString filename,CWnd* pwnd)
{
CWindowDC dc(pwnd);
CDC memdc;
memdc.CreateCompatibleDC(&dc);

CRect rect;
pwnd->GetWindowRect(rect);

CBitmap bmp;
bmp.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height()-150);

CBitmap* poldbmp = memdc.SelectObject(&bmp);
memdc.BitBlt(0,0,rect.Width(),rect.Height(),&dc,0,0,SRCCOPY);

memdc.SelectObject(poldbmp);

HANDLE hdib = ConvertDDBToDIB(bmp);
writebmp(filename,hdib);
GlobalFree(hdib);

CString strPrintFilePath = FindPrintFilePath();
HINSTANCE hInstancePrint;//,hInstanceEditor;

hInstancePrint = ShellExecute(this->m_hWnd,"print","ShipStatus.bmp",NULL,NULL,SW_HIDE);

return TRUE;

Please help me........
thanks in advance
0 Kudos
Message 1 of 2
(6,293 Views)
Hi Sairam,

Not sure what this has to do with Measurement Studio (maybe you're using our controls?) but I would try redrawing the main window before creating the new device context in windowstobmp method.

Have a great day,

Ecleamus R.
National Instruments
0 Kudos
Message 2 of 2
(6,279 Views)