|
U can catch the click in view class
because the message is posted to the CView class by the framework ,not the CMainFrame class
|
|
|
|
|
And when I didn't have any child open ?
|
|
|
|
|
Hello Friends
I am creating a mfc based application which is working fine on WinXP But If I run same application on Win7 then while Starting,a whilte image is appearing and disappearing[ like a white flash image].
But,If I Disable "Enable desktop Composition" option under system dialog named performance Options.Then it is not showing any white flash image.
After that I tried to Disable this option programmatically even,it does but then it fluctuating the screen while startup of application as we are disabling on initializing of application.
So, Any ideas to get rid of this white flash image.
Regards
Y
|
|
|
|
|
Which tools(IDE) did u used created the MFC Application?
applications that created by vc6.0 is not compatible to win7.
I Guess.
|
|
|
|
|
Get the following run time error after making a few changes in my MFC application. Not been able to find where it occurs other than when I click on the OK button of the Main Dialog.
This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while MFCTest.exe has focus.
The output window may have more diagnostic information.
HEAP[MFCTest.exe]: Invalid Address specified to RtlValidateHeap( 003C0000, 003C8E70 )
Windows has triggered a breakpoint in MFCTest.exe.
This may be due to a corruption of the heap, which indicates a bug in MFCTest.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while MFCTest.exe has focus.
The output window may have more diagnostic information.
Object dump complete.
Any suggestions to how to locate this heap problem?
I think I deleted the OK button and then tryied to undo the changes.
grahamfff
|
|
|
|
|
Do you have a handler for the OK button? If so, what's in it?
Does the problem happen when you click the Cancel button?
You mentioned "Main Dialog." Are other dialogs involved?
Does this happen with a basic application, or only after you add other code to it?
Are you linking with other libraries?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
It happens after all the code in the OnBnClose() has run.
I deleted the Cancel button a long time ago.
The are other modal dialogs but they are OK. I think I got confused when I deleted the OnOK() routine and tried to reinstate it. It is using IDOK as a resourse.
Its a big MFC application and I deleted some controls and control variables but seemed to have got in a mess. I can usually sort things out, but this time because its at the program termination phase I am a bit lost as nothing to bebug.
grahamfff
|
|
|
|
|
It's possible the memory corruption is happening way before your OnOK handler is being called; it's just being detected there.
Calling this: http://msdn.microsoft.com/en-us/library/y1132dee%28v=vs.80%29.aspx[^]
at various times will help to localize where this is happening.
Another approach is the Binary Chop Debugging Pattern: Comment out portions of your program and rerun. If the problem remains, the bug isn't in the removed code. This debugging pattern can sometimes localize the bug orders of magnitude faster than trying to find it logically.
Visual Studio 6 had a way to invoke afxCheckMemory () after each operation, which is slow but will find the memory bug when it happens. I haven't seen this facility on later VS versions, though.
|
|
|
|
|
Try enabling the "page heap" for the process. Remember to turn it off when you're done debugging.
Steve
modified 9-Apr-13 2:31am.
|
|
|
|
|
Not done the heap page (as dont know how)
But with the AfxCheckMemory() I get the following, puting the statement in InitDlg() routine.
Again do not understand.
ntdll.dll!7c90120e()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!7c96ee31()
ntdll.dll!7c95f8f4()
ntdll.dll!7c96e94d()
ntdll.dll!7c96f586()
ntdll.dll!7c962fcf()
user32.dll!7e418bd9()
user32.dll!7e41885a()
user32.dll!7e42a013()
user32.dll!7e43e577()
user32.dll!7e42a998()
user32.dll!7e43e577()
> mfc90d.dll!CWnd::DefWindowProcA(unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 1043 + 0x20 bytes C++
mfc90d.dll!CWnd::Default() Line 274 C++
mfc90d.dll!CDialog::HandleInitDialog(unsigned int __formal=723394, unsigned int __formal=723394) Line 673 + 0x8 bytes C++
mfc90d.dll!CWnd::OnWndMsg(unsigned int message=272, unsigned int wParam=723394, long lParam=0, long * pResult=0x0013e2dc) Line 2018 + 0x11 bytes C++
mfc90d.dll!CWnd::WindowProc(unsigned int message=272, unsigned int wParam=723394, long lParam=0) Line 1755 + 0x20 bytes C++
mfc90d.dll!AfxCallWndProc(CWnd * pWnd=0x0013e7b4, HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 240 + 0x1c bytes C++
mfc90d.dll!AfxWndProc(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 403 C++
mfc90d.dll!AfxWndProcBase(HWND__ * hWnd=0x00070a0c, unsigned int nMsg=272, unsigned int wParam=723394, long lParam=0) Line 441 + 0x15 bytes C++
user32.dll!7e418734()
user32.dll!7e418816()
user32.dll!7e42927b()
user32.dll!7e42651a()
user32.dll!7e42683e()
user32.dll!7e439b43()
mfc90d.dll!CWnd::CreateDlgIndirect(const DLGTEMPLATE * lpDialogTemplate=0x00480aa0, CWnd * pParentWnd=0x00000000, HINSTANCE__ * hInst=0x00400000) Line 312 + 0x2a bytes C++
mfc90d.dll!CDialog::DoModal() Line 576 + 0x20 bytes C++
MFCTest.exe!CMFCTestApp::InitInstance() Line 63 + 0xb bytes C++
mfc90d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 37 + 0xd bytes C++
MFCTest.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00161f0a, int nCmdShow=1) Line 30 C++
MFCTest.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C
MFCTest.exe!WinMainCRTStartup() Line 399 C
kernel32.dll!7c81776f()
grahamfff
|
|
|
|
|
The problem has already occurred before your app explodes. The page heap will tell you more, but it probably happens in CMFCTestApp::InitInstance (or something called from there) but before the call to DoModal.
B
Steve
modified 9-Apr-13 17:08pm.
|
|
|
|
|
Thanks for all who posted.
But as I cannot get a handle on the problem which may be due to using an existing MFC application for a simular one. I deleteled some controls and renamed some of the dialogus and classes (including files names) and seem to have done something that has resulted in the basic framework failing.
Perhaps the Close button problem was a 'red herring' and perhaps best to start again and copy over code snipps as could spend ages on this problem and get nowhere. I always found it difficult to reuse an MFC application.
I have checked butons, textboxes dropdown lists etc and the resourses and event handlers but still the problem remains.
grahamfff
|
|
|
|
|
Hai to all,
I am trying to zip the files using minizip. But in
err = zipWriteInFileInZip (zf,buf,size_read) this I got an error like err = 268480608 instead of zero. That's way file is reading only one time, it is not zipping and the zip file is closing.
Please any one help me, how to zip the file using minizip.
Thanks in advance.
|
|
|
|
|
Does that library have a header file of some sort that describes return codes?
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Dear Experts
Previously I could open a file by using following code snippet in Visual C++ 6 :
CString fileName = "c:\\1.bin";
fopen(fileName,"wb");
But now I switched to visual C++ 2005 and activate unicode character set, but above code does not work.
Please give a code snippet that I can use to feed a CString as a array of TCHAR to fopen function.
Thanks
Mahdi
|
|
|
|
|
Hello,
Since you set the property to Unicode Character Set, you can try like this.
CString fileName = L"c:\\1.bin";
CT2CA filen(fileName);
fopen(filen,"wb");
Hope this helps.
Regards,
A. Gopinath.
|
|
|
|
|
|
Use the TCHAR version of fopen . Then the code can be used with Unicode and MBCS builds:
CString fileName = _T("c:\\1.bin");
_tfopen(fileName, _T("wb"));
|
|
|
|
|
Thanks , it works perfect.
|
|
|
|
|
I write a custom symbol component like logomarker symbol ,but i use agg instead of gdi. When I open shape files in arcmap and use my custom symbol to render the data, It is successful. However , when I open geodatabase files,as the same as shape files, It will be fail. It render blank. When I load this data again. It will render with the default symbol correct. Why?
I use aggplus which is encapsulated like GDI+. the main code is follow(full code about main class in attachment):
Aggplus::Graphics *m_pGraphics;
STDMETHODIMP CCartoSymbolMarker::SetupDC(OLE_HANDLE hDC, ITransformation *Transformation)
{
m_ipTrans = Transformation;
m_pGraphics = Graphics::FromHDC((HDC)hDC);
return S_OK;
}
STDMETHODIMP CCartoSymbolMarker:raw(IGeometry *Geometry)
{
if (!Geometry)
return E_POINTER;
IPointPtr spPoint(Geometry);
if (spPoint == NULL)
return E_FAIL;
double x=0, y=0;
FromMapPoint((IDisplayTransformation*)m_ipTrans, spPoint, &x, &y);
Pen myPen(Color(255,0,0,255), 1);
m_pGraphics->DrawRectangle(&myPen, x, y, 10, 20);
return S_OK;
}
STDMETHODIMP CCartoSymbolMarker::ResetDC()
{
delete m_pGraphics;
m_pGraphics = NULL;
return S_OK;
}
Aggplus Graphics class:
Graphics *Graphics::FromHDC(HDC hdc) { return(new Graphics(hdc)); }
Graphics::Graphics(HDC hdc) : m_dwConfigFlags(0)
{
RECT clipBox;
::GetClipBox(hdc, &clipBox);
int nW=clipBox.right-clipBox.left;
int nH=clipBox.bottom-clipBox.top;
ASSERT(nW>0 && nH>0);
z_Create(nW, nH, -4*nW, NULL);
m_dwConfigFlags|=def_flag_G_FromHDC;
m_fromhdc_HDC=hdc;
m_fromhdc_X=clipBox.left;
m_fromhdc_Y=clipBox.top;
}
Graphics::~Graphics()
{
#ifdef def_AP_Update_Dc_at_End
if(m_dwConfigFlags & def_flag_G_FromHDC)
{
BITMAPINFO hDib;
memset(&hDib, 0, sizeof(BITMAPINFO));
hDib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
hDib.bmiHeader.biWidth = m_dwWidth;
hDib.bmiHeader.biHeight = m_dwHeight;
hDib.bmiHeader.biPlanes = 1;
hDib.bmiHeader.biBitCount = 32;
hDib.bmiHeader.biCompression = BI_RGB;
hDib.bmiHeader.biSizeImage = m_dwWidth * m_dwHeight * 4;
#ifndef _X_NODCAlpha_
LPVOID pBits;
HBITMAP hBitmap = CreateDIBSection(m_fromhdc_HDC, &hDib, DIB_RGB_COLORS, &pBits, NULL, 0);
if(!hBitmap) ASSERT(FALSE);
else
{
memcpy(pBits, buffer, m_dwWidth * m_dwHeight * 4);
HDC mdc=CreateCompatibleDC( m_fromhdc_HDC );
if(!mdc) ASSERT(FALSE);
else
{
HBITMAP hbmOld=(HBITMAP)::SelectObject(mdc, hBitmap);
BLENDFUNCTION bln;
bln.BlendOp=AC_SRC_OVER;
bln.BlendFlags=0;
bln.SourceConstantAlpha=255;
bln.AlphaFormat=AC_SRC_ALPHA;
AlphaBlend(m_fromhdc_HDC, m_fromhdc_X, m_fromhdc_Y, m_dwWidth, m_dwHeight, mdc, 0, 0, m_dwWidth, m_dwHeight, bln);
//BitBlt(m_fromhdc_HDC, m_fromhdc_X, m_fromhdc_Y, m_dwWidth, m_dwHeight, mdc, 0, 0, SRCCOPY);
::SelectObject(mdc, hbmOld);
//::GdiFlush();
DeleteDC(mdc);
}
:eleteObject(hBitmap);
}
#else
SetDIBitsToDevice(m_fromhdc_HDC, m_fromhdc_X, m_fromhdc_Y, m_dwWidth, m_dwHeight,
0, 0, 0, m_dwHeight,
buffer, &hDib, DIB_RGB_COLORS);
#endif //_X_NODCAlpha_
}
#endif //def_AP_Update_Dc_at_End
delete(m_agg_pREN);
delete(m_agg_ppixf);
if(!(m_dwConfigFlags&def_flag_G_ExtBuffer))
{
delete(buffer);
}
}
|
|
|
|
|
I am getting assertion in the first line of this function. ( part of wxdebug in BaseClasess lib of DirectShow 8.1) Fine, but the comment does not really say if it is bad to have a mixture of retail / debug library. Of course execution stops.
Interestingly - what is the "double negative" for anyway?
I guess basic C ! and ^ precedence "trick"?
/* Each time we create an object derived from CBaseObject the constructor will
call us to register the creation of the new object. We are passed a string
description which we store away. We return a cookie that the constructor
uses to identify the object when it is destroyed later on. We update the
total number of active objects in the DLL mainly for debugging purposes */
DWORD WINAPI DbgRegisterObjectCreation(const CHAR *szObjectName,
const WCHAR *wszObjectName) {
/* If this fires you have a mixed DEBUG/RETAIL build */
ASSERT(!!szObjectName ^ !!wszObjectName);
/* Create a place holder for this object description */
ObjectDesc *pObject = new ObjectDesc;
ASSERT(pObject);
|
|
|
|
|
The double !! is negating twice that does nothing with bool expressions but converts non-bool expressions to bool. !!szObjectName is basically the equivalent of (bool)szObjectName. Some people like !! more than (bool) because !! doesn't give "low performance because of conversion to bool" warnings with any compilers as far as I know and of course it is easier to type in than (bool). The assert expression in your case is true when exactly one of the parameters is NULL while the other is non-NULL. If both parameters are NULL or none of them is NULL then the assert fires.
|
|
|
|
|
Hi,
Can anybody suggest me how can i convert a string from utf8 (like wchar_t toTranscode[] = L"ناعسالاخخ";) format to ascii (like äÇÚÓÇáÇÎÎ)..
I have tried with the following code ..but when i am trying to print char array pToFill it is blank.
#include "stdio.h"
#include <string.h>
#include "stdlib.h"
#define _CRT_SECURE_NO_WARNINGS
int main()
{
FILE *p = NULL;
size_t len = 0;
unsigned int convertedChars = 0;
int ret;
wchar_t toTranscode[] = L"ناعسالاخخ";
unsigned int wLent = wcslen((const wchar_t*)toTranscode);
int maxCharLen = 6*wLent;
wchar_t* pWideCharBuf;
char* pToFill;
unsigned int i;
pWideCharBuf = (wchar_t*)malloc(wLent+1);
pToFill = (char*)malloc(maxCharLen+1);
for (i = 0; i < wLent; ++i)
pWideCharBuf[i] = toTranscode[i];
pWideCharBuf[wLent] = 0x00;
memset (pToFill, 0, maxCharLen+1);
ret = wcstombs_s(&convertedChars, pToFill, maxCharLen, pWideCharBuf, maxCharLen);
printf("ret is %d\n", ret);
printf("the ascii char is = %s\n", pToFill);
printf("to test\n");
p = fopen("hello.txt", "w");
if (p== NULL) {
printf("Error in opening a file..");
}
len = strlen(pToFill);
fwrite(pToFill, len, 1, p);
fclose(p);
printf("\nWritten Successfuly in the file.\n");
return 0;
}
please help
|
|
|
|
|
I get error 0x2A (EILSEQ ) when trying to convert this string. According to MSDN[^] this means it has encountered a character that it cannot convert.
Use the best guess
|
|
|
|
|
Hi sir,
Can u please suggest me then how can i convert Arabic characters stored in utf-8 format in database to ascii characters in c.
Is there any built-in function through which i can perform conversion from utf-8 to ascii.
Thanks
|
|
|
|
|