|
I do have a message loop.Adding a message box creates a temporary message loop,right.So i replaced the messagebox with a message loop,but it hangs.
Could you pl help me...
|
|
|
|
|
The third parameter to CreateEvent is whether the event is initially signalled. If you are trying to wait for ImageEventHandle, it won't since it's already signalled.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Anyone knows how to retreive/store an image in a MDB file? I'm using CByteArray and it does not work! I know there's an article on CP that is using CLongBinary but it does not suit my needs (it uses a tmp file, I need an HBITMAP).
HBITMAP CdbCieSet::GetLogo()
{
CByteArray Array;
Array.Copy( m_logo );
if( Array.GetSize() <= 0 )
{
return NULL;
}
// the header of BLOB is OLE stuff like "Paint Brush Application" .... ecc..
// the len is 78 byte ( I do not know for other headers )
int HeaderLen = 78 + sizeof(BITMAPFILEHEADER);
Array.RemoveAt( 0, HeaderLen ); // I cut all Headers
// some BMP information
BITMAPINFOHEADER &bmiHeader = *(LPBITMAPINFOHEADER)Array.GetData() ;
BITMAPINFO &bmInfo = *(LPBITMAPINFO)Array.GetData() ;
// If bmiHeader.biClrUsed is zero we have to infer the number
// of colors from the number of bits used to specify it.
int nColors = bmiHeader.biClrUsed ? bmiHeader.biClrUsed : 1 << bmiHeader.biBitCount;
LPVOID lpDIBBits;
if( bmInfo.bmiHeader.biBitCount > 8 )
{
lpDIBBits = (LPVOID)((LPDWORD)(bmInfo.bmiColors + bmInfo.bmiHeader.biClrUsed) +
((bmInfo.bmiHeader.biCompression == BI_BITFIELDS) ? 3 : 0));
}
else
{
lpDIBBits = (LPVOID)(bmInfo.bmiColors + nColors);
}
CClientDC dc(NULL);
HBITMAP hBmp = CreateDIBitmap( dc.m_hDC, // handle to device context
&bmiHeader, // pointer to bitmap size and format data
CBM_INIT, // initialization flag
lpDIBBits, // pointer to initialization data
&bmInfo, // pointer to bitmap color-format data
DIB_RGB_COLORS); // color-data usage
Array.RemoveAll(); //Release Memory
return hBmp;
}
BOOL CdbCieSet::SetLogo(CString szFileName)
{
CByteArray BlobFile;
CFile aFile(szFileName,CFile::modeRead);
BlobFile.SetSize(aFile.GetLength());
aFile.Read(BlobFile.GetData(),aFile.GetLength());
aFile.Close();
m_logo.Copy(BlobFile);
SetFieldDirty(&m_logo);
SetFieldNull(&m_logo,FALSE);
return TRUE;
}
Thanks!
---------------
http://www.edovia.com
|
|
|
|
|
nobody knows?
---------------
http://www.edovia.com
|
|
|
|
|
I want to create a DLL which will be used in an EXE. In the DLL, I want to export some simple classes, but they use MFC's CString as memebers. What kind of DLL should I create, how to export them, and import them. Should I use AFX_EXT_CLASS instead ? However, I'm planning remove MFC dependency by using some kind of CString clone in the future.
I tried use __declspec(dllexport) and __declspec(dllimport) with created the DLL as regular MFC DLL. However, in using it, in deleting the heap allocated instances, it has memory violation.
Can anyone tell me the hints ?
|
|
|
|
|
Use the multithreaded DLL version of the C run-time library in both the DLL and the EXE. This will ensure only one heap is used globally.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I checked both the EXE and the DLL are using Debug Multithreaded DLL.
|
|
|
|
|
You must create a MFC Extension Dll and declare your classes with the AFX_EXT_CLASSES like this:
class AFX_EXT_CLASS CMyClass
{
....
};
Best regards,
Alexandru Savescu
|
|
|
|
|
hi,
how do i know when users dial-up to the internet (if success), and when they disconnect from internet ????
thanks !
lenhan
|
|
|
|
|
Check internet part in CP,you have to use sockrt programming codes:
http://www.codeproject.com/internet/
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
Linking...
mfcs70d.lib(stdafx.obj) : fatal error LNK1000: Internal error during Pass2
Version 7.00.9466
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 1031C9BE (10300000) "C:\Program Files\Microsoft Visual Studio .NET\Common7\ide\mspdb70.dll"
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 42306940
CONTEXT:
Eax = 10002F4A Esp = 0012E940
Ebx = 10003F4A Ebp = 0012EA7C
Ecx = 023EFEF0 Esi = 02257090
Edx = 022FAC18 Edi = 023EFEEC
Eip = 1031C9BE EFlags = 00010202
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 00000038 SegGs = 00000000
Dr0 = 0012E940 Dr3 = 10003F4A
Dr1 = 0012EA7C Dr6 = 023EFEF0
I just suddenly started getting this. It is happening in multiple projects.... not *all*. Is that a MFC dll? One common thread seems to be that all the ones that won't compile use MFC.
The debug version is the only one that gives this error. Release works fine...
Any ideas??
Thanks
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
I just suddenly started getting this. It is happening in multiple projects.... not *all*. Is that a MFC dll?
Ehh, "foo"? No, it's an error (a terminal bug) in the linker.
Reading the MS NG microsoft.public.dotnet.languages.vc I can only come to the conclusion that this release should never have happened. It contains so many (terminal) bugs that it's apparent their so-called QA was on vacation this year also.
For a more authorative answer you should try to post this to that NG (and watch the "maybe fixed in the next version" comment you'll get from MS).
++luck;
/Mike
|
|
|
|
|
Did post it there last night, about the same time I posted here. Haven't got an answer there yet.
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
Yup, you have hit an internal bug in the linker. Try a rebuild all.
That MSPDB70.DLL is probably a common DLL they use to support the .PDB debug files.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Did a full rebuild, made no difference. Still fails in the linking
Adam Clauss
cabadam@tamu.edu
|
|
|
|
|
I do some draw action:
void CMyView::OnPaint()
{
CPaintDC dc(this); // device context for painting
if( m_bDraw == FALSE )
return;
/**/
CDC* pDC = GetDC();
CDC cacheDC;
VERIFY( cacheDC.CreateCompatibleDC( pDC ));
if( m_pBitmap == NULL )
{
m_pBitmap = new CBitmap;
VERIFY( m_pBitmap->CreateCompatibleBitmap( pDC, m_ClientRect.Width(), m_ClientRect.Height() ) );
}
CBitmap* pOldBmp = cacheDC.SelectObject( m_pBitmap );
//Draw background
CRect rect( m_ClientRect );
cacheDC.FillSolidRect( &rect, RGB(255, 255, 255) );
//cacheDC.Rectangle( rect );
cacheDC.Draw3dRect( &rect, RGB( 0, 0, 0 ), RGB( 255, 255, 255 ) );
//!! Some draw actions here, use cacheDC
pDC->BitBlt( m_ClientRect.left,
m_ClientRect.top,
m_ClientRect.Width(),
m_ClientRect.Height(),
&cacheDC, 0, 0, SRCCOPY );
cacheDC.SelectObject( pOldBmp );
cacheDC.DeleteDC();
}
When I open tha "TaskManager", I notice that the memory usage of My app is increase, what's wrong with my draw method?
I'm amumu, and you?
|
|
|
|
|
You are not deleting your m_pBitmap after you are done with it. Your code should look like this:
cacheDC.SelectObject( pOldBmp );
cacheDC.DeleteDC();
m_pBitmap->DeleteObject();
|
|
|
|
|
1.I have tried your method, Now, if I send the WM_PAINT to view on mouse click, it seems no effect, but if I delete the clause, it can work properly.
2.If you choose a new object for CDC, for example CPen, CBrush, etc, must you do the DeleteObject() on exit?
3.If I use the this->GetDC() to draw directly, does it cause memory leak or allocated but not freed? I notice the memory is increasing when use the view's CDC directly.
I'm amumu, and you?
|
|
|
|
|
qf0421 wrote:
1.I have tried your method, Now, if I send the WM_PAINT to view on mouse click, it seems no effect, but if I delete the clause, it can work properly.
Do not send a WM_PAINT message directly, instead do either one of these two things to force a repaint.
InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd);
RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
qf0421 wrote:
2.If you choose a new object for CDC, for example CPen, CBrush, etc, must you do the DeleteObject() on exit?
Yes, if you create a new brush, pen, palette or bitmap, you must select the original GDI Object back into the DC, and then delete your GDI Object that you allocated.
qf0421 wrote:
3.If I use the this->GetDC() to draw directly, does it cause memory leak or allocated but not freed? I notice the memory is increasing when use the view's CDC directly.
You should not call GetDC from inside of your paint handler. You should use BeginPaint, or the CPaintDC (Which internally calls BeginPaint). Then when you are done with a DC you need to release the DC, otherwise it will use up system resources. If you call BeginPaint to get the DC, then you will need to call EndPaint to release the Dc. If you call GetDC, GetWindowDC, or GetDCEx then you will need to call ReleaseDC to free the DC resource.
|
|
|
|
|
Thank you for your help and code, I have got it
I'm amumu, and you?
|
|
|
|
|
You also need to call
pDC->ReleaseDC() ;
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
How Can I get MFC support in ATL EXE COM Server project?
I want my program like MS Word!
|
|
|
|
|
Help,
The post that I've been dreading. A post that I do not know the answer to. One of my members wants to know how to create custom types, eg. an unsigned int of 8 bits
http://www.jyse.com/phpBB2/viewtopic.php?p=129#129
please help.
|
|
|
|
|
Create a type using bitfields. For example
struct strtype
{
unsigned p1:2;
unsigned p2:3;
unsigned p3:5;
unsigned p4:5;
};
Creates a struct which holds four fields, one of two bits, one of three, and two of five.
Naturally I'd presume you'd create a class and provide all the operators necessary to deal with it, like operator =, operator <, etc.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Christian, I hope you don't mind me cutting and pasting this onto Jyse.com
|
|
|
|
|