Form Is Scrolling Down

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Form Is Scrolling Down

 
0
  #1
Jun 12th, 2008
I wonder something. I have a Form with Vertical ScrollBars.
When running this code below that are inside a buttoncontrol when the scrollbar is at the top of the Form, the Form Scroll downs a bit, perheps 5-10 cm.

This is because I set button1->Enabled = false;
(I don´t know why the Form is scrolling down though when doing this)

Is it possible to not let the Form scroll down when running the code ?


  1. button1->Enabled = false;
  2.  
  3. // Code Here
  4.  
  5. button1->Enabled = true;
Last edited by Jennifer84; Jun 12th, 2008 at 8:13 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Form Is Scrolling Down

 
0
  #2
Jun 13th, 2008
I'm wondering something too.

Like how are we supposed to guess which OS / Compiler / UI Toolkit you're using from just a few UI buzzwords scattered through the post and 2 lines of code.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 351
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Solved Threads: 62
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: Form Is Scrolling Down

 
0
  #3
Jun 13th, 2008
> Is it possible to not let the Form scroll down when running the code ?
It's hard to tell what your problem is without seeing all of the code, but to mitigate the effect of the problem you can move the scroll bar position back to 0. It's kludgy, but gives the desired effect.

> how are we supposed to guess which OS / Compiler / UI Toolkit you're using
Jennifer84 isn't new to the forum, and all of her GUI questions that Edward has seen have been about Windows Forms in C++/CLI. Do you expect her to repeat the same information in every post despite her frequent threads concerning the same API?
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Form Is Scrolling Down

 
0
  #4
Jun 13th, 2008
Thank you. I use VC++ 2008 Express Edition.

I thought this perheps wasn´t so easy to know without see all the code.
The problem is that there is thousands of lines of code inside this button. : )

I tried to put it like this. It works but what happens is that the Form scroll down and
up again very fast, so it kind of ´blinks´.
It is probably not easy to know what it could depend on. I will try to experiment and
see if I can find any solution.

Why I want to Disable the button when pressing it is because if you press the button again and again very fast at the same time, you will have a "vector out of range" Error because
the calculation isn´t finished.
Perheps there could be an other way to disable it or prevent to press the button until it is finished.
button1->Visible = true; perheps isn´t the best either because calculations can take a while sometimes and the user might wonder where the button is

  1. button1->Enabled = false;
  2. Form2::VerticalScroll->Value = 0;
  3.  
  4. button1->Enabled = true;
Last edited by Jennifer84; Jun 13th, 2008 at 9:56 am.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 351
Reputation: Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about Radical Edward has a spectacular aura about 
Solved Threads: 62
Radical Edward's Avatar
Radical Edward Radical Edward is offline Offline
Posting Whiz

Re: Form Is Scrolling Down

 
0
  #5
Jun 13th, 2008
> Perheps there could be an other way to disable it or prevent to press the button until it is finished.
Edward would probably use a processing flag while the calculation is running. Set the flag to true when the button is clicked--or do nothing if the flag is already set--and unset it when the calculation finishes:
  1. bool _isProcessing;
  2.  
  3. void buttonCalculate_Click(Object^, EventArgs^)
  4. {
  5. if (_isProcessing)
  6. return;
  7.  
  8. _isProcessing = true;
  9.  
  10. // Run calculation
  11. }
  12.  
  13. void backgroundWorker_RunWorkerCompleted(Object^, RunWorkerCompletedEventArgs^)
  14. {
  15. _isProcessing = false;
  16. }
That assumes you're running the calculation in a BackgroundWorker thread.
If at first you don't succeed, keep on sucking until you do succeed.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Form Is Scrolling Down

 
0
  #6
Jun 13th, 2008
Yes ofcourse, this is a very good idéa. I will try this approach.

Thank you...

Originally Posted by Radical Edward View Post
> Perheps there could be an other way to disable it or prevent to press the button until it is finished.
Edward would probably use a processing flag while the calculation is running. Set the flag to true when the button is clicked--or do nothing if the flag is already set--and unset it when the calculation finishes:
  1. bool _isProcessing;
  2.  
  3. void buttonCalculate_Click(Object^, EventArgs^)
  4. {
  5. if (_isProcessing)
  6. return;
  7.  
  8. _isProcessing = true;
  9.  
  10. // Run calculation
  11. }
  12.  
  13. void backgroundWorker_RunWorkerCompleted(Object^, RunWorkerCompletedEventArgs^)
  14. {
  15. _isProcessing = false;
  16. }
That assumes you're running the calculation in a BackgroundWorker thread.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC