|
See above communication with SP 24
URL is text
the problem is with .lnk
which is NOT TEXT!!!!
|
|
|
|
|
Did you look inside the file like I suggested?
The best things in life are not things.
|
|
|
|
|
|
But that message just links back here, so it adds nothing to the discusion.
The best things in life are not things.
|
|
|
|
|
|
|
I have a problem into gather information into CStringArray reference :
first , I define a CMap object :
CMap<CString,LPCTSTR,CStringArray*,CStringArray*> m_mapType;
and I insert a new element :
CString sTemp = _T("test value");
CStringArray* psaTest = new CStringArray;
psaTest->Add(sTemp);
m_mapType[_T("index")] = psaTest;
psaTest->RemoveAll();
delete psaTest;
and when I try to read this element :
CStringArray* psaRes = new CStringArray;;
if(m_mapType.Lookup(_T("index"),psaRes))AfxMessageBox("Found index");
else AfxMessageBox("Not found");
if(psaRes->GetSize())AfxMessageBox(psaRes->GetAt(0));
else AfxMessageBox("Empty psaRes");
delete psaRes;
my code says that I found CMap element , but psaRes is empty , why ? Because I put wrong CStringArray reference in Lookup method ?
Thank you .
P.S.
I put here entire code , because I try above code in the same place :
CString sTemp = _T("test value");
CStringArray* psaTest = new CStringArray;
psaTest->Add(sTemp);
m_mapType[_T("index")] = psaTest;
psaTest->RemoveAll();
delete psaTest;
CStringArray* psaRes = new CStringArray;;
if(m_mapType.Lookup(_T("index"),psaRes))AfxMessageBox("Found index");
else AfxMessageBox("Not found");
if(psaRes->GetSize())AfxMessageBox(psaRes->GetAt(0));
else AfxMessageBox("Empty psaRes");
delete psaRes;
|
|
|
|
|
Your CMap holds the pointers to CStringArray. You should enure that those pointers are valid till you retrieve them from map. Here you are deleting CStringArray pointers after inserting them to map. Obviously you will not get what you actually inserted. Delete the pointers only when the map is no longer needed.
|
|
|
|
|
Let's say that somewhere I serialize the map object , how can I retrieve CStringArray values ? Because there I simulate something like that.
|
|
|
|
|
CMap is derived from CObject, thereby Serialize method is there. I am not pretty sure what will happen if the map members are pointers, i mean whether the data it points to get serialized or the pointer itself. However its just a matter of a test app to verify the case. 
|
|
|
|
|
You are putting a pointer to a CStringArray in your map, which means that it always points to the same instance of CStringArray that you were originally using (it's not a copy). And you do something like this:
psaTest->RemoveAll();
just after adding the pointer to the map. So, your CStringArray will be empty.
By the way, you shouldn't do something like this:
CStringArray* psaRes = new CStringArray;
...
...
m_mapType.Lookup(_T("index"),psaRes);
Because in that case you will have a memory leak. There's no need to make a new CStringArray: if the pointer is found in the map, it will be copied into the psaRes pointer (the address will be copied, not the content of course).
BTW, I suggest you take a look at the STL containers (map, list, ...) they are much easier to use (once you are confortable with the syntax).
|
|
|
|
|
Thank you for advice , much people say to me to use STL , I didn't work with , I try to keep all in MFC way .
|
|
|
|
|
I have an MFC application which uses the WebBrowser2 object to view html files and pdf files.
Application works fine in Windows XP but it crashes in Windows 7 when viewing pdf files. This application is built on Windows XP and distributed to XP/7 machines.
I have no available Windows 7 machines for debug as of this moment so I couldn't get any other useful information about the problem.
Anyone else experience this or can maybe point me to something that could shed some light? Thanks
|
|
|
|
|
Hi all. I try to do something , but maybe it's stupid thing ?
I want to draft a CMap object , with key as CString and as values CStringArray , something like this :
CMap<CString,CString&,CStringArray,CStringArray&> m_mapPack;
but I get :
error C2582: 'CStringArray' : 'operator =' function is unavailable
my question is, can I setup an CStringArray value into CMap object ? And how ?
Thank you .
|
|
|
|
|
Without a copy constructor or assignment operator, I do not think that CStringArray is copyable. You may want to derive your own class from it where you can provide one of the aforementioned constructs.
As an alternative, consider an STL solution. Something like:
typedef vector<string> myVector;
typedef map<string, myVector> myMap;
"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
|
|
|
|
|
Thank you for the solution ... if I can , I avoid STL , I try to keep all in MFC way ... hmm ... I write something like that :
CMap<CString,LPCTSTR,CStringArray*,CStringArray*> m_mapType;
it's compile , I'm working with ...
modified on Monday, May 23, 2011 3:25 PM
|
|
|
|
|
The problem with that is that when you add a new element to the map, only a pointer will be copied, not the contents of the array. So you need to keep track of these pointers and make sure they'll be deleted later.
The STL construct suggested above doesn't suffer from these problems, they'd do the copying for you.
I can think of no reason at all why anyone would want to use MFC when there is an easy to use alternative. Much of the MFC library is ancient and in a very bad shape. My personal experience is that, while you don't run into problems often, when you do it can take days to resolve the cause. I know for a fact that back in the time when I still used MFC I've lost weeks of valuable time just due to sloppy programming inside MFC. I've never had any such problems with STL.
|
|
|
|
|
2 threads call same global function at almost same time, the global function looks like
void MyFunction(int iWho)
{
CString cs;
cs.Format("%d",iWho);
edit.SetWindowText(cs);
edit.RedrawWindow();
Sleep(3000);
edit.SetWindowText(cs);
edit.RedrawWindow();
Sleep(3000);
edit.SetWindowText(cs);
edit.RedrawWindow();
Sleep(3000);
}
2 threads pass param 0 and 1 respectively to the function.
I hope that I can see 2 treads call the function in turn.
In other words, '0' and '1' are displayed in turn in some way.
But, at test, '1' appears only when all of 3 '0' are displayed.
Any suggestion for the "in turn" thread test?
.
|
|
|
|
|
Why would you think manipulating a UI control (i.e., edit box) from a secondary thread would be a good idea?
"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
|
|
|
|
|
You cannot force such a behaviour (expecially on a single core machine ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Dual or more cores machine as I use now?
|
|
|
|
|
Well even on multiple cores, there's no way for user code to predict thread scheduling sequence.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
includeh10 wrote: I hope that I can see 2 treads call the function in turn.
Hope away. In software development, there is no room for hope.
FWIW: the macroscopic behavior of threads (at a rate the human eye can discern) often is quite different from their actual, microscopic behavior. That is due to the specific scheduling algorithms implemented in the operating system; there always are some constants (e.g. "time slice") and, at least with Windows, there even is some cheating as far as thread priorities go.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
this kind replies should be thrown into rubbish bin.
|
|
|
|
|
You shouldn't throw away knowledge. Instead you should accept reality as it is.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|