|
I wouldn't use a vector or a list for this task. Use a vector for containing items where random access to the items is important, and there is a definite order to them. Use a list where you plan on accessing the items sequentially, and the order of insertion is maintained.
If you want to keep container of strings and you want to check later whether or not a string exists, consider using a set. The items in the set will be maintained in sorted order (not in order of insertion), only unique items will exist in the set (you won't be able to "Bob" in there twice). Use a set if the order in which you inserted the items into the container is not important. Use the set::find method to determine if an item already exists in the set. This will save you the trouble of traversing the entire container to find out if an item exists in the set. Also, since sets store their contents in a tree, determining if an items already exists in the set is less computationally expensive than determining if an items exists in a linear sequence (like a list or vector).
|
|
|
|
|
With list or vector you can perform only linear search . With set (which is a balanced binary tree) you use binary search, and that is a lot faster.
I vote pro drink
|
|
|
|
|
Others have already mentioned set, so I won't repeat them.
However, for future reference, the advantage of list is that it allows easy insertion/deletion in the middle, vector would need to reallocate the entire array to do this. The down side is that list cannot be randomly accessed - you need to start at the top and work your way through to find a particular location.
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.
|
|
|
|
|
Thanks a lot guys! I found your suggestions very, very helpful.
Jeremy.
"Hey man, Taliban, Tali me Banana."
|
|
|
|
|
I'm writing a DLL that uses DirectShow to capture some video off a firewire (WDM) device, and I'm having a small problem.
We have an MFC app that creates the view in the EXE, and then passes a pointer to the view to the DLL so that we can put the preview window into the view. If the preview window consumes all of the client rectangle, I can't get the veiew to respond to mouse clicks. If I maximize the view window, I get a border of unused area around the preview window that responds to mouse clicks.
Can anyone provide any clues,documentation, books, magazines, help from aliens, anything?
|
|
|
|
|
Can you call SetCapture() in your view ? That's how I usually get around those sort of problems, although I often find it's tricky to get the code to a state where the mouse actually responds as you'd expect.
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 basically can't change the exe. Anything I do has to be done in the DLL since we support many different DLL which perform similar functionality, using WDM instead of Video For Windows.
|
|
|
|
|
I've got myself a treeview (yeah!). When I select a node, the tvitem structure I get with the message doesn't contain the image (TVI_IMAGE) attribute. Is there a way of finding out what image the selection has? I'd like to use the image as a way of knowing what type of object was selected.
Thanks,
WAVK
|
|
|
|
|
You'll have to call CTreeCtrl::GetItem, passing HTREEITEM from NMTREEVIEW. Don't forget about TVIF_IMAGE flag.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I need to know when my parent gets WM_SIZE and WM_MOVE messages (i am a CButton derived control )
any help?
|
|
|
|
|
Your parent must co-operate and call some method exposed by button. There's no built-in notification going from parent to child during move/size operations.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello, the codegurus around the world.;)
We can put the code likes SendMessage with the user-defined message or some Get function
from Dialog (or button) in WM_SIZE and WM_MOVE of the parent's message handler.
The only issue is how we get CWnd of the child dialog or the button of its dialog.
There are many ways to do this.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
How can I force all buttons, edit- boxes and list-boxes to be resized when resize the application window ? Objects should be smaller but still at the same location within the application window.
Hans
|
|
|
|
|
If you're using MFC you may have a look at ResizableLib on this site.
If using plain Win32 APIs, that same article can give you some ideas.
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|
|
this is the easiest way to place an icon on a button:
// Button = m_SafeButton
// Icon = IDI_FLOPPY
m_SafeButton.SetIcon(AfxGetApp()->LoadIcon(IDI_FLOPPY));
m_SafeButton.EnableWindow( true);
that´s all.
Hans
|
|
|
|
|
i am using NtQuerySystemInformation() from NTDLL.
my worry is whether this function will be supported in future versions of Windows.
isn't XP the next version of Win2k and ME that of Win9x??
i am unfamiliar with Windows Architecture...could someone help me out??
|
|
|
|
|
I want to control word through the interface the word provided. But I found some problems. I found not all the controls such as buttons, comboboxs are window control. They don't have the window handles. But I want to process some messages it sended. you can found this through spyxx.What can I do?
thanks to all the programmers who have helped me.
|
|
|
|
|
How on earth do you presume to have found that a button or combobox in Word does not have a HWND associated with it ? I believe Word does not use MFC, ( so no CWnd ), but I can't see how it could possibly show you a button without it being a window, with a handle.
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.
|
|
|
|
|
How on earth do you presume to have found that a button or combobox in Word does not have a HWND associated with it
He's probably thinking about Word toolbars - the comboboxes and buttons you can see there aren't real tax-paying, HWND-having windows.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I want to use my own dialog to control word. for example, I want to control the "insert -> index and content" dialog in my code. So I can send a message to set the checkboxes status. But i can't get the checkboxs' window handle now.
thanks to all the programmers who have helped me.
|
|
|
|
|
What are you trying to make Word do? Which controls/windows are you trying to control?
You seem to be approaching this from a strange angle. What do you want to achieve?
Michael
|
|
|
|
|
to be simple, I want to create a word document with my own format. And I will provide some dialogs to let people coustomize the format. so have to use some word's automation interface. But when a dialog of word do modaled, I can't get the status untile the dialog ended. for example, in the dialog "insert -> index and content" there are some check boxes, and i want to set the check boxes' status in my code. what can I do?
thanks to all the programmers who have helped me.
|
|
|
|
|
Hello, the codegurus around the world.;)
It seems that you want to use some functionality of Word.
We can use Word Automation to access all Word functionality in our application.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
right! But when the dialogs of the word show modal, I can't use the interfaces, I have to waiting for the user to select an item. How can I do it automaticly?
thanks to all the programmers who have helped me.
|
|
|
|
|
I need in my application to resize at each step of a for loop 2 arrays. I have read that for reallocate memory, it's better to use <vector>, rather than use the definition of the usual pointer. But, as i'm a beginner in this kind of knowledges, i would like to know if someone could explain me how i could declare 2 arrays, with 2 differents size, so that at each step, as i use an iterative method, one of this array "becomes" the other.
thanks in advance
gerald
|
|
|
|