|
Do you need to SHGetFileInfo ?
|
|
|
|
|
hi all,
in the dialog we are initializing through initdialog , as like in the form how we do that?
thanks
panthal
|
|
|
|
|
look for OnInitialUpdate
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
thank u nelek, just now i found that.
thanks for ur response
panthal
|
|
|
|
|
Hi,
I need to use a function that uses an array of pointers to a base class, and inside the function handles the pointer according to it's real type (Tha actual type is a derived class).
But i get an error when i call the function :
"Object0124.cpp(1905) : error C2664: 'InsertOutputData' : cannot convert parameter 1 from 'class Array<class Object0124::CDerived *,class Object0124::CDerived *> *' to 'class Array<class Object0124::CBase *,class Object0124::CBase *> &'
A reference that is not to 'const' cannot be bound to a non-lvalue"
I hope that it's clear:
h. file
----------
class CBase
{
int x;
CBase(){x=0;}
};
class CDrived :public base
{
int y;
CString z;
CDrived(){y = 0;z = _T("");}
};
typedef Array<CBase*,CBase *> m_CBaseArray;
typedef Array<CDerived*,CDerived *> m_CderivedArray;
void InsertOutputData(CBaseArray &arrInput,int Mode);
cpp file
---------
void Func()
{
CderivedArray arr;
CDrived var;
var.x = 10;
var.y = 16.533;
var.z = "value"
arr.Add(var)
InsertOutputData(&arr);//or InsertOutputData(arr);//error C2664
}
void InsertOutputData(CBaseArray & arrInput,int mode)
{
for(i = 0;j = 1; j < arrInput.GetSize(),!; j++)
{
if((arrInput.GetAt(i)->x != arrInput.GetAt(j)->x))
{
if(arrInput.GetAt(i)->y == arrInput.GetAt(j)->y)
{
//do something
}
}
}
}
Can anyone tell me what am i doing wrong???
-- modified at 5:22 Tuesday 6th November, 2007
|
|
|
|
|
Your code is unreadable. Check point 5 here[^]
|
|
|
|
|
mrobeda wrote: Can anyone tell me what am i doing wrong???
You treat
typedef Array<CBase*,CBase *> m_CBaseArray;
typedef Array<CDerived*,CDerived *> m_CderivedArray; as being related types.
They are not. The fact that CDerived is related to CBase does not make the container types releated.
What is related, though, are the dereferenced items of both containers.
What is Array<T>, btw?
A bastardized STL-class?
MFcs CArray, the handicapped step-brother of a STL-class?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Array - inherit from MFC's CArray and created my AArray.
So how can i use a generic array that can handle different type of objects?
I need that the fuction will get each time a different type of object in the array.
|
|
|
|
|
mrobeda wrote: So how can i use a generic array that can handle different type of objects?
You just have to use an array that is declared as an array of pointers to your base class. Then you can fill it with pointers to child classes if you want to (but you need to create the objects dynamically with new, and not forget to delete them afterwards). That's the power of polymorphism
|
|
|
|
|
mrobeda wrote: So how can i use a generic array that can handle different type of objects?
Personally, I would create a pure abstract base class (Interface) for the object-types I would need to put in the container.
You could then either use RTTI/dynamic_cast or a self-devised mechanism of type-determination.
May I ask if you come from a scripting-language background?
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
hi,
Thanks for your help, i took Cedric Moonen advise (part of it).
btw - the answear to your question is no.
|
|
|
|
|
On my MFC application I read file and do some process on it. Here is the code I used to open and read only.
<br />
CFile srf_ReadFile;<br />
char * srf_FilePath = "ReadFile_001.txt";<br />
if(srf_ReadFile.Open(srf_FilePath, CFile::modeRead))<br />
{<br />
}<br />
So, the file should be always in the same folder which the project/solution contain. If I want to read another file, say ReadFile_002.txt, have to do it manually, go to the code and gives the new file name.
char * srf_FilePath = "ReadFile_002.txt";
It is too boring. So I want to make it more reliable to use. I want to add a browse button(I think that is the correct word, which is used to find the file in Windows) and set it as the file which I want to read.
How can I do it. Can you guys explain.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: I want to add a browse button(I think that is the correct word, which is used to find the file in Windows) and set it as the file which I want to read.
GetOpenFileName[^] will help you.
|
|
|
|
|
Thanks, I read it and little bit confusing. Do you know any place I can see a small worked example.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: I read it
Mmmh, if you had scrolled down the page, there is a link to an exemple here[^].
|
|
|
|
|
Thanks pal, now I have two such examples. I'll be if I got any issue there.
Thanks again.
I appreciate your help all the time...
Eranga
|
|
|
|
|
hai...
in codeproject site itself so many examples are there.....y cant u go and search...any how... refer this <pre<a href="http://www.codeproject.com/buttonctrl/CBrowseCtrl.asp">http://www.codeproject.com/buttonctrl/CBrowseCtrl.asp</a>[<a href="http://www.codeproject.com/buttonctrl/CBrowseCtrl.asp" target="_blank" title="New Window">^</a>]>
Born to win...!
|
|
|
|
|
What about calling CFileDialog ??? Would it help you?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Actually all the worked examples I've found are too complected for me. Is there any easy way. All of the program use a edit box and use it for browsing. I'm not clear what's happened there.
I appreciate your help all the time...
Eranga
|
|
|
|
|
There are not difficult maybe you need to more work for learn them.
|
|
|
|
|
Yes, it's true. Those things are really new for me. That's why I'm stuck on different steps.
I appreciate your help all the time...
Eranga
|
|
|
|
|
I think if you buy a book about mfc is helpful for you.
|
|
|
|
|
donot get confused.
do as nelek has suggested using a CFileDialog. i had been using it since years.
see the example here.
CFileDialog dlg(true,NULL,_T("*.*"),OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"textfiles(*.*)|*.*|*.*");<br />
dlg.m_ofn.lpstrTitle="select the required file";<br />
if(dlg.DoModal()!=IDCANCEL)<br />
{<br />
CString filename=dlg.GetPathName();<br />
}<br />
else<br />
return;
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
|