//========================================================================
//title:
// evc编程经验点滴(二)
//author:
// norains
//date:
// monday 23-october-2006
//========================================================================
1.在对话框中标题栏添加ok按钮
如果是是新建对话框的话,往往标题栏没有"ok"按键,并且在evc中也没有相关的设置选项.如果需要在标题栏中显示"ok",可以用文本文件打开资源文件.rc,然后在style下添加代码行:exstyle ws_ex_appwindow | 0x80000000l
依我的理解,后面的0x80000000l应该是在模式对话框中按下"ok"键返回的消息.在这里,0x80000000l是用evc创建程序时默认有ok键的对话框里的模板文件中的值
2.一段将某个文件夹中的文件和文件夹添加到列表控件的代码
tchar szaddstring[max_path_length];
win32_find_data fd;
handle hfind;
hfind=findfirstfile(szfinddir,&fd);
if(hfind!=invalid_handle_value)
{
do{
if(fd.dwfileattributes==file_attribute_directory)
{
//it must be directory
postmessage(hlist,lb_addstring,0,(lparam)(lpctstr)fd.cfilename);
}
else
{
//it is file
postmessage(hlist,lb_addstring,0,(lparam)(lpctstr)fd.cfilename);
}
}while(findnextfile(hfind,&fd));
}
3.list control的bug
如果list control的style中的view选择的是small icon,并且align选择的是top,那么这里将会出现一个小bug,就是我们看不到垂直的滚动条.这个是evc的bug,可以用文本编辑器打开.rc文件,在list控件的属性加上lvs_aligntop即可.
4.笔针调整的shell
直接调用touchcalibrate()函数即可
5.读取文件时容易犯的一个小问题
在下面这段代码里,tchar szbuf[2] 需要初始化为0,否则字符串将显示不出.这是因为读取的文件流中,即使读到文件的最后,也不会有字符串结束符\0.
//get the old back light level from the file
handle hfile = createfile(save_file,
generic_read,
file_share_read,
null,
open_existing,
file_attribute_normal,
null
);
if(hfile==invalid_handle_value )
{
g_ibklevel=default_backlight_level;
}
else
{
tchar szbuf[2]={0}; //这里要全部初始化为0
dword dwread;
bool bres = readfile(hfile,
szbuf,
1,
&dwread,
null
);
if(bres = false)
{
g_ibklevel=default_backlight_level;
}
else
{
g_ibklevel=_wtoi(szbuf);
}
closehandle(hfile);
}
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


