Welcome![Sign In][Sign Up]
Location:
Search - Form1

Search list

[Windows DevelopForm1

Description: 电子秤采样源代码 电子秤采样源代码
Platform: | Size: 1676 | Author: 黄银 | Hits:

[Other resourceyuanwenjian

Description: Private Sub cancel_Click(Index As Integer) Unload form1 End Sub
Platform: | Size: 5621 | Author: scf | Hits:

[Other resourceForm1

Description: 用C#.NET做的一个小小记事本.功能做了大部分,还有一些细节没有处理.
Platform: | Size: 4457 | Author: 冬天的日子 | Hits:

[Other resourceForm1

Description: C++ for RS232(1) To read the port without using the tools
Platform: | Size: 5946 | Author: sunzhens | Hits:

[Other resourceForm1

Description: 曲线拟合小工具,包括对数拟合,多项式拟合,直线拟合,指数拟合,乘幂拟合
Platform: | Size: 4095 | Author: guhaipeng | Hits:

[Otherform1.frm

Description: 计算器小程序源代码,供学习。是论坛上的,我自己的不小心格式化了~~将后缀.zip改为.txt-small calculator program's source code for study. The forum is, I do not own a carefully formatted to ~ ~ suffix. Zip changed. Txt
Platform: | Size: 10370 | Author: 萧腾 | Hits:

[Other resource制作加密文本文件程序

Description: 制作加密文本文件程序1.原理从源文本文件中按顺序读出每一个字符,然后把读出的字符转换为相应的ASCII码,将此ASCII码加上整数密钥Key,最后把所得结果再转回相应的字符并同时把它写入到另外一个文件中,这就是加密过程。解密码过程与加密过程刚好是相反的操作。2.界面设计新建一个工程,在Form1中添加一个Label,一个Edit和两个Button,程序的界面设置与布局如图所示。图一 界面布局-encryption produced a text file procedures. Principle from the source text file sequentially read out each character and then read out the characters into the corresponding ASCII, ASCII with this integer key Key, the final results were then put back to the corresponding character and turn it into another one of the documents This is the encryption process. Xie password and encryption process is exactly the opposite of operation. 2. Interface design of a new project, Form1 add a Label, a Edit Button and the two procedures are set up and interface layout shown in the figure. A layout map interface
Platform: | Size: 1316 | Author: 万宏兴 | Hits:

[Printing programAClass2PrintRecordset

Description: 打印预览设计Few things to note.1. If you make rowheight too small the text will be printed in the cell one below that cell.2. If you want to print field names issue PrintFields method. This method should always be used before PrintOut method.3. Font is not handled in class. Therefore font must be set if youare not going to use the default one.4. For Column width and alignments see comments in ClassSetup moduleof form1.Although this class is free for all, if you use it in commercial ornon commercial software, a notification is appreciated.-design Few things to note.1. If you make rowheight too small the text will be printed in the cell below that cell.2 one. If you want to print field names issue PrintFields method. This method should always be used before PrintOut method.3. Font is not handled in class. Therefore font must be set if youare not going to use the default one.4. For Column width and alignments see comments in ClassSetup moduleof form1.Although this class is free for all, if you use it in commercial ornon commercial software, a notification is appreciated.
Platform: | Size: 29553 | Author: zz | Hits:

[OtherVB.net编程实例--抢答器的制作

Description: 1、新建一个项目,调整窗口的大小,修改form1属性窗口中的text属性为“抢答器” 2、在form1中添加一个按钮控件。名称分别为button1.button2.button3.并且分别将控件的test属性设置为“1号2号3号”。 3、在form1右侧添加textbox控件,名称为textbox1.将其text属性清空。 4、再次添加一个按钮控件,名称为button4 ,将其text属性设置为“复位”。 5、双击一号按钮,打开代码编辑窗口,添加按钮点击执行代码如图所示。-1, a new item, adjust the window size changes Form1 properties window of text attributes to "Responder" two in Form1 add a button control. Names were button1.button2.button3. Respectively, to control the test attribute set to "on the 1st on the 2nd on the 3rd." 3, in addition Form1 right textbox controls, to name textbox1. Its text attributes emptied. 4 again to add a button control, the name of Button4, its text attribute set to "reset." 5, click the button on the 1st, open source editor window, click the Add button code execution shown in the figure.
Platform: | Size: 590630 | Author: 沈嘉祺 | Hits:

[Other resource基本画线实现算法

Description: 新建一个C++Builder项目 设置Form1的font为“宋体,小五” 在Form1中添加一个TRadioGroup组件rgDrawWhat供选择画什么图形;添加一个Tbutton组件colorBtn和一个TcolorDialog组件ColorDialog1;添加一个TImage组件Image1。 3、 将当前项目保存在自己实验文件夹的exp1子文件夹中(以防错误操作而前功尽弃)。 编写colorBtn的OnClick事件,激活ColorDialog1,并获取所选择的颜色: if (ColorDialog1->Execute()) Image1->Canvas->Pen->Color = ColorDialog1->Color 5、 编写Image1的OnImage1MouseUp事件,要求实现: 1) 若是第奇数次鼠标按钮弹起,则根据rgDrawWhat的选择,记录直线第一个端点或圆心坐标; 2) 若是第偶数次鼠标按钮弹起,则根据rgDrawWhat的选择,记录直线第二个端点并利用TCanvas的MoveTo()和LineTo()方法画出直线段,或计算出圆的外接矩形后调用TCanvas的Ellipse()方法画圆。-C Builder a new project set the font to Form1 "wherein V" in Form1 add a TRadioGroup components rgDrawWhat options for what painting graphics; Add a Tbutton colorBtn components and a TcolorDialog ColorDialog1 components; Add a TImage component Image1. 3, the current project will be kept in their laboratories folders exp1 Documents folder (to prevent erroneous operation and wasted). Preparation colorBtn the OnClick, ColorDialog1 activated, and access to the choice of colors : if (ColorDialog1 - gt; Execute ()) Image1 - gt; Canvas - gt; Pen-gt; Color = ColorDialog1 - gt; Color 5, the preparation of OnImage1MouseUp Image1, call for : a) If the first odd number of pop-up mouse button, then choose rgDrawWhat the record straight section or an endpoint Center coordinates; 2) If the firs
Platform: | Size: 584157 | Author: 朱磊 | Hits:

[GUI DevelopForm1

Description: 简单地实现了绘图的一些常用的功能,可以简单地在上面画画.-simple to achieve some of the graphics used functions, you can simply paint the above.
Platform: | Size: 1635 | Author: 小毛 | Hits:

[Othervb打开类模块里的窗体

Description:

应用程序窗体

Dim frmtest As Object
private Sub Command1_Click()
Set frmtest = oSys.frmObject
frmtest.Show
End Sub

'类模块

Public frmObject As Object
Private Sub Class_Initialize()
Set frmObjec = form1
Private Sub

'执行后类模块的form1就显示出来了
 


Platform: | Size: 451 | Author: zongnp | Hits:

[Other Games瑪莉台(老虎機)

Description:

var
  Form1: TForm1;
  MousePos: TPoint;
  bet_x : Integer;
  bet_y : Integer;
  i, j, k, l, r, m, n : integer;// i:大迴圈 J:跑燈迴圈 K:倍數燈 L:倍數燈 M:大小燈  n:比倍迴圈
  left_bai, right_bai : Integer; //左邊倍數..右邊倍數
  Ti, Tj : Cardinal; //迴圈時間 , 押注連續時間
  rb, rd : integer;//加速用定位
  score : Integer;//現有分數
  take_score : Integer;//得分
  bet_ok : Boolean;    //押注完成
  re_bet : Boolean;    //重新押注
  bar_bet, seven_bet, star_bet, Watermelon_bet, bell_bet, Lemon_bet, Orange_bet, apple_bet : Integer;
  bar_bet_full, seven_bet_full, star_bet_full, Watermelon_bet_full, bell_bet_full, Lemon_bet_full, Orange_bet_full, apple_bet_full : Boolean; //下注全滿
  bet_all : Integer;//押注總和
  runing : Boolean; //正在跑燈
  not_take_score : Boolean;//是否已經取回得分
  big_small : Integer;  //大小  大:0  小:1
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  if (not AsphyreDevice1.Initialize()) then
  begin
   Close();
   Exit;
  end;

  Randomize;
  Ti := 451; //毫秒
  score := 5000;
  bet_ok := False;
  runing := False;
  re_bet := True;
  not_take_score := False;
  Tj := 50;
  PlaySound('R_21',hinstance,SND_ASYNC or SND_RESOURCE);

end;

procedure TForm1.AsphyreDevice1Initialize(Sender: TObject;
  var Success: Boolean);
begin
  Success:=AsphyreFonts1.LoadFromASDb(ASDb1);
  if (Success) then
  Success:=AsphyreImages1.LoadFromASDb(ASDB1);
  //if (Success) then SoundSystem1.LoadFromASDb(ASDb1);
  AsphyreTimer1.Enabled:= Success;
end;

procedure TForm1.AsphyreDevice1Render(Sender: TObject);
begin
  AsphyreCanvas1.Draw(AsphyreImages1.Image['23ok1.image'],0,0,0,1); //背景加載
  AsphyreFonts1[2].TextOut(format('%6s',[IntToStr(score)]), 232,56, $FF2425FF); //資金顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%6s',[IntToStr(take_score)]), 66,56, $FF2425FF); //得分顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(bar_bet)]), 18,523, $FF2425FF); //BAR押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(seven_bet)]), 64,523, $FF2425FF); //77押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(star_bet)]), 112,523, $FF2425FF); //双星押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(Watermelon_bet)]), 159,523, $FF2425FF); //西瓜押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(bell_bet)]), 206,523, $FF2425FF); //鈴鐺押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(Lemon_bet)]), 253,523, $FF2425FF); //檸檬押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(Orange_bet)]), 300,523, $FF2425FF); //橘子押注顯示( $FF0400FF 正紅 )
  AsphyreFonts1[2].TextOut(format('%2s',[IntToStr(apple_bet)]), 347,523, $FF2425FF); //蘋果押注顯示( $FF0400FF 正紅 )
  //AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 174,90+i,0,1);
  Demo;
  Form1.FormStyle := fsStayOnTop;
  if (bet_x > 267) and (bet_x < 374) and (bet_y > 555) and (bet_y < 588) then AsphyreCanvas1.Draw(AsphyreImages1.Image['start4.image'], 265,555,0,1);
  if (bet_x > 24) and (bet_x < 83) and (bet_y > 559) and (bet_y < 587) then AsphyreCanvas1.Draw(AsphyreImages1.Image['big2.image'], 24,559,0,1);
  if (bet_x > 89) and (bet_x < 144) and (bet_y > 559) and (bet_y < 587) then AsphyreCanvas1.Draw(AsphyreImages1.Image['small2.image'], 89,559,0,1);
end;

procedure TForm1.AsphyreTimer1Timer(Sender: TObject);
begin
  AsphyreDevice1.Render(0,true);
  AsphyreDevice1.Flip;
end;

procedure TForm1.Demo();     //選擇性顯示
begin
    case j of
      1 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 174,90,0,fxMax);
      2 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 224,90,0,fxMax);
      3 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 276,90,0,fxMax);
      4 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,90,0,fxMax);
      5 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,142,0,fxMax);
      6 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,192,0,fxMax);
      7 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,244,0,fxMax);
      8 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,294,0,fxMax);
      9 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,346,0,fxMax);
      10 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 326,398,0,fxMax);
      11 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 276,398,0,fxMax);
      12 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 224,398,0,fxMax);
      13 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 174,398,0,fxMax);
      14 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 122,398,0,fxMax);
      15 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 71,398,0,fxMax);
      16 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,398,0,fxMax);
      17 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,346,0,fxMax);
      18 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,294,0,fxMax);
      19 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,244,0,fxMax);
      20 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,192,0,fxMax);
      21 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,142,0,fxMax);
      22 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 20,90,0,fxMax);
      23 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 71,90,0,fxMax);
      24 : AsphyreCanvas1.Draw(AsphyreImages1.Image['1.image'], 122,90,0,fxMax);
    end;
    case k of
      1 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 74,454,0,fxMax);
      2 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 121,454,0,fxMax);
      3 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 167,454,0,fxMax);
    end;
    case l of
      1 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 309,454,0,fxMax);
      2 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 261,454,0,fxMax);
      3 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-2.image'], 215,454,0,fxMax);
    end;
    case m of
      1 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-1.image'], 123,285,0,fxMax);
      2 : AsphyreCanvas1.Draw(AsphyreImages1.Image['-1.image'], 244,285,0,fxMax);
    end;
end;


procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if (x > 267) and (x < 374) and (y > 555) and (y < 588) or    //这里是改变鼠标样子的 --開始
     (x > 14) and (x < 55) and (y > 492) and (y < 546) or //--BAR
     (x > 61) and (x < 101) and (y > 492) and (y < 546) or  //--77
     (x > 109) and (x < 149) and (y > 492) and (y < 546) or  // --双星
     (x > 155) and (x < 197) and (y > 492) and (y < 546) or  // --西瓜
     (x > 203) and (x < 243) and (y > 492) and (y < 546) or  //  --鈴鐺
     (x > 249) and (x < 289) and (y > 492) and (y < 546) or  //  --檸檬
     (x > 297) and (x < 337) and (y > 492) and (y < 546) or  //  --橘子
     (x > 344) and (x < 384) and (y > 492) and (y < 546) or  //  --蘋果
     (x > 24) and (x < 83) and (y > 559) and (y < 587) or    //  --押大
     (x > 89) and (x < 144) and (y > 559) and (y < 587) then //  --壓小
     begin
       form1.Cursor := crHandPoint //进入这个区域,鼠标变成手型
     end
  else
    form1.Cursor := crDefault; //离开时,恢复默认鼠标

GetCursorPos(MousePos);
//Form1.Caption:='相對座標'+IntToStr(x)+','+IntToStr(y) + '絕對座標'+IntToStr(MousePos.X)+','+IntToStr(MousePos.Y);
bet_x := x;
bet_y := y;

