|
I am having problems with my owner-drawn toolbar. I am programming in Win32 so, no MFC code can fix this problem.
I need to be able to get rid of the default highlight of items that have the TBSTATE_MARKED state and in the MSDN library tells me that when the dwDrawStage of the custom draw is at CDDS_ITEMPREPAINT, I should return the TBCDRF_NOMARK value but the problem is that the dwDrawStage is NEVER CDDS_ITEMPREPAINT. It is only ever CDDS_PREPAINT. Can anyone get this to work? Do I need to set each of the toolbar buttons to TBSTYLE_CUSTOMDRAW as well?
Thanks in advance,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
In the prepaint stage, you need to return CDRF_NOTIFYITEMDRAW to get custom draw messages for each button.
--Mike--
http://home.inreach.com/mdunn/
"The Earth is doomed." -- Rupert Giles
your with and
|
|
|
|
|
I run english version of windows 2000 Pro and the input locales is set to norwegian as default.
When I run sysprep and gosted the pc's and the minisetup is finished, the input language is set back to english and I must change it back to norwegian on all the computers in the classroom again.
Here is the case.
Can someone write a script that changes the input language to norwegian that I can put into the "Run once" section in the sysprep.inf file.
Please mail me: koklo@klotech.com
Thanx
Knut Olav Klo
Norway
|
|
|
|
|
Is there a version of Windows localized in Norwegian? Things might not be as simple as just going out and then rolling that out for your people, but then again if there is a Norwegian windows that might do the trick.
Sincerely Yours,
Brian Hart
"And that's the news from Lake Wobegon, where all the women are strong, the men are good-looking, and the children are above-average." - Garrison Keillor
|
|
|
|
|
Hi,
I'm trying to track down some GDi leakage in my application and think i may be using hIcon incorrectly.
At what point does a hIcon resource get released ? I have a dialog which sets ups some icon buttons during OnInitDialog() like this :
[b]
HICON hIcon;
hIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_STOP), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
m_BtnStop.SetIcon(hIcon);
hIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_REWIND), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
m_BtnRewind.SetIcon(hIcon);
hIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON_FORWARD), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
m_BtnForward.SetIcon(hIcon);
hIcon = (HICON)LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTSIZE);
m_BtnPanel.SetIcon(hIcon);
[/b]
Question 1.
-----------
When this function is run over and over (dialog is destroyed then reopened), am i leaking icon resources ? I suspect that i need to have a HICON for each of the buttons, and in the dialogs destructor (or some other function - please tell me which) i need to DestroyIcon(). Is this correct ?
Question 2.
-----------
I guess this is really answered by question 1, but if i change the icon for a button dynamically (i.e. depending upon the state of my app, the button uses different icons), should i use DestroyIcon() before using SetIcon() with new icon definition ?
Any other tips you can give me regarding icons ? Also, is there a tool i can use to see GDI resources so i can see if they're leaking ?
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
|
|
|
|
|
1. Yes you do have to call DestroyIcon()
2. that depends, if you are going to reuse the icon, keep it around until your dialog is destroyed, that way you don't have to constantly reload it. If you are finished with it then call DestroyIcon().
As for monitoring resource leaks, I use Windows Resource meter (RSRCMTR.EXE on Win98 - I assume other versions of windows have the program (or something similar), there may be better programs around, but I have this one).
---
Blessed are those who can laugh at themselves, for they shall never cease to be amused
|
|
|
|
|
Thanks for your reply.
Would you suggest loading my icon resource in OnCreate and destrying them in OnDestroy() then ? Those are my current thought on this based on your reply.
Thanks also for telling me aboutr RSRCMTR.EXE . I didn't know I had this program!
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
|
|
|
|
|
Can you give me any advice on tracking GDI resource leaks ? My application leaks quite badly! I have dealt with the HICON issue now, creating in OnCreate and destroying in OnDestroy(). I was also using a class called CSXButton which leaks pretty badly too, so i've removed all traces of that and am now using just a CButton with icons. I also did use some text drawing functions on a splash screen which had leaks, but i resolved that by freeing my CFonts before changing them and started to use dc.save and dc.restore. I don't believe i am using any other gdi functions, but i am using several control classes sourced from codeguru and from here that may be leaking. How can i trace the source of the leak ? Please don't suggest a third party product that i have to pay for ... i want to become familar with some methods to track these problems myself.
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
|
|
|
|
|
It is easy to forget (I forget quite often ), but you just have to make sure that everytime you load or create a resource you delete it when you are finished with it. If you look in MSDN at the functions that load/create a resource, there will be info on the function that is needed to delete it.
for example, if you load a cursor with the ::LoadImage() function, you have to remove it with the ::DestroyCursor() function.
The way I find leaks is to read the source code, and lots of trial and error, sorry I don't have a quick fix for you, but c'ést la vie.
---
Blessed are those who can laugh at themselves, for they shall never cease to be amused
|
|
|
|
|
Well, as the other guy mentioned, you always need to free everything you allocate. So, tracking resource usage at its simplest is mental; remember all the resources loaded by a class & make sure they're released before the class is destroyed, either by an OnDestroy() message handler (for a window class) or by the class destructor. If you've a lot of resources to keep track of, consider creating a separate manager class to deal with allocating and releasing them.
And now, i'm going to contradict myself ... Looking at the example given in your original post, one easy solution suggests itself: use the LR_SHARED option in your call to LoadImage(). Unless you have multiple resources with the same ID, this will allow you to put the responsibility of managing these icons back on Windows. No need to free them, no need to worry about loading the same resource multiple times.
As for more advanced tools... I guess if you're using Win2000, you could watch the USER objects / GDI objects columns in the task manager over time... If you change your mind on commercial products, i'll recommend the one i use from time to time.
|
|
|
|
|
Hi,
Thanks for your reply. So tell me then, which commercial product do you use and is there an evaluation version ?
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
|
|
|
|
|
NuMega BoundsChecker; http://www.numega.com
They do provide an evaluation version, though not as a direct download. Definately worth a try, as is their TrueTime profiling app.
|
|
|
|
|
Hi
I need to write a dll in VC++6 that can be used in delphi
What kind of dll should I use?
regards
|
|
|
|
|
It must be a regular DLL (it cannot be an extension DLL).
You *can* use MFC in the DLL as long as you don't try to export any MFC classes. It may also be a good idea to choose to link MFC statically.
You must provide export functions, and I think you may even need a def file but I'm not sure on that.
The best way to find out what you need (beyond the requirement to be a regular DLL), is to write a small DLL with one exported function, and make that work first.
To hell with those thin-skinned pillow-biters. - Me, 10/03/2001
|
|
|
|
|
It does depend on what you want delphi to access. If you are just exporting straight C functions like the Windows API does, then a regular DLL will do just fine. You are limited to exporting just C Datatypes so you can't pass in and out things like CString.
If you wanted to communicate via objects then you have to go the COM root. ATL simplifies this, but COM isn't for the faint-hearted (A least not at the start)
MFC DLL's are a non-started with Delphi, so you either have to use a regular C DLL or create a COM object.
Michael
|
|
|
|
|
Thank you !
I need objects as CDialog in it and I'm faint-hearted and beginner.
So what do you say on my idea :
1. make extension DLL
2. after make a regular dll that import in own the extention DLL
3. provide the last dll(that use in the first dll);)
Is it not a good idea ?
|
|
|
|
|
Is dll that good for delphi will match to every another language ?
|
|
|
|
|
It depends, you might have trouble using it with COBOL for instance . You'd be able to use it in VB though as well if you wanted and the .NET languages.
--
Andrew.
|
|
|
|
|
1. What you mean : .NET languages ?
2. Is the Idea that Anonymous suggest good ?
|
|
|
|
|
1 - .NET languages - you know, the new set programming idiom from Microsoft (C#, Managed C++ [not actually a language in itself, but an extension to one], ASP.NET etc?).
2 - What John and Matt said is perfectly correct - I would suggest doing a regular DLL. If you need to access a CDialog class then do a regular DLL which itself uses the extension DLL. This should work. You will have to make the regular DLL link with MFC but it CAN'T be an extension DLL itself to work with Delphi/VB.
If you need objects to be exported (i.e. providing an API for an extension DLL isn't enough) then the only solution is to use COM. I can't give you any Pascal examples 'cause I don't use Delphi.
If you want quicker responses then register and post through a proper account 'cause then we get notified when you reply to our messages, as Christian will tell you .
--
Andrew.
|
|
|
|
|
* "If you need to access a CDialog class then do a regular DLL which itself uses the extension DLL. " -
and this way dont good for delphi and another ??? Why ???
* "to use COM" -
Are you mean to ATL ?
|
|
|
|
|
|
Chill out, everyones questions are 'urgent'
ATL is a template library that simplifies creation of COM objects. I have a feeling I've answered this question several times by advising you that COM objects will not create themselves for you via a wizard and you need to go buy some books and learn some ATL if you want to do what you're intending. My advice on this front stands - I'm sure others as well as myself would be glad to keep helping, but you are *not* going to learn ATL from a post like this, you're going to learn it by reading a book and doing the examples in it. Richard Grimes books are good, the 'teach yourself in 24 hours' book is a better start if you're not confident or you get lost ( I resorted to it before going back to the Grimes book )
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 second Christian's comments. I would recommend a book like "Inside COM" (from microsoft press at http://www.microsoft.com/mspress/) or "Professional DCOM Programming" by Richard Grimes, Wrox Press (http://www.wrox.co.uk/).
These should easily get you started. I know that Grimes was my bible during a big project no too long ago.
Sincerely Yours,
Brian Hart
"And that's the news from Lake Wobegon, where all the women are strong, the men are good-looking, and the children are above-average." - Garrison Keillor
|
|
|
|
|
I must it urgent , So I need book that teach quickly and clearly.
It seems that what I need is the book :
'teach yourself in 24 hours' is about ATL in fact ?
Who is the author ?
|
|
|
|