You are not logged in.

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

1

Wednesday, July 30th 2014, 10:45am

cancelling the Unload is not functioning

Hello...

I am experimenting in my project when i had this problem with unload event.
How do I cancel the operation for Unload when using a msgbox

Jabaco Source

1
2
3
4
5
6
7
8
Public Sub Form_Unload(cancel As Integer)
   If MsgBox ("You will be logged out!", vbInformation + vbOKCancel ) = vbOK Then
	Load Form1
	Form1.Show
   Else
	cancel = 1
   End If
End Sub

Supposedly it should cancel the Unload event. but its not working.

Also pls help me in loading the the Previous form which is Form1.

Jabaco Source

1
2
Load Form1
	Form1.Show
.
.
Spare me, im new to Programming

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

2

Thursday, July 31st 2014, 3:46am

Ok, I found this on the other post http://code.google.com/p/jabacoframework…rc/VB/Form.jsrc

it stated here that the cancel for unload is not used for compatibility.
that means there is no way to cancel the unload event..

so how do I go back to the previous form? or how can i display the form1 if I am now on Form2?
someone pls help..
.
.
Spare me, im new to Programming

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

3

Friday, August 1st 2014, 6:57am

Currently, my solution to this problem is by using Dialog wherein the Form1 will serve as the main form and the Dialogs will serve as Form2 and so on...

im just disabling the form1 once there is a Dialog taht is open, and enabling the form1 in the deactivate event of the dialog.

you could also hide the form so that only the Dialog will be displayed in the screen.
.
.
Spare me, im new to Programming

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

4

Friday, August 8th 2014, 11:07am

Ok, tried it now a little bit out:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Public Sub windowClosing(arg2 As WindowEvent)
  Me.Parent.setDefaultCloseOperation(0)
  Dim p As Integer
  p = Form_Unload()
  If p <> 1 Then
    System.exit(0)
  End If
End Sub

Public Function Form_Unload() As Integer
  If MsgBox ("You will be logged out!", vbInformation + vbOKCancel ) = vbOK Then
 	   Form_Unload = 0
  Else
	   Form_Unload = 1
  End If
End Function


So, if I add the feature in the JabacoFramework, then you have to set Form_Unload the value, instead of cancel. I see no other way to implement it.

Greatings
theuserbl

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

5

Monday, August 11th 2014, 3:18am

Thanks Theusrbl.
is it already included in framework rev.149?

I tried it but it gives me an error on windows event not identified yet on my jabacos framework.

by the way. in vb6 the Cancel will be true as long as it has a non zero number (negative or positive). it will only executes the unload if the cancel value is equal to zero, The cancel value is zero by default.
.
.
Spare me, im new to Programming

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

6

Monday, August 18th 2014, 1:27am

Now in the latest Jabaco-Framework it is added.
So you only need to write

Jabaco Source

1
2
3
4
5
6
7
Public Function Form_Unload() As Integer
  If MsgBox ("You will be logged out!", vbInformation + vbOKCancel ) <> vbOK Then
    Form_Unload = 1
  Else
    Form_Unload = 0
  End If
End Function
and there is a working cancel dialogbox.

There is no other possibility, then setting that 0 means to close the window (not cancel).
Because if nobody sets Form_Unload to a value, it is per default 0 and I can not change anything on that. And as default the window have to close.

Greatings
theuserbl

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

7

Tuesday, August 19th 2014, 3:01am

Awesome. Another system interaction is on the house. maybe small but still important.
Thanks for this theuserbl :thumbsup:
.
.
Spare me, im new to Programming

spysonic

Trainee

  • "spysonic" is male
  • "spysonic" started this thread

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

8

Friday, August 29th 2014, 10:56am

hey there,
i had no problems invoking the form_unload from a private function but what about the form unload subroutine?

what am i missing?
just by having an Unload subroutine without any code in it gives me an error?
spysonic has attached the following image:
  • Issue-06.jpg
.
.
Spare me, im new to Programming

This post has been edited 1 times, last edit by "spysonic" (Aug 29th 2014, 11:03am)


theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

9

Monday, September 1st 2014, 1:19am

hey there,
i had no problems invoking the form_unload from a private function but what about the form unload subroutine?

what am i missing?
just by having an Unload subroutine without any code in it gives me an error?

You already said it: you have reaplace Sub to Function, then it works.

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

10

Saturday, September 6th 2014, 8:05pm

Hey there,

Jabaco Source

1
2
3
Public Sub Form_Unload() As Integer
   
End Sub


as generated by the Jabaco IDE throws an ERROR as mentioned above!
Not very nice ... and breaks VB compatibillaty.

Can we not somehow redirect to a Public Sub Form_Unload() ?

Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

11

Friday, September 26th 2014, 1:11pm

Hey there,

as I mentioned above,
I would prefer a solution where the VB resemblance stays untouched!
So here is another approach.

Use Rev 151 of the Jabaco Framework as a base and add / replace the following to AbstractForm in the framework. All other classes do not need to be changed:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Dim myCancelUnload As Boolean

Public Sub windowClosing(arg2 As WindowEvent) 
   On Error Resume Next
   Me.Parent.setDefaultCloseOperation(0)
   Call Form_Unload()
   If myCancelUnload = False Then
      System.exit(0)
   End If
End Sub

Public Property Let CancelUnload(v As Boolean)
   myCancelUnload = v
End Property

Public Sub Form_Unload(Optional Cancel As Integer)    'cancel is not used, is only for compatibility
   'myCancelUnload = Cancel  'unfortunatly does not work!
End Sub



and in your project add:

Jabaco Source

1
2
3
Public Sub Form_Unload(cancel As Integer)
   Me.CancelUnload = True
End Sub



This only works when using the optional parameter. I tried overloading too but for some reason the event does not get redirected.
The Optional parameter keword has not been used in the framework so far, I am not sure why?!!

This is not ideal, but I find it a bit cleaner ^^

Let me know what you think...


Dani

Rate this thread
WoltLab Burning Board