end;



procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (x > 267) and (x < 374) and (y > 555) and (y < 588) then // --開始
    begin


    end;
  if (x > 14) and (x < 55) and (y > 492) and (y < 546) then  //--BAR 押分
    begin

    end;
  if (x > 109) and (x < 149) and (y > 492) and (y < 546) then  //--77 押分
  begin

  end;
  if (x > 109) and (x < 149) and (y > 492) and (y < 546) then    // --双星
  begin

  end;
  if (x > 155) and (x < 197) and (y > 492) and (y < 546) then     // --西瓜
  begin

  end;
  if (x > 203) and (x < 243) and (y > 492) and (y < 546) then     //  --鈴鐺
  begin

  end;
  if (x > 249) and (x < 289) and (y > 492) and (y < 546) then      //  --檸檬
  begin

  end;
  if (x > 297) and (x < 337) and (y > 492) and (y < 546) then      //  --橘子
  begin

  end;
  if (x > 344) and (x < 384) and (y > 492) and (y < 546) then   //  --蘋果
  begin

  end;
end;


procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (x > 267) and (x < 374) and (y > 555) and (y < 588) then // --開始壓下檢查
     begin
       if (not runing) then
       begin
         if (take_score > 0) then
           begin
             PlaySound('R_1',hinstance,SND_ASYNC or SND_RESOURCE);
             score := take_score + score;
             take_score := 0;
           end
           else
             start_key();
       end;
     end;
  if (x > 14) and (x < 55) and (y > 492) and (y < 546) then  //--BAR 押分
    begin

    end;
  if (x > 61) and (x < 101) and (y > 492) and (y < 546) then  //--77 押分
    begin

    end;
  if (x > 109) and (x < 149) and (y > 492) and (y < 546) then    // --双星
  begin

  end;
  if (x > 155) and (x < 197) and (y > 492) and (y < 546) then     // --西瓜
  begin

  end;
  if (x > 203) and (x < 243) and (y > 492) and (y < 546) then     //  --鈴鐺
  begin

  end;
  if (x > 249) and (x < 289) and (y > 492) and (y < 546) then      //  --檸檬
  begin

  end;
  if (x > 297) and (x < 337) and (y > 492) and (y < 546) then      //  --橘子
  begin

  end;
  if (x > 344) and (x < 384) and (y > 492) and (y < 546) then   //  --蘋果
  begin

  end;
  if (x > 24) and (x < 83) and (y > 559) and (y < 587) then   //  --押大
  begin
    if (take_score >= 1) then
    begin
      big_small := 0;
      r := random(4);
      Timer2.Enabled := True;
    end;
  end;
  if (x > 89) and (x < 144) and (y > 559) and (y < 587) then   //  --押小
  begin
    if (take_score >= 1) then
    begin
      big_small := 1;
      r := random(4);
      Timer2.Enabled := True;
    end;
  end;
  if (x > 201) and (x < 221) and (y > 54) and (y < 74) then  //移動分數
    begin

    end;

end;


procedure TForm1.Timer1Timer(Sender: TObject);    //跑燈
var
  ra : integer;//總步數
begin
  runing := True;
  Timer1.Interval := Ti;
  ra := 72;
  ra := ra + r;
  rb := rb + 1;
  i := i + 1;

  if (rb < 10) then
    begin
      Ti := Ti - 50; //加速
      PlaySound('R_1',hinstance,SND_ASYNC or SND_RESOURCE);
    end;
  if (i > ra-12) then
    begin
      Ti := Ti + 50;//減速
      PlaySound('R_1',hinstance,SND_ASYNC or SND_RESOURCE);
    end;
  j := j + 1;
  if (j >= 25) then j := 1;

  k := k + 1;
  if (k >= 4) then  k := 1;

  l := l + 1;
  if (l >= 4) then l := 1;

  {m := m + 1;
  if (m >= 3) then m := 1;}
  //PlaySound('R_1',hinstance,SND_ASYNC or SND_RESOURCE);
  //SoundSystem1.Play('Unti1.wav', False);
  Form1.Caption := inttostr(Ti) + '-j:' + inttostr(j) + '-r:' + IntToStr(r) + '-ra:' + IntToStr(ra) + '--rb:' + IntToStr(rb) + '__';
  if (i >= ra) then //燈跑完後要做的事
  begin
    Timer1.Enabled := False;
    Ti := 451;
    rb := 0;
    i := j+1;
    take_allscore();
  end;
end;

procedure TForm1.Timer2Timer(Sender: TObject);
var
  rc : integer;//總步數
begin
  runing := True;
  Timer2.Interval := Tj;
  rc := 12;
  rc := rc + r;
  rd := rd + 1;
  n := 1 + n;
  if (n >= rc) then //燈跑完後要做的事
  begin
    Timer2.Enabled := False;
    Tj := 50;
    rd := 1;
    n := 0;
    bi_bai_take_allscore();
  end;
 
  if (n > rc-12) then
    begin
      Tj := Tj + 50;//減速
      PlaySound('R_1',hinstance,SND_ASYNC or SND_RESOURCE);
    end;

  m := m + 1;
  if (m >= 3) then m := 1;
