|
Any help would be appreciated.
cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Have you tried GetDlgCtrlID(hWnd) ?
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
That'll do for me.
Cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
What kind of object do you have a handle to? For example, you could use DWORD GetWindowThreadProcessId() for a window.
-----
DWORD GetWindowThreadProcessId(HWND hWnd, LPDWORD lpdwProcessId);
-----
Kuphryn
|
|
|
|
|
I need the following
- sorted container of items, sorted based on a function that compares the objects and returns true/false.
- access to the container based on index. container[index] or something similar.
- insertion, search by value and querying are all of almost equal frequency
What container do you guys suggest for this?
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Do you forsee the container fluctuating heavily in size, or remaining constant? IE is there some maximum number of records? Will you always insert at one of the ends of the container, or possibly in between?
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
In most situations, the insert will occur at the end, because it is a sequence of objects sorted on time - but I could get an out-of sequence object once in a while, which should be inserted in between.
The container will grow in time, chances of shrinking is 0.
I was thinking about vector. Then I do a compare with the last item and if it is supposed to be at the end, then i push back. If it requires to be inserted somewhere else I push_back and call a sort. I get indexed access to the list
If I use set, I will have automatic sorting. But, then how do i get indexed access? Forwading an iterator?.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
You must forward an iterator to access items in a set.
vector, deque, and string are the only containers that have random access iterators.
From what you've described, it sounds like vector is the way to go. Also, if you haven't used STL containers before, I think vector would be the best to start with because it is the one you will most often use.
Lan
|
|
|
|
|
I have used both set and vector before, but wanted to get a second opinion on this because it is quite a performance-critical section in the code. I was leaning towards vector because of the random access part, but the only thing that made me think was the sorting part since set does it automatically on insert. .
Guess I was trying to be lazy here.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hey, nothing wrong with being lazy!
I think that is at least half the reason I use the STL.
Lan
|
|
|
|
|
I would have to agree. The only problem with vector is that it is implemented as a contiguous block of memory, like an array. If you keep growing the vector, it becomes expensive to keep adding elements since it has to constantly keep allocating and moving things around to keep it contiguous. A list would solve that, but of course you lose the random access iterator. In addition, repeated sorts on a vector consume more CPU cycles than say a list since a vector has to shuffle data around whereas a list would just shuffle pointers.
Use reserve() right away with your vector to pre-allocate a specific number of elements. This will save time overall since it can immediately allocate its chunk in one fell swoop as opposed to constantly having to re-allocate and move the existing chunk every time you do a push_back as the vector begins to grow. If you have a rough idea of how many elements will be required, you can play with this reserved amount to get the right mix of as few resizes as possible during the life of the vector.
For example, if you grow your vector from 1 to 1024 elements, it would take 11 resizes if no initial reserve is set. If you set the reserve to 512, there would only be two resizes. The disadvantage is the "wasted" memory as the vector grows to reach 512 elements. Memory versus CPU time is the age-old quandary
Ty
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein
|
|
|
|
|
Thomas George wrote:
If it requires to be inserted somewhere else I push_back and call a sort. I get indexed access to the lis
Don't sort every time you add - this gives you O(n*log(n)) complexity, which will be a performance killer. Assuming that vector is sorted before insertion, you may find the right place for insert in O(n) time. std::upper_bound even will find the index for you.
Tomasz Sowinski -- http://www.shooltz.com
*** Vodka. Connecting people. ***
|
|
|
|
|
that is cool!
I never used upper_bound before because i never knew that I can use a predicate for comparison.
Thank you
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
You could use a vector of pointers to your objects. That way resizing the array doesn't get to costly.
Todd Smith
|
|
|
|
|
They are already pointers.
But, Thanks for the reply
I lOVE CP. Always gets so many tips and suggestions.
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
|
Hi,
I have a Visual C++ MFC Dialog based application. And I would like to include a .c and .h file in the project.
When I tried to compile this project I had the following error:
Unexpected end of file while looking for precompiled header directive, fatal error C1010.
If anyone could help me with regards including c-code files in my project.
Thanking you in anticipation
|
|
|
|
|
You need to use automatic use of precompliled headers. Select project/settings (or ALT+F7) then, in the Project Settings Dialog, select the C/C++ tab, then select the Precompiled Headers item in the combo box, and select the Automatic use of precompliled headers option.
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
The project has set the c file to use a precompiled header (through stdafx.h).
Since the c file doesn't have an #include "stdafx.h" the compiler gets an error searching for it.
You just need to turn this option off for the file, through the file properties.
Hope this helps,
Lan
|
|
|
|
|
also #include the "stdafx.h" file inside your c file.
Or turn off the use of precompiled headers.
|
|
|
|
|
It's working, thank you all!!!
|
|
|
|
|
Hi,
Is it possile to tell VC++ that I wish to save all debug file to ONE directory. I dont like deleting this files from Debug directories . Id like to delete only one with all files !!
Wiizi
|
|
|
|
|
You can delete the files, using the menu item Clear....
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Where is it ? I cannot find this :/
Wiizi
|
|
|
|
|
i guess he wanted to say Clean, its under build menu
but i prefer to find every "debug" using the find files or folder then CTRL + A then SHIFT + DELETE!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|