Click here to Skip to main content
15,917,613 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGDI+ BMP conversion Pin
Ajesh kumar29-Jul-03 20:16
Ajesh kumar29-Jul-03 20:16 
GeneralMemory leaks eliminating Pin
El'Cachubrey29-Jul-03 20:06
El'Cachubrey29-Jul-03 20:06 
GeneralRe: Memory leaks eliminating Pin
Joe Woodbury29-Jul-03 21:58
professionalJoe Woodbury29-Jul-03 21:58 
GeneralRe: Memory leaks eliminating Pin
Andrew Walker29-Jul-03 22:43
Andrew Walker29-Jul-03 22:43 
GeneralRe: Memory leaks eliminating Pin
LittleYellowBird30-Jul-03 3:13
LittleYellowBird30-Jul-03 3:13 
GeneralSerial Communication Write/Read using events Pin
Member 42422129-Jul-03 19:56
Member 42422129-Jul-03 19:56 
Questionhow to print a bitmap from a view? Pin
sherryfa29-Jul-03 19:22
sherryfa29-Jul-03 19:22 
AnswerRe: how to print a bitmap from a view? Pin
Frank K29-Jul-03 19:59
Frank K29-Jul-03 19:59 
Hi,

a little example

PRINTDLG pd;
DOCINFO di;
int iError;
float fx, fy;
float fPixXWnd, fPixYWnd, fPixXPrint, fPixYPrint;
float fScaleX, fScaleY;
HDC ScreenHdc;

// Initialize the PRINTDLG structure.
memset(&pd, 0, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
pd.lpfnPrintHook = NULL;
pd.lpfnSetupHook = NULL;
pd.Flags = /*PD_RETURNDEFAULT |*/ PD_RETURNDC;

//open the Printdialog and get a HDC for the printer
if(PrintDlg(&pd))
{
memset( &di, 0, sizeof(DOCINFO) );
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "DocName";
di.lpszOutput = (LPTSTR) NULL;

// Begin a print job by calling the StartDoc function.
iError = StartDoc(pd.hDC, &di);
if (iError == SP_ERROR)
{
ASSERT(0);
}

// Inform the driver that the application is about to begin sending data.
iError = StartPage(pd.hDC);
if (iError <= 0)
{
ASSERT(0);
}

//Get the Screen-resolution(1)
ScreenHdc = ::GetDC(NULL);
fPixXWnd = ::GetDeviceCaps(ScreenHdc, LOGPIXELSX);
fPixYWnd = ::GetDeviceCaps(ScreenHdc, LOGPIXELSY);
::ReleaseDC(NULL, ScreenHdc);

//...or get the Screen-resolution(2), not tested
fPixXWnd = ::GetSystemMetrics(SM_CXFULLSCREEN);
fPixYWnd = ::GetSystemMetrics(SM_CYFULLSCREEN);

//Get the Printer-resolution
fPixXPrint = (float)::GetDeviceCaps(pd.hDC, LOGPIXELSX);
fPixYPrint = (float)::GetDeviceCaps(pd.hDC, LOGPIXELSY);

//the alignment for your window-coordinate
fScaleX = fPixXPrint / fPixXWnd;
fScaleY = fPixYPrint / fPixYWnd;

....
e.g. you draw your Bitmap to your view with
StretchBlt(hdcWnd, 10, 10, 100, 100, hdcBmp, 0, 0, 50, 50, SRCCOPY);

now write the following for your Printer
StretchBlt(hdcPrint, 10*fScaleX, 10*fScaleY, 100*fScaleX, 100*fScaleY, hdcBmp, 0, 0, 50, 50, SRCCOPY);

HTH

Regards
Frank
Generalopen the printer device Pin
Jerome Conus29-Jul-03 19:19
Jerome Conus29-Jul-03 19:19 
GeneralRe: open the printer device Pin
Joel Lucsy30-Jul-03 8:47
Joel Lucsy30-Jul-03 8:47 
GeneralRe: open the printer device Pin
Jerome Conus30-Jul-03 19:11
Jerome Conus30-Jul-03 19:11 
GeneralRe: open the printer device Pin
Joel Lucsy31-Jul-03 2:06
Joel Lucsy31-Jul-03 2:06 
GeneralRe: open the printer device Pin
Jerome Conus31-Jul-03 2:09
Jerome Conus31-Jul-03 2:09 
GeneralRe: open the printer device Pin
Joel Lucsy31-Jul-03 2:20
Joel Lucsy31-Jul-03 2:20 
Generalwindows startup help!!!!! Pin
xxhimanshu29-Jul-03 18:58
xxhimanshu29-Jul-03 18:58 
GeneralRe: windows startup help!!!!! Pin
Frank K29-Jul-03 22:26
Frank K29-Jul-03 22:26 
GeneralRe: windows startup help!!!!! Pin
David Crow30-Jul-03 4:07
David Crow30-Jul-03 4:07 
Generaltext editor! Pin
ariez29-Jul-03 18:08
ariez29-Jul-03 18:08 
GeneralRe: text editor! Pin
Toni7829-Jul-03 18:19
Toni7829-Jul-03 18:19 
GeneralRe: text editor! Pin
David Crow30-Jul-03 4:09
David Crow30-Jul-03 4:09 
GeneralOnChange Event Pin
Small Rat29-Jul-03 18:04
Small Rat29-Jul-03 18:04 
QuestionHow to change the size of one pane in the SplitterWnd ? Pin
benben29-Jul-03 17:41
benben29-Jul-03 17:41 
AnswerRe: How to change the size of one pane in the SplitterWnd ? Pin
Ryan Binns29-Jul-03 18:29
Ryan Binns29-Jul-03 18:29 
GeneralRe: How to change the size of one pane in the SplitterWnd ? Pin
Toni7829-Jul-03 18:36
Toni7829-Jul-03 18:36 
GeneralRe: How to change the size of one pane in the SplitterWnd ? Pin
Ryan Binns29-Jul-03 18:44
Ryan Binns29-Jul-03 18:44 

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.