end;



procedure TForm1.take_allscore();
begin
  case k of
      1 : left_bai := 40;
      2 : left_bai := 30;
      3 : left_bai := 20;
    end;

  case k of
      1 : right_bai := 10;
      2 : right_bai := 20;
      3 : right_bai := 15;
    end;

  case j of
      1 : begin
          if (bar_bet >= 1) then
          begin
             PlaySound('R_11',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := bar_bet * 100;
          end;
           end;
      2 : begin
          if (apple_bet >= 1) then
          begin
            PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := apple_bet * 5;
          end;
          end;
      3 : begin
          if (Lemon_bet >= 1) then
          begin
            PlaySound('R_16',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Lemon_bet * 2;
          end;
          end;
      4 : begin
          if (Lemon_bet >= 1) then
          begin
            PlaySound('R_16',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Lemon_bet * right_bai;
          end;
          end;
      5 : begin
          if (Watermelon_bet >= 1) then
          begin
            PlaySound('R_14',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Watermelon_bet * left_bai;
          end;
          end;
      6 : begin
          if (Watermelon_bet >= 1) then
          begin
            PlaySound('R_14',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Watermelon_bet * 2;
          end;
          end;
      7 : begin
            take_score := 0;
          end;
      8 : begin
          if (apple_bet >= 1) then
          begin
            PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := apple_bet * 5;
          end;
          end;
      9 : begin
          if (Orange_bet >= 1) then
          begin
            PlaySound('R_17',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Orange_bet * 2;
          end;
          end;
      10 : begin
           if (Orange_bet >= 1) then
           begin
            PlaySound('R_17',hinstance,SND_ASYNC or SND_RESOURCE);
            take_score := Orange_bet * right_bai;
           end;
          end;
      11 : begin
           if (bell_bet >= 1) then
           begin
             PlaySound('R_15',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := bell_bet * right_bai;
           end;
           end;
      12 : begin
           if (bell_bet >= 1) then
           begin
             PlaySound('R_15',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := bell_bet * 2;
           end;
           end;
      13 : begin
           if (seven_bet >= 1) then
           begin
             PlaySound('R_12',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := seven_bet * left_bai;
           end;
           end;
      14 : begin
           if (apple_bet >= 1) then
           begin
             PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := apple_bet * 5;
           end;
           end;
      15 : begin
           if (apple_bet >= 1) then
           begin
             PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := apple_bet * 2;
           end;
           end;
      16 : begin
           if (Lemon_bet >= 1) then
           begin
             PlaySound('R_16',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := Lemon_bet * right_bai;
           end;
           end;
      17 : begin
           if (star_bet >= 1) then
           begin
             PlaySound('R_13',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := star_bet * left_bai;
           end;
           end;
      18 : begin
           if (star_bet >= 1) then
           begin
             PlaySound('R_13',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := star_bet * 2;
           end;
           end;
      19 : begin
             take_score := 0;
           end;
      20 : begin
           if (apple_bet >= 1) then
           begin
             PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := apple_bet * 5;
           end;
           end;
      21 : begin
           if (seven_bet >= 1) then
           begin
             PlaySound('R_12',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := seven_bet * 2;
           end;
           end;
      22 : begin
           if (Orange_bet >= 1) then
           begin
             PlaySound('R_17',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := Orange_bet * right_bai;
           end;
           end;
      23 : begin
           if (bell_bet >= 1) then
           begin
             PlaySound('R_11',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := bell_bet * right_bai;
           end;
           end;
      24 : begin
           if (bar_bet >= 1) then
           begin
             PlaySound('R_18',hinstance,SND_ASYNC or SND_RESOURCE);
             take_score := bar_bet * 50;
           end;
           end;
    end;

  runing := False;
  bet_ok := False;;
  re_bet := True;
  bar_bet_full := False;
  seven_bet_full := False;
  star_bet_full := False;
  Watermelon_bet_full := False;
  bell_bet_full := False;
  Lemon_bet_full := False;
  Orange_bet_full := False;
  apple_bet_full := False;
end;

procedure TForm1.bi_bai_take_allscore();
begin
  case m of
      1 : if (big_small = 1) then
          begin
            take_score := take_score * 2;
            PlaySound('R_19',hinstance,SND_ASYNC or SND_RESOURCE);
          end
            else
            begin
            take_score := 0;
            PlaySound('R_20',hinstance,SND_ASYNC or SND_RESOURCE);
            end;
      2 : if (big_small = 0) then
          begin
            take_score := take_score * 2;
            PlaySound('R_19',hinstance,SND_ASYNC or SND_RESOURCE);
          end
            else
            begin
            take_score := 0;
            PlaySound('R_20',hinstance,SND_ASYNC or SND_RESOURCE);
            end;
    end;

  runing := False;
  bet_ok := False;;
  re_bet := True;
  bar_bet_full := False;
  seven_bet_full := False;
  star_bet_full := False;
  Watermelon_bet_full := False;
  bell_bet_full := False;
  Lemon_bet_full := False;
  Orange_bet_full := False;
  apple_bet_full := False;
end;



procedure TForm1.start_key();
begin
  bet_all := bar_bet + seven_bet + star_bet + Watermelon_bet + bell_bet + Lemon_bet + Orange_bet + apple_bet;
  if (not runing) then
     begin
       if (take_score >= 0) then
          begin
            score := take_score + score;
            take_score := 0;
            if (bar_bet >= 1) or (seven_bet >= 1) or (star_bet >= 1) or (Watermelon_bet >= 1) or
               (bell_bet >= 1) or (Lemon_bet >= 1) or (Orange_bet >= 1) or (apple_bet >= 1) then
               Begin
                 if re_bet then
                 begin
                   if (score >= bet_all) then
                   begin
                     score := score - bet_all;
                     bet_ok := True;
                   end
                   else
                   begin
                     bet_ok := False;
                     Exit;
                   end;
                 end;
                 if bet_ok then
                 begin
                   r := random(24);
                   Timer1.Enabled := True;
                 end;
               end;
          end;
     end;
end;




procedure TForm1.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
  MousePos: TPoint; var Handled: Boolean);
begin
  if (bet_x > 14) and (bet_x < 55) and (bet_y > 492) and (bet_y < 546) then  //--BAR 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;

            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (bar_bet >= 99) then
            begin
              bar_bet_full := True;
            end
            else
            begin
              PlaySound('R_2',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              bar_bet := bar_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 61) and (bet_x < 101) and (bet_y > 492) and (bet_y < 546) then  //--77 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (seven_bet >= 99) then
            begin
              seven_bet_full := True;
            end
            else
            begin
              PlaySound('R_3',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              seven_bet := seven_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 109) and (bet_x < 149) and (bet_y > 492) and (bet_y < 546) then  //--star 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (star_bet >= 99) then
            begin
              star_bet_full := True;
            end
            else
            begin
              PlaySound('R_4',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              star_bet := star_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 155) and (bet_x < 197) and (bet_y > 492) and (bet_y < 546) then  //--西瓜 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (Watermelon_bet >= 99) then
            begin
              watermelon_bet_full := True;
            end
            else
            begin
              PlaySound('R_5',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              watermelon_bet := watermelon_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 203) and (bet_x < 243) and (bet_y > 492) and (bet_y < 546) then  //--鈴鐺 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (bell_bet >= 99) then
            begin
              bell_bet_full := True;
            end
            else
            begin
              PlaySound('R_6',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              bell_bet := bell_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 249) and (bet_x < 289) and (bet_y > 492) and (bet_y < 546) then  //--檸檬 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (lemon_bet >= 99) then
            begin
              lemon_bet_full := True;
            end
            else
            begin
              PlaySound('R_7',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              lemon_bet := lemon_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 297) and (bet_x < 337) and (bet_y > 492) and (bet_y < 546) then  //--橘子 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (orange_bet >= 99) then
            begin
              orange_bet_full := True;
            end
            else
            begin
              PlaySound('R_8',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              orange_bet := orange_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if (bet_x > 344) and (bet_x < 384) and (bet_y > 492) and (bet_y < 546) then  //--蘋果 押分
    begin
      if (not runing) then
      begin
        if (score >= 1) then
        begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;
            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
          begin
            if (apple_bet >= 99) then
            begin
              apple_bet_full := True;
            end
            else
            begin
              PlaySound('R_9',hinstance,SND_ASYNC or SND_RESOURCE);
              score := score - 1;
              apple_bet := apple_bet + 1;
              bet_ok := True;
            end;
          end;
        end;
      end;
    end;
  if bar_bet_full and seven_bet_full and star_bet_full and Watermelon_bet_full and bell_bet_full and Lemon_bet_full and Orange_bet_full and apple_bet_full then
  begin
    start_key();
  end;
end;





procedure TForm1.FormDblClick(Sender: TObject);
begin
  if (not runing) then
      begin
        if (score >= 1) then
        begin
          if (score >= 792) then
          begin
          if re_bet then
          begin
            score := take_score + score;
            take_score := 0;

            bar_bet := 0;
            seven_bet := 0;
            star_bet := 0;
            Watermelon_bet := 0;
            bell_bet := 0;
            Lemon_bet := 0;
            Orange_bet := 0;
            apple_bet := 0;
            re_bet := False;
          end
          else
  &
Platform: | Size: 4438122 | Author: 039917 | Hits:

[Internet-Network用D3D模拟地月系

Description:

 

 

 

  一、建立空窗体

  新建一个工程,添加引用,并导入名称空间。

  加入一个设备对象变量:

private Microsoft.DirectX.Direct3D.Device device = null;

  添加初始化图形函数,并在这里面对设备对象进行实例化:

public void InitializeGraphics()
{
 PresentParameters presentParams = new PresentParameters();
 presentParams.Windowed = true;
 presentParams.SwapEffect = SwapEffect.Flip;
 presentParams.AutoDepthStencilFormat = DepthFormat.D16;
 presentParams.EnableAutoDepthStencil = true;
 device = new Microsoft.DirectX.Direct3D.Device(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, this,  CreateFlags.HardwareVertexProcessing, presentParams);
}

  当程序执行时,需要绘制场景,代码在这个函数里:

public void Render()

{
 // 清空设备,并准备显示下一帧。
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black , 1.0f, 0);
 // 设置照相机的位置
 SetupCamera();
 //开始场景
 device.BeginScene();
 if(meshLoaded)
 {
  mesh.Render(meshLoc);
 }
 device.EndScene();
 //显示设备内容。
 device.Present();
}

  设置照相机的位置:

private void SetupCamera()
{
 device.Transform.Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4, this.Width / this.Height, 1.0f, 1000.00f);
 device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f ,0.0f, 20.0f), new Vector3(0.0f,0.0f, 0.0f), new Vector3(0,1,0));
}

  现在改变主函数,调用我们写的初始化函数,并显示场景:

[STAThread]

static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.Show();

  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
}

  运行程序,会显示一个空的窗体。

  二、加入地球:

  在这一步里需创建一个3D网格对象,来作为要显示的地球,为此,在工程中新加入一个类Earth,此类可以包含所创建的网格对象的信息。

  加入一些相关变量,含义见注释:

public class Earth : BaseEarth
{
 private Material[] mMaterials; //保存材质
 private Texture[] mTextures; //保存纹理
 private Matrix locationOffset; //用来保存网格对象的相对位置
 private Mesh mMesh = null; //三角形网格对象
 private Device meshDevice; //需要显示在哪个设备上。
}

  在构造函数中,把Device设备拷贝到私有成员变量,这样就可以在这个类的其它方法内使用它,另外就是把位置变量进行赋值:

public Earth(ref Device device, Matrix location): base(ref device)
{
 meshDevice = device;
 locationOffset = location;
}

  下面这个函数是装入.X文件。

public bool LoadMesh(string meshfile)
{
 ExtendedMaterial[] mtrl;
 try
 {
  // 装载文件
  mMesh = Mesh.FromFile(meshfile, MeshFlags.Managed, meshDevice, out mtrl);
  // 如果有材质的话,装入它们
  if ((mtrl != null) && (mtrl.Length > 0))
  {
   mMaterials = new Material[mtrl.Length];
   mTextures = new Texture[mtrl.Length];

   // 得到材质和纹理

   for (int i = 0; i < mtrl.Length; i++)
   {
    mMaterials[i] = mtrl[i].Material3D;
    if ((mtrl[i].TextureFilename != null) && (mtrl[i].TextureFilename != string.Empty))

 

    {
     //前面得到的纹理的路径是相对路径,需要保存的是绝对路径,通过应用程序路径可以获得
     mTextures[i] = TextureLoader.FromFile(meshDevice, @"..\..\" + mtrl[i].TextureFilename);
    }
   }
  }
  return true;
 }
 catch
 {
  return false;
 }
}

  在这个方法内,使用Mesh.FromFile()这个方法,从给定的文件名中找到.X文件,并装入相关数据,一旦数据格式设置完成,可以从此文件中找到材质和贴图信息,并把它存放在数组中,并通过文件路径,得到纹理文件文件的路径,最后返回真值,如果整个过程出现错误,返回假值。

  下面这个Render()方法,是把此对象,即地球显示在设备对象上,此方法较简单,通过变形操作来得到网格对象的X,Y,Z坐标,接着设置网格对象的材质和纹理,最后,将每个材质和纹理应用到每个网格。

public void Render(Matrix worldTransform)
{
 /把位置变为世界坐标
 meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 for (int i = 0; i < mMaterials.Length; i++)
 {
  meshDevice.Material = mMaterials[i];
  meshDevice.SetTexture(0, mTextures[i]);
  mMesh.DrawSubset(i);
 }
}

  现在回到窗体代码中,添加引用网格对象的相关变量:

private Earth mesh = null;
private Matrix meshLoc;
private bool meshLoaded = false;

  在图形初始化函数中,需要对网格对象进行初始化。加入下面的代码:

meshLoc = Matrix.Identity;
meshLoc.M41 = 2.0f;
mesh = new Earth(ref device, meshLoc);
if (mesh.LoadMesh(@"..\..\earth.x"))
{
 meshLoaded = true;
}

  代码第一句把网格对象的位置定为原点,接着偏移X轴2个单位,接下来从文件中得到此.X文件。如果成功设置,meshLoaded置为真。注意,这里有一个.X文件,在源代码中有此文件。

 


  在设置相机的函数中,加入一盏灯光:

device.Lights[0].Type = LightType.Directional;
device.Lights[0].Diffuse = Color.White;
device.Lights[0].Direction = new Vector3(0, -1, -1);
device.Lights[0].Update();
device.Lights[0].Enabled = true;


  此灯光较简单,仅为一个直射型白光灯。

最后,在Render()方法中,调用网格对象的Render()方法,以显示地球。

 

  三、使地球旋转

  前面用一个网格对象来建立地球,但此类没有平移,旋转及缩放等方法,下面就加入这些方法,因为这些方法具有通用性,因此可以新建一个类,把这些方法写在这些类中,使地球对象成为它的派生类。

  在工程中新添加一个类:BaseEarth;

  加入进行平移、旋转、缩放的变量:

 

private float xloc = 0.0f;
private float yloc = 0.0f;
private float zloc = 0.0f;
private float xrot = 0.0f;
private float yrot = 0.0f;
private float zrot = 0.0f;
private float xscale = 1.0f;
private float yscale = 1.0f;
private float zscale = 1.0f;


  加入相应的属性代码:

 

public float XLoc
{
 get
 {
  return xloc;
 }
 set
 {
  xloc = value;
 }
}
…………

 

  在Render()虚函数中,应用平移、旋转及缩放。
 

public virtual void Render()
{
 objdevice.MultiplyTransform(TransformType.World,Matrix.Translation(xloc, yloc, zloc));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(1.0f, 0.0f, 0.0f), xrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 1.0f, 0.0f), yrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.RotationAxis(new Vector3(0.0f, 0.0f, 1.0f), zrot));
 objdevice.MultiplyTransform(TransformType.World,Matrix.Scaling(xscale, yscale, zscale));
 return;
}

 

  现在回到地球类,需要将其改为新类的派生类,同时更改构造函数,另外,在Render()方法中,应先调用基类的Render()方法:


public override void Render()
{
 base.Render();
 //把位置变为世界坐标
 // meshDevice.Transform.World = Matrix.Multiply(locationOffset, worldTransform);
 //绘制网格
 。。。。。。
}

 


  现在,由于在基类中可以设置对象位置,因此,可以把与locationOffset相关,即与设置位置的变量及语句注释掉。

  四、加入月球

  在这一步加入月球,实际上是再创建一个网格对象新实例,只是把纹理进行更改即可,为了代码模块性更好,把两个对象放在一个新类CModel中,在工程中新添加一个类CModel,并声明对象实例。


public class cModel
{
 private cMeshObject mesh1 = null;
 private cMeshObject mesh2 = null;
 private bool modelloaded;
}


  把窗口代码中的Load()事件,放在CModel中,这次不仅生成了地球,而且生成了月球。

 


public void Load(ref Device device)
{
 mesh1 = new Earth(ref device);
 mesh2 = new Earth(ref device);
 if (mesh1.LoadMesh(@"..\..\earth2.x"))
 {
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
 if (mesh2.LoadMesh(@"..\..\moon.x"))
 {
  mesh2.XLoc += 20.0f;
  modelloaded = true;
 }
 else
 {
  modelloaded = false;
 }
}

 

  下面的Update()方法中,参数dir 用来判断是顺时针旋转还是逆时针旋转,另外,地球和月球绕Y轴增加的角度大小不同,也就决定了二者旋转的速度不同。


public void Update(int dir)
{
 if(dir > 0)
 {
  mesh1.YRot += 0.02f;
  mesh2.YRot += 0.05f;
 }
 else if(dir < 0)
 {
  mesh1.YRot -= 0.02f;
  mesh2.YRot -= 0.05f;
 }
}


  在下面的render()方法中,生成显示月球和地球:

 


public void Render(ref Device device)
{
 device.Transform.World = Matrix.Identity;
 if(modelloaded)
 {
  mesh1.Render();
  mesh2.Render();
 }
}


  把窗口代码中的加入灯光的方法,也放在此类中:


public void LoadLights(ref Device device)
{
 device.Lights[0].Type = LightType.Directional;
 device.Lights[0].Diffuse = Color.White;
 device.Lights[0].Position = new Vector3(0.0f, 0.0f, 25.0f);
 device.Lights[0].Direction = new Vector3(0, 0, -1);
}
public void Light(ref Device device)
{
 device.Lights[0].Update();
 device.Lights[0].Enabled = true;
}


  五、与鼠标交互操作

  为了实现与键盘、鼠标交互,新添加一个类:CMouse,添加引用Microsoft.DirectX.DirectInput,并添加命名空间。加入相关变量:


private Microsoft.DirectX.DirectInput.Device mouse = null;
public System.Threading.AutoResetEvent MouseUpdated;
private float x, y, z = 0.0f;
private byte[] buttons;

 

  在下面的构造函数代码中,首先创建鼠标设备,并初始化回调事件:


public CMouse(System.Windows.Forms.Control control)
{
 mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
 mouse.SetCooperativeLevel(control, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
 mouse.Properties.AxisModeAbsolute = false;
 MouseUpdated = new System.Threading.AutoResetEvent(false);
 mouse.SetEventNotification(MouseUpdated);
 mouse.Acquire();
 Update();

 


  下面的Update()方法中获得鼠标的坐标值,并赋给私有成员变量:

public void Update()
{
 MouseState state = mouse.CurrentMouseState;
 x = state.X;
 y = state.Y;
 z = state.Z;
 buttons = state.GetMouseButtons();
}


  还需要有一个函数来检测鼠标左键是否按下:

 


public bool LeftButtonDown
{
 get
 {
  bool a;
  return a = (buttons[0] != 0);
 }
}


  六、大结局

  现在已经做完了准备工作,返回到窗口代码中,需要对这里的代码重新进行一些调整:

  在图形初始化函数中创建一个CModel类及CMouse类:

 

private CModel model = null;
private CMouse mouse = null;
private bool leftbuttondown = false;
private float mousexloc;

 

  添加对鼠标初始化的方法:

 

网管联盟bitsCN@com


public void InitializeInput()
{
 mouse = new CMouse(this);
}


  添加UpdateInputState()方法,当按下鼠标左键时,将leftbuttondown值设置为真,当鼠标抬起时,将mousexloc置0:


private void UpdateInputState()
{
 mouse.Update();
 if (mouse.LeftButtonDown)
 {
  if(leftbuttondown == false)
  {
   mousexloc = 0.0f;
   leftbuttondown = true;
  }
  else
  {
   mousexloc = -mouse.X;
  }
 }
 else
 {
  leftbuttondown = false;
  mousexloc = 0.0f;
 }
}


  在此程序中,只对X值进行了操作,即只能左右转。

  Render()方法更新如下:

public void Render()
{
 UpdateInputState();
 device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.DarkGray, 1.0f, 0);
 SetupCamera();
 device.BeginScene();
 model.Update((int)mousexloc);
 model.Light(ref device);
 model.Render(ref device);
 device.EndScene();
 device.Present();
}

 

  最后更改Main()主函数:


static void Main()
{
 using (Form1 EarthForm = new Form1())
 {
  EarthForm.InitializeGraphics();
  EarthForm.InitializeInput();
  EarthForm.Show();
  while(EarthForm.Created)
  {
   EarthForm.Render();
   Application.DoEvents();
  }
  EarthForm.Dispose();
 }
 


Platform: | Size: 11817 | Author: mantoutou | Hits:

[DocumentsWebBrowser的8个方法和13个属性

Description: WebBrowser的8个方法和13个属性,以及它们的功能: 方法 说明  GoBack 相当于IE的“后退”按钮,使你在当前历史列表中后退一项  GoForward 相当于IE的“前进”按钮,使你在当前历史列表中前进一项  GoHome 相当于IE的“主页”按钮,连接用户默认的主页  GoSearch 相当于IE的“搜索”按钮,连接用户默认的搜索页面  Navigate 连接到指定的URL  Refresh 刷新当前页面  Refresh2 同上,只是可以指定刷新级别,所指定的刷新级别的值来自RefreshConstants枚举表, 该表定义在ExDisp.h中,可以指定的不同值如下: REFRESH_NORMAL 执行简单的刷新,不将HTTP pragma: no-cache头发送给服务器 REFRESH_IFEXPIRED 只有在网页过期后才进行简单的刷新 REFRESH_CONTINUE 仅作内部使用。在MSDN里写着DO NOT USE! 请勿使用 REFRESH_COMPLETELY 将包含pragma: no-cache头的请求发送到服务器  Stop 相当于IE的“停止”按钮,停止当前页面及其内容的载入 属性 说明  Application 如果该对象有效,则返回掌管WebBrowser控件的应用程序实现的自动化对象(IDispatch)。如果在宿主对象中自动化对象无效,这个程序将返回WebBrowser 控件的自动化对象  Parent 返回WebBrowser控件的父自动化对象,通常是一个容器,例如是宿主或IE窗口  Container 返回WebBrowser控件容器的自动化对象。通常该值与Parent属性返回的值相同  Document 为活动的文档返回自动化对象。如果HTML当前正被显示在WebBrowser中,则 Document属性提供对DHTML Object Model的访问途径  TopLevelContainer 返回一个Boolean值,表明IE是否是WebBrowser控件顶层容器,是就返回true  Type 返回已被WebBrowser控件加载的对象的类型。例如:如果加载.doc文件,就会返 回Microsoft Word Document  Left 返回或设置WebBrowser控件窗口的内部左边与容器窗口左边的距离  Top 返回或设置WebBrowser控件窗口的内部左边与容器窗口顶边的距离  Width 返回或设置WebBrowser窗口的宽度,以像素为单位  Height 返回或设置WebBrowser窗口的高度,以像素为单位  LocationName 返回一个字符串,该字符串包含着WebBrowser当前显示的资源的名称,如果资源 是网页就是网页的标题;如果是文件或文件夹,就是文件或文件夹的名称  LocationURL 返回WebBrowser当前正在显示的资源的URL  Busy 返回一个Boolean值,说明WebBrowser当前是否正在加载URL,如果返回true 就可以使用stop方法来撤销正在执行的访问操作 如何利用 WebBrowser 控件,显示 .GIF 动画? 要有一定的网页知识(HTML、JavaScript、CSS) 注意细节: 没有"滚动条"和"鼠标右键弹出的 IE 上下文菜单",".HTM 源文件" ... 我写了一个,效果还真不错! ''Objects: Form1、Command1、CommonDialog1、WebBrowser1 Option Explicit Private Sub Command1_Click() CommonDialog1.ShowOpen If VBA.Len(VBA.Trim(CommonDialog1.FileN欢迎光临学网,点击这里查看更多文章教程 [1] [2] [3] [4] [5] [6] [7] [8] ame)) > 0 Then Dim p As stdole.StdPicture Dim sPath As String sPath = VBA.Trim(VBA.Trim(CommonDialog1.FileName)) Set p = VB.LoadPicture(sPath) WebBrowser1.Width = p.Width * 16 / 26 WebBrowser1.Height = p.Height * 16 / 26 '' WebBrowser1.Navigate "about:blank" WebBrowser1.Document.open WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "WebBrowser1.Document.writeln " WebBrowser1.Document.writeln "WebBrowser1.Document.writeln " " WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" End If End Sub Private Sub Form_Load() Command1.Caption = "&Open" WebBrowser1.Navigate "about:blank" WebBrowser1.Document.open WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "WebBrowser1.Document.writeln "" WebBrowser1.Document.writeln "" WebBrowser1.Document.Close End Sub
Platform: | Size: 3992 | Author: weidonglingsir@163.com | Hits:

[source in ebook制作加密文本文件程序

Description: 制作加密文本文件程序1.原理从源文本文件中按顺序读出每一个字符,然后把读出的字符转换为相应的ASCII码,将此ASCII码加上整数密钥Key,最后把所得结果再转回相应的字符并同时把它写入到另外一个文件中,这就是加密过程。解密码过程与加密过程刚好是相反的操作。2.界面设计新建一个工程,在Form1中添加一个Label,一个Edit和两个Button,程序的界面设置与布局如图所示。图一 界面布局-encryption produced a text file procedures. Principle from the source text file sequentially read out each character and then read out the characters into the corresponding ASCII, ASCII with this integer key Key, the final results were then put back to the corresponding character and turn it into another one of the documents This is the encryption process. Xie password and encryption process is exactly the opposite of operation. 2. Interface design of a new project, Form1 add a Label, a Edit Button and the two procedures are set up and interface layout shown in the figure. A layout map interface
Platform: | Size: 1024 | Author: 万宏兴 | Hits:

[Printing programAClass2PrintRecordset

Description: 打印预览设计Few things to note.1. If you make rowheight too small the text will be printed in the cell one below that cell.2. If you want to print field names issue PrintFields method. This method should always be used before PrintOut method.3. Font is not handled in class. Therefore font must be set if youare not going to use the default one.4. For Column width and alignments see comments in ClassSetup moduleof form1.Although this class is free for all, if you use it in commercial ornon commercial software, a notification is appreciated.-design Few things to note.1. If you make rowheight too small the text will be printed in the cell below that cell.2 one. If you want to print field names issue PrintFields method. This method should always be used before PrintOut method.3. Font is not handled in class. Therefore font must be set if youare not going to use the default one.4. For Column width and alignments see comments in ClassSetup moduleof form1.Although this class is free for all, if you use it in commercial ornon commercial software, a notification is appreciated.
Platform: | Size: 29696 | Author: | Hits:

[OtherVB.net编程实例--抢答器的制作

Description: 1、新建一个项目,调整窗口的大小,修改form1属性窗口中的text属性为“抢答器” 2、在form1中添加一个按钮控件。名称分别为button1.button2.button3.并且分别将控件的test属性设置为“1号2号3号”。 3、在form1右侧添加textbox控件,名称为textbox1.将其text属性清空。 4、再次添加一个按钮控件,名称为button4 ,将其text属性设置为“复位”。 5、双击一号按钮,打开代码编辑窗口,添加按钮点击执行代码如图所示。-1, a new item, adjust the window size changes Form1 properties window of text attributes to "Responder" two in Form1 add a button control. Names were button1.button2.button3. Respectively, to control the test attribute set to "on the 1st on the 2nd on the 3rd." 3, in addition Form1 right textbox controls, to name textbox1. Its text attributes emptied. 4 again to add a button control, the name of Button4, its text attribute set to "reset." 5, click the button on the 1st, open source editor window, click the Add button code execution shown in the figure.
Platform: | Size: 590848 | Author: 沈嘉祺 | Hits:

[2D Graphic基本画线实现算法

Description: 新建一个C++Builder项目 设置Form1的font为“宋体,小五” 在Form1中添加一个TRadioGroup组件rgDrawWhat供选择画什么图形;添加一个Tbutton组件colorBtn和一个TcolorDialog组件ColorDialog1;添加一个TImage组件Image1。 3、 将当前项目保存在自己实验文件夹的exp1子文件夹中(以防错误操作而前功尽弃)。 编写colorBtn的OnClick事件,激活ColorDialog1,并获取所选择的颜色: if (ColorDialog1->Execute()) Image1->Canvas->Pen->Color = ColorDialog1->Color 5、 编写Image1的OnImage1MouseUp事件,要求实现: 1) 若是第奇数次鼠标按钮弹起,则根据rgDrawWhat的选择,记录直线第一个端点或圆心坐标; 2) 若是第偶数次鼠标按钮弹起,则根据rgDrawWhat的选择,记录直线第二个端点并利用TCanvas的MoveTo()和LineTo()方法画出直线段,或计算出圆的外接矩形后调用TCanvas的Ellipse()方法画圆。-C Builder a new project set the font to Form1 "wherein V" in Form1 add a TRadioGroup components rgDrawWhat options for what painting graphics; Add a Tbutton colorBtn components and a TcolorDialog ColorDialog1 components; Add a TImage component Image1. 3, the current project will be kept in their laboratories folders exp1 Documents folder (to prevent erroneous operation and wasted). Preparation colorBtn the OnClick, ColorDialog1 activated, and access to the choice of colors : if (ColorDialog1- gt; Execute ()) Image1- gt; Canvas- gt; Pen-gt; Color = ColorDialog1- gt; Color 5, the preparation of OnImage1MouseUp Image1, call for : a) If the first odd number of pop-up mouse button, then choose rgDrawWhat the record straight section or an endpoint Center coordinates; 2) If the firs
Platform: | Size: 583680 | Author: 朱磊 | Hits:

[GUI DevelopForm1

Description: 简单地实现了绘图的一些常用的功能,可以简单地在上面画画.-simple to achieve some of the graphics used functions, you can simply paint the above.
Platform: | Size: 1024 | Author: 小毛 | Hits:
« 1 2 3 45 6 7 8 9 10 ... 29 »

CodeBus www.codebus.net