Click here to Skip to main content
14,327,460 members
Rate this:
Please Sign up or sign in to vote.
See more:

Can some one please help me find more details about how this works : ((CEditView*)m_viewList.GetHead()). I couldn't find much details about how viewList is maintained.

It seems like something has changed between Windows XP and Windows-7 [not sure of Vista] w.r.t. this functionality. I am using VC2005. I see in Windows7 that :

((CEditView*)m_viewList.GetHead())->SerializeRaw(ar); fails to write anything in Windows7. The reason being :
((CEditView*)m_viewList.GetHead())->LockBuffer(); returns an empty string and bufferLength being 1 [end of line character I presume].

Though, they work fine on WindowsXP. Hence, I am thinking something must have changed w.r.t. how the viewList is maintained.

Thanks in advance,
Updated 22-Oct-10 22:58pm
Rate this:
Please Sign up or sign in to vote.

Solution 1

Presumably m_viewList is some type of MFC list containing CEditViews. Take a look at the MSDN documentation for the class you are using to see if anything has changed recently. You could also try breaking your code down into its constituent parts, so instead of writing:

you have something like:
CEditView* pView = m_viewList.GetHead();

Then run it through your debugger to see what values you are receiving.
GoonerGator 25-Oct-10 15:36pm
Hi Richard,

Sorry, I had been staring at this code for entire day and missed indicating what m_viewList is. It is basically a CPtrList type; a member of CDocument class.

I don't have Windows-7 installed in the same machine where my code base is present. I am relying on logs for analysis. This is what I have been able to put together :

I have overloaded function : CMyDocument::Serialize(CArchieve ar)
In Windows-XP, all I required to do was call SerializeRaw this way : ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar); // ar is the CArchieve mfc class which is an argument to serialize.

In Windows-7, it is failing. On further inspection, I observed that the following line which should be retrieving the data is failing :
LPCTSTR lpszText = ((CEditView*)m_viewList.GetHead())->LockBuffer(); // misnomer !!
It internally calls GetWindowText() and GetWindowSize(). I tried to GetWindowText Manually and was half successful. For some reason, CArchieve would end up having some garbage data at the beginning.

Please indicate if you have any-thing that you might want me to try. Right now, I am completely stuck..

Rate this:
Please Sign up or sign in to vote.

Solution 2

This is a very wild guess, but it could be a permissions issue. And possibly UAC related. To check that out, run your app as Administrator to see if the problem goes away.
GoonerGator 25-Oct-10 14:48pm
Hi Nishant, thanks for the reply. That was my first guess too.. But it turns out that its not a UAC related issue since I am having all the rights and still able to reproduce it.
Nish Nishant 25-Oct-10 14:50pm
Remember that under Vista/Windows 7, even if you are logged in as Administrator, you are still not running as Administrator unless you explicitly escalate rights (example by running as Administrator from Explorer). If you've already done this too, please ignore this comment.
Rate this:
Please Sign up or sign in to vote.

Solution 3

LPCTSTR lpszText = ((CEditView*)m_viewList.GetHead())->LockBuffer(); // misnomer !!

Try breaking this down into its constituent parts so you can see the results at each stage, such as:
LPCTSTR lpszText;
CEditView* pView;
pView = (CEditView*)m_viewList.GetHead();
lpszText = pView->LockBuffer();

At each point you should be able to inspect the content of the variables to check that they are as you expect.

I'm also interested in what you mean by "// misnomer !!"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100