|
Hey,
I have a fundamental problem.
When I close my (SDI)Application with a CustomToolbar (with an Combobox and CmageList), memoryleaks where detected by the compiler.
<br />
CImageList *pImageList = new CImageList();<br />
<br />
<br />
pImageList->Create(16,16,TRUE,4,4);<br />
...<br />
<br />
How can I solve this problem?
Errormessage:
Detected memory leaks!
Dumping objects ->
{87} client block at 0x00332910, subtype c0, 8 bytes long.
a CImageList object at $00332910, 8 bytes long
Object dump complete.
|
|
|
|
|
delete pImageList; ???
Seriously, you need to store this pointer, and call delete in your destructor. Of course, the leak is trivial ( it is cleaned up as soon as it happens, when the process ends ), but still it's nice to do it right.
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 I call delete pImageList in my Class-Destructor nothing happend!
|
|
|
|
|
How do you mean, nothing happened ?
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
|
|
|
|
|
Ok, I solved my problem, thanx.
--> I create a member-variable in my Class (CImageList *m_pStorePointer) and store the pointer of the CImageList there (m_pStorePointer = pImageList).
In my class-destructor I call m_pStorePointer.DeleteImageList(). THIS WORKS!
But is it nessassary the create a seperat membervariable?
I tried to declare the pImageList variable as a membervariable and called in my function: pImageList = new CImageList(); So the Imagelist is stored in a membervariable. But when I Close my Application I get an exception in my destructor... WHY???
<br />
CMyHxToolbar::~CMyHxToolbar()<br />
{ pImageList->DeleteImageList();<br />
delete pImageList;<br />
<br />
}
|
|
|
|
|
AnTri wrote:
But when I Close my Application I get an exception in my destructor... WHY???
Because you're deleting the image list twice. You need to call pImageList->DeleteImageList(); and you might have to set pImageList to NULL , especially if you're going to re-use it, but you don't need to subsequently delete pImageList; .
-Alex
|
|
|
|
|
When I delete the line "delete pImageList..." the exception-error exists anyway.
<br />
CMyHxToolbar::~CMyHxToolbar()<br />
{<br />
pImageList->DeleteImageList();<br />
}<br />
|
|
|
|
|
Are you sure that the ImageList has not already been deleted at that point?
Have you stepped through with the debugger to find out which line is causing the exception?
What are the details of the exception? If it references memory at 0xC0000005 then it sounds like you're trying to access (possibly delete) something that doesn't exist, such as element i+1 of an array that is i long, or an ImageList.
Have you read up on CImageList::DeleteImageList() in MSDN to make sure you're using it the right way and doing all the things you should do.
Try adding pImageList->AssertValid() above pImageList->DeleteImageList() and running a debug build to make sure your pointer is valid.
Let us know how you get on.
-Alex
|
|
|
|
|
Hi y'all.
How can I change a control with another control, and how can I make an invisible control visible programmatically???
|
|
|
|
|
Change it how ?
ShowWindow(SW_SHOW);
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
|
|
|
|
|
What do you mean change one control with another control? Do you mean like when you click a button to disable a control? If yes, one solution is to add an event handle for the source control.
Kuphryn
|
|
|
|
|
Dennis L wrote:
how can I make an invisible control visible programmatically???
to hise/show
call your
control_Variable.ShowWindow(SW_HIDE);
control_Variable.ShowWindow(SW_SHOW);
Code the Dreams.
|
|
|
|
|
You can , for example, draw a CStatic (give it a real name, not the default one!) and get its CRect.
You can then Create() another Control (say, CEdit ) on top of it.
All the following is completely from head to keys. It probably does not compile:
test.h:
CTest : public CDialog
{
...
CStatic m_Placeholder;
CEdit m_Edit;
...
}
test.cpp:
...
void CTest::Overwrite_static()
{
CRect rect;
m_Placeholder.GetWindowRect(&rect);
m_Edit.Create(youreditstyle, rect, this, 1 )
}
...
This way your m_Edit sits directly on top of m_Placeholder.
I hope this was about what you intended.
--
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
In the Encapsulating Win32 Threads in C++ article on this website[1], I have downloaded the Demo code and loaded it into VC++ (manually, ie one file at a time). However I am getting the following error:
C:\temp\boserver\test\CMyThread.cpp(34) : error C2065: '_T' : undeclared identifier
I am wondering have I done something silly like not included a header file, or a library or something silly of the sort. Thank you for your time,
--Mark
[1] http://www.codeproject.com/threads/thread_win32.asp
|
|
|
|
|
_T (or _TEXT) is used to allow string literals to be compiled as either MBCS or UNICODE, and it is defined in tchar.h as something like:
#ifdef _UNICODE
#define _T(x) L##x
#else
#define _T(x) x
#endif
Dave
|
|
|
|
|
#include <tchar.h>
Michel
<i>It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.</i>
<br> - TreeBeard
|
|
|
|
|
Is there any who can help???
I want a windowobject (works as an graph class) to have its own OnPaint call so that its not the mainframe thats have to make the OnPaint Call. In this way it will work much faster...
Please, I really want this help... Its for studying - Very important...
by the way im new at this CodeProject... it seems to be a cool site...
THANKS!!!!
HUSTLER!!!
|
|
|
|
|
I guess it's one way in VC to solve your problem
1) use Class Wizard to insert a new class in your project,
2) inherit it from CStatic class (or whatever you want),
3) in your new class add a windows message handler for message WM_PAINT,
4) in this handler do what you want
5) change the class declaration of your window object to your new class
Dmitry Timin
|
|
|
|
|
hi all,
I have an image saved into clipboard, it is possible to print it? how?
If I save the file how to print it?
tks!
|
|
|
|
|
Here is a small example that plots a metafile from the clipboard into a DC. This would work with a display DC or a printer DC:
CRect metafile(0, 0, 100, 100);
if (IsClipboardFormatAvailable(CF_METAFILEPICT))
{
GLOBALHANDLE hGMem ;
LPMETAFILEPICT lpMFP ;
OpenClipboard() ;
hGMem = GetClipboardData(CF_METAFILEPICT) ;
lpMFP = (LPMETAFILEPICT)GlobalLock(hGMem) ;
pDC->SaveDC() ;
pDC->SetMapMode(lpMFP->mm) ;
pDC->SetViewportExt(metafile.Width(), metafile.Height()) ;
pDC->SetViewportOrg(metafile.left, metafile.top) ;
pDC->PlayMetaFile(lpMFP->hMF) ;
VERIFY(pDC->RestoreDC(-1)) ;
GlobalUnlock(hGMem) ;
CloseClipboard() ;
}
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!
|
|
|
|
|
Hi.
I would like to scale a progress bar for smaller numbers. For example:
x = 0
y = 999999999
I would lke to update the progress bar such that you will see changes, i.e. progress even though the x is still small. In other words, x = 1000 will update the progress bar just a slightly even though it is not 1% of y.
Is that possible and how do you scale the progress bar for such a slight change?
Thanks,
Kuphryn
|
|
|
|
|
You set the progress bars range to be 0-99999999 and then set it's position. SetRange and maybe SetStep are the methods you need.
http://msdn.microsoft.com[^] is your friend when you want to know how to do something with MFC.
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
|
|
|
|
|
I have a question about TreeCtrl.
When I use mouse right click one item in the TreeCtrl, this item is highlight when the right mouse key is down. But when the right mouse key is up, this item loses highlight, the previous highlight item is highlight again.
How can I keep the item that I right click highlight?
Thanks in advance.
|
|
|
|
|
<br />
void CFileViewTab::OnRclickTreeWorkspace(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
LRESULT lReturn = 0;<br />
CPoint point(GetMessagePos());<br />
ScreenToClient(&point);<br />
CTreeCtrl *pTree = (CTreeCtrl *)GetDlgItem(IDC_TREE_WORKSPACE);<br />
UINT flag;<br />
HTREEITEM hItem;<br />
if ((hItem = pTree->HitTest(point, &flag)) != NULL) {<br />
if (flag & TVHT_ONITEM) {<br />
pTree->SelectItem(hItem);<br />
......<br />
.....<br />
|
|
|
|
|
If you highlight a bunch of Excel files and then right click and select Open from the menu, a single copy of Excel starts up with all files opened. I've been trying to make an MDI app of my own to work this same way, but to no avail. Does anyone have a link to an article that describes the techniques used to do this. Thanks for any tips.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|