Best way to show a picture in an X# VOForm

This forum is meant for questions and discussions about the X# language and tools
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Best way to show a picture in an X# VOForm

Post by ic2 »

Hello Fabrice,

As you know I have much more confidence in most of the VO & VO tools code, like yours than in anything Microsoft wrote. So my remarks are not at all to disqualify your products. However, when in a .Net environment, it makes sense not to include external libraries if the job can be done with code already available.

About the PictureBox it looks like 2 lines would do, and in this sample 4 if you set height & width. That's 100% more than the minimum in in VO with FabPaint, but there's not much at all in C#/.Net which can be done with less code than in VO :unsure:

Image image = Image.FromFile("BeigeMonitor1.png");
pictureBox1.Image = image;
pictureBox1.Height = image.Height;
pictureBox1.Width = image.Width;

Dick
Frank Müßner
Posts: 276
Joined: Sat Dec 12, 2015 2:22 pm
Location: Germany

Best way to show a picture in an X# VOForm

Post by Frank Müßner »

Hi Dick,

help this ?

Frank
Attachments
VOMDIApp2.zip
(84.72 KiB) Downloaded 26 times
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Best way to show a picture in an X# VOForm

Post by ic2 »

Hello Frank,

Yes, thank you very much! That's great. It means that you can actually "paint" a Winforms control on a VO style X# window but you have to do it by code, not by using the toolbox, add a control and use the mouse to give it it's position and size.

To explain to other readers:

There's no control painted on the VO Windows form, instead this code displays the picture. It places the picture in the given Location of the window with the given Size; I added SizeMode to zoom it, otherwise a large picture only shows that portion of the picture that fits in the assigned Size. Frank has this code in the PostInit of the VO style window.

Self:pictureBox1:= System.Windows.Forms.PictureBox{}
Self:pictureBox1:Location := System.Drawing.Point{1, 1}
Self:pictureBox1:Name := "e""pictureEdit1"
Self:pictureBox1:Size := System.Drawing.Size{400, 400}
Self:pictureBox1:SizeMode:= System.Windows.Forms.PictureBoxSizeMode.Zoom
Self:pictureBox1:Visible := True
Self:pictureBox1:TabIndex := 700
Self:pictureBox1:Load("https://dt9qzg9h465rt.cloudfront.net/c:tempSomePicture.jpg")
SetParent(Self:pictureBox1:Handle, Self:Handle())
Return Nil


But I have 1 issue which is probably a X#/VS issue and maybe someone recognizes . The programs compiles & runs. But of the .xsfrm or .xsmnu open when I double click or right click View Designer. I have checked if any files needed to be set to trusted but no. I added a VO form and that only gives some XML code. No designer.

I have a converted VO app, SSA, and every form opens the designed in VS. I actually copied the Window1.prg/xsfrm/rc files from Frank's sample and dragged them in the SSA solution. Here I could open it and saw that there were no controls on the window.

What am I missing here?

Dick
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Best way to show a picture in an X# VOForm

Post by Chris »

Hi Dick,

How did you add the menus and windows to the project? Can you send me the project to have a look?

About the toolbox, you can choose to add a CustomControl to the window (from the VO toolbox), make it as large as you want and position it accordingly on the window, and then when you use SetParent(), use the handle of that custom control, instead of the handle of the window. That should do the trick.

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Best way to show a picture in an X# VOForm

Post by ic2 »

Hello Chris,

Well, you can find the project a little bit higher in this thread. It's the zip download in the post of Frank. It is no my solution.

I unzipped it and it is not possible to open an editor for the menu's or screens in that solution, in VS 2019.

And thanks for the customer control info!

Dick
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Best way to show a picture in an X# VOForm

Post by Chris »

Hi Dick,

Ah, sorry, I did not realize this. But I just checked Frank's sample and all menus and windows seem to open fine. Not sure if someone else also sees a problem?

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Best way to show a picture in an X# VOForm

Post by ic2 »

Hello Chris,

Hmmm, strange.

What I did:

1 I just dragged the VOMDIApp2 dir to my disk from the zip, opened in Windows Explorer
2 Then doubleclicked VOMDIApp2.xsproj also in Explorer. VS opens it as if I clicked a .sln file
3 Then I doubleclick Window1.Window1.xsfrm and nothing happens.

But the application runs fine.

I retried it to another location with the same result. For me it's not important but it's a bit strange, given that in other projects with VO style forms or menu the editor opens fine. Only difference is that I had to open it using the xsproj file as there was no .sln file in it.

I also tried it in Xide but I always have trouble opening a project in Xide as I can'open a xsproj file and Xide expects a .viproj file. I never know how to open an existing project like this in Xide.

Dick
User avatar
Chris
Posts: 4584
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Best way to show a picture in an X# VOForm

Post by Chris »

Hi Dick,

Yes indeed, XIDE cannot open VS project files. Sorry, can't think of a reason why the window does not open in your PC unfortunately. But in your own projects, windows openfine, is that right? In which case I would just ignore this, as anyway the window in Frank's sample is completely empty, there's nothing to see there.

.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
leon-ts
Posts: 429
Joined: Fri Feb 03, 2017 1:43 pm

Best way to show a picture in an X# VOForm

Post by leon-ts »

Hi all,

One of my classic Windows applications has a display of staff photos on a VO form. GDI is used for drawing. I recently ported this application to X#. To load images from files, I used classes from the System.Drawing (NET) namespace. Drawing a photo on a VO-form is left on GDI. I cut out an example from the original code and made it into a small test project (archive attached). Maybe someone will find something interesting for themselves.

Best regards,
Leonid
Attachments
TestDialog.zip
(21.5 KiB) Downloaded 26 times
Best regards,
Leonid
ic2
Posts: 1804
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Best way to show a picture in an X# VOForm

Post by ic2 »

Hello Chris,
Chris wrote: Yes indeed, XIDE cannot open VS project files. Sorry, can't think of a reason why the window does not open in your PC unfortunately. But in your own projects, windows openfine, is that right? In which case I would just ignore this, as anyway the window in Frank's sample is completely empty, there's nothing to see there..
Yes, in my own projects the editor appears and you should not further spend time on it. Just keep it in mind if it happens for someone else, you can always ask me to open this solution again while you look with Teamviewer, if it helps you solving an issue.

Dick
Post Reply