What I really wanted in vc.net
-
Nish asked yesterday something like "why don't you like VC.Net".. frankly i'm not really informed what's hot and new in .net (excluded gc which i am not interested in)... and most of the things microsoft wrote where sthing like "use c# instead of the old c++. and if you are really that oldschool that you want to use c++, use managed c++ (the only thing which is new that it has got garbage collection)" yesterday and today i was messing around with drawing / printing.. so i was thinking what i wanted from the new MFC: * double buffering for all the drawing (who uses NOT double buffering?).. and if not EASIER double buffering (like CMemDC.. i want to thank Keith Rule...) * easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc * resizable dialogs without a big effort and from the C++ point of view: * STANDARDISE THIS BASTARD just my 2 cents bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.
I totally agree on your C++ point of view, particularly the lack of support for PTS(Partial Template Specialization) PTS PTS PTS PTS PTS PTS PTS PTS :omg: I'm investing my time on heavy template(and generic) programming, and i don't like very muck of the hacks to simulate this, like the templatized IF and SWITCH techiniques, neither the Struct hacks ... Bahhhhhhhhhh Waiting for the update... :mad: Cheers, Joao Vaz
-
Bernhard wrote: resizable dialogs without a big effort Yup, that'd be something. I am sure CG would agree :-) Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut
Hey, what about some REAL photo in your profile? (I'm just curious :-D) -- See me: www.magerquark.de
-
Nish asked yesterday something like "why don't you like VC.Net".. frankly i'm not really informed what's hot and new in .net (excluded gc which i am not interested in)... and most of the things microsoft wrote where sthing like "use c# instead of the old c++. and if you are really that oldschool that you want to use c++, use managed c++ (the only thing which is new that it has got garbage collection)" yesterday and today i was messing around with drawing / printing.. so i was thinking what i wanted from the new MFC: * double buffering for all the drawing (who uses NOT double buffering?).. and if not EASIER double buffering (like CMemDC.. i want to thank Keith Rule...) * easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc * resizable dialogs without a big effort and from the C++ point of view: * STANDARDISE THIS BASTARD just my 2 cents bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.
You might want to try porting WTL's CDialogResize over to MFC; it's not a large class, but it's extremely powerful and does what you're looking for. CodeGuy The WTL newsgroup: over 1100 members! Be a part of it. http://groups.yahoo.com/group/wtl
-
You might want to try porting WTL's CDialogResize over to MFC; it's not a large class, but it's extremely powerful and does what you're looking for. CodeGuy The WTL newsgroup: over 1100 members! Be a part of it. http://groups.yahoo.com/group/wtl
there are tons of classes out there doing this (e.g. paul di lascia wrote on for msdn in the last 3 month) i just wish it would be easy as that: making a dialog resource, doing all the aligment graphically that's it.. i didn't want to say that all the things i've said are impossible (obviously) i just think they're too comberume and that the system should support them as it supports e.g. scrollviews.. bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.
-
there are tons of classes out there doing this (e.g. paul di lascia wrote on for msdn in the last 3 month) i just wish it would be easy as that: making a dialog resource, doing all the aligment graphically that's it.. i didn't want to say that all the things i've said are impossible (obviously) i just think they're too comberume and that the system should support them as it supports e.g. scrollviews.. bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.
Well, I won't say anymore except that CDialogResize is about as easy as you can make resizing. For each control on a resource, you specify in a DLGRESIZE_MAP macro whether you want it moved or sized in the X direction, the Y direction or both. Aside from some minimal code to initialize the resizing, that's it. The class takes care of the rest. CDialogResize article by Michael Dunn CodeGuy The WTL newsgroup: over 1100 members! Be a part of it. http://groups.yahoo.com/group/wtl
-
Hey, what about some REAL photo in your profile? (I'm just curious :-D) -- See me: www.magerquark.de
http://www.codeproject.com/script/profile/whos\_who.asp?id=20248 Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut
-
Nish asked yesterday something like "why don't you like VC.Net".. frankly i'm not really informed what's hot and new in .net (excluded gc which i am not interested in)... and most of the things microsoft wrote where sthing like "use c# instead of the old c++. and if you are really that oldschool that you want to use c++, use managed c++ (the only thing which is new that it has got garbage collection)" yesterday and today i was messing around with drawing / printing.. so i was thinking what i wanted from the new MFC: * double buffering for all the drawing (who uses NOT double buffering?).. and if not EASIER double buffering (like CMemDC.. i want to thank Keith Rule...) * easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc * resizable dialogs without a big effort and from the C++ point of view: * STANDARDISE THIS BASTARD just my 2 cents bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.
* easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc Use private DCs. They're not a resource bottleneck anymore, and you don't have to bother with all the saving and restoring. Tim Lesher http://www.lesher.ws
-
* easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc Use private DCs. They're not a resource bottleneck anymore, and you don't have to bother with all the saving and restoring. Tim Lesher http://www.lesher.ws
-
* easier handling with resources.. wdf should be the use of this whole saveDC, restoreDC and all that stuff.. i want to construct it, i want to use it.. the rest should be the matter of the mfc Use private DCs. They're not a resource bottleneck anymore, and you don't have to bother with all the saving and restoring. Tim Lesher http://www.lesher.ws
-
http://www.codeproject.com/script/profile/whos\_who.asp?id=20248 Nish Sonork ID 100.9786 voidmain www.busterboy.org If you don't find me on CP, I'll be at Bob's HungOut
Aaaaaaaah. Much better :-D -- See me: www.magerquark.de
-
"Use private DCs. They're not a resource bottleneck anymore, and you don't have to bother with all the saving and restoring." What do you mean when you say "private DCs"? Declared in the class as private or something WAY different? Mark Lenz
Windows allocates a private DC for a window if the window class (not the C++ class, mind you, but the class of the window as defined using RegisterClass() in Win32 or AfxRegisterClass() or AfxRegisterWndClass() in MFC) specifies CS_OWNDC as one of the class styles. This means that you never have to call GetDC() and ReleaseDC() more than once--call it once in your WM_CREATE handler or OnCreate() function, store it, and don't release it until you're ready to destroy the window. It also means none of this hOldPen = SelectObject(); SelectObject(oldPen) restoration garbage. GetDC()/ReleaseDC() are expensive calls, so you can not only simplify your code, you can also speed it up if your code is graphics-intensive.
The drawbacks? On NT/2000/XP, there are none. DCs are allocated from the system heap. On Win95/98/ME, they're allocated from the 64k GDI heap, which means they're somewhat limited (but nowhere near as badly as on Win3.1, since a lot of other structures were moved out of the GDI heap).
So, if you're running on NT/2000/XP, use them as much as possible. If you're running on 95/98/ME, use them when your GetDC()/ReleaseDC() usage is getting to be a pain to manage or a performance bottleneck. Tim Lesher http://www.lesher.ws
-
"Use private DCs. They're not a resource bottleneck anymore, and you don't have to bother with all the saving and restoring." What do you mean when you say "private DCs"? Declared in the class as private or something WAY different? Mark Lenz
Or use GDI+ which is an object oriented toolkit for GDI by MS.
Todd Smith
-
Windows allocates a private DC for a window if the window class (not the C++ class, mind you, but the class of the window as defined using RegisterClass() in Win32 or AfxRegisterClass() or AfxRegisterWndClass() in MFC) specifies CS_OWNDC as one of the class styles. This means that you never have to call GetDC() and ReleaseDC() more than once--call it once in your WM_CREATE handler or OnCreate() function, store it, and don't release it until you're ready to destroy the window. It also means none of this hOldPen = SelectObject(); SelectObject(oldPen) restoration garbage. GetDC()/ReleaseDC() are expensive calls, so you can not only simplify your code, you can also speed it up if your code is graphics-intensive.
The drawbacks? On NT/2000/XP, there are none. DCs are allocated from the system heap. On Win95/98/ME, they're allocated from the 64k GDI heap, which means they're somewhat limited (but nowhere near as badly as on Win3.1, since a lot of other structures were moved out of the GDI heap).
So, if you're running on NT/2000/XP, use them as much as possible. If you're running on 95/98/ME, use them when your GetDC()/ReleaseDC() usage is getting to be a pain to manage or a performance bottleneck. Tim Lesher http://www.lesher.ws
Thanks, I had never heard of them before. I'm having a problem where it looks like I'm running out of device contexts. I have a control which looks kinda like a fuel guage. The value that the needle represents is updated about every second, so the needle must be redrawn about every second. I have about 4 or 5 of these controls in my view. When I have been displaying the view for about 3 minutes, things start to get weird. All of my fonts revert to a standard font and it starts to draw white where there was supposed to another color. This starts to affect the title bar, making it white. Sometimes it even starts to affect other applications. Would using a private DC solve this, even running on Windows 98? Or is there something else I'm missing? Thanks. Mark Lenz
-
Thanks, I had never heard of them before. I'm having a problem where it looks like I'm running out of device contexts. I have a control which looks kinda like a fuel guage. The value that the needle represents is updated about every second, so the needle must be redrawn about every second. I have about 4 or 5 of these controls in my view. When I have been displaying the view for about 3 minutes, things start to get weird. All of my fonts revert to a standard font and it starts to draw white where there was supposed to another color. This starts to affect the title bar, making it white. Sometimes it even starts to affect other applications. Would using a private DC solve this, even running on Windows 98? Or is there something else I'm missing? Thanks. Mark Lenz
That definitely sounds like a resource leak. A private DC might appear to solve the problem, but it might just mask it. Look for calls to GetDC() that aren't balanced by calls to DeleteDC(). Also look for GDI objects that are created, selected into the DC, and then deleted before being selected back out--they won't actually be deleted, because they're still in use. Tim Lesher http://www.lesher.ws
-
That definitely sounds like a resource leak. A private DC might appear to solve the problem, but it might just mask it. Look for calls to GetDC() that aren't balanced by calls to DeleteDC(). Also look for GDI objects that are created, selected into the DC, and then deleted before being selected back out--they won't actually be deleted, because they're still in use. Tim Lesher http://www.lesher.ws
I have been using SaveDC() before I create any new GDI objects and then RestoreDC() when I'm done with them. Example: void DumbControl::OnPaint() { CPaintDC dc(this); int saveDC = dc.SaveDC(); CBrush brush; /*....using GDI object....*/ dc.RestoreDC(saveDC); } I make function calls within the OnPaint() method who take a pointer to the DC and then use GDI objects created within their scope, but those functions don't make a call to SaveDC(). Do I need to call SaveDC() in those functions as well, or am I missing something else? Thanks. Mark Lenz
-
That definitely sounds like a resource leak. A private DC might appear to solve the problem, but it might just mask it. Look for calls to GetDC() that aren't balanced by calls to DeleteDC(). Also look for GDI objects that are created, selected into the DC, and then deleted before being selected back out--they won't actually be deleted, because they're still in use. Tim Lesher http://www.lesher.ws
-
I had the same problem with a program I wrote. It's because Win2K manages it's GDI resources better. "The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants." - Omar Bradley
-
I have been using SaveDC() before I create any new GDI objects and then RestoreDC() when I'm done with them. Example: void DumbControl::OnPaint() { CPaintDC dc(this); int saveDC = dc.SaveDC(); CBrush brush; /*....using GDI object....*/ dc.RestoreDC(saveDC); } I make function calls within the OnPaint() method who take a pointer to the DC and then use GDI objects created within their scope, but those functions don't make a call to SaveDC(). Do I need to call SaveDC() in those functions as well, or am I missing something else? Thanks. Mark Lenz
I make function calls within the OnPaint() method who take a pointer to the DC and then use GDI objects created within their scope, but those functions don't make a call to SaveDC(). That's probably your problem. The path of execution looks like this: 1. Acquire DC 2. Save DC context 3. Call function 4. (in function) create resource 5. (in function) select resource into DC 6. (function returning) delete resource 7. Restore DC context Notice that you're still destroying the objects while they're still selected into the DC. The objects are probably what are leaking. Tim Lesher http://www.lesher.ws
-
Makes sense--under NT, device contexts aren't allocated in a small heap, as they are under Win 9x. Tim Lesher http://www.lesher.ws
-
I make function calls within the OnPaint() method who take a pointer to the DC and then use GDI objects created within their scope, but those functions don't make a call to SaveDC(). That's probably your problem. The path of execution looks like this: 1. Acquire DC 2. Save DC context 3. Call function 4. (in function) create resource 5. (in function) select resource into DC 6. (function returning) delete resource 7. Restore DC context Notice that you're still destroying the objects while they're still selected into the DC. The objects are probably what are leaking. Tim Lesher http://www.lesher.ws
hi... i've read your explanations, but there are still some things i don't get.. my normal drawing routine looks something like:
void CView::OnDraw(CDC *pDC)
{
CObjectList::iterator i;for (i = m\_ObjList.begin(); i != m\_ObjList.end(); i++) (\*i)->Draw(pDC);
}
//this is one of the objects i am drawing
void CDrawObject::Draw(CDC *pDC)
{
int i_save = pDC->SaveDC()pDC->SelectObject (&cp\_dashdot); pDC->SelectObject (&cf\_arial20); pDC->Rectangle (0, 0, 100, 100); //Aufräumen pDC->RestoreDC (i\_save);
}
i really like to make the pens and fonts member of the base class of all draw objects.. cause they all use the same font - and pen - settings and then select em into the device contexts.. my problem now is WHEN should i do the things you've told me to. (cause i found out that i am leaking resources.. when drawing more than 1000 objects or so (when printing out.. more than 6 pages,i got the standard font on WIN NT) and if this is a good idea to make this in a base class.. and what would be other ways to share the same font / pen - settings for all objects.. thanks in advance bernhard
Sometimes I think the surest sign for intelligent life elsewhere in the universe is that none of them ever tried to contact us.