SystemMenuClose etc

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

SystemMenuClose etc

Post by lumberjack »

BiggyRat wrote:I think people are missing my point. please see the attached files. It should make it very clear (I hope). The code as I said above was written in VO as you will see in the attached screenshots
Jeff, nope remember we are now talking merging two different environments, you totally confused me, I thought from your post you want to emulate the VO behaviour with WinForms. You should basically be able to just take the code as is and recompile with language syntax VO selected...
What version of VO is this code coming from? Have you used the transporter to get the code converted... etc. There are a lot of things to consider... If you have done all of these.... send the DevTeam a zipped file with your application, I am sure it can be resolved quickly...
______________________
Johan Nel
Boshof, South Africa
User avatar
wriedmann
Posts: 3773
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

SystemMenuClose etc

Post by wriedmann »

Hi Jeff,
as I wrote: even if you are using the VO GUI classes in X#, the correct place is the QueryClose() event.

Please remember: you can move your VO applications to X#, but as long as they use the VO compatible GUI classes library, they look like the VO applications. But under the hood you can use all the .NET classes, and with some helper classes you are even able to add a WinForms window to the application.
If you are asking why you should do this: your application will not only become more stable, but you can use all the new language features, and all the .NET framework classes, and a lot of additional libraries from other sources.
Most vendors distribute their APIs as C# libraries, and with an X# application you can use them without any limitation.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4950
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

SystemMenuClose etc

Post by Chris »

BiggyRat wrote:I think people are missing my point. please see the attached files. It should make it very clear (I hope). The code as I said above was written in VO as you will see in the attached screenshots
Jeff, please do answer the questions we are making, to help us understand what you are doing. X# is mainly a compiler, it can be used to create anything. You can do web apps with it, you can do WPF apps, you can do WinForms apps, you can do services and you can do apps that use the VOGUI classes, like VO does. We need to understand what of all you are trying to do.

If you are writing an X# app that uses the VOSDK/VOGUI, then the equivalent of QueryClose is the same method, you can use the exact same code that you used in VO. It is the exact same GUI.

If you are writing an app that uses the Windows Forms GUI that comes with .Net, then the equivalent of QueryClose is the FormClosing event, to find it please go to the Properties window of XIDE while you have your form in the designer, go to the ExEvents page and you will find it there. Double click on it to create it and press the button with the "..." to open it in the editor. In order to tell windows not to close the window, you need to type e:Cancel := TRUE in the method that will get generated:

METHOD Form1Closing(sender AS System.Object , e AS System.ComponentModel.CancelEventArgs) AS VOID
e:Cancel := TRUE

I could go in more detail, but since I do not know what you are trying to do, I might be just saying irrelevant things. Maybe you can zip the project you have created and post it here so we can see what you are doing?
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
BiggyRat

SystemMenuClose etc

Post by BiggyRat »

Here is some X# code, built MOSTLY by the XIDE, except for the VAR and IF statements.:Is it any wonder I'm confused???

METHOD Form1Closing(sender AS System.Object , e AS System.ComponentModel.CancelEventArgs) AS VOID

VAR result = System.Windows.Forms.MessageBox.Show("Business Manager 2.0", "Do you really want to quit?", System.Windows.Forms.MessageBoxButtons.YesNo);

IF (result == System.Windows.Forms.DialogResult.Yes) <== This says CLEARLY to me, if you press the YES button, close. Correct? Apparently not. Click Yes, nothing happens. Click NO, and the window ends... WTH?

// Closes the parent form.

self.close()
ENDIF

RETURN

What happens if NO is clicked? Surely the MerssageBox should disappear. No, it stays right there!I just want the same result I used to get in the VO code above, in X#. Shouldn't be hard I wouldn't have thought. I've now been on this about 10 hours, googling EVERYTHING I can find. NOTHING Helps.
User avatar
robert
Posts: 4552
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

SystemMenuClose etc

Post by robert »

Jeff,

If you want to prevent the form to close, then you need so set the Cancel property of the e argument to TRUE. If you do nothing , and simply return then the form will close.

You should NOT call self:Close() from this method because that will bring the code in an endless loop (remember your form is already closing when this event happens).

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
BiggyRat

SystemMenuClose etc

Post by BiggyRat »

Thanks Johan, but your code here:

using System.Windows.Forms
FUNCTION Start() AS VOID
LOCAL oForm AS Form
oForm := MyForm{}
Application.Run(oForm)
RETURN
CLASS MyForm INHERIT Form
CONSTRUCTOR()
SUPER()
SELF:InitializeForm()
RETURN
METHOD InitializeForm() AS VOID
// Inside here you might probably have a Close button, menu with with Close option.
// Both work the same they have a click event.
LOCAL oCtrl AS Control
oCtrl := Button{}
oCtrl:Click := CloseClickEvent
oCtrl := ToolStripMenuItem{}
oCtrl:Click := CloseClickEvent
RETURN
METHOD CloseClickEvent(o AS OBJECT, e AS EventArgs) AS VOID
IF MessageBox.Show(;
"Are you really wanting to close the form?", "Question", ;
MessageBoxButtons.YesNo, MessageBoxIcon.Question;
) == DialogResult.Yes
SELF:Close()
ENDIF
RETURN
END CLASS


Does EXACTLY what I'm experiencing. Hit YES, and it DOESN'T close the window (or the Messagebox itself for that matter) Hitting NO closes everything. It's ass about.
ngpollarolo
Posts: 20
Joined: Mon Feb 29, 2016 3:51 pm
Location: Nicaragua

SystemMenuClose etc

Post by ngpollarolo »

METHOD ExitButtonClick(sender AS OBJECT , e AS System.EventArgs) AS VOID
SELF:CLOSE()

RETURN


