fbpx
Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET

TOPIC: SystemMenuClose etc

SystemMenuClose etc 8 months 2 days ago #7690

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 228
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:\XIDE\Projects\Test Project\Bin\Debug\MdiApp1.exe' for writing -- 'The process cannot access the file 'C:\XIDE\Projects\Test Project\Bin\Debug\MdiApp1.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?

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7693

  lumberjack's Avatar lumberjack Offline Posts: 610

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?

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.

.NET and WinForms have a bit of different way of doing things.

See this pseudo hand written example:
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
Regarding the "locking" issue. I reported it to Chris quite a while ago and in his environment cannot reproduce. It is almost as if the compiler is slow in releasing and exiting when you have an error. I found it to happen when I have the /ppo switch on while UnitTesting #command implementations.
HTH,
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7694

  Chris's Avatar Chris Away Posts: 1460
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
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7697

  wriedmann's Avatar wriedmann Away Posts: 1853
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:
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

Wolfgang

P.S. this code comes from the VO GUI classes help:

Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it
Attachments:

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7699

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 228
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.

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7700

  wriedmann's Avatar wriedmann Away Posts: 1853
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
Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7703

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 228
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?

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7704

  robert's Avatar robert Offline Posts: 1310
Jeff,

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:\XIDE\Projects\Test Project\Bin\Debug\MdiApp1.exe' for writing -- 'The process cannot access the file 'C:\XIDE\Projects\Test Project\Bin\Debug\MdiApp1.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?


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.
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

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7705

  robert's Avatar robert Offline Posts: 1310
Jeff,
PARTIAL classes allow you to spread the contents of a class over multiple source files.

Robert
XSharp Development Team
The Netherlands

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7706

  lumberjack's Avatar lumberjack Offline Posts: 610
Hi Jeff,

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?

First paradigm shift, you need to clearly specify your "Environment". I am trying to make this VO code work on a WinForm:
My VO code that I want to do on a WinForm(DOTNET)
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.
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
HTH,
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

Last edit: by lumberjack.

SystemMenuClose etc 8 months 2 days ago #7707

  wriedmann's Avatar wriedmann Away Posts: 1853
Hi Jeff,

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.

Please distinguish between the X# language and the Class libraries.
You have different layers:
  • the X# language itself
  • the .NET Framework classes
  • the #X runtime
  • the VO compatibilty classes
and then you have several GUI choices:
  • Console and GUI-less applications like Windows services
  • the VO compatible GUI classes
  • WinForms applications
  • WPFapplications
  • other GUI class libraries like Xamarin etc.
Your GUI choice dictates what functions/methods you have to use in the GUI layer, but even if you use the VO compatible GUI classes, you can use all the new X# language extensions and the .NET Framework classes like collections, ADO.NET and other interesting things in the relative methods.
But you cannot mix GUI choices (or only in a limited mode).
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7708

  lumberjack's Avatar lumberjack Offline Posts: 610
Hi Jeff,

BiggyRat wrote: 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?

Further to what Robert said:

The easiest way to see how a partial class work. In XIDE (I assume that is what you using) right click in the projects folder on a .prg which have a "Designer" form. You will see a Add Designer option. I always do this.

You will then end with two .prg's
  • MyForm.prg
  • MyForm.<designer>.prg
All your "Designer drag and drops" onto your form will go into the PARTIAL CLASS MyForm in the <designer>.prg.

Your hard coded stuff, e.g. what clickevent method needs to be called, will go into MyForm.prg PARTIAL CLASS MyForm. It is just a nice way of splitting designer code from your own code. If designer mess up things, it only mess up the designer, not your blood sweat and tears.... Ask me, I experienced it many times in VO repo crashes. Luckily with XIDE/VS so far never happened.

HTH,
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7709

  wriedmann's Avatar wriedmann Away Posts: 1853
Hi Jeff,
let me add something to what Robert and Johan wrote:
in VO, you can distribute your methods of the the same class over various modules, and in fact also over various applications/libraries.
In .NET, this is not more possible so easily, since a class needs to be kept together between a "class" and a "end class" statement.
If you wish to have methods of the same class distributed over several source files, you need to tell that to the compiler using the "partial" keyword.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy

