|
MSDN mag ran an article in the last 12-18 months and not in the last 6, which was a program that showed you the bitmaps/pens/etc that had not been deleted. It rocked, if you cannot find it LMK and I'll dig it up.
Also, W2000 makes you work pretty hard to leak GDI memory, because it cleans up after you. This I know from bitter experience.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I think the tool you mentioned is the tool i mentioned earlier. It is only 95/98 , and you're right - it shows the pensd , palletes and fonts that you are leaking. And it does indeed display lots of them! Only i don't use any, so its not my app thats leaking them
From the outset, it looks pretty good. But in truth, it doesn't reflect the state of my application one iota.
It's called GDIUsage - is this the one ? You have to build it from source - available from MSJ online.
Jase
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows
Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com
|
|
|
|
|
That sounds like it. I dunno about NT 4, but I can tell you that code that runs fine under W2000 will crash W98 for GDI leaks in seconds. It's possible NT4 protects itself in a similar way, but the reason the code only ran under 95/98 (and I guess ME ) is that the handles to the objects were all global. It shows you what exists on the system, not what has leaked, that is why it fills up. You look to see if the list is growing a lot by taking snapshots and seeing what is different between two points in time, and if there is a lot there you should have deleted.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Hi,
Thanks for your reply.
I have managed to trace the problem that i had (thanks to an evaluation copy of Bounds Checker) - it was all thanks to a couple of HKEY's which i had forgot to do a RegClose() on. Just a silly mistake really (but aren't they all?).
Still, it begs the question - why did the gdi tool we are discussing show me lots of fonts , pallettes and regions when i took the comparison snapshots? I had no other program running at the time, so these resources weren't being created by any other application. Is it possible that it could mistake HKEY's (and whatever may be internally allocated when opening a registry key) for GDI resources , and then point me at some bogus resources ?
Are registry keys treated similarly to file's / sockets ? i.e. there are a physical limit to the number of open files you can have - is the same true for reg keys ? Would this also make sense of all the 'A resource you requested was unavailable' msg boxes that popped up when my 'resources' were running low. Am i likely to get this error if it was in fact due to reg keys ?
damn, there's so much to learn.
Jase
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
View your digital photos and images with ease using the ultimate desktop image manager for Microsoft Windows
Download your free copy of SlideShow Desktop today from http://www.slideshowdesktop.com
|
|
|
|
|
How did you manage to get an evaluation of Boundschecker?
James Spibey
I love the word naked, it's brilliant isn't it, 'naked'. When I was a kid I used to write the word naked on a bit of paper hundreds of times and rub my face in it - Jeff, Coupling, BBC2
|
|
|
|
|
I use the CWinXPButtonST class to set a cool look to my buttons.
I have a background image on my dialog and and when I using CWinXPButtonST class, and the old gray color that the buttons has is ugly. When I called the DrawTransparent() function to make it transparent the highlight event disables!
How ot make it transparent and still have the highlight event there??
MP-219
|
|
|
|
|
I haven't used CWinXPButtonST but I have used CButtonST and it sounds like maybe the button isn't flat (Highlight only works on flat buttons).. You may have to do something like m_bButton.SetFlat(TRUE);...
Hope this helps,
Rob Jones
|
|
|
|
|
Texts in titles of all windows are getting smaller and smaller when I have the fonts of controls in one window such as buttons and statics changed. I wonder how the operation on this window affulent all the windows on desktop ---- the whole OS, even after this window has exited.
my code is below:
// CDlg is derived from CDialog
BOOL CDlg::OnInitDialog(){
CDialog::OnInitDialog();
// m_button is a child button in CDlg
SetFont(&m_button, "Times New Roman", 12); // see below
m_button.SetFocus();
return false
}
CDlg::SetFont(CWnd* pWnd, char* strFont, int nSize){
CFont font;
LOGFONT logFont;
memset(&logFont, 0, sizeof(logFont));
logFont.lfHeight=-nSize;
logFont.CharSet=DEFAULT_CHARSET;
strcpy((char*)logFont.lfFaceName, strFont);
font.CreateFontIndirect(&logFont);
pWnd->SetFont(&font);
}
Maybe I should have keep the "font" variable until the dialog is ended, but the problem above still exists when I allocate memory from heap (malloc()) for "font" and "logFont". Can you change the fonts of all windows on desktop?
Tiny Flying Elephant
I love flying...
|
|
|
|
|
Make CFont a member variable of the dialog class. Fonts will then work. At least they did for me when I had this problem.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
"Don't belong. Never join. Think for yourself. Peace"
- Victor Stone
|
|
|
|
|
Yes, the font variable lifetime should be longer. Just make it a data member of CYourDialog - no need for malloc or new.
LOGFONT is needed only to call CreateFontIndirect. It can be a local variable.
Have no idea why your app changes the systemwide settings - does this happen only if you call CWnd::SetFont?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I have an application that shows a splash screen for 5 seconds, the splash screen is deleted and a dialog box should be shown. The problem I had was that the dialog box would be behind everything else (the edit box inside the dialog would still have focus, which is correct). To solve this, in the OnInitDialog of the dialog I set the window position and size etc and set the first parameter to wndTopMost. This worked up to a point. The dialog is now on top and the cursor is flashing in the edit box where it should, BUT the box itself still doesn't have focus and you have to click on it before you can type in the edit box. Any ideas how to rectify this?
Thanks in advance for any help,
Nick
|
|
|
|
|
This is probably a problem with splash screen which is disabling your dialog window. Check if splash calls EnableWindow.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I was actually using the splash class wrongly and putting a line of code in the wrong place (doh), thanks for the help though,
Nick
|
|
|
|
|
I noticed in various program loops that allocating a buffer with the new operator didn't seem to work each time. I mean it did work but partially, I sometime have partially allocated buffers (?).
This:
char* pBuf = new char[iVariable];
is not safe. When iVariable is a constant, like MAX_PATH it always succeed but not when it has a dynamic value.
I admit, I seldom test if the allocation succeded or not but the buffer is always allocated but not on the entire sequence (?). Maybe doesn't the new operator allocate contiguous memory blocks and then a pointer operation (pBuf++) is not safe ?
Then, I wonder when I should use malloc instead of new to get sure the buffer is allocated ?
Yarp
|
|
|
|
|
malloc() is for C programs, new is for C++ programs. You can never be sure that your allocation succeeds, always check the result! If the allocation succeeds, the memory block is always contiguous and the size you requested.
|
|
|
|
|
malloc() is for C programs, new is for C++ programs.
This is too strict. One can safely use malloc/free in C++ program. Just don't mix malloc with delete and new wih free
- what was allocated with new should be deallocated with delete, malloc() should be accompanied by free().
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
char* pBuf = new char[iVariable];
is safe, at least when iVariable is correctly initialized. If iVariable contains bogus bits, the buffer size may be too large to fit on the heap. In such case, operator new fails and returns NULL on VC6 or throws bad_alloc exception on standard-conforming compilers.
the buffer is always allocated but not on the entire sequence (?).
I don't understand what do you mean.
Maybe doesn't the new operator allocate contiguous memory blocks
It allocates contiguos block of size passed in iVariable.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi, thank you all for replying.
the buffer is always allocated but not on the entire sequence (?).
I mean that I was reading a file buffer and I read the beginning of the buffer but the buffer is empty before the end of it, so I suppose it was partially initialized.
Yarp
|
|
|
|
|
I found out the problem: iVariable ;((
I used the size of another -smaller- disk file (i used it to load a file buffer in memory). The "smaller" makes all difference and actually did the partial buffer load that I noticed.
Anyway, I'm now sure that new and malloc have the same usage and that they both create contiguous memory buffer.
Sorry and thanks )
Yarp
|
|
|
|
|
In OLE/COM Object viewer My object present in the folder : Automation Objects but if I try open it by press on the + , I gets the messageBox:
------------------------
CoGetClassObject failed
class not registered
REGDB_E_CLASSNOTREG(..)
------------------------
I try to register it again by: regsvr32 <dll filename="">
but I get error message that the LoadLibrary failed .
(the path is clearly ok !).
What can I do ?
|
|
|
|
|
According to MSDN
Q. What are the reasons an ATL server might fail to register?
The following also applies to ATL 3.0:
A. The following are the top three reasons an ATL server might fail to register:
You built your project with _WIN32_WINNT=0x400 (the default), and you are not running the ATL server under Windows NT 4.0 or you do not have an up-to-date version of Oleaut32.dll. To solve this problem, run "DUMPBIN /EXPORTS OLEAUT32.DLL" and search for UnregisterTypelib. If it is not there, then your server cannot run. Remove this #define statement from Stdafx.h if you want to run the ATL server under Windows 95 or older versions of Windows NT. Alternatively, you can use LoadLibrary and GetProcAddress so that you can run optimally under both Windows 95 and Windows NT 4.0. The Oleaut32.dll that ships with the Internet Explorer 3.x is up-to-date.
You built your project as MinSize and Atl.dll is not properly installed on the system. The correct version of Atl.dll must be copied and registered by Regsvr32. There are Windows NT and Windows 95 versions of Atl.dll. The Windows 95 version runs under Windows NT. However, since it does not use the UNICODE APIs, it is slightly less efficient. Unless you build your project as MinDependency, you will need to install the correct version of Atl.dll and run Regsvr32 on it before you install your server.
You built your project as UNICODE, and you cannot run it under Windows 95.
The following are the steps to troubleshoot:
For a DLL server, run Regsvr32 in the debugger. Open the Project Settings dialog box and click the Debug tab. In the Executable for debug session text box, enter the full path to Regsvr32.exe, such as C:\Sharedide\Bin\Regsvr32.exe. In the Program arguments text box, specify the full path to your DLL, such as C:\Myprojects\MyFolder\Debug\MyFile.dll. Set a breakpoint at DllRegisterServer and start stepping.
For an EXE server, run it in the debugger and specify /REGSVR as its command-line argument.
I suggest if you need to ask this question again tomorrow you try to provide some more information, because it's obvious based on what you're asking that either you're not providing enough info, or you have got the right answers and want to hear something else. Have you got your books yet ?
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
thank you
So this is what I understant from all this :
*For the DLL server*
-----------------------
Open the Project Settings -Debug tab.
In the Executable for debug session text box, enter the path to Regsvr32.exe and In the Program arguments text box, specify the full path to my DLL.
Is that all ?
* I have windows98
|
|
|
|
|
To be honest I opened MSDN and looked for something that sounded helpful. What the above is going to do is pass the dll path as the argument to RegSrv32, it's the same as navigating to the dll path and typing regsrv32 mydll.dll in the console.
If you don't have access to MSDN, try msdn.microsoft.com, there are a lot of articles that matched my search, you might find something more helpful there.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I tried it and I gets again the errorMessage that it failed !
I dont understand where exactly I have put a breakpoint (What means "at DllRegisterServer" ???)
|
|
|
|
|
If you don't have a dllRegisterServer function, then RegSrv32 is obviously not going to work.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|