help with "disabling" a button

Reply

Join Date: Feb 2005
Posts: 46
Reputation: blackdove is an unknown quantity at this point 
Solved Threads: 0
blackdove blackdove is offline Offline
Light Poster

help with "disabling" a button

 
0
  #1
Mar 28th, 2005
I'm doing a "magic square" program and I'm having trouble with a button. It is supposed to stay active for as many clicks as it takes to fill the array storing the numbers, then become disabled. The button stops working the first time i click it though, and i dont know what i'm doing wrong. could someone help me please?

heres the code for my button.

  1.  
  2. void CLab10Dlg::OnEnterDataButton()
  3. {
  4. // TODO: Add your control notification handler code here
  5. GetDlgItemText(IDC_ROW_NUM, m_row_num);
  6. GetDlgItemText(IDC_COL_NUM, m_col_num);
  7. GetDlgItemText(IDC_DATA, m_data);
  8. int row_num = atoi((LPCTSTR)m_row_num);
  9. int col_num = atoi((LPCTSTR)m_col_num);
  10. int data = atoi((LPCTSTR)m_data);
  11. int i;
  12. if(i < num_rows_cols)
  13. {
  14. magic_array[row_num-1][col_num-1] = data;
  15. i++;
  16. }
  17. if(i >= num_rows_cols)
  18. m_enter_data_button.EnableWindow(false);
  19.  
  20. }
and when I initialize "i" to zero, i get the error message:
error C2252: 'i' : pure specifier can only be specified for functions
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 22
Reputation: Auto is an unknown quantity at this point 
Solved Threads: 0
Auto Auto is offline Offline
Newbie Poster

Re: help with "disabling" a button

 
0
  #2
Mar 28th, 2005
I may be wrong on this, but I'll take a crack it. It looks as if you're declaring an int i, assigning it no value which in turn will leave some unknown garbage data. And since your array is probably not too large num_row_cols will probably be lower than the garbage data which can be as high as 65,536.
int i;
if(i < num_rows_cols)
{
magic_array[row_num-1][col_num-1] = data;
   i++;
}
if(i >= num_rows_cols)
   m_enter_data_button.EnableWindow(false);

Edit: My apologies I didn't see the statement under your code.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 46
Reputation: blackdove is an unknown quantity at this point 
Solved Threads: 0
blackdove blackdove is offline Offline
Light Poster

Re: help with "disabling" a button

 
0
  #3
Mar 28th, 2005
i know i need to initialize it, but i must be doing it wrong, because whenever i intitialize it to zero i get an error message.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 22
Reputation: Auto is an unknown quantity at this point 
Solved Threads: 0
Auto Auto is offline Offline
Newbie Poster

Re: help with "disabling" a button

 
0
  #4
Mar 28th, 2005
I looked up this error and here is what I found.

Error:
pure specifier can only be specified for functions

Suggestion
In a class definition, you are not allowed to set variables or call functions (including other class constructors). Thus code such as int a = 0; and vector<int> b(10); is not allowed. Setting variables and calling functions should be done in constructors. To make a function a pure virtual function, one that must be overridden by a derived class, set the function =0, as in void Draw() = 0;
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 46
Reputation: blackdove is an unknown quantity at this point 
Solved Threads: 0
blackdove blackdove is offline Offline
Light Poster

Re: help with "disabling" a button

 
0
  #5
Mar 28th, 2005
okay i'll try that thx.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 46
Reputation: blackdove is an unknown quantity at this point 
Solved Threads: 0
blackdove blackdove is offline Offline
Light Poster

Re: help with "disabling" a button

 
0
  #6
Mar 29th, 2005
I still can't get it right. Could someone give me an example of something like what im trying to do? Or atleast tell me exactly what i have wrong. This is the only way i can think of to get the button to disable, and obviously its wrong.
My professor told me to define all of my variables in the header file directly before the "protected" area. And when i put the variable "i" there, that's when i get the error that i posted above.

Thx in advance for any help that you may offer me.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC