2010年08月01日 vc基础(3)

工程:DailyHelper

1.       取得桌面大小(不包括任务栏)

RECT rc; 
SystemParametersInfo(SPI_GETWORKAREA, 0, (PVOID) &rc, 0);

2.       设置对话框背景颜色

定义成员变量CBrush m_brush;

OnInitDialog里面:m_brush.CreateSolidBrush(RGB(xx, yy, zz);

OnCtlColor里面:if(pWnd==this) { return m_brush; }        //注意上一步不能放到这里面,

                                                                                                                  //至于原因还未知

3.       使窗口置顶:SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

4.       关闭当前对话框:this->OnOK();

5.       创建一个非模态对话框:

  增加成员变量m_dlgHello;  一定要用成员变量,临时变量会被析构。当然,也可以用临时指针变量

  m_dlgHello.Create(IDD_DIALOG1, NULL);

  m_dlgHello.ShowWindow(SW_SHOWNORMAL);

 

其它:

1. 若:

char *str1 = "hello";

char str2[] = "world";

则:sizeof(str1)=4,sizeof(str2)=6; 看来笔试的时候全填错了,晕。。。

2. 对于一个Based on Dialog的VC project, 窗体的OnChar事件是捕捉不到的,要响应OnChar事件,则需要重写PreTranslateMessage函数. 对于PreTranslateMessage,一个按键事件会调用它两次(OnKeyUp一次,OnKeyDown)一次,为避免重复,可以

 if(pMsg->message==WM_KEYDOWN)

 {

...

 }

3. VC 支持多媒体:

#include <mmsystem.h>

#pragma comment(lib,"winmm.lib")

4. Consider  a call in C like 
    count = read(fd, buf, nbytes) ;
to make the call, the caller pushes the parameters onto the stack in order, last one first. The reason that C compilers push the parameters in reverse order has to do with printf-- by doing so, printf can always locate its first parameter, the format string.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值