Control.FromHandle equivalent in CF

  • Thread starter Thread starter Klaudiusz Bryja
  • Start date Start date
K

Klaudiusz Bryja

Hi,

Have Control.FromHandle method equivalent in CF? Do you know how to do
it? Or meybe you know how to pass form as reference to external class
in that way:

class myForm : Form
{
....
myMethod(ref this); // I call this method in my form class and this
method change my form.
....
}

I can do this:
myForm f = new myForm()
....
myMethod(ref f);

but I want to do this in myForm class - is it possible?

Best regards
Klaudiusz
 
I am confused by your request. Where is "myMethod" defined?

If "myMethod" is defined within the same class as "myForm", then you don't
need to pass in a reference to the form. Simply used "this" to reference it
within the "myMethod".

If "myMethod" is defined external to the "myForm" class, the you would
simply use the define "myMethod" as follows...

class someOtherClass
{
void myMethod(myForm f) {
f.changeMyForm();
}
}

-Drew
 
I am confused by your request. Where is "myMethod" defined?

If "myMethod" is defined within the same class as "myForm", then you don't
need to pass in a reference to the form. Simply used "this" to reference it
within the "myMethod".

If "myMethod" is defined external to the "myForm" class, the you would
simply use the define "myMethod" as follows...

class someOtherClass
{
void myMethod(myForm f) {
f.changeMyForm();
}

}

-Drew

Hi,

myMethoid is in external class. The method you show don't work because
when I call myMethod passing this as parameter I couldn't change form.
I don't know why - this is reference, when debugging I see that every
changes are
made but finally I can see this. It looks like in myMethod I have
local copy of form.

Best regards,
Klaudiusz
 
When you say "couldn't change form", what do you mean?

Do you mean you can't change properties of the form, or you can't access
controls you've placed on the form?

If you can't access controls on the form, I'm guessing it is because they
are marked 'private' and not 'public' or 'internal'. Verify the "Modifiers"
property of the controls on the form from the designer - or just look at the
code.

-Drew
 
Back
Top