www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7710

  FFF's Avatar FFF Offline Posts: 738

BiggyRat wrote: use it for the EXIT button on the main menu of one of my apps

Hm. "Button" on "Menu"? Do you talk about a toolbar-icon?
Regardless which UI you use, for using a menu it has to sit on a form, either you have a shell as in VO, or at least a Form, which holds the menu.

Re. the locked problem: I take it you use Xide, so, is the "check for running" option Chris mentioned set, or not? Mine is, and i always get reminded when i forgot to close the app - and NEVER see the the lock you have.
Regards
Karl

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7711

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 228
Hi FFF. The main menu I refer to is a screen I designed and called it Main Menu. Something I notice seems to be a class of the same name in X#. If your familiar with the old ACCESS database .net programming, Microsoft called the same screen the "Switchboard"

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7712

  lumberjack's Avatar lumberjack Offline Posts: 610
Hi Jeff,

BiggyRat wrote: The main menu I refer to is a screen I designed and called it Main Menu. Something I notice seems to be a class of the same name in X#. If your familiar with the old ACCESS database .net programming, Microsoft called the same screen the "Switchboard"

Hmmm, reading again your message, a screen(window) called Main Menu? Do you mean a Menu on the MainScreen called Main Menu?

Again, forget about old terminology. .NET we talk about Forms or WinForm found in System.Windows.Forms.Form. There is actually no difference between "DataWindow" and "MainShellWindow". You just create a Form and have a property to specify it is a MdiContainer and there you go, a "MainShellWindow" created.

Same with a "DataWindow", it is just again a Form or WinForm, you just specify its parent, the Form you created as having the Property IsMdiContainer in layman's terms.

We don't use Menu anymore, use the MenuStrip, ToolStrip and StatusStrip

Just google the above and you will find the implementation on the Microsoft MSDN website.

Also you need to get grips with Referenced Assemblies, NameSpaces and USING. If you don't understand that it will be a lengthy and bumpy ride till you grasp that concept.

Let us know where you still battling.
______________________
Johan Nel
George, South Africa

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 2 days ago #7719

  FFF's Avatar FFF Offline Posts: 738
Johan,
nope, i think he made a form to place buttons on it. Did similiar, albeit on regular forms, in Vo times, because button's actions were easier to grasp than modifying menus ;)

Karl
Regards
Karl

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 1 day ago #7722

  Chris's Avatar Chris Away Posts: 1460
Jeff, first please explain exactly what you are doing. How did you create your app, did you use the VO-compatible Mdi template? So you have a ShellWindow, DataWIndows etc? If yes, then you should be able to use the same exact methods as in VO.

If not, so you are not using any VOSDK classes, but created a WinForms app, then you can forget all the above :). If you are gonna use the "new" windows that come with .Net, then you cannot use VOGUI code. The equivalent of VOGUI's QueryClose() in WinForms, is the "Closing" event, you need to react to it. And when you want to display a message, you will need to use a .Net method as well, please have a look at MessageBox.Show():

docs.microsoft.com/en-us/dotnet/api/?vie...orms.MessageBox.Show
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

SystemMenuClose etc 8 months 1 day ago #7723

  BiggyRat's Avatar Topic Author BiggyRat Offline Posts: 228
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
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by BiggyRat.

SystemMenuClose etc 8 months 1 day ago #7724

  FFF's Avatar FFF Offline Posts: 738
Jeff,
sorry to say, but you write lousy bugreports. ;)
Did you try to view your attachments?
Anyway: If this is VO, your "Main Menu" is simply a dialogwindow with buttons on it? As in the Basic dialog sample? Do you want to continue with the "VO" window?
If so, go to the form, click on it, in the properties pane, tab WindowsEvents there's your Queryclose. Doubleclick the "..." and the code is there. Nothing changed re VO ;)

Karl
Regards
Karl

Please Log in or Create an account to join the conversation.