|
I create a MFC project,and print a Bitmap on it,but when run it and want to change the size of the Windows,it just can't,it will bugged and show the warning message below,besides when i move the window,it also show the warning message.
Bebug Assertion Failed!
Program ~~~~~
file:wingdi.cpp
line ~~
for information on how your program can cause an assertion
fail,see the VC++ documentation on asserts.
any one can help me!Please.
Thanks in advance.
modified on Sunday, March 8, 2009 12:44 AM
|
|
|
|
|
Can you show your code that it generates this error?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
void CGobangView::OnDraw(CDC* pDC)
{
CGobangDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_chessboard.LoadBitmap(IDB_ChessBoard); //绑定位图
CGobangView::m_begin.LoadBitmap(IDB_Start);
CGobangView::m_end.LoadBitmap(IDB_Stop);
static int i=0;
if(i==0)
{
CGobangView::Chessboard.CreateCompatibleDC(pDC);
Chessboard.SelectObject(m_chessboard);
CGobangView::Begin.CreateCompatibleDC(pDC);
Begin.SelectObject(m_begin);
CGobangView::End.CreateCompatibleDC(pDC);
End.SelectObject(m_end);
i=1;
}
else
{
}
pDC->BitBlt(0,0,800,600,&Chessboard,0,0,SRCCOPY);
// TODO: add draw code for native data here
}
The above is the code; i only modify the onDraw() function,and The others is the Generated code by MFC wizard.
|
|
|
|
|
What line in wingdi reports an ASSERT or error?
It looks like you have locked something and the window cannot get it for its own drawing.
|
|
|
|
|
Did you check values return of CreateCompatibleDC? what was it?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
for (int d = 0; d<=width-1; d++)
{
str.Format("");
for (int e=0; e<=height-1; e++)
{
Point1.x = d;
Point1.y = e;
Color1 = GetPixel(MemDC,Point1.x,Point1.y);
str1.Format(_T("%x"),Color1);
if ((str1.CompareNoCase(_T("0")) == 0))
{
str.Append(str1);
TillSize[d][e] = 0;
}
else
{
str.Append(_T(""));
}
}
}
for (int d = 0; d<=height-1; d++)
{
str.Format("");
for (int e=0; e<=width-1; e++)
{
str.Append(_T("%d"),TillSize[e][d]);
}
str.Append(_T("\n"));
::AfxMessageBox(str);
FILE* f = fopen("c:\\tillrecord.txt", "a+");
length = strlen(str);
fwrite(str, sizeof(char), length, f);
fclose(f);
}
I have compiled it fine. However when I run the app I get an error which is
File: F:\?????? I have no fdrive
and Line413 Expression:_atl_condVal
Please help.
|
|
|
|
|
FISH786 wrote: str.Append(_T("%d"),TillSize[e][d]);
This statement is wrong. I guess it should be AppendFormat .
FISH786 wrote: str.Format("");
FISH786 wrote: str.Append(_T(""));
You shouldn't be using them like this.
You need to debug and find out in which line the error occurs.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thank you. I will try changing that. Debugging I guess should have been it.
I am sorry. I am just getting into C++ from VB and It's been a nightmare.
Thanks A million.
|
|
|
|
|
Hang on. Don't give up. You will get there.
The guys here at CP will definitely help you on your way.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks. However I have spent the whole day searching on this for loop with bitmaps,arrays and somesort of convertion of bitmap to text and haven't been sucessful.
I have a bitmap in memory. I have been able to tell the location of the text I need and with some good firsttimers luck am sucessful in telling different characters out. This is one of the reasons I am learning C++. However since I am new with this.
My question is
The bitmap is 100 by 20 that I have been able to capture so far.
I have also been able to identify that the character is only using up 6X15 of the space. followed by a consistent gap between characters to form a word or numbers.
My question now is what would be the easiest way to be able to relate that information to a textfile as opposed to a bitmap.
I know it's dumb doing it but if I can get someone's help on this I think I will not be bothering anyone for a while.
Please advice.
|
|
|
|
|
Dear all
I have a project which can be both compiled with VC6 and VC 2005
When I compile it by VC6, the content of LPCSTR is one byte per character
but when I compile the project under VC2005 , I find that each character of LPCSTR is consist of 2 bytes which first byte contains the character data and second byte contains a "0" in it.
thus I cant show the data properly as I want
what happened under VC2005
could you please help me how I can overcome this problem.
Is is about unicode and MCBS
How can I disable it under VC2005
Could you please send me an article for this problem.
I want to become more familiar with UNICODE
thanks in advance
Mahdi
|
|
|
|
|
I never used 2005, but in 2003 you can right-click your project in solution explorer, select Properties, under General you can set the the character set between unicode, MBCS and unset which basicly means simple, everyday, 1 byte per char strings.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
modified on Saturday, March 7, 2009 4:21 PM
|
|
|
|
|
Yes, it is about UNICODE and MBCS as you correctly suspected.
VC6 by default does not use UNICODE , but VC 2005 used UNICODE as the default.
You can disable this through
Project -> Properties -> Configuration Properties -> General -> Character Set .
Here you can choose between UNICODE and MBCS .
On the other side, you can show the data or do any manipulation on UNICODE characters. You just need to use the wide version of the functions or the _t macros.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Chinese character is coming from "GetValue().bstrVal".. Take a look of following code..
bstrString_Dest = m_cpRecordsetSearch->Fields->GetItem("DestinationValue")->GetValue().bstrVal;
bstrString_Dest is declared as _bstr_t..
bstr_t bstrString_Dest
I tried with const whar_t *
const whar_t * bstrString_Dest
but no success..
My question is what data type should i use to hold chinese character in bstrString_Dest????
Thanks all..
|
|
|
|
|
I'd highly recommend you read these two articles:
These should answer your question and will be invaluable for the future, however make sure to read part I first as part II relies on knowledge obtained there.
|
|
|
|
|
A _bstr_t should certainly hold Chinese characters (it's effectively a managed wchar_t) - what's the problem that you're seeing?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
_bstr_t did hold chinese character.. But when i see the data using watch or print to any file it shows "????" only... Chinese fonts are definately installed in my system..As i'm reading from database and i can vivdly see chinese character in database.
Do i further need to typecast it??
Thanks..
|
|
|
|
|
How are you writing it to a file?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Now using this..
(char *)(wchar_t*)bstrString_Dest
|
|
|
|
|
As I asked before, "How are you writing it to a file?"
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm writing in ini file..Also i'm displaying in messagebox..Say the data is "Abc(Some chinese character)"
MessageBoxW(0, (wchar_t*)bstrString_Dest, 0, 0);
The messagebox prints "Abc(square brackets)".
WritePrivateProfileString(pszSection,pszKey,(char *)(wchar_t*)bstrString_Dest,
pszinipath);
And this prints "A" only...
|
|
|
|
|
gothic_coder wrote: The messagebox prints "Abc(square brackets)".
It's probably using non-Unicode font? The following code prints the expected ideaographs with Visual Studio 2008 and Windows 7
MessageBoxW(L"丁丂七", L"Test", MB_OK);
gothic_coder wrote: WritePrivateProfileString(pszSection,pszKey,(char *)(wchar_t*)bstrString_Dest,
pszinipath);
That's the ANSI call, so it's no surprise that you can't write Unicode successfully with that call. However, I don't think WritePrivateProfileString will write Unicode anyway.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Alright..
when i copy
MessageBoxW(L"丁丂七", L"Test", MB_OK);
It comes as
MessageBoxW(L"???", L"Test", MB_OK);
So it has something to do with my VC 6 setting..Isn't it..
Can someone throw light on it..
And please Stuart tell me how do i write the data on file (Notepad)???
Thanks
|
|
|
|
|
Well
MessageBoxW(0, (wchar_t *)bstrString_Dest, 0, 0);
giving me right data... Now the problem is how do i print this data to file?? Notepad??
Thanks..
|
|
|
|
|
Hello all,
I have a application where the file properties dialog is inadequate for the task so I want to use mine. There is an API for the application but there is no event for that particular dialog box so I am looking into windows hooks.
What I want to do is to capture this specific dialog box opeing so that I can shut it down and display my own.
I ideally want to do this in c# but from reading some articles, I understand that there is a certain amount i'll have to do in c++...Does anyone have any sample code that will achieve this or know of some good articles that will help? All I can seem to find are articles on keyboard and mouse hooks, I cannot find any articles that help with capturing dialog boxes let along specific dialog boxes of specific applications.
Any help will be appreciated.
Thanks
|
|
|
|