SystemMenuClose etc
SystemMenuClose etc
Hi Johan, OK, I had tried to use the USING statement at the top of the file, but what I assumed to be the top, seems not to be the case. Again not documented anywhere on the net that I could find.
Originally I tried this:
// Application : MdiApp1
// Form1.prg , Created : 10/3/2019 12:06 PM
// User : Jeff
USING System.Windows.Forms
that DID NOT work surely the first 3 lines of code are just a header/notation then the "top of the file" would be next. Basically just as it did in Clipper. But this DID work:
USING System.Windows.Forms
// Application : MdiApp1
// Form1.prg , Created : 10/3/2019 12:06 PM
// User : Jeff
be that as it may, the MessageBox still doesn't display...
Originally I tried this:
// Application : MdiApp1
// Form1.prg , Created : 10/3/2019 12:06 PM
// User : Jeff
USING System.Windows.Forms
that DID NOT work surely the first 3 lines of code are just a header/notation then the "top of the file" would be next. Basically just as it did in Clipper. But this DID work:
USING System.Windows.Forms
// Application : MdiApp1
// Form1.prg , Created : 10/3/2019 12:06 PM
// User : Jeff
be that as it may, the MessageBox still doesn't display...
SystemMenuClose etc
Hi Jeff,
ok, please look here:
https://docs.xsharp.it/doku.php?id=name ... _reference
Do you had added the System.Windows.Forms library to your references?
Wolfgang
P.S. if it does not work, please export yur application and attach the viaef file zipped to your message. We'll give it a look
ok, please look here:
https://docs.xsharp.it/doku.php?id=name ... _reference
Do you had added the System.Windows.Forms library to your references?
Wolfgang
P.S. if it does not work, please export yur application and attach the viaef file zipped to your message. We'll give it a look
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
SystemMenuClose etc
Jeff,
All this conversation would had taken just one post, if you had simply zipped and posted your project folder. Or do it a different way, select Project->Export Project and then send only the one file that will be created. Then it will be just a very simple thing for somebody to have a look and tell you exactly what the problem is.
Right now we are going in the dark, so our suggestions is just speculation really. It could be a using statement missing, it could be references missing, it could be something else, but if you give us the exact project you are working on, it will not take more than 5 minutes to give you a solution and explain to you exactly what is going on an why.
All this conversation would had taken just one post, if you had simply zipped and posted your project folder. Or do it a different way, select Project->Export Project and then send only the one file that will be created. Then it will be just a very simple thing for somebody to have a look and tell you exactly what the problem is.
Right now we are going in the dark, so our suggestions is just speculation really. It could be a using statement missing, it could be references missing, it could be something else, but if you give us the exact project you are working on, it will not take more than 5 minutes to give you a solution and explain to you exactly what is going on an why.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
SystemMenuClose etc
OK, here it is. Bear in mind it's a crap app. Designed purely for my testing purposes...
- Attachments
-
[The extension viaef has been deactivated and can no longer be displayed.]
SystemMenuClose etc
Hi Jeff,
first error:
must be
The same is in the line before:
should be
But the main problem is another one: you are mixing VO GUI ( the App class) and WinForms.
The VO GUI classes don't know nothing about the WinForms classes - it is entirely another world.
In a WinForms application the Start() function needs this code:
And to understand why your application does not runs, you should add a basic error handling:
or look in the event viewer what is going wrong.
And the please use not the "run", but the "Debug" function.
On my system, I had to remove all the VO compatibility libraries, and remove and add again the X# runtime.
And then it runs: Please find your changed application attached.
Wolfgang
first error:
Code: Select all
e:Cancel = true
Code: Select all
e:Cancel := true
Code: Select all
var result = MessageBox.Show("Business Manager 2.0", "Do you really want to quit?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand)
Code: Select all
var result := MessageBox.Show("Business Manager 2.0", "Do you really want to quit?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand)
The VO GUI classes don't know nothing about the WinForms classes - it is entirely another world.
In a WinForms application the Start() function needs this code:
Code: Select all
oWin := Form1{}
Application.Run(oWin)
Code: Select all
try
oWin := Form1{}
Application.Run(oWin)
catch oEx as Exception
MessageBox.Show( oEx:Message + CRLF + oEx:StackTrace, "Runtime error" )
end try
And the please use not the "run", but the "Debug" function.
On my system, I had to remove all the VO compatibility libraries, and remove and add again the X# runtime.
And then it runs: Please find your changed application attached.
Wolfgang
- Attachments
-
- Jeff_App.zip
- (3 MiB) Downloaded 39 times
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
SystemMenuClose etc
Hi Jeff,
after posting my message I have tried the code that closed the window.
This is your code:
but it should be:
Please find the app attached to this message.
Wolfgang
after posting my message I have tried the code that closed the window.
This is your code:
Code: Select all
method Form1FormClosing(sender as System.Object , e as System.Windows.Forms.FormClosingEventArgs) as void
var result := MessageBox.Show("Business Manager 2.0", "Do you really want to quit?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand)
if result == DialogResult.Yes
e:Cancel := true
endif
return
Code: Select all
method Form1FormClosing(sender as System.Object , e as System.Windows.Forms.FormClosingEventArgs) as void
var result := MessageBox.Show("Business Manager 2.0", "Do you really want to quit?", MessageBoxButtons.YesNo, MessageBoxIcon.Hand)
if result != DialogResult.Yes
e:Cancel := true
endif
return
Wolfgang
- Attachments
-
- Jeff_App.zip
- (3 MiB) Downloaded 37 times
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
SystemMenuClose etc
Thanks for sending the project, it's a fine app, do not worry, I have created plenty such test apps myself that are still laying in my XIDE projects and yours is way prettier than most of mine
To further expand on what Wolfgang said: Since you are taking the .Net way of WInForms, rather than the way of using the VOGUI, then you need to use WinForms classes and do not mix them with VOGUI. You must not use the "App" class anymore, this is a VOGUI thing. Instead, use this:
System.Windows.Forms.Application.Run(oWin)
which is the equivalent of oApp:Exec(), it just tells .Net that you want to start your app by displaying oWin and terminate the app when oWin closes. You could also do this instead, the code is self describable:
oWin:ShowDialog() // and remove Application.Run()
Seeing your code, it now explains also why you were getting an error when compiling your code for the second time. It is because you were using two GUIs together (WinFOrms and VOGUI) and even when the one got shutdown when you closed the form, the VOGUI was stil running, because you had used and instantiated the App class. Just completely remove the oApp LOCAL and its uses from your code and this problem will go away.
Wofgang has covered the rest about the code in the closing event, hope you feel more confident now to further explore the .Net framework classes!
To further expand on what Wolfgang said: Since you are taking the .Net way of WInForms, rather than the way of using the VOGUI, then you need to use WinForms classes and do not mix them with VOGUI. You must not use the "App" class anymore, this is a VOGUI thing. Instead, use this:
System.Windows.Forms.Application.Run(oWin)
which is the equivalent of oApp:Exec(), it just tells .Net that you want to start your app by displaying oWin and terminate the app when oWin closes. You could also do this instead, the code is self describable:
oWin:ShowDialog() // and remove Application.Run()
Seeing your code, it now explains also why you were getting an error when compiling your code for the second time. It is because you were using two GUIs together (WinFOrms and VOGUI) and even when the one got shutdown when you closed the form, the VOGUI was stil running, because you had used and instantiated the App class. Just completely remove the oApp LOCAL and its uses from your code and this problem will go away.
Wofgang has covered the rest about the code in the closing event, hope you feel more confident now to further explore the .Net framework classes!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
SystemMenuClose etc
Brilliant. Thanks very much Wolfgang and Chris. I really appreciate your help.
Here is an example of how I get confused/led astray... Everyone says "look at Microsoft MSDN", google it etc. Heres the syntax from the Microsoft .Net Docs. notice the difference?
// Display message box parented to the main form.
// The Help button opens the Mspaint.chm Help file,
// and the "mspaint.chm::/paint_brush.htm" Help keyword shows the
// associated topic.
DialogResult r8 = MessageBox.Show (this, "Message with Help file and keyword.",
"Help Caption", MessageBoxButtons.OK,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, 0,
"mspaint.chm",
"mspaint.chm::/paint_brush.htm");
They say use = NOT := so, I did as they say, assuming they are correct... seems not. Also, their examples of "e" show e.cancel not e:cancel as you've used, and which I first noticed in ngpolarolo's post. As I say, it makes it damn hard to learn:
// If the no button was pressed ...
if (result == DialogResult.No) <======= Exact opposite of how it should be done it seems? (== not !=)
{
// cancel the closure of the form.
e.Cancel = true;
Here is an example of how I get confused/led astray... Everyone says "look at Microsoft MSDN", google it etc. Heres the syntax from the Microsoft .Net Docs. notice the difference?
// Display message box parented to the main form.
// The Help button opens the Mspaint.chm Help file,
// and the "mspaint.chm::/paint_brush.htm" Help keyword shows the
// associated topic.
DialogResult r8 = MessageBox.Show (this, "Message with Help file and keyword.",
"Help Caption", MessageBoxButtons.OK,
MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, 0,
"mspaint.chm",
"mspaint.chm::/paint_brush.htm");
They say use = NOT := so, I did as they say, assuming they are correct... seems not. Also, their examples of "e" show e.cancel not e:cancel as you've used, and which I first noticed in ngpolarolo's post. As I say, it makes it damn hard to learn:
// If the no button was pressed ...
if (result == DialogResult.No) <======= Exact opposite of how it should be done it seems? (== not !=)
{
// cancel the closure of the form.
e.Cancel = true;
- lumberjack
- Posts: 726
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
SystemMenuClose etc
Hi Jeff,
Remember those are c# examples. X# is the XBase version of c#.
You will soon get the hang of it. Again, and I will say it again. Get yourself ILSpy 3.2 and add the XSharp Language plug-in...
Remember those are c# examples. X# is the XBase version of c#.
You will soon get the hang of it. Again, and I will say it again. Get yourself ILSpy 3.2 and add the XSharp Language plug-in...
Code: Select all
Variable declarion
LOCAL i AS INT
C#: int i;
Assignment
i := 1
C#: i = 1;
Comparison:
if i = 0
if "X#" == "X"
if "X#" = "X" // c# don't have this behavior IF "X#" begins with "X"
C#: if (i = 0)
if ("C#" == "X")
if ("C#".StartWith("X")) // The X# if "X#" = "X"
Method calls
LOCAL s AS STRING
s := "x# rules"
s := s:ToUpper() // Method call
C#:
string s;
s = "c# sucks"
s = s.ToUpper()
Static method
VAR s := String.ToUpper("x# rules")
C#:
var s = String.ToUpper("c# sucks")
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
- lumberjack
- Posts: 726
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
SystemMenuClose etc
Hi Jeff,
You confusing yourself....
Just hang in, we will ride the storm with you. You will slowly learn to read c# code, if that is a problem, most examples on MSDN also have the VB.NET code, get used to understand it. All your examples are going to be one of those languages. Look at both ways, get to understand it, it is the way you operate in .NET.
PS: By the way, how is the ILSpy 3.2 download going?
You confusing yourself....
Well it depends what the Question was that was asked in the MessageBox example: Do you really want to close. OR Do you want to stay on this form?BiggyRat wrote:Code: Select all
// If the no button was pressed ... if (result == DialogResult.No) <======= Exact opposite of how it should be done it seems? (== not !=) { // cancel the closure of the form. e.Cancel = true;
Code: Select all
// If the no button was pressed ...
if (result != DialogResult.Yes)
{
// cancel the closure of the form.
e.Cancel = true;
PS: By the way, how is the ILSpy 3.2 download going?
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa