|
i want draw lines on desktop.not on bitmap
can you help me?
|
|
|
|
|
You probably need to start here[^].
The best things in life are not things.
|
|
|
|
|
ok thanks....i had HWND của desktop window...
and then...may i paint on it?
|
|
|
|
|
I guess so; what happens when you try?
The best things in life are not things.
|
|
|
|
|
|
i try ... tk so much
|
|
|
|
|
no prob... good luck n happy coding!
|
|
|
|
|
Hi all,
When i insert 50000 item in my list, my application memory starts increasing.
Can anybody please tell me that why this is happening and what can i do remove this problem.
Thanks in advance
modified on Thursday, June 16, 2011 4:00 AM
|
|
|
|
|
Your memory will obvouisly grow when working with data since all this memory is most likely read into the memory, so nothing strange there in my opinion. However you are loading 50.000! items in a list and that is a bad practise for several reasons:
1) Performance, it slows down the application because it has to load 50000 items at once
2) Usability, A user will not be happy scrolling through 50.000 items. Give them filtering and paging
3) Memory, 50.000 items can consume a lot of memory.
So my suggestion: Limit the amount of data by implementing paging (somewhere between 20 and 50 items each time) and filtering.
|
|
|
|
|
Your argument is valid in principle, but you shouldn't base your it on the assumption that this list is actually being displayed to a user - there is no mention of such a thing. In fact there may be no UI involved at all.
The only issue we know of so far is memory consumption. Paging is a solution, but whether a page should hold 20 or 20000 items depends on the actual problem.
|
|
|
|
|
True, you are correct. I simplified his problem maybe a bit too much
|
|
|
|
|
If you are using your own implementation of a list then we obviously cannot say what it does. I will therefore assume that you are using an existing implementation, such as std::list (you didn't say!).
Every time you insert an item into a list, a new list node will be allocated. This node - depending on te actual implementation - will at least contain one or, more likely, two pointers that are required to maintain the links to the remainder of the list, and the actual data. So, even if your list only holds short values, each node might in fact take 10 bytes (2*sizeof (pointer_type) + 2) to allocate 50 thousand items thus will require half a million bytes of memory.
If your list items are large, requiring 1000 bytes each to store, then each node will be 1000+2*sizeof(pointer_type) in size, and the whole list will require 500 MB of storage.
If your list maintains large objects and you've decided to store them elsewhere you might want to only stor epointers to these items in your list, but even then each list node will store three pointers: two to maintain the list, and one to point to the actual data. On a 32 bit system that would be 12 bytes, or 600 thousand bytes for a list of 50 thousand items.
In short, you're storing information in memory, a lot of it - why are you surprised this takes up memory?
P.S.: according to your question the list takes up more memory than you are comfortable with. This begs some questions:
1. How much memory do you have available (i. e. what does the target system provide)?
2. How large is each indivuidual item?
3. Are these items stored redundantly, i. e. are they being held in several lists at once, or in other sorts of containers?
4. Where do you get the data from (files, media streams, internet, other applications)?
5. Would it be possible to store just one or a few items, process them and store away the results?
6. Have you considered compressing the data - either each node individually, or by storing only the differences to previous items?
modified on Thursday, June 16, 2011 5:02 AM
|
|
|
|
|
That's normal.
You add/create data to a datastructure.
To remove the problem just remove the items from the list ( and be certain to do house-cleaning )
are you doing/allocating/creating your list :
(pseudo code-ish)
int myArray[50000];
for ( int i = 0; i < 50000; i++)
myArray[i] = i;
or
int* myArray = malloc (sizeof(int) * 50000);
for ( int i = 0 i < 50000; i++ )
myArray[i] = i;
or
std::list<int> myList;
for ( unsigned int i = 0; i < 50000; i++ )
myList.push_back( i );
Watched code never compiles.
|
|
|
|
|
what did you expect would happen ?
adding things to memory takes memory.
|
|
|
|
|
Chris Losinger wrote: adding things to memory takes memory.
They never told me that at PC World!
The best things in life are not things.
|
|
|
|
|
Just imagine what you could have done with that knowledge!
|
|
|
|
|
I surprised you got something coherent out of PC world in the first place...
|
|
|
|
|
VCProgrammer wrote: When i insert 50000 item in my list, my application memory starts increasing.
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi, I want to add a bitmap to a button in my DialogBox.
The code is:
case WM_INITDIALOG:
hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_QUIT));
SendMessage(GetDlgItem(hDlg,ID_QUIT),BM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBmp);
return (INT_PTR)TRUE;
but why don't work?
|
|
|
|
|
|
but is it possible to add an image with BM_SETIMAGE without ownerdraw button?
|
|
|
|
|
are you setting the BS_BITMAP style when you create the button?
|
|
|
|
|
no because with BS_BITMAP style show bitmap only without text in the button.
I need [Bitmap+Text]
|
|
|
|
|
Member 2965471 wrote: I need [Bitmap+Text]
See here[^] for more details.
The best things in life are not things.
|
|
|
|
|
I know but don't work in that way!
|
|
|
|