📄 c语言嵌入式系统编程修炼之屏幕操作-开发频道-c-天极网3.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0038)http://dev.yesky.com/9/2018509_2.shtml -->
<HTML lang=zh-CN xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网</TITLE>
<META
content="C语言嵌入式系统编程修炼之屏幕操作,开发者网络瞄准中国程序员群体,涵盖软件开发的各个技术层面,从Windows下的应用程序开发,到Java、Web开发、游戏开发和移动开发领域,均有相关教程和实例、技巧。 "
name=description>
<META content=C语言嵌入式系统编程修炼之屏幕操作,软件开发,嵌入式开发,java开发工具,驱动开发,软件工程,IBM,微软,数据库
name=keywords>
<META content="天极网 | 全球中文IT第一门户" name=author>
<META content="天极网 | 全球中文IT第一门户" name=Copyright>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META http-equiv=Content-Language content=zh-CN><LINK media=all
href="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/y_mobile_content.css" type=text/css
rel=stylesheet>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/showlay.js"></SCRIPT>
<META content="MSHTML 6.00.2900.3314" name=GENERATOR></HEAD>
<BODY><!--页面头部--><!--头部-->
<DIV>
<SCRIPT
src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/kingsoft-kuanban-071105.js"></SCRIPT>
</DIV>
<DIV id=topmenu><A href="http://www.yesky.com/">Yesky首页</A>| <A
href="http://product.yesky.com/">产品报价</A>| <A
href="http://cseek.yesky.com/">行情</A>| <A href="http://mobile.yesky.com/">手机</A>
| <A href="http://digital.yesky.com/">数码</A> | <A
href="http://notebook.yesky.com/">笔记本</A> | <A
href="http://pc.yesky.com/">台式机</A> | <A href="http://diy.yesky.com/">DIY硬件</A>
| <A href="http://oa.yesky.com/">外设</A> | <A href="http://net.yesky.com/">网络</A>
| <A href="http://dh.yesky.com/">数字家庭</A> | <A
href="http://lab.yesky.com/">评测</A> | <A href="http://soft.yesky.com/">软件</A> |
<A href="http://fashion.yesky.com/">e时代</A> | <A
href="http://game.yesky.com/">游戏</A> | <A href="http://pic.yesky.com/">图片</A> |
<A href="http://desktop.yesky.com/">壁纸</A> | <A
href="http://q.yesky.com/">群乐</A> | <A href="http://my.yesky.com/">社区</A> | <A
href="http://blog.yesky.com/">博客</A> | <A
href="http://www.mydown.com/">下载</A></DIV>
<DIV id=topbox>
<DIV class=tleft><A id=pagelogo href="http://www.yesky.com/"><IMG
alt=天极Yesky_全球中文IT第一门户 src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/logo.gif"
border=0></A></DIV>
<DIV class=tad><SPAN id=ad1></SPAN></DIV>
<DIV id=search>
<DIV>
<FORM name=searchform action=http://search.chinabyte.com/search method=get
target=_blank><INPUT id=searchzz onmouseover=this.focus() onfocus=this.select()
name=q><INPUT type=hidden value=GB2312 name=encoding><INPUT type=hidden
value=connect name=dir><INPUT type=hidden value=20002 name=cid><INPUT id=search_btn type=submit value=天极搜索> </FORM></DIV>
<DIV class=tdq>
<DIV class=rightarea><A href="http://bj.yesky.com/">北京</A> <A
href="http://hd.yesky.com/">上海</A> <A href="http://gd.yesky.com/">广州</A> <A
href="http://sz.yesky.com/">深圳</A><BR><A href="http://cd.yesky.com/">成都</A> <A
href="http://cq.yesky.com/">重庆</A> <A href="http://sy.yesky.com/">沈阳</A> <A
href="http://xa.yesky.com/">西安</A> </DIV>
<DIV class=rightarea_right><A
href="http://my.yesky.com/">用户<BR>登录</A></DIV></DIV></DIV>
<DIV class=tright>
<DIV class=box1>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/content_text_ad.js"
type=text/javascript></SCRIPT>
</DIV></DIV></DIV>
<SCRIPT src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/flash.js"
type=text/javascript></SCRIPT>
<DIV id=childmenu twffan="done"><A href="http://soft.yesky.com/"
target=_self>软件频道></A><A href="http://dev.yesky.com/"
target=_self>程序开发></A><A href="http://dev.yesky.com/devjava/"
target=_self>Java</A><A href="http://dev.yesky.com/ysdevvb"
target=_self>VB</A><A href="http://dev.yesky.com/ysdevvc" target=_self>VC</A><A
href="http://dev.yesky.com/ysdevdelphi" target=_self>Delphi</A><A
href="http://dev.yesky.com/ysdevc" target=_self>C/C++</A><A
href="http://dev.yesky.com/web/" target=_self>Web开发</A><A
href="http://dev.yesky.com/msdn/" target=_self>微软专栏</A><A
href="http://dev.yesky.com/devydkf/" target=_self>移动</A><A
href="http://dev.yesky.com/devsjk/" target=_self>数据库</A><A
href="http://dev.yesky.com/ysdevcxrs" target=_self>程序人生</A><A
href="http://dev.yesky.com/ysdevrjgc" target=_self>软件工程</A>|<A
href="http://soft.yesky.com/lesson/" target=_self>产品中心</A><A
href="http://www.mydown.com/soft/develop/news.shtml" target=_self>下载</A><A
href="http://www.ibm.com/developerworks/cn/rational/rationaledge/content/mar06/eeles/?S_TACT=105AGX52&S_CMP=top-yesky">什么是软件架构</A></DIV><!--导航条-->
<DIV id=location>
<DIV class=loleft>您现在的位置: <A href="http://www.yesky.com/" target=_self>天极网</A>
> <A href="http://dev.yesky.com/" target=_self>开发频道</A> >
C语言嵌入式系统编程修炼之屏幕操作</DIV>
<DIV class=adright><SPAN id=ad2></SPAN></DIV></DIV><!--内容块开始-->
<DIV id=conbox><!--左边开始-->
<DIV id=conleft>
<DIV id=contopla1>
<DIV id=__001>
<DIV class=qkong></DIV>
<DIV class=qw1>全文</DIV>
<DIV class=zkong>
<DIV class=kl></DIV>
<DIV class=bj><A href="http://dev.yesky.com/9/2018509_2.shtml#pls"
target=_self>评论</A></DIV>
<DIV class=kr></DIV><!-- Error -->
<SCRIPT type=text/javascript>
var titiepic ="#";
if (titiepic!="#")
{
document.write("<div class=\"kl\"></div><div class=\"bj\"><a href=\"#\" target=\"_blank\">图片</a></div><div class=\"kr\"></div>");
}
</SCRIPT>
<!-- Error --></DIV></DIV></DIV>
<DIV class=topadbg style="PADDING-BOTTOM: 5px"><SPAN id=ad10></SPAN></DIV><A
name=top></A>
<DIV id=contitle>
<H1>C语言嵌入式系统编程修炼之屏幕操作</H1></DIV>
<DIV id=conauthor><SPAN>2005-06-20 15:54 </SPAN><SPAN>作者: 宋宝华 </SPAN><SPAN>出处:
天极网 </SPAN><SPAN>责任编辑:<A title=向本编辑提问
href="http://comments.yesky.com/t/·½ÖÛ/6,324/2018509.shtml" target=_blank>方舟</A>
</SPAN></DIV>
<DIV class=topadbg><SPAN id=ad9></SPAN></DIV>
<DIV id=conneirong><SPAN id=ad3></SPAN>
<DIV class=guanggao><SPAN
id=contentAdv></SPAN></DIV> <B>模拟MessageBox函数</B><BR><BR> MessageBox函数,这个Windows编程中的超级猛料,不知道是多少入门者第一次用到的函数。还记得我们第一次在Windows中利用MessageBox输出
"Hello,World!"对话框时新奇的感觉吗?无法统计,这个世界上究竟有多少程序员学习Windows编程是从MessageBox("Hello,World!",…)开始的。在我本科的学校,广泛流传着一个词汇,叫做"’Hello,World’级程序员",意指入门级程序员,但似乎"’Hello,World’级"这个说法更搞笑而形象。<BR><BR>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR>
<TD>
<DIV align=center><IMG
src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/t1c4y2ay6189.jpg"
border=0> <IMG
src="C语言嵌入式系统编程修炼之屏幕操作-开发频道-C-天极网3.files/i7t6qm8ztsz2.jpg" border=0><BR>图2
经典的Hello,World!</DIV></TD></TR></TBODY></TABLE><BR> 图2给出了两种永恒经典的Hello,World对话框,一种只具有"确定",一种则包含"确定"、"取消"。是的,MessageBox的确有,而且也应该有两类!这完全是由特定的应用需求决定的。<BR><BR> 嵌入式系统中没有给我们提供MessageBox,但是鉴于其功能强大,我们需要模拟之,一个模拟的MessageBox函数为:<BR><BR>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf border=1>
<TBODY>
<TR>
<TD>/******************************************<BR>/* 函数名称:
MessageBox<BR>/* 功能说明: 弹出式对话框,显示提醒用户的信息<BR>/* 参数说明: lpStr ---
提醒用户的字符串输出信息<BR>/* TYPE --- 输出格式(ID_OK = 0, ID_OKCANCEL = 1)<BR>/* 返回值:
返回对话框接收的键值,只有两种 KEY_OK,
KEY_CANCEL<BR>/******************************************<BR>typedef enum
TYPE { ID_OK,ID_OKCANCEL }MSG_TYPE;<BR>extern BYTE MessageBox(LPBYTE
lpStr, BYTE TYPE)<BR>{<BR> BYTE keyValue = -1;<BR><BR> ClearScreen(); /*
清除屏幕 */<BR> DisplayString(xPos,yPos,lpStr,TRUE); /* 显示字符串 */<BR> /*
根据对话框类型决定是否显示确定、取消 */<BR> switch (TYPE)<BR> {<BR> case
ID_OK:<BR> DisplayString(13,yPos+High+1, " 确定 ",
0);<BR> break;<BR> case ID_OKCANCEL:<BR> DisplayString(8,
yPos+High+1, " 确定 ", 0);<BR> DisplayString(17,yPos+High+1, " 取消 ",
0);<BR> break;<BR> default:<BR> break;<BR> }<BR> DrawRect(0, 0, 239,
yPos+High+16+4); /* 绘制外框 */<BR> /* MessageBox是模式对话框,阻塞运行,等待按键
*/<BR> while( (keyValue != KEY_OK) || (keyValue != KEY_CANCEL)
)<BR> {<BR> keyValue = getSysKey();<BR> }<BR> /* 返回按键类型
*/<BR> if(keyValue== KEY_OK)<BR> {<BR> return
ID_OK;<BR> }<BR> else<BR> {<BR> return
ID_CANCEL;<BR> }<BR>}</TD></TR></TBODY></TABLE><BR> 上述函数与我们平素在VC++等中使用的MessageBox是何等的神似啊?实现这个函数,你会看到它在嵌入式系统中的妙用是无穷的。<BR><BR> <B>总结</B><BR><BR> 本篇是本系列文章中技巧性最深的一篇,它提供了嵌入式系统屏幕显示方面一些很巧妙的处理方法,灵活使用它们,我们将不再被LCD上凌乱不堪的显示内容所困扰。<BR><BR> 屏幕乃嵌入式系统生存之重要辅助,面目可憎之显示将另用户逃之夭夭。屏幕编程若处理不好,将是软件中最不系统、最混乱的部分,笔者曾深受其害。
<DIV class=right>共3页。 <A class=page href="http://dev.yesky.com/9/2018509.shtml"
target=_self><FONT face=Webdings>9</FONT></A> <A class=page
href="http://dev.yesky.com/9/2018509_1.shtml" target=_self><FONT
face=Webdings>7</FONT></A> <A class=page
href="http://dev.yesky.com/9/2018509.shtml" target=_self><B>1</B></A> <A
class=page href="http://dev.yesky.com/9/2018509_1.shtml"
target=_self><B>2</B></A> <A class=page
href="http://dev.yesky.com/9/2018509_2.shtml" target=_self><FONT
color=#666666><B>3</B></FONT></A></DIV></DIV><!--广告代码开始-->
<SCRIPT>
var ad_cid;
if (window.location.search.substring(1) != "")
{
ad_cid = window.location.search.substring(1);
} else {
ad_cid = 412;
}
</SCRIPT>
<!--小通栏:c-scolumn顶部500*90--><SPAN id=span_ad1>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-scolumn.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
document.getElementById("ad1").innerHTML=document.getElementById("span_ad1").innerHTML;
document.getElementById("span_ad1").innerHTML="";
</SCRIPT>
<!--c-pip文章正文中间240*200--><SPAN id=span_ad3>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-pip.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT>
if(document.getElementById("contentAdv")) {
document.getElementById("contentAdv").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
} else {
document.getElementById("ad3").innerHTML=document.getElementById("span_ad3").innerHTML;
document.getElementById("span_ad3").innerHTML="";
}</SCRIPT>
<!--c-text-1“您现在的位置”右侧文字--><SPAN id=span_ad2>
<SCRIPT language=JavaScript>
document.write("<script src=\"http://vd.yesky.com/html/"+ad_cid+"/"+ad_cid+"_c-text-1.js\"><\/script>");</SCRIPT>
</SPAN>
<SCRIPT language=JavaScript>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -