![]() |
|
||||||||||||||
| | 网站首页 | 数据库教程 | web编程 | 服务器 | 程序设计 | | ||
|
||
|
||||||
| vb 实列 2 | ||||||
作者:佚名 文章来源:不详 点击数: 更新时间:2007-8-6 ![]() |
||||||
|
Namespace Form
'******************************************************************************** Public Class BaseForm Inherits Windows.Forms.Form #Region " Windows フォーム デザイナで生成されたコード " Public Sub New() MyBase.New() ' この呼び出しは Windows フォーム デザイナで必要です。
InitializeComponent() End Sub ' Form は、コンポーネント一覧に後処理を実行するために dispose をオーバーライドします。 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ' Windows フォーム デザイナで必要です。 Private components As System.ComponentModel.IContainer ' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。 'Windows フォーム デザイナを使って変更してください。 ' コード エディタを使って変更しないでください。 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() ' 'BaseForm ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12) Me.ClientSize = New System.Drawing.Size(1018, 736) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.KeyPreview = True Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "BaseForm" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "BaseForm" End Sub #End Region #Region "全局函数" Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Integer, ByVal bRevert As Long) As Integer Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer Private Declare Function DrawMenuBar Lib "User32" (ByVal hwnd As Integer) As Integer Private Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu As Integer) As Integer Private Const MF_BYPOSITION As Integer = &H400& Private Const MF_DISABLED As Integer = &H2& #End Region #Region "重画Menu" Private Sub disableX(ByVal wnd As System.Windows.Forms.Form) Dim hMenu As Integer, nCount As Integer hMenu = GetSystemMenu(wnd.Handle.ToInt32, 0) nCount = GetMenuItemCount(hMenu) Call RemoveMenu(hMenu, nCount - 1, MF_BYPOSITION Or MF_DISABLED) DrawMenuBar(Me.Handle.ToInt32) End Sub #End Region #Region "屏蔽alt+F4" 'Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) ' Dim SC_CLOSE As Integer = 61536 ' Dim WM_SYSCOMMAND As Integer = 274 ' If m.Msg = WM_SYSCOMMAND AndAlso m.WParam.ToInt32 = SC_CLOSE Then ' Exit Sub ' End If ' MyBase.WndProc(m) 'End Sub #End Region #Region "画面Title" Protected Sub SetFormTitle(ByVal strTitle As String) Me.Text = Me.Text & Space(1) & strTitle End Sub #End Region #Region "画面初始化" Private Sub BaseForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'disableX(Me) 'SetCtrNMValue() FormParent = CType(Model.FormList.Getinstance.GetParentForm(Me), BaseForm) End Sub #End Region #Region "画面Controls's Name/Value設定" Protected Sub GetCtrNMValue(ByRef shtParam As Util.StringHashTable) shtParam = Nothing shtParam = New Util.StringHashTable For Each ctr As Control In Me.Controls If TypeOf (ctr) Is GroupBox Then CheckGroupBox(CType(ctr, GroupBox), shtParam) ElseIf TypeOf (ctr) Is TextBox OrElse TypeOf (ctr) Is Label Then shtParam.Add(ctr.Name, ctr.Text) ElseIf TypeOf (ctr) Is Util.ucComboBox Then shtParam.Add(ctr.Name, CType(ctr, Util.ucComboBox).GetSelectedIndex) End If Next End Sub Private Sub CheckGroupBox(ByVal cbo As GroupBox, ByRef shtParam As Util.StringHashTable) For Each ctr As Control In cbo.Controls If TypeOf (ctr) Is GroupBox Then CheckGroupBox(CType(ctr, GroupBox), shtParam) ElseIf TypeOf (ctr) Is TextBox OrElse TypeOf (ctr) Is Label Then shtParam.Add(ctr.Name, ctr.Text) ElseIf TypeOf (ctr) Is Util.ucComboBox Then shtParam.Add(ctr.Name, CType(ctr, Util.ucComboBox).GetSelectedIndex) End If Next End Sub #End Region #Region "画面遷移" '父窗體 Private FormParent As BaseForm '遷移参数 Private htParentParams As Hashtable '遷移標誌 Private iResultFlg As Integer Public Overridable Sub SeiSanShow(ByVal objForm As BaseForm, _ Optional ByVal iTranfserFlag As Integer = -1, _ Optional ByVal htParams As Hashtable = Nothing) If Not IsExistForm(objForm, Me) Then Dim tForm As Model.FormList.T_FormList tForm.ParForm = objForm tForm.CurrForm = Me Model.FormList.Getinstance.AddForm(tForm) End If Me.iResultFlg = iTranfserFlag Me.htParentParams = htParams objForm.Visible = False Me.Show() End Sub Public Overridable Sub SeiSanShowDilog(ByRef objForm As BaseForm, _ Optional ByVal iTranfserFlag As Integer = -1, _ Optional ByVal htParams As Hashtable = Nothing) If Not IsExistForm(objForm, Me) Then Dim tForm As Model.FormList.T_FormList tForm.ParForm = objForm tForm.CurrForm = Me Model.FormList.Getinstance.AddForm(tForm) End If objForm.Enabled = False Me.iResultFlg = iTranfserFlag Me.htParentParams = htParams Me.ShowDialog() End Sub Protected Function GetParentTransferInfo() As Hashtable Return Me.htParentParams End Function Private Function IsFirstForm(ByVal objForm As BaseForm) As Boolean For Each tForm As Model.FormList.T_FormList In Model.FormList.Getinstance.GetFormList If tForm.CurrForm Is objForm Then If tForm.ParForm Is Nothing Then Return True End If End If Next Return False End Function Private Function IsExistForm(ByVal ParrentForm As BaseForm, ByVal CurrForm As BaseForm) As Boolean Dim bHave As Boolean = False For Each tTempForm As Model.FormList.T_FormList In Model.FormList.Getinstance.GetFormList If tTempForm.ParForm Is ParrentForm AndAlso tTempForm.CurrForm Is CurrForm Then bHave = True Exit For End If Next Return bHave End Function #End Region #Region "ファンクションキーのF1~F12" '******************************************************************************** ' Private Sub BaseForm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp Select Case e.KeyData Case Keys.F1 DoF1() Case Keys.F2 DoF2() Case Keys.F3 DoF3() Case Keys.F4 DoF4() Case Keys.F5 DoF5() Case Keys.F6 DoF6() 'Case Keys.F7 ' DoF7() 'Case Keys.F8 ' DoF8() 'Case Keys.F9 ' DoF9() 'Case Keys.F10 ' DoF10() Case Keys.F11 DoF11() Case Keys.F12 DoF12() Case Keys.Tab DoTAB() End Select End Sub Protected Overridable Function DoTAB() As Boolean Return True End Function '******************************************************************************** Protected Overridable Function DoF1() As Boolean Return True End Function '******************************************************************************** Protected Overridable Function DoF2() As Boolean Return True End Function '******************************************************************************** Protected Overridable Function DoF3() As Boolean Return True End Function '******************************************************************************** ' Protected Overridable Function DoF4() As Boolean Return True End Function '******************************************************************************** Protected Overridable Function DoF5() As Boolean Return True End Function '****************************************** Protected Overridable Function DoF6() As Boolean Return True End Function '******************************************** Protected Overridable Function DoF7() As Boolean Return True End Function '************************************************* Protected Overridable Function DoF8() As Boolean Return True End Function Protected Overridable Function DoF9() As Boolean Return True End Function '******************************************************************************** Protected Overridable Function DoF10() As Boolean Return True End Function Protected Overridable Function DoF11() As Boolean Return True End Function Protected Overridable Function DoF12() As Boolean Return True End Function #End Region #Region "彈出窗體close后的代碼" Protected Overridable Sub OpenFormResult(ByVal iTranfserFlag As Integer, _ ByVal iCloseStatus As Integer, _ ByVal htHashTable As Hashtable) End Sub #End Region #Region "画面を閉じる" '画面を閉じるステータス Private iChildrenClose As Integer = -1 '窗體戻り参数 Private htChildrenParams As Hashtable Protected Overrides Sub OnClosed(ByVal e As System.EventArgs) If Not FormParent Is Nothing Then FormParent.Enabled = True Model.FormList.Getinstance.RemoveForm(Me) FormParent.Visible = True FormParent.OpenFormResult(Me.iResultFlg, iChildrenClose, Me.htChildrenParams) End If End Sub '**************************************************************************** Public Overridable Sub SeiSanFormClose(Optional ByVal iCloseStatus As Integer = -1, _ Optional ByVal htHashTable As Hashtable = Nothing) Me.iChildrenClose = iCloseStatus Me.htChildrenParams = htHashTable Me.Close() End Sub #End Region #Region "WaitCursor start " Public Sub WaitCursorStart() 'Me.Enabled = False Me.Cursor = Windows.Forms.Cursors.WaitCursor End Sub Public Sub WaitCursorEnd() Me.Cursor = Windows.Forms.Cursors.Default 'Me.Enabled = True End Sub #End Region End Class End Namespace 本文来源:http://blog.csdn.net/Adi_liu/archive/2007/07/02/1675641.aspx
|
||||||
| 文章录入:admin 责任编辑:admin | ||||||
| 【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 | ||||||
| 网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| | 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 网站地图 | 管理登录 | | |||
|