|
Looks good to me. You don't need to (and shouldn't) call pOldBitmap->DeleteObject() because the bitmap is still selected into the device context. Shouldn't cause any problems because you're deleting the device context without doing anything else to it, but you should remove that line
A couple of other points though...
What is the reason for setting pDC to NULL in OnEraseBkgnd() ? It's not necessary and will have absolutely no effect at all
Why are you using IsWindowVisible() ? OnPaint() won't get called unless the window is visible...
And you don't need to set the clip region in your memory device context. Your BitBlt() call is only copying the parts in the clip box anyway. Speed may seem like a reason to do it, but the process of checking everything against the clip region can be slower than simply writing everything to a memory device context, particularly for lower-end graphics cards.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
You don't need to (and shouldn't) call pOldBitmap->DeleteObject()
Thanks, I'll remove that...
Ryan Binns wrote:
What is the reason for setting pDC to NULL in OnEraseBkgnd()?
I set that to NULL to get rid of the level 4 warning..
Ryan Binns wrote:
Why are you using IsWindowVisible()? OnPaint() won't get called unless the window is visible...
I'll take that out..
I'll remove the clip region too..
Thanks for all your help!
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
RobJones wrote:
I set that to NULL to get rid of the level 4 warning
Try using the UNUSED() or UNUSED_ALWAYS() macros, or simply declaring the parameter without a name:
BOOL CMyTreeView::OnEraseBkgnd(CDC* ) If a parameter has no name, the compiler assumes it isn't used, and just ignores it. I usually leave it in a comment, so I can see what it actually is if I need it later
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I used the /*pDC*/ instead of pDC = NULL;
Thanks for all your help..
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
You're welcome
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
If we want to display a bmp onto a CView derived class's DC, why do we usually create a memory DC first and then select the bmp into that memory DC and then BitBlt the memory DC onto the CView DC?
Why not directly select the bmp into the CView DC?
Why do we go through a memory DC? Is it because it is faster to do it that way??
Regards,
Melwyn
|
|
|
|
|
Bitmaps cannot be selected into windows DCs, they can only be selected into memory DCs.
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 Paul,
Thanks for the reply. It cleared a long-standing doubt of mine.
By the way, is it absolutely necessary to select atleast 1 bitmap into the memory DC before you can start drawing into the memory DC?
Thanks,
Melwyn
|
|
|
|
|
Hello
I am trying to allocate more than 1.3 Gb memory in my MFC based program.But it doesn't work with error No 8(not enough memory)
While I could do this on Non-MFC application.Anyone has a solution for this?
|
|
|
|
|
If the memory is not available, it's not available. Remember that your process only gets a 2GB address space (unless you have NT and started it with the /3GB option), and unless 1.3GB of that is contiguous, the allocation request will fail.
|
|
|
|
|
Because of the scattered loading of dlls inside the process address (2GB) space this is almost impossible...
DavidCrow wrote:
/3GB option
And the /3GB option is only available on the advanced server and data center server versions of windows.
John
|
|
|
|
|
try using memory mapped files?
|
|
|
|
|
amiru wrote:
I am trying to allocate more than 1.3 Gb memory in my MFC based program.
Just curious, but what (in broad terms if necessary) are you doing that requires a 1.3GB allocation? Is this just an experiment?
|
|
|
|
|
David Kentley wrote:
Just curious, but what (in broad terms if necessary) are you doing that requires a 1.3GB allocation? Is this just an experiment?
I am curious too, but there are certain applications that eat up your memory like crazy. I have never seen them being used in Windows (only in Unix), but they are Cadence Tools, Silicon Ensemble, etc. I have written programs by using some data structures called Binary Decision Diagrams (for research purposes), that would consume up to 1GB of memory in just a few minutes. Of course the machines would work so slowly afterwards because the swap space was being used afterwards. We would use all sorts of tricks not to let the programs use so much memory. I know of cases where these BDDs would reach 10GB and more, but our machines didn't have more than 1GB of memory.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Video editing would easily use this much memory, as would high-resolution image processing, high-quality audio processing (studio work), just about any military algorithms (radar, sonar etc...).
They're pretty specialised applications, but they certainly exist
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
Video editing would easily use this much memory, as would high-resolution image processing, high-quality audio processing (studio work), just about any military algorithms (radar, sonar etc...).
They're pretty specialised applications, but they certainly exist
I don't doubt it. It just seems to me that when talking about THAT much memory (at least on a standard PC), that you would generally get better performance by figuring out ways to not use so much memory at once.
I guess that could be tough to do in some cases. I wonder how much memory is alloc'd at one time for today's high end video games? It's gotta be getting pretty high.
|
|
|
|
|
David Kentley wrote:
I wonder how much memory is alloc'd at one time for today's high end video games?
I <marquee behavior="alternate" height="17" width="54" direction="up" scrollamount="1" scrolldelay="5" truespeed=""><marquee behavior="alternate" height="12" width="54" direction="left" scrollamount="1" scrolldelay="3" truespeed="">shudder to think...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
hello ppl
what i am trying to do here is find out what functions are available for a particular DLL for example most of the API function are contained in USER32.DLL file we can write code for accessing functions like SendInput and SetLayeredWindowAttributes that is we can explicitly link the DLL file and get those functions to work now what i want to do it there is a third party DLL that i would like to explicitly link now the problem is with USER32.dll i am aware of the functions their return types and their parameters but such is not the case with a third party DLL how do i know what functions this DLL contains the parameters the return type and everything any help would be appreciated
Regards
Ahmed Ajmal
|
|
|
|
|
You can't get parameter and return value information from a DLL. You'll need third-party-supplied information to know that. You can get a list of the functions it exports by examining the export table, but you can't get any information about them, other than their name.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
yeah ryan actually i tried the DEPENDS tool that installs with the Visual Studio and yes i did find out the functions their names but not any other imformation and what do u mean by EXPORT TABLE how do i use that
Ahmed Ajmal
|
|
|
|
|
Cyberizen wrote:
what do u mean by EXPORT TABLE how do i use that
A DLL's export table is the list of functions that it exports. Read about it in more detail on MSDN.
|
|
|
|
|
The export table in the DLL lists all the functions that the DLL exports. This is what the DEPENDS tool examines, so you can't get more than what DEPENDS gives you. It doesn't give parameters or return type.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I want to start the same routine which runs if I press the searchbutton when I press enter on my keyboard. I think that I can realize that with the function OnChar(UINT nChar, UNINT nRepCnt, UINT nFlags) but it doesn't work.
OnChar(UINT nChar, UNINT nRepCnt, UINT nFlags)
{
if(nChar ==VK_RETURN)
{
OnSearch();
}
}
Please give me a tip if you know something. I am a beginner.
Julia
|
|
|
|
|
You should override PretranslateMessage of view/dialog
If you button is focused and < Enter > is pressed, call your routine.
"...hasn't really been well accepted as far as the ratings tell us so far " - Nishant S
|
|
|
|
|
Hello all
I wonder, does anyone knows the limit for of threads that the Os is allowing for one application to open ?
10x'
|
|
|
|