METHOD BasicFormClosing(sender AS System.Object , e AS System.ComponentModel.CancelEventArgs) AS VOID
IF messagebox.Show("Are you really wanting to close the form?", "Question", ;
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.yes

e:Cancel:=.f.
ELSE
e:Cancel:=.t.

ENDIF
RETURN
BiggyRat

SystemMenuClose etc

Post by BiggyRat »

OK, I concede defeat. I think I'll stick with the "Devil I know" in VO, rather than annoy you guys and continue my endless frustration with X#. Clearly I'm doing something wrong, but I have no idea what, and cannot find any clues online anywhere. No examples I've found online, or here even compile. Not one. It makes it extremely hard to learn, when the examples won't even compile...

Here's the entirety of this current problem, including ngpollarolo's code, which looked extremely straight forward, but again, won't compile without errors.

// Application : MdiApp1
// Form1.prg , Created : 10/3/2019 12:06 PM
// User : Jeff

PARTIAL CLASS Form1 INHERIT System.Windows.Forms.Form


CONSTRUCTOR()

SUPER()

SELF:InitializeForm()

RETURN

METHOD GroupBox1Paint(sender AS System.Object , e AS System.Windows.Forms.PaintEventArgs) AS VOID
RETURN


METHOD ToolStripSplitButton1Click(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN


METHOD Form1ContextMenuStripChanged(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN


//METHOD Form1Closing(sender AS System.Object, e AS FormClosingEventArgs) AS VOID

METHOD ExitButtonClick(sender AS OBJECT , e AS System.EventArgs) AS VOID
SELF:CLOSE()

RETURN


METHOD Form1Closing(sender AS System.Object , e AS System.ComponentModel.CancelEventArgs) AS VOID
IF messagebox.Show("Are you really wanting to close the form?", "Question", ;
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.yes

e:Cancel:=.f.
ELSE
e:Cancel:=.t.

ENDIF
RETURN


METHOD Form1Closed(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN


METHOD Form1FormClosing(sender AS System.Object , e AS System.Windows.Forms.FormClosingEventArgs) AS VOID

RETURN


METHOD MenuItem1Click(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN SELF

RETURN
METHOD QueryClose(oEvent) CLASS Form1

RETURN SELF


METHOD ToolStripMenuItem1Click(sender AS System.Object , e AS System.EventArgs) AS VOID
RETURN


END CLASS
GLOBAL cAppVersion := "Test BM 2.0"

The errors are (this time....)

error XS0103: The name 'MessageBoxButtons' does not exist in the current context 37,1 Form1.prg MdiApp1
error XS0103: The name 'MessageBoxIcon' does not exist in the current context 37,1 Form1.prg MdiApp1
error XS0246: The type or namespace name 'messagebox' could not be found (are you missing a using directive or an assembly reference?) 37,1 Form1.prg MdiApp1
error XS0246: The type or namespace name 'DialogResult' could not be found (are you missing a using directive or an assembly reference?) 37,1 Form1.prg MdiApp1
Compilation failed (4 errors)


So thanks very much one and all, but I'll stay with VO for a while yet I think.
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

SystemMenuClose etc

Post by lumberjack »

Hi Jeff,
The first paradigm .NET opens up the world so to speak. So it is not anymore a question "How do I do XYZ in VO/X#. Google to the rescue... Search : "How do I prompt a user if he wants to close a window when a button is pressed c# .NET DOTNET"
Remember, DOTNET is language agnostic, at the Intermediate Level (IL) all compiled code looks the same. Hence why a product like ILSpy can take a DOTNET.dll and decompile it to c#/vb/X#. You just need to supply it the language plug-in.
You will find thousands of examples in c# this way. The beauty of X#, you can line for line, less the {} translate every statement of c# into X#.
If you find your c# code example via your search, and there is something you don't understand about a method etc. MSDN have the whole .NET "Help file" it is huge there are so many classes, it is almost impossible to think you will have to write your own, except business classes. Good luck, I know it might feel we not helping you, but once you get the hang of it you should enjoy it.

Just read a bit about the concepts of DOTNET. Assemblies, Namespaces, Static methods, METHODS, Singleton classes, Reflection, WFP, Entity Framework. It is like starting school again, but in a month or two you will speak the lingo...

Good luck.
______________________
Johan Nel
Boshof, South Africa
User avatar
lumberjack
Posts: 727
Joined: Fri Sep 25, 2015 3:11 pm
Location: South Africa

SystemMenuClose etc

Post by lumberjack »

BiggyRat wrote:OK, I concede defeat.[/code]
No! Don't do that, you so close. As I said you need to understand namespaces. Look at your designer code. System.Windows.Forms.Form

Code: Select all

// Application : MdiApp1
// Form1.prg , Created : 10/3/2019   12:06 PM
// User : Jeff
USING System.Windows.Forms // See NAMESPACE
PARTIAL CLASS Form1 INHERIT System.Windows.Forms.Form  

METHOD Form1Closing(sender AS System.Object , e AS System.ComponentModel.CancelEventArgs) AS VOID
IF messagebox.Show("Are you really wanting to close the form?", "Question", ;
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.yes
The errors are (this time....)

Code: Select all

error XS0103: The name 'XXXXX' does not exist in the current context	37,1	Form1.prg	MdiApp1
error XS0246: The type or namespace name 'YYYYYY' could not be found (are you missing a using directive or an assembly reference?)	37,1	Form1.prg	MdiApp1
I have said over and over, namespace assembly, get the concepts.

If you have said USING System.Windows.Forms at the top of the file then you can MessageBox.Show(), otherwise you need to fully qualify the Class with its namespace System.Windows.Forms.MessageBox.Show(), same for all the other errors. The USING should take all errors away.
______________________
Johan Nel
Boshof, South Africa
Post Reply