-
May 16th, 2013, 10:34 AM
#1
[RESOLVED] Creating Method with parameters
I am wanting to separate the logic from the visual, but I'm having problems when calling the method that controls the actions of the progress bar timer.
Code:
ifndef PROGRESS_BAR
define PROGRESS_BAR
class Progress_bar{
public:
void set_Progress(ToolStripProgressBar^ progress_bar,
ToolStripStatusLabel^ label,
Timer^ time){
toolStripProgressBar1 = progress_bar;
toolStripStatusLabel1 = label;
timer1 = time;
// Increment the value of the ProgressBar a value of one each time.
this->toolStripProgressBar1->Increment(10);
// Display the textual value of the ProgressBar in the StatusBar control's first panel.
toolStripStatusLabel1->Text = String::Concat( toolStripProgressBar1->Value, "% Loading" );
if ( toolStripProgressBar1->Value == toolStripProgressBar1->Maximum ){
// Stop the timer.
toolStripStatusLabel1->Text = "Completed";
timer1->Stop();
}
}
private: System::Windows::Forms::ToolStripProgressBar^ toolStripProgressBar1;
System::Windows::Forms::ToolStripStatusLabel^ toolStripStatusLabel1;
System::Windows::Forms::Timer^ timer1;
};
# endif
Code:
the way that i´m calling this method on Form1.h
void set_Progress( toolStripProgressBar1, toolStripStatusLabel1 ,timer1);
errors:
Code:
Error 1 error C2182: 'set_Progress' : illegal use of type 'void' h:\cry_dev\programming\c++\school_media\school_media\Form1.h 277
Error 2 error C2078: too many initializers h:\cry_dev\programming\c++\school_media\school_media\Form1.h 277
Error 3 error C2440: 'initializing' : cannot convert from 'System::Windows::Forms::Timer ^' to 'int' h:\cry_dev\programming\c++\school_media\school_media\Form1.h 277
Last edited by crisdeveloper; May 16th, 2013 at 11:27 AM.
-
May 16th, 2013, 11:40 AM
#2
Re: Creating Method with parameters
i forget to call this way:
Code:
ProgressBar increment;
increment.set_Progress(toolStripProgressBar1,toolStripStatusLabel1 ,timer1);
and include the header:
Code:
#include "ProgressBar.h"
but the errors in this time is bigger then before:
Code:
Error 1 error C2146: syntax error : missing ';' before identifier 'PROGRESS_BAR' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 1
Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 1
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 1
Error 4 error C2146: syntax error : missing ';' before identifier 'PROGRESS_BAR' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 5
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 5
Error 6 error C2143: syntax error : missing ';' before '<class-head>' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 5
Error 7 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 5
Error 8 error C2086: 'int PROGRESS_BAR' : redefinition h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 5
Error 9 error C2061: syntax error : identifier 'ToolStripProgressBar' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 10
Error 10 error C3265: cannot declare a managed 'toolStripProgressBar1' in an unmanaged 'Progress_bar' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 43
Error 11 error C3265: cannot declare a managed 'toolStripStatusLabel1' in an unmanaged 'Progress_bar' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 44
Error 12 error C3265: cannot declare a managed 'timer1' in an unmanaged 'Progress_bar' h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 45
Error 13 error C2065: 'progress_bar' : undeclared identifier h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 16
Error 14 error C2065: 'label' : undeclared identifier h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 17
Error 15 error C2065: 'time' : undeclared identifier h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 18
Error 16 error C2653: 'String' : is not a class or namespace name h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 27
Error 17 error C3861: 'Concat': identifier not found h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 27
Error 18 error C1020: unexpected #endif h:\cry_dev\programming\c++\school_media\school_media\ProgressBar.h 51
-
May 16th, 2013, 12:15 PM
#3
Re: Creating Method with parameters
my code now is this:
Code:
class Progress_bar{
public:
void set_Progress(System::Windows::Forms::ToolStripProgressBar^ ProgressBar1,
System::Windows::Forms::ToolStripStatusLabel^ LabelBar1,
System::Windows::Forms::Timer^ timer1)
{
ProgressBar1 = ProgressBar1;
LabelBar1 = LabelBar1;
timer1 = timer1;
// Increment the value of the ProgressBar a value of one each time.
ProgressBar1->Increment(10);
// Display the textual value of the ProgressBar in the StatusBar control's first panel.
LabelBar1->Text = System::String::Concat( ProgressBar1->Value, "% Loading" );
if ( ProgressBar1->Value == ProgressBar1->Maximum ){
// Stop the timer.
LabelBar1->Text = "Completed";
timer1->Stop();
}
}
private:
System::Windows::Forms::ToolStripProgressBar^ ProgressBar1;
System::Windows::Forms::ToolStripStatusLabel^ LabelBar1;
System::Windows::Forms::Timer^ timer1;
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ProgressBar p;
p.set_Progress(ProgressBar1,LabelBar1 ,timer1);
Last edited by crisdeveloper; May 16th, 2013 at 12:24 PM.
-
May 16th, 2013, 12:16 PM
#4
Re: Creating Method with parameters
and i have only 3 errors
Code:
Error 1 error C3265: cannot declare a managed 'ProgressBar1' in an unmanaged 'Progress_bar'
Error 2 error C3265: cannot declare a managed 'LabelBar1' in an unmanaged 'Progress_bar'
Error 3 error C3265: cannot declare a managed 'timer1' in an unmanaged 'Progress_bar'
-
May 16th, 2013, 01:58 PM
#5
Re: Creating Method with parameters
i fixed this errors, for now i need to know how i can call the class ProgressBar to access the method set_Progress() in Person.h.
i tried
ProgressBar p;
ProgressBar* p;
still wrong...
-
May 16th, 2013, 02:48 PM
#6
Re: Creating Method with parameters
Resolved!
i spelled wrong the name of class
before: ProgressBar
now the right form
Progress_bar p;
p.set_Progress(ProgressBar1,LabelBar1 ,timer1);
-
May 25th, 2013, 10:48 PM
#7
Re: [RESOLVED] Creating Method with parameters
Woow Brilliant coding to resolved creating method with parameters
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|