菜鸟用MFC,问界面问题。。。 如何在一个Cview 中添加一个背景图片网上什么地方有例程??? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CMDIClientWnd::CMDIClientWnd(){ m_bitmap.LoadBitmap(IDB_SERVER_MAINBIT); m_bitmap.GetObject(sizeof(BITMAP),&m_bmp);}CMDIClientWnd::~CMDIClientWnd(){}BEGIN_MESSAGE_MAP(CMDIClientWnd, CWnd) //{{AFX_MSG_MAP(CMDIClientWnd) ON_WM_PAINT() //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CMDIClientWnd message handlersvoid CMDIClientWnd::OnPaint() { CPaintDC dc(this); // device context for painting CDC dcMem; dcMem.CreateCompatibleDC(&dc); dcMem.SelectObject(m_bitmap); CRect rect; GetClientRect(&rect); int nWidth=rect.Width(); int nHeight=rect.Height(); dc.BitBlt(0,0,nWidth,nHeight,&dcMem,rect.left,rect.top,SRCCOPY); // Do not call CWnd::OnPaint() for painting messages} Windows 向窗口发送一个WM_ERASEBKGND 消息通知该窗口擦除背景,可以使用ClassWizard 重载该消息的缺省处理程序来擦除背景(实际是画),并返回TRUE 以防止Windows擦除窗口。BOOL CSampleView : : OnEraseBkgnd (CDC* pDC){ CBrush Brush (RGB (128 , 0 , 128) ); // Create a pruple brush. // Select the brush into the device context . CBrush* pOldBrush = pDC—>SelcetObject (&brush); // Get the area that needs to be erased . CRect reClip ; pDC—>GetCilpBox (&rcClip); //Paint the area. pDC->PatBlt(rcClip.left,rcClip.top,rcClip.Width(),rcClip.Height(),PATCOPY); //Unselect brush out of device context . pDC—>SelectObject (pOldBrush ); // Return nonzero to half fruther processing . return TRUE;}上面的是改背景色,你用图片来创建一个画刷就是 操作剪切板进行进程通信时,传递英文字母时出现乱码! 关于使用CxImage类保存客户区绘图为jpg图像的问题。 这样的SQL语句怎么写 请问,当一个对话框之上运行一个模态对话框时,原对话框的定时器还在工作吗? 求助,该走什么方向? 请教高手,如何在视图中显示CButton?代码放在哪个函数中? 请教了,如何在基类中的回调函数中将消息发送给派生类? 初学vc,遇到一些问题想请教各位高手: 如何在turbo c 中嵌入汇编语句? 一个very easy 的 question! 50 谁有Windows网络编程技术源码 各位大侠,数据库编程奇怪问题高手请进
{
m_bitmap.LoadBitmap(IDB_SERVER_MAINBIT);
m_bitmap.GetObject(sizeof(BITMAP),&m_bmp);
}CMDIClientWnd::~CMDIClientWnd()
{
}
BEGIN_MESSAGE_MAP(CMDIClientWnd, CWnd)
//{{AFX_MSG_MAP(CMDIClientWnd)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMDIClientWnd message handlersvoid CMDIClientWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
dcMem.SelectObject(m_bitmap);
CRect rect;
GetClientRect(&rect);
int nWidth=rect.Width();
int nHeight=rect.Height();
dc.BitBlt(0,0,nWidth,nHeight,&dcMem,rect.left,rect.top,SRCCOPY);
// Do not call CWnd::OnPaint() for painting messages
}
BOOL CSampleView : : OnEraseBkgnd (CDC* pDC)
{
CBrush Brush (RGB (128 , 0 , 128) ); // Create a pruple brush.
// Select the brush into the device context .
CBrush* pOldBrush = pDC—>SelcetObject (&brush);
// Get the area that needs to be erased .
CRect reClip ;
pDC—>GetCilpBox (&rcClip);
//Paint the area.
pDC->PatBlt(rcClip.left,rcClip.top,rcClip.Width(),rcClip.Height(),PATCOPY);
//Unselect brush out of device context .
pDC—>SelectObject (pOldBrush );
// Return nonzero to half fruther processing .
return TRUE;
}上面的是改背景色,你用图片来创建一个画刷就是