Click here to Skip to main content
15,905,504 members

Comments by maladuk (Top 4 by date)

maladuk 14-Dec-14 10:55am View    
OK... I have reused some code that I found elsewhere. I guess it is set that big to simply ensure there is enough memory allocated. But changing it to 1024x768 does not make any difference. The Bitmap still does not show.

m
maladuk 14-Dec-14 10:37am View    
Thank you for answering. Yes, I should have upgraded to newer VS-tools long time ago, but as a project worker there is never enough time for it. And since the programs involved are made up of several thousands lines of code this will not be an option this time. Thank you anyway!

maladuk
maladuk 14-Dec-14 10:30am View    
Thank you for answering! I like this solution since it seems that it makes it possible to keep the original width x height on the main window when moving on to new screen resolutions. However, since I am rather unfamiliar with windows programming I would need some axample code to look at. So, if you have an example code as well, I would surely appreciate it.

maladuk
maladuk 14-Dec-14 10:24am View    
Thank you for answering! Since I use MFC the code is a little different from the code in your test app. And I am too unfamiliar with windows programming to identify what must be changed. Below is the ::OnPaint function where my BitMap is loaded, and my attempt to use your Resample-function. It compiles, but no resampled bitmap is loaded onto the canvas. If you have some suggestions I will be very grateful.

maladuk

void CSaulandDlg::OnPaint()
{
if (IsIconic())
{
....
}
else
{
CPaintDC dc( this ); // Device context for painting
CBitmap bmpBackground, *poldbmp;
/*new*/ CBitmap bmpResampled;
CDC memdc;


// Load the bitmap resource
bmpBackground.LoadBitmap( IDB_BACKGROUND );


// Create a compatible memory DC
memdc.CreateCompatibleDC( &dc );

/*new*/ //Create resampled bitmap
/*new*/ bmpResampled.FromHandle(CreateResampledBitmap(dc, (HBITMAP) bmpBackground.m_hObject, 1024, 768, STOCK_FILTER_BOX));

// Select the bitmap into the DC
//poldbmp = memdc.SelectObject( &bmpBackground );
/*new*/ poldbmp = memdc.SelectObject( &bmpResampled );

// Copy (BitBlt) bitmap from memory DC to screen DC
dc.BitBlt( 0, 0, 4700, 4700, &memdc, 0, 0, SRCCOPY );

memdc.SelectObject( poldbmp );
CDialog::OnPaint();
}
}