sjesper Posted April 25, 2012 Share Posted April 25, 2012 Hello. I was wondering how to wait in a form. Example: I have a button called ">" that will make the form larger (ClientHeight) and i want it to loop like 10 times with a wait of 100 ms, and make the form a little larger everytime so it get's really smooth :-) Do i have to make it calc some big numbers as a wait, cause i can't just use the command Wait() in a form. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 25, 2012 Share Posted April 25, 2012 Do i have to make it calc some big numbers as a wait, cause i can't just use the command Wait() in a form. Create a TTimer, and do your resize inside the timer's code body, then disable the timer after x times? Although I don't see why you can't call Wait inside the OnClick event for the button. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted April 25, 2012 Share Posted April 25, 2012 Forms have an onResize event handler, buttons an OnClick event handler. So you could resize the form from the edges and have the controls inside the form auto resize. Or OnClick event handler you could do something like this: [sCAR] procedure ResizeForm(Sender: TObject); begin if Sender = Button then Form.Width := Form.Width + 60; end; Button.OnClick := @ResizeForm; [/sCAR] Quote Link to comment Share on other sites More sharing options...
sjesper Posted April 25, 2012 Author Share Posted April 25, 2012 Create a TTimer, and do your resize inside the timer's code body, then disable the timer after x times? Although I don't see why you can't call Wait inside the OnClick event for the button. I was thinking about using an TTimer, but i meaby though there was another way. But can you call wait() when a form is open cause i can't . If you want i can send you my code :-) Quote Link to comment Share on other sites More sharing options...
LordJashin Posted April 25, 2012 Share Posted April 25, 2012 I was thinking about using an TTimer, but i meaby though there was another way. But can you call wait() when a form is open cause i can't . If you want i can send you my code :-) I have a thread in the tutorials section that has tutorials on forms. Use the event handlers you do not need a timer for this. Edit: Yes you can use the wait procedure. Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 25, 2012 Share Posted April 25, 2012 You shouldn't have to wait in a form at all... It will freeze up the main thread. Quote Link to comment Share on other sites More sharing options...
sjesper Posted April 25, 2012 Author Share Posted April 25, 2012 I have a thread in the tutorials section that has tutorials on forms. Use the event handlers you do not need a timer for this. Edit: Yes you can use the wait procedure. Ahh so if i understand ur right i need to resize the form when i click the button and use the TNotifyEvent: OnResize with the form until it's the right amount :-) Just gonna try that :-) Quote Link to comment Share on other sites More sharing options...
LordJashin Posted April 25, 2012 Share Posted April 25, 2012 (edited) Ahh so if i understand ur right i need to resize the form when i click the button and use the TNotifyEvent: OnResize with the form until it's the right amount :-) Just gonna try that :-) Haha, I wouldn't go that route if I were you. You have to resize each control manually in the procedure. Its hectic, I've done it before and have gotten it to work. I haven't tried this yet, but I would try/look into doing things outlined here instead (Autoresizing form controls). Good luck. Use google if you can't find out what the type is. So if onResize used (made up) TOnResizeEvent. Instead of TNotifyEvent, it could be something like this. [sCAR] procedure OnResizeEvent(Sender: TObject; var Action: TOnResizeAction); // Made up begin Action := TonResizeFree; end; Form.OnResize := @OnResizeEvent; [/sCAR] Could be something like that instead of the default TNotifyEvent's (Sender:TObject) If you are going to just use the TNotifyEvent then make sure you base all the controls w, h, top, left on the Forms width and height. Like if your form is 200 by 200, do like Button.top := form.height /20; just make everything relative in order to achieve the resizing somehow. Make 1 control relative to the form, then the rest of the controls relative to that control. Control = form component like a TButton. Edited April 25, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 25, 2012 Share Posted April 25, 2012 I'd like to see a snippet of the code. I must be missing something here, because I don't see why you couldn't put everything you need in the event handler for the button. Quote Link to comment Share on other sites More sharing options...
LordJashin Posted April 25, 2012 Share Posted April 25, 2012 I'd like to see a snippet of the code. I must be missing something here, because I don't see why you couldn't put everything you need in the event handler for the button. You can, but why when you can just drag the edges of the form, and set the largest/smallest the form can be. OnResize event for the form means, when someone drags the edge of the form this event is triggered. Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted April 25, 2012 Share Posted April 25, 2012 Just fix the objects on the form and when it is resized the objects will resize as the person drags the form bigger or smaller. I would show example but I'm on my phone ATM. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted April 25, 2012 Share Posted April 25, 2012 Heh, just tried this. Wait appears to have no effect inside the button handler. Who knew? Quote Link to comment Share on other sites More sharing options...
FHannes Posted April 26, 2012 Share Posted April 26, 2012 Heh, just tried this. Wait appears to have no effect inside the button handler. Who knew? Actually, wait has no effect outside of the script thread, if I'd enable it in the main thread, you would freeze up SCAR. Quote Link to comment Share on other sites More sharing options...