免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3239 | 回复: 3
打印 上一主题 下一主题

如何获取WINDOWS 窗口句柄? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-05 11:43 |只看该作者 |倒序浏览
那位兄弟能给我推荐个模块,如果能给个例子就更好了,先谢谢!

论坛徽章:
0
2 [报告]
发表于 2008-06-05 12:03 |只看该作者

回复 #1 junchen2 的帖子

要写GUI,应该要用TK吧?

论坛徽章:
0
3 [报告]
发表于 2008-06-10 16:14 |只看该作者
你想做什么呢?下面的这个实例对于使用TK来说比较不错。
貌似你说清楚你要干什么比较方便大家一起分析。

  1. #!/usr/bin/perl -w
  2. # tksample3 - demonstrate dialog boxes

  3. use strict;  
  4. use Tk;
  5. use Tk::DialogBox;

  6. my $main = MainWindow->new( );

  7. my $dialog = $main->DialogBox( -title   => "Register",
  8.                             -buttons => [ "Register", "Cancel" ],
  9.                            );

  10. # the top part of the dialog box will let people enter their names,
  11. # with a Label as a prompt

  12. $dialog->add("Label", -text => "Name")->pack( );
  13. my $entry = $dialog->add("Entry", -width => 35)->pack( );

  14. # we bring up the dialog box with a button
  15. $main->Button( -text    => "Click Here For Registration Form",
  16.                -command => \&register)    ->pack(-side => "left");
  17. $main->Button( -text    => "Quit",
  18.                -command => sub { exit } ) ->pack(-side => "left");

  19. MainLoop;

  20. #
  21. # register
  22. #
  23. # Called to pop up the registration dialog box
  24. #

  25. sub register {
  26.     my $button;
  27.     my $done = 0;

  28.     do {   
  29.         # show the dialog
  30.         $button = $dialog->Show;

  31.         # act based on what button they pushed
  32.         if ($button eq "Register") {
  33.             my $name = $entry->get;

  34.             if (defined($name) && length($name)) {
  35.                 print "Welcome to the fold, $name\n";
  36.                 $done = 1;
  37.             } else {
  38.                 print "You didn't give me your name!\n";
  39.             }
  40.         } else {
  41.             print "Sorry you decided not to register.\n";
  42.             $done = 1;
  43.         }
  44.     } until $done;
  45. }
复制代码

[ 本帖最后由 不死草 于 2008-6-10 16:18 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2008-06-12 13:20 |只看该作者
多谢分享,现在研究研究
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP