|
I have an MDI application and I implement the serialize function to read data in . In case the File read is not a trusted file , how do i abort the process of displaying the view. i want the document to not show the view but to just display an error message. Thank you .
|
|
|
|
|
I'm french, so I hope you will excuse me for my poor english.
I have an MFC application which load lot of DLL. In this Dll I make allocation with new, so It use the MFC checking system for leak memory.
And when I terminate my application, I free all my librairies with function 'FreeLibrary()'. But If I have some leak memory in a DLL the MFC Dumping Leak will display to me :
Dumping Object->
#File Error#, etc....
I don't have the FileName.
MFC can't find the name of the File (__FILE__) because the memory where the FileName where store was allocate in the DLL where the 'new' is made. So when I call the function 'FreeLibrary()' on my DLL, all memory which containt '__FILE__' were release.
So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application).
Thanks you for reading my question.
|
|
|
|
|
leander wrote:
So how can I do to see my memory leak even if i have call FreeLibrary ? (I must call function FreeLibrary() otherwise I will have lot of problems with my application).
I am not biblically familiar with MFC as I had to lookup exactly what FreeLibrary() does. Anytime you use the new operator to allocate memory on the heap you will need to release it with the delete operator. It appears that the FreeLibrary *only* handles ref counting and will unmap the module from the address space itself, I would belive that you still need to handle the internal allocation/deallocation of memory yourself. Hope this helps.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Cant you turn off FreeLibrary, only for so long as to find the memory leak?
Also, Are the DLLs in debug mode? To completely debug the application, both your application and DLLs should be built in Debug mode.
|
|
|
|
|
I try to turn off the call() to FreeLibrary() to Debug my leak, but it's little complicate to do it, because I have static object how make allocation with a memory manager (only for malloc and free, not for new and delete). So if I don't call the FreeLibrary the destructor off my static object is not call, and i have some crash when I free my memory manager.
So for the moment, to debug leak, I remove the Freeliberary() and I don't release my memory manager to see the leak.
But I hope to find an other solution without changing some code to with memory leak.
My application and my DLL are compile in Debug with option "Multithread DLL"
|
|
|
|
|
I don't understand why failing to call FreeLibrary causes a lot of problems in your app. But that's what I would do: comment out the FreeLibrary calls (temporarily) and see if you can get a better reading on where the leaks are occurring.
If that doesn't work, let me know and I'll help you find the leaks the hard way.
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Hello,
I have created a dll in c that can draw on a picture box. But the problem is that i need to be able to place new lines or rect or ellipses... using the mouse and also be able to move or resize them (using the mouse) after placement. Any ideas???
Thank you in advance
Nicolas Siatras
|
|
|
|
|
Is there any way to create a device context that will let me draw on a bitmap that isn't necessarily the same format as the display device?
For example, if I created a 640 x 480 8-bit bitmap wit CreateDIBSection, could I somehow create a device context to draw text on the bitmap even if the primary display is 24-bit?
|
|
|
|
|
You need a DIBSection. To be honest, there is no reason I can see ever to use anything else. A DIBSection is a DIB, but it can be selected into a DC and drawn on with GDI functions as if it was a DDB.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
When you create a DC with ::CreateCompatibleDC, it basically creates a DC that is ready to support a monochromatic display. It does not create a display that matches the same color format as the display. When you select a bitmap into the memDC, the color depth of the DC is set to the same as what is set in the bitmap.
Then when you use bitblt or stretchblt, the GDI does all of the color conversions for you if you are drawing from a 24 bit color DC to an 8-bit DC.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi everyone,
my knowledge of VC++ is slightly over basic so please be gentle with any responses.
My problem is that I have a generated image array (300x300) of 8-bit data (gray levels) stored in an unsigned char called imagedata (ironically).
I want to display this image on the screen of a dialogue based application but have been failing miserably.
If anyone can let me know what classes and routines I need to use, or even any sample code I can get my hands on, would be much appreciated.
Thanks in advance,
Rooster76
|
|
|
|
|
for a start, have a look at CBitmap::CreateBitmap.
Max.
|
|
|
|
|
you first need to convert that image into a DIB. this is Window's native image type.
1. a DIB is vertically flipped (first pixel is bottom-left)
2. all pixel rows in a DIB must be a multiple of four bytes wide. this may mean you have to add padding bytes to the end of the rows
3. a DIB starts with a BITMAPINFOHEADER struct
4. in an 8-bit DIB, the palette (256 entries in this case) immediately follows the header struct
5. the pixel bytes immediately follow the palette
so, to turn that image of yours in to a DIB:
find out how wide the pixel rows will be (accounting for the row padding), multiple that by the height. add 256 * sizeof(RGBQUAD) for the palette and sizeof(BITMAPINFOHEADER) for the header. allocate that much memory. then, fill in the header, copy the palette, copy the pixel rows (accounting for padding! and the vertical flip), and you're done!
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
Its sooooo eaaassyyyy.....
But then you write graphic apps all the time don't you?
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Roger Allen wrote:
But then you write graphic apps all the time don't you?
yep. but i wrote the ISColormappedToDIB function just once.
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
In CMainFrame file,
I defined CSplitterWnd m_wndSplitter;
and Split a Docounment into two View.
here is code:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) <br />
{<br />
m_wndSplitter.CreateStatic(this,1,2);<br />
<br />
m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CMyFindDialogView),CSize(400,400),pContext);<br />
m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyFindDialogView),CSize(400,400),pContext);<br />
<br />
return 1;<br />
}
In A NEW CLASS ,
I am do :
#include "MainFrm.h" in it's cpp header.
and
i want to do :
<br />
CWnd* m_pHexWnd = CMainFrame::m_wndSplitter.GetPane(0,1);<br />
but faied.
how to do it?
explain: i want get the CWnd* of SplitterWnd'CWnd.
because ,i want use it in a Create(,parameters,A CWnd*) Function.
i feel good.
|
|
|
|
|
Consider GetParent() and AfxGetMainWnd().
Kuphryn
|
|
|
|
|
Don't know it exactly.
can give a example?
Study Together!
|
|
|
|
|
I've got a window with a docking toolbar and blank screen. When I click one of the toolbar buttons, a series of pixels enclosed in a circle appears (this is a simulation model). The first time I run the model, the circle overlays the toolbar, but is positioned correctly afterwards upon a WM_PAINT message (say, when resizing the window). RunModel() and OnDraw()use the same script to draw the circle/pixels. The script creates a rectangle with GetClientRect(), which then is used in the Ellipse() function call to draw the circle.
How can the mispositioning of the circle upon startup be corrected? Thx,
Ralf.
ralf.riedel@usm.edu
|
|
|
|
|
This may be caused by the type of DC your getting from the window.
Are you using a CWindowDC or a CCLientDC or different types in different places?
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
I use GetClientRect(&rectMyClient) to initialize a CRect object for the client region. I then use rectMyClient to center the circle I'm drawing. I do that the first time I draw a circle and everytime a WM_PAINT is sent. Somehow the toolbar region is only considered when a WM_PAINT message is issued. That's why the circle I'm drawing is nicely centered in the white screen area (my bkground is white) when I, say, resize the window, but partly overlays the toolbar when I first display the circle.
One thing: when I run the simulation, I obtain a CDC pointer using CWnd::GetDC(). The CDC pointer is then passed to OnCircleDraw(). Could it be that the CDC pointer used by CView::OnDraw() is different from the one I'm passing to OnCircleDraw()? In other words, could it be that the client area from OnDraw() is of a different dimension from that of OnCircleDraw()?
ralf.riedel@usm.edu
|
|
|
|
|
I need to develop a taskbar application similar to the ones that ships with Microsoft Office, and the standard taskbar. I need it to support all the standard features like: auto hide, docking to all sides of the desktop, resizing, and so on. Does anybody know of some code in CP or elsewhere that I can use as an example or a framework?
Regards,
Victor
phpWebNotes is a page annotation system modelled after php.net.
http://webnotes.sourceforge.net/demo.php[^]
|
|
|
|
|
|
Michael is right. Or you can just build it using a CDialog and be responsive to screen size changes. That's how my product FooBar[^] works.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi!
For reasons too long to explain here (mail me for details) we can not use any standard modal dialog box function, but we occasionaly need to show windows modally and return a result when finished, like ::DialogBox() do.
Therefore I need some advice on what technique would be good/best to implement our own modal window function that returns a value when closed and prohibits activating/focusing the calling (parent) window when running.
Thanks for any input on this matter.
/Johann Gerell
|
|
|
|