各位高手请帮忙,我new 了一个新工程项目,然后添加dialog资源 ID=ID_DIALOG_BAR,我在MainFrm.h定义一个CDialogBar的变量,m_ControlBar,然后在MainFrm.cpp create,然后,这个dialog就会显示在主界面中,我想问的是,如何更改dialog(ID_DIALOG_BAR)的背景色和如何把它的背景设为一个图片,请帮忙。谢谢。
解决方案 »
- tcp 中seq 和 ack 的问题
- 为什么FindWindow找不到已知标题栏的窗口,此窗口在任务管理器的应用程序里看不到,但在进程里有程序名。好像此窗口是应用程序起的一个对
- 请教:指针作为影射表的关键字时怎么用
- 100分,旋转问题,感兴趣的来看看,蛮有意思的!
- vc++运行win32 console程序出错!
- 熟悉音频压缩的看过来
- 谁有网络通信的源程序?或讲解原理,制作手段,又说推荐站点!
- 请问一个新加入的类如何让它在classward中可视
- vc画一个简单三维的抛物曲线
- 怎样设定新坐标系支持gluLookAt?
- 难度系数10.0,很有挑战性,有关动态执行Click事件的问题!!!!!!!!
- 菜鸟的一个文件保存的问题
http://www.codeguru.com/dialog/IrrBmpDlg.html
http://www.codeguru.com/dialog/dlg_back_text_color.shtml
BOOL CControlButton::OnInitDialog()
{
/* CButton *MyButton;
HBITMAP Bitmap;
Bitmap=::LoadBitmap(AfxGetResourceHandle(),MAKEINTRESOURCE(IDB_BITMAP2));
MyButton=(CButton*)GetDlgItem(IDC_BUTTON1);
MyButton->SetBitmap(Bitmap);*/ CDialog::OnInitDialog();
m_brushBackground.CreateSolidBrush(RGB(255, 255, 255)); // TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
另一个函数:HBRUSH CControlButton::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
//HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return m_brushBackground;
}
结果没什么反映,为什么?
{
CRect rect;
GetWindowRect( &rect );
CDC *pMem;
CBitmap *m_OldBitmap;
CBitmap mShowbit; pMem = new CDC(); if( str_Back.IsEmpty() )
mShowbit.LoadBitmap( IDB_BACK );
else{
HBITMAP bitmap;
mShowbit.Detach();
bitmap = (HBITMAP)::LoadImage( NULL , str_Back , IMAGE_BITMAP , 0 , 0 , LR_CREATEDIBSECTION|LR_LOADFROMFILE|LR_DEFAULTSIZE );
mShowbit.Attach(bitmap);
} pMem->CreateCompatibleDC( pDC );
m_OldBitmap=pMem->SelectObject( &mShowbit );
pDC->BitBlt( 0 , 0 , rect.Width() , rect.Height() , pMem , 0 , 0 , SRCCOPY );
pMem->SelectObject( m_OldBitmap ); return true;
}