| View previous topic :: View next topic |
| Author |
Message |
Kevin Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Mar 2007 Posts: 1139 Location: Spiderman-World
|
Posted: Tue Jul 03, 2007 5:31 am Post subject: Form1.ClientHeight -- Integer and Strings? |
|
|
i want to be able to set the 1st forms Height and width.
| Code: |
procedure TForm2.Button1Click(Sender: TObject);
begin
form1.clientheight:= ('edit1.text');
end;
end.
|
-but it says Incompatible types: 'Integer' and 'String'
i want to do so you can enter your height/width in edit1 and edit2 and as many times as you want.
i did this yesterday. but now i dont remember what i did more than this...
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Tue Jul 03, 2007 7:26 am Post subject: |
|
|
Because you're trying to set the height to 'edit1.text'
What you want to do is
form1.clientheight:= StrToInt(edit1.text);
|
|
| Back to top |
|
 |
Kevin Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Mar 2007 Posts: 1139 Location: Spiderman-World
|
Posted: Tue Jul 03, 2007 7:29 am Post subject: |
|
|
yes. thanks
but how can i set a limit on? i did this too yesterday but i dont remember now O_o
example: Limit is 700, when you type in 701 you get an error message "To big" and then it goes back to what it was before/goes to 700.
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Tue Jul 03, 2007 7:31 am Post subject: |
|
|
if StrToInt(Edit1.Text) >= 700 then
ShowMessage('Must be lower than 700.')
else
form1.clientheight:= StrToInt(edit1.text);
|
|
| Back to top |
|
 |
Kevin Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Mar 2007 Posts: 1139 Location: Spiderman-World
|
Posted: Tue Jul 03, 2007 7:39 am Post subject: |
|
|
| yes, but it still goes to whatever you write before it shows the message. so you can set it to 900, then it shows the message but stays at 900. doesnt go back to 700/whatever it was before.
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Tue Jul 03, 2007 8:11 am Post subject: |
|
|
if StrToInt(Edit1.Text) >= 700 then //Check if it is 700 or greater
ShowMessage('Must be lower than 700.')//Tell the person
else//If it is NOT 700 or greater
form1.clientheight:= StrToInt(edit1.text);//Set the client height
That wouldn't do anything to the height if it was 700 or greater...
|
|
| Back to top |
|
 |
Kevin Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Mar 2007 Posts: 1139 Location: Spiderman-World
|
Posted: Tue Jul 03, 2007 8:25 am Post subject: |
|
|
i removed the ShowMessage and just put
if StrToInt(Edit1.Text) >= 700 then
form1.clientheight:= StrToInt ('700')
else
form1.clientheight:= StrToInt(edit1.text);
it dont show a message, but it doesnt go over 700. thanks again compact.
|
|
| Back to top |
|
 |
magicalimp Expert Cheater
Reputation: 0
Joined: 03 Dec 2006 Posts: 105
|
Posted: Tue Jul 03, 2007 9:49 pm Post subject: |
|
|
| This code is so horrible: form1.clientheight:= StrToInt ('700')
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Wed Jul 04, 2007 5:13 am Post subject: |
|
|
| magicalimp wrote: | | This code is so horrible: form1.clientheight:= StrToInt ('700') |
What he's saying, is he wants to choose the clientheight thru an edit box.
And your code has '700' as a string. (Unnecessary)
|
|
| Back to top |
|
 |
Kevin Grandmaster Cheater Supreme
Reputation: 0
Joined: 07 Mar 2007 Posts: 1139 Location: Spiderman-World
|
Posted: Wed Jul 04, 2007 5:32 am Post subject: |
|
|
| yea, and now i got so if you go higher than 700, lets say you enter 800. then it automaticly goes back to 700.
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Wed Jul 04, 2007 5:46 am Post subject: |
|
|
| Code: | myInteger:=StrToInt(edit1.text);
if myInteger>700 then
myInteger:=700;
Form1.ClientHeight:=myInteger; |
_________________
|
|
| Back to top |
|
 |
|