XiaoHui.net 笑汇程序员论坛首页
工作并快乐着,职业并休闲着
寻梦的岁月从不言辛苦几许,
不问收获几多……
» 游客:  申请新用户 | 登录 | 会员 | 统计 | 帮助 » XiaoHui.Net 笑汇程序员论坛 | 纯文字版 | 全站索引 | XiaoHui.com


[其他] 一个WIN32 SDK编程的问题

RSS 订阅当前论坛  

上一主题 下一主题
     

标题: [其他] 一个WIN32 SDK编程的问题  
 
dr33
小水手
Rank: 1



UID 8522
精华 0
积分 20
帖子 20
阅读权限 10
注册 2001-9-6
状态 离线
一个WIN32 SDK编程的问题

Charles Petzold 在其 Programming Windows一书第三章Queued and Nonqueued Messages一节中写道:

QUOTE:
the window procedure could call a function that sends the window procedure another message, in which case the window procedure must finish processing the second message before the function call returns, at which time the window procedure proceeds with the original message. For example, when a window procedure calls UpdateWindow, Windows calls the window procedure with a WM_PAINT message. When the window procedure finishes processing the WM_PAINT message, the UpdateWindow call will return controls back to the window procedure.
于是我做了一个小试验,代码如下:

               static char i[2] = {'0','\0'};
                case WM_PAINT:
                        hdc = BeginPaint(hWnd, &ps);
                        // TODO: Add any drawing code here...
                        RECT rt;
                       
                        GetClientRect(hWnd, &rt);
                        DrawText(hdc, "start", 5, &rt, DT_CENTER);
                        EndPaint(hWnd, &ps);
                        SendMessage(hWnd, WM_PAINT,0 ,0);
                        MessageBox(hWnd,i,"paint",0);
                        DrawText(hdc, "end", 3, &rt, DT_CENTER);
                        EndPaint(hWnd, &ps);
                       
                        i[0] = i[0]+1;
                        break;
按照上面文章的说法,我应该看不到任何MessageBox()起作用才对啊..
我理解错了吗?望各位高人指教.



[ 本帖最后由 dr33 于 2006-8-20 02:21 编辑 ]
2006-8-20 02:20#1
查看资料  Blog  发短消息  顶部
 
真忍血虾
小水手
Rank: 1


UID 22877
精华 0
积分 2
帖子 2
阅读权限 10
注册 2006-8-28
状态 离线
老大,问问题就别拽英语了,倒霉的是你
2006-8-28 19:09#2
查看资料  Blog  发短消息  顶部
 
麦斯
版主
Rank: 7Rank: 7Rank: 7



UID 1285
精华 0
积分 1678
帖子 1678
阅读权限 100
注册 2002-4-24
状态 离线
这么写运行起来就是栈溢出了,你理解应该没问题。
2006-9-6 13:48#3
查看资料  Blog  发短消息  顶部
 
orchead
小水手
Rank: 1



UID 23996
精华 0
积分 4
帖子 4
阅读权限 10
注册 2006-10-11
状态 离线
对消息循环没有理解
实际上是根据消息队列来选择执行的代码片段
SendMessage();只能让执行完当前队列中对应的那些代码片断才执行WM_PAINT对应的代码片断
你可以参照CPU的分时系统理解
不同的是分时系统以时间片来控制代码片断的执行
消息循环是代码片断执行完后再葱消息队列中选择(注意是执行完后再选择)
2006-10-11 12:56#4
查看资料  Blog  发短消息  QQ  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题  


 


所有时间为 GMT+8, 现在时间是 2008-12-3 04:53 Powered by Discuz! 4.1.0 清除 Cookies - XiaoHui.Net 笑汇程序员论坛 - Archiver