Recently I've found a very neat blog that explains how to implement some basic physics of a very similar kind as what you are trying to achieve. Check out Physics engine for dummies for some very useful explanations and code that can get you started. The explanations you can find there on how best to implement collision control are very exhaustive.
Although the code examples do not feature rectangular bricks, I am sure you can adapt them quite easily by stealing the code from the collision control with the outside border. You just need to make sure that you will always have to check all borders, rather than just 1 at a time. However, for a start it may be easier to just use circular bricks and a circular ball.
well, if u insist on it, subclass your web browser control. I think the CExplorer class (generated from web browser activeX) would be derived from CWnd. Handle WM_PAINT or ON_WM_ERASEBKGND messages in it. do your background painting there.
hopefully this may work.
// Explorer .h
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
Are you making a copy of the image list and using that copy as the list view's imagelist? If so, that's the problem.
Each process gets its own copy of the system imagelist. That copy only contains a handful of icons at first. When you query for a file type's icon the first time, the icon is added to your process's copy of the imagelist.
If you use the HIMAGELIST returned by SHGetFileInfo as the list view's image list, and be sure that the list control has LVS_SHAREIMAGELISTS so it doesn't destroy the imagelist unexpectedly, you should be able to use new icons right away as they are added.
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.
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...
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.
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?
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();
if (m_dispatch->CreateDispatch(_T("99AA66456-082d-5b87-0df-51705603gdbd"), &comError))
//Do some stuff here
//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.
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.
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.
David is correct, that's the way to do it, if you don't like his options, then you probably shouldn't have made it virtual, if its not virtual, then the call gets evaluated at runtime according to the pointer.
if not virtual...
CBase* cp = new CDerived();
cp->testApp(); //calls base testApp() because pointer is of type CBase
((CDerived *)cp)->testApp(); //calls derived testApp() because pointer is of type CDerived
..you just have to know exactly what it is you want.
Its not dead, its just the whole purpose behind the "virtual" keyword... that the base method can be overriden... stefan's solution probably works as well, but again, you're overriding a behavior that is designed.
You can invoke methods of base classes by adding the name of that class, separated by '::' to the name of the function you want to call. In doing so you ignore the virtual function table for that call only. You can freely mix calls of that type with normal calls that use the virtual functions, as you can see in the example above.