Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Jabaco Source |
|
1 |
Form2.Show vbModal |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Option Explicit Private m_Pt As MyPoint Public Sub Form_Load() Set m_Pt = New_MyPoint(123.456, 345.678) End Sub Private Sub Command1_Click() Dim F As New Form2 If F.ShowDialog(m_Pt) = vbOK Then MsgBox m_Pt.ToString End If End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Option Explicit Private m_RetVal As VbMsgBoxResult Private m_Point As MyPoint Public Function ShowDialog(Point As MyPoint) As VbMsgBoxResult Set m_Point = Point Text1.Text = m_Point.X Text2.Text = m_Point.Y Call Me.Show(vbModal) ShowDialog = m_RetVal End Function Private Sub BtnOK_Click() m_RetVal = vbOK Call m_Point.Parse(Text1.Text, Text2.Text) Unload Me End Sub Private Sub BtnCancel_Click() m_RetVal = vbCancel Unload Me End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 |
Public Function GetModalDialog(Frm As Form) As JDialog GetModalDialog = New javax#swing#JDialog GetModalDialog.setModal(True) GetModalDialog.reshape(Frm.Left, Frm.Top, Frm.Width, Frm.Height) Dim D As New Dimension(Frm.Width, Frm.Height) GetModalDialog.setMinimumSize(D) 'transfer the whole stuff from the Form to the JDialog GetModalDialog.setContentPane(Frm.ContentFrame) GetModalDialog.setTitle(Frm.Caption) End Function |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Option Explicit Private m_Pt As MyPoint Public Sub Form_Load() m_Pt = New MyPoint(123.456, 345.678) End Sub Public Sub Command1_Click() Dim F As New Form2 F.Parent.hide If F.ShowDialog(m_Pt) = vbOK Then MsgBox m_Pt.toString F.Parent.dispose End If End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Option Explicit Private m_Dlg As JDialog Private m_RetVal As VBMsgBoxResult Private m_Point As MyPoint Public Function ShowDialog(Point As MyPoint) As VBMsgBoxResult Set m_Point = Point Text1.Text = CStr(Point.X) Text2.Text = CStr(Point.Y) Set m_Dlg = GetModalDialog(Me): m_Dlg.show ShowDialog = m_RetVal Me.Parent.dispose End Function Public Sub BtnOK_Click() m_RetVal = vbOK m_Point.Parse(Text1.Text, Text2.Text) m_Dlg.dispose End Sub Public Sub BtnCancel_Click() m_RetVal = vbCancel m_Dlg.dispose End Sub |
Jabaco Source |
|
1 2 3 4 |
Public Sub Init(md As ModalDialog, obj As Object) End Sub Public Function Accept() As Boolean End Function |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
Option Explicit Implements IModalDialog Private m_Pt As MyPoint Public Sub Init(md As ModalDialog, obj As Object) 'Do some initializing stuff 'First set the buttons md.SetButtons(Me.BtnOK, Me.BtnCancel) 'Set the desired object m_Pt = Cast(obj, MyPoint) 'Show the values from the object in the textboxes of the dialog Me.TxtX.Text = CStr(m_Pt.X) Me.TxtY.Text = CStr(m_Pt.Y) End Sub Public Function Accept() As Boolean ' ' implement something like this ' here the variables will be validated ' and in case everything is valid ' the user input will be passed and ' the function returns True ' Dim errmsg As String Dim msg As String = "Please give a numeric value for " If Not IsNumeric(txtX.Text) Then _ errmsg = errmsg & msg & "x: " & txtX.Text & vbCrLf If Not IsNumeric(txtY.Text) Then _ errmsg = errmsg & msg & "y: " & txtY.Text & vbCrLf 'if there were errors the errormessage is not null If Len(errmsg) > 0 Then MsgBox errmsg Accept = False Else m_Pt.Parse(Me.TxtX.Text, Me.TxtY.Text) Accept = True End If End Function |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
Option Explicit Implements java#awt#Event#MouseListener Private m_Result As VBMsgBoxResult Private m_Form As Form Private m_IForm As IModalDialog Private m_BtnAccept As CommandButton Private m_BtnCancel As CommandButton Public Sub ModalDialog(aFrm As IModalDialog) m_IForm = aFrm m_Form = Cast(m_IForm, Form) m_Form.Visible = False Me.setContentPane(m_Form.ContentFrame) Me.setLocation(New Point(m_Form.Left, m_Form.Top)) Me.setSize(New Dimension(m_Form.Width, m_Form.Height)) Me.setTitle(m_Form.Caption) Me.setModal(True) End Sub Public Function ShowDialog(obj As Object) As VBMsgBoxResult m_IForm.Init(Me, obj) Me.show ShowDialog = m_Result End Function Public Sub SetButtons(aBtnOK As CommandButton) Me.SetButtons(aBtnOK, Nothing) End Sub Public Sub SetButtons(aBtnOK As CommandButton, aBtnCancel As CommandButton) m_BtnAccept = aBtnOK m_BtnCancel = aBtnCancel m_BtnAccept.Parent.addMouseListener(Me) m_BtnCancel.Parent.addMouseListener(Me) End Sub Public Sub mouseClicked(arg2 As MouseEvent) If arg2.getComponent = m_BtnAccept Then If m_IForm.Accept Then m_Result = vbOK m_Form.dispose m_Form = Nothing Me.dispose End If ElseIf arg2.getComponent = m_BtnCancel Then m_Result = vbCancel Me.dispose End If End Sub Public Property Get DialogResult As VBMsgBoxResult DialogResult = m_Result End Property Public Property Get IsAccepted() As Boolean IsAccepted = (m_Result = vbOK) End Property Public Property Get IsCanceled() As Boolean IsCanceled = (m_Result = vbCancel) End Property ' =+=+=+=+=+=+=+=+ ' will not be used ' =+=+=+=+=+=+=+=+ ' Public Sub mousePressed(arg2 As MouseEvent) End Sub Public Sub mouseReleased(arg2 As MouseEvent) End Sub Public Sub mouseEntered(arg2 As MouseEvent) End Sub Public Sub mouseExited(arg2 As MouseEvent) End Sub |
Trainee
Date of registration: Nov 24th 2008
Location: Cologne, Germany
Occupation: Second Vice President of Distributed Junk and Trash Development
Jabaco Source |
|
1 2 |
Dim myDialog As New Dialog1 myDialog.Show(vbModal) |
This post has been edited 1 times, last edit by "Peter" (Sep 19th 2010, 3:27am)
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves