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

C / C++ / MFC

 
QuestionMerging (Linking) two static library Pin
Hirakawa11-Oct-07 4:54
Hirakawa11-Oct-07 4:54 
AnswerRe: Merging (Linking) two static library Pin
jhwurmbach11-Oct-07 5:50
jhwurmbach11-Oct-07 5:50 
GeneralRe: Merging (Linking) two static library [modified] Pin
Hirakawa11-Oct-07 8:06
Hirakawa11-Oct-07 8:06 
AnswerRe: Merging (Linking) two static library Pin
Cedric Moonen11-Oct-07 7:27
Cedric Moonen11-Oct-07 7:27 
GeneralRe: Merging (Linking) two static library Pin
Hirakawa11-Oct-07 8:08
Hirakawa11-Oct-07 8:08 
GeneralRe: Merging (Linking) two static library Pin
Cedric Moonen11-Oct-07 9:43
Cedric Moonen11-Oct-07 9:43 
GeneralRe: Merging (Linking) two static library Pin
Hirakawa11-Oct-07 20:54
Hirakawa11-Oct-07 20:54 
QuestionPrint a bitmap at a specified X-Y position Pin
ShilpaPotnis11-Oct-07 4:05
ShilpaPotnis11-Oct-07 4:05 
I need to print a bitmap image (about 2inch X 2inch) at a specific location on a paper but the following code always prints it at the upper left corner. How can I specify the x and y coordinated of the paper? What am I doing wrong? Even if I specify the first 2 parameters of StretchBlt function to my desired location(like 7,7), it prints at the upper left corner of the paper.
Please help!!!

void PrintBitmap(LPCTSTR filename)
{
CPrintDialog printDlg(FALSE);
printDlg.GetDefaults();

CDC dc;
if (!dc.Attach(printDlg.GetPrinterDC()))
{
AfxMessageBox(_T("No printer found!")); return;
}

dc.m_bPrinting = TRUE;
DOCINFO di;
// Initialise print document details
::ZeroMemory (&di, sizeof (DOCINFO));
di.cbSize = sizeof (DOCINFO);
//di.lpszDocName = filename;

BOOL bPrintingOK = dc.StartDoc(&di); // Begin a new print job
// Get the printing extents
// and store in the m_rectDraw field of a
// CPrintInfo object
CPrintInfo Info;
Info.SetMaxPage(1); // just one page
int maxw = dc.GetDeviceCaps(HORZRES);
int maxh = dc.GetDeviceCaps(VERTRES);

Info.m_rectDraw.SetRect(0, 0, maxw, maxh);

dc.StartPage(); // begin new page
//Info.m_nCurPage = page;
CBitmap bitmap;
// LoadImage does the trick here, it creates a DIB section
// You can also use a resource here
// by using MAKEINTRESOURCE() ... etc.

if(!bitmap.Attach(::LoadImage(::GetModuleHandle(NULL), filename, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE)))
{
AfxMessageBox(_T("Error loading bitmap!")); return;
}
BITMAP bm;
bitmap.GetBitmap(&bm);
int w = bm.bmWidth;
int h = bm.bmHeight;
// create memory device context
CDC memDC;

memDC.CreateCompatibleDC(&dc);
CBitmap *pBmp = memDC.SelectObject(&bitmap);
memDC.SetMapMode(dc.GetMapMode());
//dc.SetStretchBltMode(FULLTONE);

dc.StretchBlt(7, 7, 2*w, 2*h, &memDC, 0, 0, w, h, SRCCOPY);

// clean up
memDC.SelectObject(pBmp);

bPrintingOK = (dc.EndPage() > 0); // end page
//}
if (bPrintingOK)
dc.EndDoc(); // end a print job
else dc.AbortDoc(); // abort job.
}
QuestionRe: Print a bitmap at a specified X-Y position Pin
David Crow11-Oct-07 4:19
David Crow11-Oct-07 4:19 
AnswerRe: Print a bitmap at a specified X-Y position Pin
ShilpaPotnis11-Oct-07 4:30
ShilpaPotnis11-Oct-07 4:30 
AnswerRe: Print a bitmap at a specified X-Y position Pin
chandu00411-Oct-07 5:04
chandu00411-Oct-07 5:04 
GeneralRe: Print a bitmap at a specified X-Y position Pin
ShilpaPotnis11-Oct-07 5:49
ShilpaPotnis11-Oct-07 5:49 
GeneralRe: Print a bitmap at a specified X-Y position Pin
chandu00411-Oct-07 7:21
chandu00411-Oct-07 7:21 
GeneralRe: Print a bitmap at a specified X-Y position Pin
ShilpaPotnis11-Oct-07 8:15
ShilpaPotnis11-Oct-07 8:15 
GeneralRe: Print a bitmap at a specified X-Y position Pin
ShilpaPotnis11-Oct-07 8:24
ShilpaPotnis11-Oct-07 8:24 
AnswerRe: Print a bitmap at a specified X-Y position Pin
Mark Salsbery11-Oct-07 12:30
Mark Salsbery11-Oct-07 12:30 
GeneralRe: Print a bitmap at a specified X-Y position Pin
ShilpaPotnis12-Oct-07 4:59
ShilpaPotnis12-Oct-07 4:59 
Questionwhen do we need to define INC_OLE2? Pin
George_George11-Oct-07 4:01
George_George11-Oct-07 4:01 
AnswerRe: when do we need to define INC_OLE2? Pin
Mike Dimmick11-Oct-07 9:30
Mike Dimmick11-Oct-07 9:30 
GeneralRe: when do we need to define INC_OLE2? Pin
George_George11-Oct-07 18:04
George_George11-Oct-07 18:04 
GeneralRe: when do we need to define INC_OLE2? Pin
Mike Dimmick12-Oct-07 9:13
Mike Dimmick12-Oct-07 9:13 
GeneralRe: when do we need to define INC_OLE2? Pin
George_George13-Oct-07 4:03
George_George13-Oct-07 4:03 
Question16 color to black and white Pin
sanjutvm11-Oct-07 4:01
sanjutvm11-Oct-07 4:01 
AnswerRe: 16 color to black and white Pin
ThatsAlok11-Oct-07 4:10
ThatsAlok11-Oct-07 4:10 
AnswerRe: 16 color to black and white Pin
Mark Salsbery11-Oct-07 12:33
Mark Salsbery11-Oct-07 12:33 

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.