USING System
USING System.Collections.Generic
USING System.Linq
USING System.Text
USING System.Windows.Forms
USING WindowsFormsApplication1
[STAThread] ;
FUNCTION Start() AS VOID
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault( FALSE )
Application.Run( Form1{} )
RETURN
For a VO MDI Application a file Start.prg is created with this code:
[STAThread];
FUNCTION Start() AS INT
LOCAL oXApp AS XApp
TRY
oXApp := XApp{}
oXApp:Start()
CATCH oException AS Exception
ErrorDialog(oException)
END TRY
RETURN 0
CLASS XApp INHERIT App
METHOD Start()
LOCAL oMainWindow AS StandardShellWindow
oMainWindow := StandardShellWindow{SELF}
oMainWindow:Show(SHOWCENTERED)
SELF:Exec()
RETURN NIL
END CLASS
The reason for my question is that I would like to change an existing Windows Forms application with mainly VO code into a VO MDI Application, so start with a StandardShellWindow instead of a Windows Forms window. I have now done this by simply changing FUNCTION Start() and it appears to work fine but I wonder if there are any other differences that I should worry about.
Hi Kees,
the difference is the architecture: with the VO GUI Classes they are in control of the Windows message pump, whereas in a Windows Forms application the message pump is controlled by Windows Forms.
There are some hybrid forms, one with a VO ShellWindow as main window and some Windows Forms children, and one with a Windows Forms Shell and some VO DataWindows and DialogWindows as children.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
As Wolfgang mentioned, you just change how the windows message are being handled. They are both essentially very similar, they only have some small differences for each system taking into account implementation details that are not found in the other.
So using a message loop for Windows Forms will cause a few things in VO windows to not work properly (as you probably already noticed), and when using a VO message loop, will possibly cause a few issues in WinForms windows. But usually those are limited (and I don't even have something specific in mind), so if your app mainly uses VO windows, then it's the natural selection to use the VO message loop. If you do come across a serious problem on a WinForms window, possibly we can workaround it.
As Wolfgang mentioned, you just change how the windows message are being handled. They are both essentially very similar, they only have some small differences for each system taking into account implementation details that are not found in the other.
So using a message loop for Windows Forms will cause a few things in VO windows to not work properly (as you probably already noticed), and when using a VO message loop, will possibly cause a few issues in WinForms windows. But usually those are limited (and I don't even have something specific in mind), so if your app mainly uses VO windows, then it's the natural selection to use the VO message loop. If you do come across a serious problem on a WinForms window, possibly we can workaround it.
Hi Chris,
Yes, I know that Windows.Forms forms and VO windows do not work well together. I also know of the hybrid classes with their extremely limited usefulness. This was all discussed here: https://www.xsharp.eu/forum/topic/5644. But that is not what my question was about. Let me try to rephrase it. Suppose I have created a new X# Windows.Forms solution with the default startup code containing "Application.Run( Form1{} )" etc. (full code in my first message). Then I replace that startup code by the default startup code for a new X# VO windows solution which uses "oXApp := XApp{}" etc. (full code also in my first message). Question: is that all I need to change or are there other (hidden) differences in the solutions?
That's what I tried to explain, that if you make such a change, to use a VO message loop, there might be changes (hacks) needed in the code to make some WinForms controls work properly (if they depended on the WinForms standard message loop).
Regarding the basic code replacement in order to use the VO message loop, that's the only thing necessary, only other thing that comes to mind is regarding the visual styles, which in WinForms you enable with Application.EnableVisualStyles(), while for VO apps you do that by including a manifest resource (you can simply copy it from a sample VO Mdi project).
That's what I tried to explain, that if you make such a change, to use a VO message loop, there might be changes (hacks) needed in the code to make some WinForms controls work properly (if they depended on the WinForms standard message loop).
Regarding the basic code replacement in order to use the VO message loop, that's the only thing necessary, only other thing that comes to mind is regarding the visual styles, which in WinForms you enable with Application.EnableVisualStyles(), while for VO apps you do that by including a manifest resource (you can simply copy it from a sample VO Mdi project).
Hi Chris,
Thank you very much, that is all I wanted to know. I split the application into two separate solutions: a VO windows version (which is finished) and a Windows.Forms version (work in progress). I am not mixing so in the VO version there is no WinForms and vice versa. Because the original combined application started life as a WinForms application I had to change that into a pure VO application. As I understand it now the only thing needed is to remove the WinForms message loop and start a VO message loop.