07-13-2021 04:26 AM
Hi,
I have an existing program with a user interface developed in labwindows.
I would like to change it and make it more user-friendly, "beautiful" and in step with the times.
Unfortunately using labwindows I cannot do it because the UI development tools are not adequate.
I want to develop my UI in Visual Studio with C#.
Which is the simplest way to connect the Ansi C labwindows program with the Gui in C#?
(My idea was to "Insert" the gui in a dll and call it from labwindows, but I don't know if it's possible)
Thanks in advance.
07-13-2021 08:37 AM - edited 07-13-2021 09:11 AM
@johnbop wrote:
I want to develop my UI in Visual Studio with C#.
Which is the simplest way to connect the Ansi C labwindows program with the Gui in C#?
(My idea was to "Insert" the gui in a dll and call it from labwindows, but I don't know if it's possible)
That sounds like putting the cart in front of the horse!
If I would want to do it, which I won't very soon as I'm not someone who feels like chasing the latest craze in UI development and getting excited about changing rounded corners to sharp corners (Win7 to Win 10), and then changing them back to round corners is like the nirwana of UI development, I would separate the business logic of the CVI program into its own library and then access that library from a Visual C application.
There you can go all wild with your UI design as much as you want, only to change it back in a few years again when Visual Studio 2023 will be released, which might use all UWP, or maybe they declare GDI again the defacto standard. 😁 It sure will keep you busy! 😀
Trying to shoehorn an UI library into a development environment is always a problem. Using predeveloped (and of course fully tested) function libraries in a specific environment is a lot easier. You have to implement some bindings of course, such as a PInvoke interface if you want to access the unmanaged CVI libraries from a managed .Net application developed in C#, but that while it can be tedious work to do, is magnitudes easier than trying to wrap a predefined external UI around your functions in CVI.
07-13-2021 09:23 AM - edited 07-13-2021 09:24 AM
Thanks Rolfk for the answer,
So do you recommend to use PInvoke?
(Consider that the project is big and it uses many functions of the CVI)
Thanks
07-13-2021 11:32 AM - edited 07-13-2021 11:34 AM
@johnbop wrote:
Thanks Rolfk for the answer,
So do you recommend to use PInvoke?
(Consider that the project is big and it uses many functions of the CVI)
Thanks
Whatever works for you. If you program in C# your program is managed. LabWindows CVI code is not managed (in the meaning of .Net). That means you have to somehow create managed-unmanaged bindings to use LabWindows CVI libraries in your C# code.
If you use PInvoke, create your own C++ CLI interface or do Interop Marshalling directly in the C# code, is up to you. Each has its own pros and cons but none is trivial.
It may be the perfect time to review your program code and identify clear and concise libraries and interfaces in order to minimize the effort you have to do in creating those bindings.
07-14-2021 02:19 AM
Thanks Rolfk,
if anyone else has ideas please write them below.
Thanks in advance
07-14-2021 02:46 AM
Just out of curiosity, I would like to have some samples of what you intend for user-friendly, "beautiful" and in step with the times user interface.
As I told you in your other thread I'm not willing to experiment with such language mixture, nevertheless I'm curious and always prone to understand if there's some new and useful concepts out there so please share your ideas with us.
07-14-2021 02:58 AM
Dear Roberto,
Thanks for your precious help,
I attached some example:
https://github.com/mklanac/EPEdashboard
(the avast example is only at the "start menu" level).
Thanks.
07-14-2021 03:02 AM
When I see such UIs I always think, nice, someone spend lots of hours to make a shiny UI, I hope he spend 10 times as much energy to make the actual functionality underneath work! But quite often that is idle hope!
07-14-2021 03:29 AM
Rolfk,
This program has been working great for 10 years, so now I want to focus on Ui.
Thanks in advance
07-15-2021 04:49 AM
From what I understand there are some possibilities, like:
-Pinvoke
-C# Dll with "internal" Gui
-Network Variables, but I don't know how to use it
- .Net Controller
-Active X Server
In general, however, I didn't understand how to do it and which method to choose.
Thanks in advance for advice