如何在MFC中导入一张位图啊? 我刚学mfc,想导入一张图片但不知道怎么做,请教一下各位高手! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 技术内幕里面提供的那个dib类就可以搞定了! CBitmap::LoadBitmap( UINT nIDResource );搞定了三! 先打开Insert菜单中的Resource选项,选中Bitmap,点击右边的Import,弹出一个文件对话框,选择你想加入的位图文件,点击该文件对话框的Import,这时你在Resource View中的Bitmap中看见你加入的位图文件,选中对话框中picture控件,在属性中将Type改为Bitmap,在Image中选中刚刚加入的位图文件即可在类向导中添加WM_MOUSEMOVE消息函数,WM_MOUSEMOVE函数中可以返回鼠标的x,y坐标。或者参看我在视图文档中写的程序void CBresenham1View::OnLButtonDown(UINT nFlags, CPoint point) //写实现鼠标按下时的功能函数{ // TODO: Add your message handler code here and/or call default m_xold=point.x; //将当前点的x坐标赋给变量m_xold m_yold=point.y; //将当前点的y坐标赋给变量m_yold SetCapture(); //捕获鼠标 m_Dragging=1; //设置拖动开始 CView::OnLButtonDown(nFlags, point);}//////////////////////////////////////////////////////////////////////////////void CBresenham1View::OnMouseMove(UINT nFlags, CPoint point) //写鼠标拖动时的函数{ // TODO: Add your message handler code here and/or call default if(m_Dragging) //如果开始拖动 { ::SetCursor(m_HCross); //将鼠标变为十字形 } CView::OnMouseMove(nFlags, point);}///////////////////////////////////////////////////////////////////////////////void CBresenham1View::OnLButtonUp(UINT nFlags, CPoint point) //写鼠标放开时的函数{ // TODO: Add your message handler code here and/or call default if(m_Dragging) //如果拖动还在继续 { ::ReleaseCapture(); //捕获松开鼠标时的坐标 m_xnew=point.x; //将捕获点的x坐标赋给变量m_xnew m_ynew=point.y; //将捕获点的y坐标赋给变量m_ynew m_Dragging=0; //设置拖动结束 Line_Bres(m_xold,m_yold,m_xnew,m_ynew); //调用画图函数,画出直线 } CView::OnLButtonUp(nFlags, point);} 这是在对话框中添加消息函数后在一个edit中显示当前坐标的y坐标的一段代码void CAsdfDlg::OnMouseMove(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default m_edit=point.y; UpdateData(FALSE); CDialog::OnMouseMove(nFlags, point);} 谢谢wanneng882!不过有个小小的问题,你这个粘图、取坐标点是基于对话框的,但我们想用单文本框该怎么办呢,我不太清楚单文本框和对话框在功能上有什么区别?如果你愿意,能不能留一个qq啊,谢谢! 一阶偏导产生较宽边缘,二阶偏导产生较窄边缘?? 发个今天通过的面试题 关于文件夹的操作,题解结分.(高手进) 关于组合框的问题 在一个进程中定义数组,需要在另一个进程中进行数组中数据的访问,怎么办?谢谢各位!! CFile类 Copy.Open(__argv[0],CFile::modeRead)在WIN98下怎么老提示错误啊? 如何serialize 一个CListView? xtreme toolkitpro XTPSkinManager()->LoadSkin 出错 关于IP地址的问题。 网络编程:如何让服务器端支持多客户呀?谢谢! 给点意见 新手问题,关于动态改变视窗
搞定了三!
在Image中选中刚刚加入的位图文件即可
在类向导中添加WM_MOUSEMOVE消息函数,WM_MOUSEMOVE函数中可以返回鼠标的x,y坐标。
或者参看我在视图文档中写的程序
void CBresenham1View::OnLButtonDown(UINT nFlags, CPoint point) //写实现鼠标按下时的功能函数
{
// TODO: Add your message handler code here and/or call default
m_xold=point.x; //将当前点的x坐标赋给变量m_xold
m_yold=point.y; //将当前点的y坐标赋给变量m_yold
SetCapture(); //捕获鼠标
m_Dragging=1; //设置拖动开始
CView::OnLButtonDown(nFlags, point);
}
//////////////////////////////////////////////////////////////////////////////
void CBresenham1View::OnMouseMove(UINT nFlags, CPoint point) //写鼠标拖动时的函数
{
// TODO: Add your message handler code here and/or call default
if(m_Dragging) //如果开始拖动
{
::SetCursor(m_HCross); //将鼠标变为十字形
}
CView::OnMouseMove(nFlags, point);
}
///////////////////////////////////////////////////////////////////////////////
void CBresenham1View::OnLButtonUp(UINT nFlags, CPoint point) //写鼠标放开时的函数
{
// TODO: Add your message handler code here and/or call default
if(m_Dragging) //如果拖动还在继续
{
::ReleaseCapture(); //捕获松开鼠标时的坐标
m_xnew=point.x; //将捕获点的x坐标赋给变量m_xnew
m_ynew=point.y; //将捕获点的y坐标赋给变量m_ynew
m_Dragging=0; //设置拖动结束
Line_Bres(m_xold,m_yold,m_xnew,m_ynew); //调用画图函数,画出直线
}
CView::OnLButtonUp(nFlags, point);
}
{
// TODO: Add your message handler code here and/or call default
m_edit=point.y;
UpdateData(FALSE);
CDialog::OnMouseMove(nFlags, point);
}
如果你愿意,能不能留一个qq啊,谢谢!