vc常用知识点归类
来源:互联网 发布:淘宝网做兼职 编辑:程序博客网 时间:2024/05/17 23:15
1、模式对话框如何最大化?
答:在对话框的OnInitDialog里面调用:
ShowWindow(SW_MAXIMIZE);//最大化
MSDN:
OnInitDialog, OnOK, and OnCancel are virtual functions. To override them, you declare an overriding function in your derived dialog class using the Properties window.
Member function
Message it responds to
Purpose of the override
OnInitDialog
WM_INITDIALOG
Initialize the dialog box's controls.
2、如何设置static字体大小?
答:在OnInitDialog里,先CreateFont,再SetFont:
BOOL CLoginDlg::OnInitDialog(){CDialog::OnInitDialog();// TODO: Add extra initialization hereCFont font;font.CreateFont(24, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, _T( "宋体 "));//24为字体大小GetDlgItem(IDC_STATIC_NAME)->SetFont(&font);GetDlgItem(IDC_STATIC_SEX)->SetFont(&font);GetDlgItem(IDC_STATIC_GROUP)->SetFont(&font);return TRUE; // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE}
修正:上述是有问题的,刷新屏幕一次,则字体回到默认,原因就在于字体变量font应该定义为全局变量或者成员变量。
3、如何设置Tab顺序?
答:在对话框上Ctrl键+D
4、如何删除一个消息定义函数?
答:
首先,在头文件中删除消息函数定义
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
其次,在源文件中删除消息函数响应
BOOL CMatchDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return CDialog::OnEraseBkgnd(pDC);
}
最后,在BEGIN_MESSAGE_MAP和END_MESSAGE_MAP中删除消息响应宏:
ON_WM_ERASEBKGND()
5、 对话框背景图片如何自适应对话框大小?就是说,对话框变大时,图片自动放大;对话框变小时,图片自动缩小。
答:用StretchBlt函数
Msdn上的StretchBlt解释:
Copies a bitmap from a source rectangle into a destination rectangle, stretching or compressing the bitmap if necessary to fit the dimensions of the destination rectangle.(拉伸或压缩图片以适应目标矩形尺寸的大小)
在OnEraseBkgnd函数中调用StretchBlt函数。
6、求立方根
float x;x=10.1;long y;y=3;long z;z=x*y;float m=pow(z,1.0/3.0); //pow函数的第一个参数必须为long或int型,float型编译出错
//pow函数的第一个参数必须为long或int型,float型编译出错
1>d:\backup\我的文档\visual studio 2008\projects\hjh\hjh\hjhdlg.cpp(163) : error C2666: 'pow' : 6 overloads have similar conversions
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(573): or 'long double pow(long double,long double)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(525): or 'float pow(float,float)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(123): or 'double pow(double,double)'
why???
另外,第二个参数还必须写为小数点的形式,否则也提示出错:
1>d:\backup\我的文档\visual studio 2008\projects\hjh\hjh\hjhdlg.cpp(163) : error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or 'double pow(double,int)'
1> while trying to match the argument list '(long, int)'
另外,第二个参数必须大于O,否则计算结果为-1.#IND00
- vc常用知识点归类
- Android自定义ViewGroup常用知识点归类
- 常用VC++知识点
- Javascript常用脚本归类
- VC常用知识点集锦(更新中...)
- oracle常用函数归类总结
- string常用方法归类整理
- android 常用控件归类(二)
- 归类
- 对BigDecimal常用方法的归类
- 对BigDecimal常用方法的归类
- 对BigDecimal常用方法的归类
- 对BigDecimal常用方法的归类(转)
- Java对BigDecimal常用方法的归类
- 对BigDecimal常用方法的归类
- 对BigDecimal常用方法的归类
- Jquery 操作iframe的常用方法归类
- 对BigDecimal常用方法的归类
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead. Please use Android Tools
- 点击run.bat jboss启动时 窗口一闪而过
- C++标准库中函数对应头文件及头文件的说明
- C#基础知识回顾
- 博客用户名终于激活了,真不容易啊
- vc常用知识点归类
- C++编程中的头文件包含问题
- JAVA虚拟机工作原理
- java数组的合并实例总结
- C/C++字节对齐问题
- .Net:再现List<T>:相关方法使用
- 深入浅出VC++动态链接库
- VS2010 VisualAssistX破解
- 总结几种C#窗体间通讯的处理方法