Probably a very simple problem, followed by an "interesting" note
Where do I put the following VO code in an X# app please?
METHOD ExitButton( ) CLASS MainMenu
Local oTb as TextBox
oTb := TextBox{self, cAppVersion, "Do you really want to quit?"}
oTb:TYPE := BOXICONQUESTIONMARK + BUTTONYESNO
IF (oTb:Show() = BOXREPLYYES)
self:Close()
App{}:Quit()
RETURN true // Quit application.
ELSE
RETURN FALSE
// Don't quit the application.
ENDIF
RETURN NIL
I can't seem to find it anywhere. I've tried in a few places and the app either crashes with a dialog box, or does nothing..
I'll also be looking to do a similar thing with closing windows, but I'm assuming that'll just be self:EndWindow() or similar.
NOTE: EVERY time I hit COMPILE, I get the following:
error XS2012: Cannot open 'C:XIDEProjectsTest ProjectBinDebugMdiApp1.exe' for writing -- 'The process cannot access the file 'C:XIDEProjectsTest ProjectBinDebugMdiApp1.exe' because it is being used by another process.'
Sometimes I need to hit the compile button 2 or 3 times before it will compile properly. I can read what the message says, but is it something I'm doing or a switch I need to set somewhere?
SystemMenuClose etc
- lumberjack
- Posts: 726
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
SystemMenuClose etc
Hi Jeff, I assume this is a VO application and not a .NET compliant one. You should have it as per the MDI application template, sorry easiest way of saying it. Should be the same as in VO, but the MDI VO template should run as is.BiggyRat wrote:Probably a very simple problem, followed by an "interesting" note
Where do I put the following VO code in an X# app please?
I can't seem to find it anywhere. I've tried in a few places and the app either crashes with a dialog box, or does nothing..
I'll also be looking to do a similar thing with closing windows, but I'm assuming that'll just be self:EndWindow() or similar.
Sometimes I need to hit the compile button 2 or 3 times before it will compile properly. I can read what the message says, but is it something I'm doing or a switch I need to set somewhere?
.NET and WinForms have a bit of different way of doing things.
See this pseudo hand written example:
Code: Select all
FUNCTION Start() AS VOID
VAR oForm := MyFirstXSharpForm()
Application.Run(oForm)
RETURN
CLASS MyFirstXSharpForm INHERIT Form
CONSTRUCTOR()
SUPER()
Size := Size{100, 100} // Check if it is not dimension, out of top of my head
Text := "My first XSharp Form"
VAR btn := Button{}
btn:Text := "Close"
btn:Location := Point{5,5}
btn:Click := MyButtonClick // what the click event will fire
SELF:Controls:Add(btn)
RETURN
METHOD MyButtonClick(o AS OBJECT, e AS EventArgs) AS VOID
SELF:Close()
RETURN
END CLASS
HTH,
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa
SystemMenuClose etc
As Johan says, it should work exactly the same way as in VO, if you find anything that behaves in a different way in X# than in an equivalent VO app, then this is a bug, please report it to us.
Can you please explain exactly what you want to do, when do you want to exit the app? The method is named "ExitButton", which suggests you want to respond to a button click, but you are using the menu class, so maybe you just want to exit from a menu option instead? I'd say do the same thing in VO, to avoid any complexities coming from a new environment to you, and when you have it working as you expect in VO, just do the same in the X# app as well.
About the message that the file is in use, this seems that the app hasn't closed yet, after you run it. Possibly it is not visible, but it is still running for some reason. When it finally shuts down, you can now compile the app again with no problem. Please go to Tools->Preferences in XIDE, Compiler page, check the "Check if running before compile" checkbox in the bottom right, this should make XIDE check for the app already running in advance, before calling the compiler.
Chris
Can you please explain exactly what you want to do, when do you want to exit the app? The method is named "ExitButton", which suggests you want to respond to a button click, but you are using the menu class, so maybe you just want to exit from a menu option instead? I'd say do the same thing in VO, to avoid any complexities coming from a new environment to you, and when you have it working as you expect in VO, just do the same in the X# app as well.
About the message that the file is in use, this seems that the app hasn't closed yet, after you run it. Possibly it is not visible, but it is still running for some reason. When it finally shuts down, you can now compile the app again with no problem. Please go to Tools->Preferences in XIDE, Compiler page, check the "Check if running before compile" checkbox in the bottom right, this should make XIDE check for the app already running in advance, before calling the compiler.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
SystemMenuClose etc
Hi Jeff,
if you would like to put that code in a VO GUI Classes application, the ShellWindow would be the main window class.
And to stop a window from closing, you can ovveride the QueryClose() event method:
Wolfgang
P.S. this code comes from the VO GUI classes help:
if you would like to put that code in a VO GUI Classes application, the ShellWindow would be the main window class.
And to stop a window from closing, you can ovveride the QueryClose() event method:
Code: Select all
METHOD QueryClose(oEvent)
local oTB as TextBox
oTB := TextBox{SELF, "Quit", "Do you really want to quit?"}
oTB:TYPE := BOXICONQUESTIONMARK + BUTTONYESNO
IF (oTB:Show() = BOXREPLYYES)
RETURN TRUE // Quit application.
ELSE
RETURN FALSE
// Don't quit the application.
ENDIF
P.S. this code comes from the VO GUI classes help:
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 Johan, Chris and Wolfgang. That code I ripped right out of the VO manual years ago, and currently use it for the EXIT button on the main menu of one of my apps. I also have a similar one that pops up with an "Are you sure" when closing other windows (Data, Shell etc)
What I wanted to know was WHERE in the X# code do I put my "Are you sure?" code? In VO it was in the QueryClose() method of the window. I cannot find such a Method in X#. Do I need to write one? I can see Closed() and Closing() but no Closed or QueryClosed.
What I wanted to know was WHERE in the X# code do I put my "Are you sure?" code? In VO it was in the QueryClose() method of the window. I cannot find such a Method in X#. Do I need to write one? I can see Closed() and Closing() but no Closed or QueryClosed.
SystemMenuClose etc
Hi Jeff,
with X# you can use the VO GUI classes, then you need the QueryClose() method.
Or you can use the WinForms classes - I need to check it out.
Or you can use the WPF classes, with another method.
What GUI classes do you are using? The X# sample "Standard VO MDI X# runtime" uses the VO compatible GUI classes, therefore you need the QueryClose() method.
Wolfgang
with X# you can use the VO GUI classes, then you need the QueryClose() method.
Or you can use the WinForms classes - I need to check it out.
Or you can use the WPF classes, with another method.
What GUI classes do you are using? The X# sample "Standard VO MDI X# runtime" uses the VO compatible GUI classes, therefore you need the QueryClose() method.
Wolfgang
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
Ok, thanks Wolfgang. I'm trying to break the VO paradigm really. I'd like to use the "new and improved VO" - X# methods instead. I'd like to ask a user do they really want to "close this window" or "close the app" etc using X# coding.
Another thing that I can't really get my head around - PARTIAL Classes - what are they? Surely you have a Class, or you don't?
Another thing that I can't really get my head around - PARTIAL Classes - what are they? Surely you have a Class, or you don't?
SystemMenuClose etc
Jeff,
There is not much that we can do about this. I would use taskmanager or process explorer to kill the running app.
Robert
This usually means that the app has not closed properly and is still running. Considering that you are working on code that needs to quit the application that would make sense.BiggyRat wrote:Probably a very simple problem, followed by an "interesting" note
NOTE: EVERY time I hit COMPILE, I get the following:
error XS2012: Cannot open 'C:XIDEProjectsTest ProjectBinDebugMdiApp1.exe' for writing -- 'The process cannot access the file 'C:XIDEProjectsTest ProjectBinDebugMdiApp1.exe' because it is being used by another process.'
Sometimes I need to hit the compile button 2 or 3 times before it will compile properly. I can read what the message says, but is it something I'm doing or a switch I need to set somewhere?
There is not much that we can do about this. I would use taskmanager or process explorer to kill the running app.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
SystemMenuClose etc
Jeff,
PARTIAL classes allow you to spread the contents of a class over multiple source files.
Robert
PARTIAL classes allow you to spread the contents of a class over multiple source files.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
- lumberjack
- Posts: 726
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
SystemMenuClose etc
Hi Jeff,
I for one did not know why you don't get that code running, just copy it onto the VOForm you need it.... Ok a joke I assumed you wanted to have a similar behaviour on a SystemWindows.Forms.Form object.
HTH,
First paradigm shift, you need to clearly specify your "Environment". I am trying to make this VO code work on a WinForm:BiggyRat wrote:Ok, thanks Wolfgang. I'm trying to break the VO paradigm really. I'd like to use the "new and improved VO" - X# methods instead. I'd like to ask a user do they really want to "close this window" or "close the app" etc using X# coding.
Another thing that I can't really get my head around - PARTIAL Classes - what are they? Surely you have a Class, or you don't?
Code: Select all
My VO code that I want to do on a WinForm(DOTNET)
Code: Select all
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
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa