BindEvent() And other

This forum is meant for questions about the Visual FoxPro Language support in X#.

User avatar
xinjie
Posts: 108
Joined: Wed May 20, 2020 10:05 am
Location: China
Contact:

BindEvent() And other

Post by xinjie »

Hi,

I'm from China.I have been following X# for a long time.Thank you very much for the excellent work of the development team.

I have two questions:

1 BindEvent() Func.
I noticed the description in the X # help file,It's "Note: This API is now obsolete." WHY?
This function and several other related functions are very widely used. Is there any solution to this problem if I go from VFP to X #?

2 XSharp Open Software License
I noticed a description in it:i. modify or translate the Software;
According to the source code of X #, does translating the GUI into other languages(e.g. Chinese) violate the license ?


My English is poor. I am sorry if you have caused an ambiguity in understanding.

Thanks again and tribute.
简单的东西重复做,你能成为专家;重复的东西用心做,你能成为赢家!
User avatar
robert
Posts: 4555
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BindEvent() And other

Post by robert »

xinjie,

The BindEvent function is a runtime function that allows you to bind a function (method) to an event.
In X# we do that at compile time, just like in C# and VB. For example for a Form object you can bind an event with the += syntax:

Code: Select all

oForm:Loaded += Form_Loaded
The Form_Loaded method must have the right parameters (the compiler will check this)

And to remove an event handler you write the same code with the "-=" syntax,
In theory you can also do this in code (and we could therefore implement the BindEvents() function) but that is simply not the right solution.

With regard to your other question: we would love to see support for Chinese in our product.
What exactly do you want to translate: the messages in the runtime or do you want to translate our VS integration (editor support etc).
Maybe you can send me a private email to we can discuss this ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
xinjie
Posts: 108
Joined: Wed May 20, 2020 10:05 am
Location: China
Contact:

BindEvent() And other

Post by xinjie »

Robert,

Thank you for your quick reply.

I think your understanding of the first question is wrong. When I use X# to develop an application from 0, I certainly have to follow the rules of X#. However, if I want to convert my existing VFP application to X #, I want to know how you and your team will handle this function.

About "other", I will send you an email after careful consideration.
简单的东西重复做,你能成为专家;重复的东西用心做,你能成为赢家!
User avatar
robert
Posts: 4555
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BindEvent() And other

Post by robert »

xinjie,

We are writing a tool to convert FoxPro code (forms, class libraries, reports) to X#. Most likely we will convert this in the tool from the VFP syntax to the .Net syntax.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
FoxProMatt

BindEvent() And other

Post by FoxProMatt »

@ xinjie

Actually your English is pretty good.

I’m hoping your “other” email that you’ll send Robert after careful consideration is some good news like “I have access to many sponsorship dollars USD and will contribute heavily to X# Dev Team’s rapid completion of FoxPro implementation.”

Oh, well, we can dream, right.

(That’s some goofy American humor, so don’t take it seriously. Unless it’s true of course... Oh, rats, I did it again. )

On a serious note, welcome to X# FoxPro Forums. We look to seeing you around.
User avatar
kevclark64
Posts: 127
Joined: Thu Aug 15, 2019 7:30 pm
Location: USA

BindEvent() And other

Post by kevclark64 »

So, if I were creating an object in code and wanted to bind an event, then I would do something like this?

Code: Select all

objNewButton=createobject("commandbutton")
objNewButton.click += myClickCode
User avatar
robert
Posts: 4555
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BindEvent() And other

Post by robert »

Kevin,
Yes that would work if objNewButton is typed as CommandButton and if there is a click event defined on that class.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jörg
Posts: 2
Joined: Wed May 15, 2019 8:40 am

BindEvent() And other

Post by Jörg »

Hi!
Bud in VFP the Bindevent() has a 5th Parameter in which you can determine how it should behave (from help):
nFlags Specifies an additive bit flag you can set for the event binding operation.
The nFlags parameter is ignored when a Windows message event binding is created.
nFlags Bits Event Type Description
0 000 FoxPro object Call delegate code before event code. (Default)
1 001 FoxPro object Call event code before delegate code.
2 010 FoxPro object Do not trigger event (call delegate code) by simple method call.
3 011 FoxPro object Call event code before delegate code. Do not trigger event (call delegate code) when simple method calls occur.
4 100 Windows Message Prevents recursion of similar events while user event code is executing.
..

How can I set this by the += opperation?
User avatar
robert
Posts: 4555
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

BindEvent() And other

Post by robert »

Jörg,
I don't think this is possible in .Net.
Every event runs "on its own".
Can you explain how you are using this ?
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jörg
Posts: 2
Joined: Wed May 15, 2019 8:40 am

BindEvent() And other

Post by Jörg »

Hi Robert!

In VFP you can determine if a Binding is "fired" before or after en Event.
E.g. say you have a Save() Method. By Binding to the save() Method before, you can do some things before saving the Record (Change some Values).
And after Saving you can refresh a special Element in the Form.
In Our VFP Programm you can configure many, say nearly every Element of the gui by Database Entrys. So some Objects have to bind on base functions for working as expected.
Jörg
Post Reply