Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C# changing the size of a form other than itself

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Sun Dec 09, 2007 9:24 pm    Post subject: C# changing the size of a form other than itself Reply with quote

Code:
this.Size = new Size(intWidth, intHeight);


I used that and it works, but when i try to change this to something else so then it changes the size of a different form, it doesnt seem to work.

Code:
Form1 frmMain = new Form1();
frmMain.Size = new Size(313, 181);


Can someone tell me what i did wrong?


Edit: C# 2008
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Mon Dec 10, 2007 12:45 am    Post subject: Reply with quote

To modify the main form I do this
Code:

 Form1 f = new Form1();
        public Form2(Form1 main)
        {
            f = main;
            InitializeComponent();
        }


And when calling form2, I do this
Code:

Form2 f2 = new Form2(this);
Back to top
View user's profile Send private message
richie86
Grandmaster Cheater
Reputation: 0

Joined: 13 Jan 2006
Posts: 664

PostPosted: Mon Dec 10, 2007 8:03 am    Post subject: Reply with quote

yeah.. pass your form to the child form, you can control your main form though there, even call a function too.

Code:
Frm2 frm = new Frm2(this);


in your frm2 source; write a constructor

Code:
private frmMain mParent;
public sub new(frmMain frm)
{
  mParent = frmMain;
}

so you can..
Code:
mParent.size bla bla
mParent.CallFunction();

_________________
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Mon Dec 10, 2007 7:02 pm    Post subject: Reply with quote

Is the form part of your project or is it another application's window? The safest way is to use SetWindowPos to set how big your window is and use the SWP_NOMOVE flag so only the size is affected.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Mon Dec 10, 2007 10:06 pm    Post subject: Reply with quote

There are a couple branches that you could be going:

Code:

                                                      spawn it off at a certain size[a]
                                                   /
            this application -> 2 ways   ---   modify it in code, without VS [b]
                                                   \
                                                      modify a currently existing form[c]
         /
YOU
         \
            another application -> Do what the last guy said



a:

Create a constructor that takes in your form so you can do something like this:

Code:

Form2 myForm = new Form2(new Size(1,2)); //Don't do that, that's REALLY small
myForm.Show();

...

//in your other form

public Form2(Size s)
{
      InitializeComponent();
      this.Size = s;
}


b:

You'll have to go edit InitializeComponent. I don't really have any code, just go in there and find where it sets "this.Size".

c:

I'm not quite sure when this would be useful/needed, but as the people before me said, try spawning it off as a child form.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Mon Dec 10, 2007 10:53 pm    Post subject: Reply with quote

Sad

I tried these but it's giving me errors.

O well, i'll just put the thing on my main form, so it wont be modified from a different form.

Thanks for helping though Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites