|
Michael's given you a good answer. I had exactly the same problem a while ago with drive icons.
Have a look at my article (and especially the comments) for some solutions:
Detecting when drives are added or removed[^]
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Oh yeah, I resolved this problem. After move the set imageList code from the my ListCtrl controls.
But I donot know why it is.
thanks Michael Dunn & Iain Clarke, Warrior Programmer
|
|
|
|
|
Hi all .
Please tell me if I can integrate more object data types into a single MFC data structures ( Array , List or Map ).
If I have an CStringArray object , let's say m_saType , ( CStringArray type ) , and m_saItem ( CStringArray type too ) , and m_saPerson ( CStringArray type too ) ... how can I integrate all togheter into CObList MFC object , because I want to serialize all m_saType, m_saItem, m_saPerson into a single file on disk.
Thank you . I accept any ideea .
|
|
|
|
|
m_saType.Serialize(ar);
m_saItem.Serialize(ar);
m_saPerson.Serialize(ar);
Of course a better way is to declare a CObject derived class CPerson with CString members m_sType, m_sItem, m_sPerson
Implementing Serialize in this class the using a CObList and calling its Serialize...
|
|
|
|
|
#include <afxtempl.h>
class CDataPack : public CObject
{
public:
CStringArray m_saType;
CStringArray m_saItem;
CStringArray m_saPerson;
const CDataPack& operator=(const CDataPack& rdp)
{
m_saType.Copy(rdp.m_saType);
m_saItem.Copy(rdp.m_saItem);
m_saPerson.Copy(rdp.m_saPerson);
return *this;
}
BOOL IsSerializable() const { return TRUE; }
virtual void Serialize(CArchive& ar)
{
m_saType.Serialize(ar);
m_saItem.Serialize(ar);
m_saPerson.Serialize(ar);
}
};
typedef CArray<CDataPack, CDataPack&> CDataPackType;
void AnyFunc()
{
CString strElement(_T("An Element"));
CDataPack pkt;
pkt.m_saType.Add(strElement);
pkt.m_saItem.Add(strElement);
pkt.m_saPerson.Add(strElement);
CDataPackType arrData;
arrData.Add(pkt);
CFile file;
CArchive ar(&file, CArchive::store);
arrData.Serialize(ar);
}
If you don't want to use template counterpart, you can also use CObArray or even CPtrArray (or List ones such as CObList, CPtrList, see afxcoll.h). Just beware cleanup of objects.
|
|
|
|
|
Thank you very much ! You are very kind !
And if gave me good ideas , I push my luck and ask more : which structure of collection data you choose if you want to clone 3 SQL tables , every one with one unique key integer type and other fiels is strings , but keep link between tables through those unique key integer ?
|
|
|
|
|
I think, you mean which collection class? If so, Array is more efficient on random access.
I also think, you need to access the elements with Primary Keys/Forein Keys in master-detail relationships.
If you need rows in sorted order, you can fill this array sorted. You can take advantage of SQL's SELECT with ORDER BY clause while filling. If the array is sorted, you can access its items by using binary search to speed up searches.
If you just need to access items by the key, you can simply employ CMap to access its elements with key-value pair.
typedef CMap<int, int, CDataPack, CDataPack&> CDataPackMap;
You need to keep relationships yourself, or maybe, you may create more sophisticated structures.
[edit]BTW, Not at all. [/edit]
|
|
|
|
|
I think that CMap is most good ideea . Thanks again . Best wishes !
|
|
|
|
|
Hi i want to read and write a xml file in MFC dialog based application.
can i get some examples.
Thanks in advance.
|
|
|
|
|
|
|
XMLLite sample ->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
Hi
I have a MFC C++ project that calls a C# COM dll, which is registered on my development machine. However, when I step through the code, and it reaches the CreateDespatch passing in the GUID as the parameter, it throws an error "Invalid class string".
Trying to resolve this issue, I feel that I have reached a dead end, and in need of help. Typically this is caused by the dll not being registered, but it is and I can see in regedit! So, what is causing this problem? Can anyone please help me?
Thanks
|
|
|
|
|
Do you need to pass the string as wide characters (Unicode)?
|
|
|
|
|
CreateDispatch takes a CLSID GUID or a progid String
so - you do have the following entry?
HKCR\CLSID\{GUID}\InprocServer32
as an aside, it's (IMO) significantly easier to use ATL smart pointers than all the hoop-jumping IDispatch imposes ...
|
|
|
|
|
Which of these formats[^] are you using, and what is the exact content of your parameter?
The best things in life are not things.
|
|
|
|
|
Hi
I think it would be easier if I show you the relevant code snippet to see if you can assist me:
m_dispatch = new COLeDispatchDriver();
COleException comError;
if (m_dispatch->CreateDispatch(_T("99AA66456-082d-5b87-0df-51705603gdbd"), &comError))
{
//Do some stuff here
}
else
{
//trap error here
}
What I am seeing is that when it reaches the if condition it jumps to the else part an I see the error message "Invalid class string". From the examples I have seen I thought passing in the GUID in this way is correct. Is it?
|
|
|
|
|
If you look again at the link I gave you, the first parameter (in your case) needs to be a REFCLSID when providing the GUID of a registered class, whereas you have provided a string. You can always use CLSIDFromString() [^] function to do the conversion for you.
BTW when posting code snippets please use the <pre></pre> tags around it to ensure formatting is retained.
The best things in life are not things.
|
|
|
|
|
Sorry, but I must be misunderstanding this because I am unclear what you mean.
I searched for the dll in regedit and found the progid folder. Taking the name that was there along with the period for version 1 it was still throwing the same error.
For instance my test dll I have called TestCSharp that has a class called Test. This is shown in the ProgId folder as TestCSharp.Test. I have placed this as the parameter with period 1.
So, I could do with a little bit of helping hand here.
Thanks
|
|
|
|
|
I have never used the program id, only GUIDs; try what I suggested as it should work.
The best things in life are not things.
|
|
|
|
|
Hi
Sorry for not getting back to you, but I did use your solution and yes you are right it did work. Please excuse me but I am very new to C++!!
However, I have hit another problem whilst I can call my C# COM object it throws an error it says "the file or assembly xxxxxx cannot be loaded or one of its dependencies. The file sepecified can be found". In my C# COM object I am referencing another class, which itself references another class. When I compiled the C# COM Object, the bin file has the other classes as dlls are present.
What am I doing wrong here? I have to be careful here because the referenced referenced class is used elsewhere in the other project. So, I am not sure whether adding a strong key and registering it would break the program elsewhere.
Can you help?
Thanks
|
|
|
|
|
I'm not sure what the issue is here, but it sounds like you have some files missing, or not installed in the correct directories for the Windows loader to find them when they are called. You may also like to consider trying to simplify the structure of your application if at all possible.
The best things in life are not things.
|
|
|
|
|
I'm opening a Modal Dialog inside a Modal Dialog. While destroying the second Dialog, application crashes at the following assert condition:
ASSERT(::IsWindow(m_hWnd))
in the file afxwin2.inl.
How to destroy a Modal Dialog which is popped up inside another modal Dialog?
|
|
|
|
|
pix_programmer wrote: How to destroy a Modal Dialog which is popped up inside another modal Dialog?
It typically "destroys" itself by the user clicking the OK or Cancel button, or pressing the Esc key.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
This ASSERT is telling you the window doesn't exist anymore, like it was already suggested, modal dialogs don't typically get manually destroyed (although they can be).
|
|
|
|