21世纪高等学校计算机基础教育系列教材 第14章—多窗体程序设计 出
第14章 多窗体程序设计 •人民邮电出版社 21世纪高等学校计算机基础教育系列教材
建立多窗体应用程序 ◆多窗体程序设计相关的语句: ◆Load语句 ◆ Unload语句 ◆ShoW语句 ◆Hide语句
建立多窗体应用程序 多窗体程序设计相关的语句: Load 语句 Unload 语句 Show语句 Hide语句
多窗体的执行与应用 键盘敲击显示字符(需委去掉所有按钮,否则窗体得不到焦点 二窗体 详细举例完成 第三窗体 可调用 第四窗体 返鼠并关闭 西图验证 mousedown事件(画图) 返回并退出
多窗体的执行与应用 详细举例完成 可调用
程序代码(form1) Private Sub Command1 Click Form2 Show Me Hide End Sub Private Sub Command2 Click Form3. Show Me Hide End Sub Private Sub Command3 Click ●Form4.Show End Sub Private Sub Form Key Down(Key Code As Integer, Shift As Integer) Static i As Integer If i Mod 10=0 Then Print Chrs(Key Code); --- HexS(Key Code); Print: Print Elself Keycode= 13 Then Print: Print: Print Else Print Chrs(Key Code) HexS(Key Code) End If ◆ End sub
程序代码 (form1) Private Sub Command1_Click() Form2.Show Me.Hide End Sub Private Sub Command2_Click() Form3.Show Me.Hide End Sub Private Sub Command3_Click() Form4.Show Me.Hide End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Static i As Integer i = i + 1 If i Mod 10 = 0 Then Print Chr$(KeyCode); "---"; Hex$(KeyCode); " "; Print: Print ElseIf KeyCode = 13 Then i = 0 Print: Print: Print Else Print Chr$(KeyCode); "---"; Hex$(KeyCode); " "; End If End Sub
程序代码(form2) Dim paintnow As Boolean Private Sub Command1 Click Form1. Show Unload Me ● End sub Private Sub Form DblClick CIs End Sub Private Sub Form Load DrawWidth 4 Fore Color= RGB(255, 0, 0 End Sub Private Sub Form Mouse Down(Button As Integer, Shift As Integer, X AS Single, Y AS Single) paintnow= True End sul Private Sub Form Mouse Move(Button As Integer, Shift As Integer, X As Single, Y AS Single If paintnow Then PSet(X, Y) ◆Endf ◆ End sub Private Sub Form Mouse Up(Button As Integer, Shift As Integer, X As Single, Y As Single paintnow False End Sub
程序代码(form2) Dim paintnow As Boolean Private Sub Command1_Click() Form1.Show Unload Me End Sub Private Sub Form_DblClick() Cls End Sub Private Sub Form_Load() DrawWidth = 4 ForeColor = RGB(255, 0, 0) End Sub Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) paintnow = True End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If paintnow Then PSet (X, Y) End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) paintnow = False End Sub