|
i create the CArray in parent function as
CArray <cstring ,="" cstring=""> FArray;
how i have to pass it in the parametr of function ?
|
|
|
|
|
Immunity18 wrote: i create the CArray in parent function as
CArray FArray;
Did you leave out the angle brackets on purpose or by accident.
That should be
CArray < CString , CString& > FArray;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
CArray < CString , CString > FArray; so i have to go
and correct it the second CString ==> CString&
or can I work with that style ?
|
|
|
|
|
Immunity18 wrote: and correct it the second CString ==> CString&
Yes. It needs to be the same everywhere you use the template definition.
That's why a typedef can simplify things. A typedef creates an alias to the type:
typedef CArray< CString , CString &> CMyStringArray;
Now you can use "CMyStringArray" instead of "CArray< CString , CString &>" everywhere...
typedef CArray< CString , CString &> CMyStringArray;
...
double CAnaktisiDlg::FindDF(CString file , CMyStringArray &AFArray)
...
void CAnaktisiDlg::GetDF(CMyStringArray &FArray)
...
CMyStringArray FArray;
...
double retval = FindDF(filestr , FArray);
Makes it cleaner to read IMO but you're free to use the long version of course
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
ok i try to do as you command !
but where i will put typedef ? in .h ?
(for the moment i put it in .cpp )
and i will put it where the #includes or where the are the other declarations
|
|
|
|
|
I have in project.h
void GetDF( CMyStringArray &FArray);
double FindDF(CString file , CMyStringArray &AFArray);
and it pop up me errors
error C2061: syntax error : identifier 'CMyStringArray'
|
|
|
|
|
The typedef needs to be visible to any point in the code it is used -
Any .h file will do, or even at the bottom of your stdafx.h precompiled header file if it's
used all over the place
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
plx plx noob specific language !
|
|
|
|
|
The compiler works top-down - so if you refer to some defined type (class, struct, typedef alias,
#define, etc) then the definitition needs to be above the code that refers to it. That way
the compiler already knows what it means when it sees it.
Typically there's a precompiled header file to make builds faster. Typically this file is called
stdafx.h. In there is all the common stuff used throughout a project so it's a good place to
put anything you want "seen" by the compiler throughout the project.
In your example, if the only place you are reffering to "CMyStringArray" is in one header file
then you could just put the typedef near the top of that file.
Make sense?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yes yes as my before reply i did it I leveled up from 100%noob to 80%noob
|
|
|
|
|
ooooooo ! I leveled up ! \o/ its ok i put it in bottom of stafx.h and works fine thanks again ! mark
|
|
|
|
|
leveled up or down!?
You're welcome!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Oh wait, you said percent noob - that would be up!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
hehehe
thanks god I have you guys here and you fill my big holes in C++ programming
|
|
|
|
|
I have read all the above messages....Great!!!!
just want to add one thing
since the copy constructor for CArray is explict, therefore you are getting this error.
<br />
error C2664: 'GetDF' : cannot convert parameter 1 from 'class CArray' to 'class CArray'<br />
No copy constructor available for class 'CArray'<br />
Error executing cl.exe.<br />
If constructors are explicit then temporary copies will not be created during parameter passing in function calls.
|
|
|
|
|
I am way late, but Mark Salsbery did not use a single C specific word. Every one was C++ specific, as C does not use direct references (a pointer is an indirect reference). Given a choice between a copy and a reference, use a constant reference unless you want the called function to modify the values passed. If a class is not designed to be passed by value (which you are trying to do) then there is probably a good reason.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I have created a modeless dialog with a timer, but the OnTimer() function is never getting called. Is there a problem with the message pump passing the "timer fired" message to a modeless dialog? I have tried the same thing using a modal dialog and it works just fine. Any help would be much appreciated.
mrzappit
|
|
|
|
|
mrzappit wrote: Is there a problem with the message pump passing the "timer fired" message to a modeless dialog?
Only if the UI thread the dialog was created on isn't pumping messages.
What does your SetTimer() call look like? All valid params?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
The SetTimer() call is correct. If I change the dialog to a modal dialog by calling DoModal(), the timer fires correctly. I think it might have something to do with the way I'm setting up my modeless dialog. I follow the MSDN directions (which are rather vague and somewhat scattered), and I follow the tutorial article in Code Project as to how to set up modeless dialogs. I'm not using the CreateDialog() function. Rather, I call Create() to make the window appear and I use DetroyWindow() to close the dialog--I also override the PostNcDestroy() function to clean up my this pointer. Any thoughts?
|
|
|
|
|
From what method of the dialog class are you calling SetTimer()?
Can you post the code fot that call?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I need help with accessing a table in a mutlitable recordset. I have :
3 tables as follows
CString COrderSet::GetDefaultSQL()
{
return _T("[tbladdress],[tblcontact],[tbltest]");
}
and I am trying to add new record to each table individually.
My "m_pSet" that is a joint recordset of these three. How can I get a handle or pointer to each table.
When I do : m_pSet->AddNew() I get a "recordset read-only" error msg. which make sense because it doesn't know where to add a new record. (note that m_pSet is a joint set.)
Please help.
paulo.
|
|
|
|
|
paulosuckow wrote: and I am trying to add new record to each table individually.
But you're not. Your recordset is dealing with three tables, not one. Make a recordset for each table, and add to each accordingly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi all
i have a bunch of classes mostly extended base classes like Form, TabControl...
all of them needs to know abouth each other
in the moment i have
_TabCon = gcnew TabCon( this );
Controls->Add( _TabCon );<br />
...<br />
..<br />
<br />
TabCon::TabCon( MainForm^ F)<br />
{<br />
Form = F;<br />
..<br />
.
so all classes know MainForm and MainForm know all classes
is there a better way ? whit out the need of Form = F; in each class
something like
static global MainFromLink = MainForm;
so that i can reach this from anywhere
MainFrom is
ref class MainForm: public System::Windows::Forms::Form
|
|
|
|
|
Usually the reason for one control's class "needing" to know about another control is because of the data stored in the class, and has nothing to do with the control itself. If this is your situation, then consider collecting the key data together in one "data" class, and accessing that class via the CWinApp object (or a global variable).
|
|
|
|
|
Hmmmm
looks like in the moment :
namespace WhatsUp<br />
{<br />
MainForm::MainForm( )<br />
{<br />
Size = System::Drawing::Size( 600, 600 );<br />
MinimumSize = System::Drawing::Size( 600, 600 );<br />
<br />
_TabCon = gcnew TabCon( this );<br />
Controls->Add( _TabCon );<br />
<br />
_TabCon->_PageStatus = gcnew PageStatus( );<br />
_TabCon->Controls->Add ( _TabCon->_PageStatus ); <br />
<br />
_TabCon->_PageSetup = gcnew PageSetup( );<br />
_TabCon->Controls->Add ( _TabCon->_PageSetup ); <br />
<br />
_PlugLoad = gcnew PlugLoad( this );<br />
_IniLoad = gcnew IniLoad ( this );<br />
}<br />
}<br />
[System::STAThreadAttribute]<br />
int main(array<System::String^ >^ args)<br />
{ <br />
System::Windows::Forms::Application::EnableVisualStyles();<br />
System::Windows::Forms::Application::SetCompatibleTextRenderingDefault(false); <br />
System::Windows::Forms::Application::Run( gcnew WhatsUp::MainForm() );<br />
}<br />
...<br />
..<br />
namespace WhatsUp<br />
{<br />
IniLoad::IniLoad( MainForm^ F )<br />
{<br />
Form = F;<br />
Form->_TabCon->_PageStatus->StatusText->Text += "Proccessing ini File" + System::Environment::NewLine;<br />
PageSetup and PageStatus are derived TabPages
i have a few textboxes on them as output this are populated by
PlugLoad, IniLoad and many others
IniLoad loads an xml cheks it and give singel nodes to PlugLoad for future proccessing and so on
so all classes by it a derived like PageSetup or a base class like IniLoad needs to comunikate whit each other either to write something on screen or to hand over data for future proccessing
fcheng wrote: then consider collecting the key data together in one "data" class
i think this is basicli what MainForm do
it has a referenc / pointer to all used classes
i was basicly hopoing to by abel to prevent
IniLoad::IniLoad( MainForm^ F )
Form = F;
and use instead some global referenc to it but i can´t make managed things global
is there some EASY way to know who has called this class
IniLoad::IniLoad( )
Form = System::SomeFunction->The->oneWho->CalledMe;
whit out to use assembler
|
|
|
|