problematik
Programmer
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.
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.