Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bitmap problem

Status
Not open for further replies.

problematik

Programmer
Mar 23, 2004
2
DE
Hi,

Please help, what am I doing wrong. I want to display .bmp file on screen. I made somwere mistake and now I do not get even initialization of window.
I have this code and I expect to change color of window but?????
BOOL CEdgeDetectionDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

m_picture.Create(this,IDC_PICTURE);
return TRUE; // return TRUE unless you set the focus to a control
}

and Create finction look like this:
void CPicture::Create(CWnd * parent, int nResourceID)
{
m_pWndParent = parent;
m_pWndView = m_pWndParent->GetDlgItem(nResourceID);

m_pWndView->GetClientRect(&m_rect);

CClientDC DC(m_pWndView);
// DC.TextOut(0,0,"HELLO",5);

m_memDC.CreateCompatibleDC(&DC);
m_vwnd.CreateCompatibleBitmap(&DC,GetWidth(),GetHeight());
m_memDC.SelectObject(&m_vwnd);

m_brush.CreateStockObject(WHITE_BRUSH);

m_memDC.SelectStockObject(WHITE_PEN);
m_memDC.SelectObject(&m_brush);


CFont font;
font.CreatePointFont(80,"font",&DC);
m_memDC.SelectObject(&font);

m_memDC.PatBlt(0,0,GetWidth(),GetHeight(),PATCOPY);

m_memDC.SetBkMode(TRANSPARENT);
m_memDC.SetTextColor(RGB(0,0,255));
}


Thx.
 
Try putting your Blt code in "OnPaint". If it does not work, see if the dialog is OWNER_DRAW. Not sure if that is required or not. If the OnPaint does not work, repost.

Matt
 
First you need to create memeory dc using current machine's DC which you can get from OnPaint() input parameter. Second,you need draw the contents from your memDC to current machine's dc. It should be ok then.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top