|
-
June 14th, 2008, 05:05 AM
#1
MFC Picture Control W/ Bitmap Mayhem.
Ok.. My problem is kind of screwed up, I'm not even sure if there is a solution available for this. If there isn't, I'd like to know any alternative way of doing this.
I placed a Picture Control using resource compiler and using that, I was able to load a BMP or JPEG file on it. Here is the problem - I'd like to draw rectangles ON TOP of the picture that has been loaded. Let me show you my OnPaint function to see what I have attempted so far.
Code:
void CMy2d_3d_applicationDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect RectColorChanger;
// Get the location and dimensions of the control
m_picCtrl.GetWindowRect(&RectColorChanger);
CBrush BrushRed(RGB(255, 55, 5));
// Select the new brush
CBrush *pOldBrush = dc.SelectObject(&BrushRed);
// Convert the current coordinates from Screen to Client
ScreenToClient(&RectColorChanger);
// Change the background of the control
dc.Rectangle(RectColorChanger);
// Restore the old brush
dc.SelectObject(pOldBrush);
if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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();
}
}
This code is supposed to paint the whole background of the picture control with color red and it works - only if the type of the picture control is set to frame. Well, if I set the type to frame, then I can't load the JPEG or BMP files onto the picture control anymore. On the other hand, if I change the type of picture control into bitmap, then the picture loads properly - only that I will not be able to use device context to create any rectangles or circles.
Does anyone have bright ideas to overcome this problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|