幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2692|回复: 3

[通用编程] 一个Web游戏的超初级wg

[复制链接]

136

主题

1751

帖子

548

积分

版主

Rank: 7Rank: 7Rank: 7

积分
548
发表于 2009-5-10 14:02:17 | 显示全部楼层 |阅读模式
只做到获取两个参数,就发现写不下去了。好像dwin库中的IE OLE部分还不支持childNodes,找不到没有id,name的组件。
  1. import dwin.sys.win32.ie.IE;
  2. import dfl.all;
  3. import Integer = tango.text.convert.Integer;
  4. pragma(lib, "dwin.lib");
  5. pragma(lib, "pcre.lib");
  6. pragma(lib, "dfl.lib");
  7. pragma(lib, "uuid.lib");
  8. char[] to(uint u)
  9. {
  10.     return Integer.format(new char[32], u);
  11. }
  12. uint to(char[] c)
  13. {
  14.     return Integer.atoi(c);
  15. }
  16. class MyIE : Form
  17. {
  18.     IWebBrowser2 ie;
  19.     Button OBtn;
  20.     Button CBtn;
  21.     ComboBox ServerListBox;
  22.     Button TBtn;
  23.     this()
  24.     {
  25.         this.text = "牧场OnWeb控制台";
  26.         this.clientSize = Size(400,225);
  27.         this.startPosition = FormStartPosition.CENTER_SCREEN;
  28.         this.maximizeBox = false;
  29.         ServerListBox = new ComboBox();
  30.         ServerListBox.bounds = Rect(0,0,80,18);
  31.         ServerListBox.items.add("稻香");
  32.         ServerListBox.items.add("麦浪");
  33.         ServerListBox.items.add("桃源");
  34.         ServerListBox.items.add("爱情");
  35.         ServerListBox.text = "爱情";
  36.         ServerListBox.parent = this;
  37.         OBtn = new Button();
  38.         OBtn.text = "打开IE";
  39.         OBtn.bounds = Rect(82,0,80,18);
  40.         OBtn.parent = this;
  41.         OBtn.click ~= &this.createIE;
  42.         CBtn = new Button();
  43.         CBtn.text = "关闭IE";
  44.         CBtn.bounds = Rect(164,0,80,18);
  45.         CBtn.parent = this;
  46.         CBtn.click ~= &this.closeIE;
  47.         TBtn = new Button();
  48.         TBtn.text = "测试";
  49.         TBtn.bounds = Rect(246,0,80,18);
  50.         TBtn.parent = this;
  51.         TBtn.click ~= &this.test;
  52.     }
  53.     private void createIE(Object o, EventArgs e)
  54.     {
  55.         switch(ServerListBox.text)
  56.         {
  57.             case "稻香":
  58.                 ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=1");
  59.                 break;
  60.             case "麦浪":
  61.                 ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=2");
  62.                 break;
  63.             case "桃源":
  64.                 ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=3");
  65.                 break;
  66.             case "爱情":
  67.                 ie = ieCreate(null, "Width",1020, "Height",780,"Navigate", "http://web.iyoyo.com.cn/Account/LoginServer.aspx?SiteID=1&GameID=9&ServerID=4");
  68.                 break;
  69.             default:
  70.                 msgBox("没指定现有的服务器!");
  71.         }
  72.     }
  73.     private void closeIE(Object o, EventArgs e)
  74.     {
  75.         ie.Quit();
  76.     }
  77.     private void test(Object o, EventArgs e)
  78.     {
  79.         if(ie is null)
  80.         {
  81.             msgBox("没有打开网页");
  82.         }
  83.         else
  84.         {
  85.             msgBox(to(getMoney(ie)));
  86.             msgBox(to(getPower(ie)));
  87.         }
  88.     }
  89.     private uint getMoney(IWebBrowser2 i)
  90.     {
  91.         auto money = getElementById(i, "tipMoney");
  92.         return to(getInnerText(money));
  93.     }
  94.     private uint getPower(IWebBrowser2 i)
  95.     {
  96.         auto power = getElementById(i, "main");
  97.         return to(getInnerText(power));
  98.     }
  99. }
  100. void main()
  101. {
  102.     int result = 0;
  103.     try
  104.     {
  105.         Application.enableVisualStyles();
  106.         Application.run(new MyIE());
  107.     }
  108.     catch(Object o)
  109.     {
  110.         msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
  111.         
  112.         result = 1;
  113.     }
  114.    
  115.     return result;
  116. }
复制代码
え~え~お!!!
回复

使用道具 举报

86

主题

250

帖子

390

积分

版主

Rank: 7Rank: 7Rank: 7

积分
390
发表于 2009-5-10 14:37:49 | 显示全部楼层
朋友每月花15元去买 逐鹿天下 那个webgame的WG,真不知道他怎么想的。

我是理解不了花钱买WG的乐趣了。
回复 支持 反对

使用道具 举报

136

主题

1751

帖子

548

积分

版主

Rank: 7Rank: 7Rank: 7

积分
548
 楼主| 发表于 2009-5-10 14:45:00 | 显示全部楼层
引用第1楼貘良了于2009-05-10 14:37发表的  :
朋友每月花15元去买 逐鹿天下 那个webgame的WG,真不知道他怎么想的。

我是理解不了花钱买WG的乐趣了。

人和人不一样,各取所需吧。
え~え~お!!!
回复 支持 反对

使用道具 举报

136

主题

1751

帖子

548

积分

版主

Rank: 7Rank: 7Rank: 7

积分
548
 楼主| 发表于 2009-5-10 14:47:15 | 显示全部楼层
又看了下,原来dwin中还有com,再来试试看这个东西能不能有完整功能。
え~え~お!!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-3-29 00:39 , Processed in 0.024256 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表