|
void CPerspectiveDoc::OnShowMsg(CCmdUI* pCmdUI)
{
char str1[150];
CString strValue;
//strValue.SetLength(100);
strValue.Format("%s", message.GetString());
//sprintf(str1, "%s",message.GetString());
pCmdUI->Enable(TRUE);
pCmdUI->SetText(strValue);
CDC* pDC = m_wndStatusBar.GetDC();
CSize mSize = pDC->GetTextExtent(strValue);
m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_NORMAL, mSize.cx);
//m_wndStatusBar.SetPaneInfo(1, IDS_MESSAGE, SBPS_STRETCH, len);
}
When I add this code I got an exception stating ,
'Unhandled exception at 0x7c1d71bb (MFC71.dll) in Perspective.exe: 0xC0000005: Access violation writing location 0x00000014.'
When I break this exception, it ends in a class barstat.cpp which is not created by me.
Also this exception occurs only when we add the status bar variable(m_wndStatusBar) to this class CPerspectiveDoc.
The Status Bar Pane is created in some other class.
How to resolve this?
Pls help
-- modified at 4:01 Tuesday 6th February, 2007
|
|
|
|
|
Oh, dear friend, I think u've made a mistake! In my opinion, the CDoc class in your project is constructed before the CMainFrame class, and the status bar is created in Oncreate() function of the CMainFrame class. So, you'd used a status object before you created it. Am I right?
OK, U can resolve this by many methods.there r 2 simple resolutions follow:
1. U can do this in the CMainFrame class after the status bar object is created.
2. U can do it in the CView class as the same.
-- modified at 4:36 Tuesday 6th February, 2007
freeman
|
|
|
|
|
Hello,everyone! I want to ask a question about my practice. I created some string entries in the string table such as IDS_STRING1,IDS_STRING2,IDS_STRING3... .Now, I want to load one of them for the CString object by a string I specified. for example, the string I specified was "IDS_STRING1" , how can I convert "IDS_STRING1" to the right Resource ID? Thank u so much!
freeman
|
|
|
|
|
i'm not sure at all to understand what you want.
if i'm right, you want to get the actual string behing the string ID in the resource string table.
for this, 2 solutions :
CString::LoadString()
or
CString::Format()
|
|
|
|
|
Thank u for your reply, I wish u a good day!
freeman
|
|
|
|
|
See if this answers your question....
Answer 1:
CString Str;
Str.Format(IDS_STRING1);
Answer 2:
CString str;
if (! str.LoadString( IDS_STRING1 ))
{
AfxMessageBox("Error Loading String: IDS_STRING1");
...
}
|
|
|
|
|
Thank u all the same!
freeman
|
|
|
|
|
In additional with other members after reads Resource with CString::Load on the loop you can read all strings for example
IDS_STRING1 has "one,two,three,four,"
now on a loop set for find , in this string and reads all strings
|
|
|
|
|
Thanks! God will bless u.
freeman
|
|
|
|
|
You're welcome
|
|
|
|
|
There's no automatic way to do that. You'll basically need a lookup table to know that "IDS_STRING1" should be mapped to 101 or whatever the numeric value is.
|
|
|
|
|
Thank u, u get my idear!I know how to resolve it now.
freeman
|
|
|
|
|
Hi
friends
can any one please tell me how to convert string data from
utf-8 to unicode 16 bit format?
i need it ,its very urgent.
Thanx
tunu
|
|
|
|
|
use WideCharToMultiByte()
nave
|
|
|
|
|
|
Actually, MultiByteToWideChar() is the right API. WideCharToMultiByte() goes the other way.
|
|
|
|
|
Hi!
I can not figure this one out: I have two MFC-projects. One compiles in VS 2002 and one in VS 2005.
At a certain point I have this line in both projects:
<br />
const TCHAR szHeaders[] =<br />
_T("Accept: text/*\r\nUser-Agent: XYZ\r\n");<br />
Now, in VS 2002 \r\n is intrepreted as a normal CRLF but not in VS 2005 it seems.
(MS: "The _TCHAR data type is defined conditionally in Tchar.h. If the symbol _UNICODE is defined for your build, _TCHAR is defined as wchar_t; otherwise, for single-byte and MBCS builds, it is defined as char.")
I have tried #undef _UNICODE without any luck! Debugger shows two squares: □□ like when !isascii() and does not break the line. Is it just the debugger or some conspericy going on here?
-- modified at 7:35 Monday 5th February, 2007
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|
|
Could it be a mix up between the plain text return and the rich text return?
Brad
Australian
- Christian Graus on "Best books for VBscript"
A big thick one, so you can whack yourself on the head with it.
|
|
|
|
|
Or some wierd compiler bug? - I mean since I have not added/removed any defines etc.
Hmmmm...
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|
|
It looks like this thread has been *handled* by the Policy Control Authority. Did he actually post this in the lounge?
Dario: How is "directory" in French? (I mean a file system directory).
John Simmons: "zee file holdaire thingie"
|
|
|
|
|
*sniff* smells like something for the C++ forum...
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
He can't catch a breal can he....
Brad
Australian
- Christian Graus on "Best books for VBscript"
A big thick one, so you can whack yourself on the head with it.
|
|
|
|
|
It's clearly just a rant.
Gary Kirkham
Forever Forgiven and Alive in the Spirit
He is no fool who gives what he cannot keep to gain what he cannot lose. - Jim Elliot
Me blog, You read
|
|
|
|
|
Michael Mogensen wrote:
Now, in VS 2002 \r\n is intrepreted as a normal CRLF but not in VS 2005 it seems.
How are you verifying this?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Just by looking into the buffer at a breakpoint after assignment/creation. It MUST be something I've missed but I just can't see it! I'll go into the hex tonight.
Regards,
Michael Mogensen, mm it-consult dk.
><((((º> ·.¸¸.· ><((((º> ·.¸¸.· ><((((º>
|
|
|
|