|
I have a combobox which I have put onto a view using the create function. I have also added three strings using the addstring method. My problem is that when I press the down arrow I get just a line where the top of the list box should go and I can't see anything. I could only guess that the height is of the box is set to one. How do I make the drop down box bigger?
Please Help,
Clint
PS. I am using WTL
|
|
|
|
|
I have recently done something very similar with MFC (guess WTL won't differ much on this). The dimensions you pass to CComboBox::Create() determine the height of the dropdown list. After creation you set the height of the unrolled comobo with CComboBox::SetItemHeight() . You might want to confront this snippet of mine with your code and see if there's any relevant mismatch:
m_combobox.Create(
CBS_DROPDOWNLIST|WS_CHILD|WS_VISIBLE|WS_TABSTOP,
CRect(x,y,x+COMBO_WIDTH,y+4*COMBO_HEIGHT),
this,0xFFFF);
m_combobox.SetItemHeight(0,COMBO_HEIGHT);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I got the combo box to draw with your code (Slight modifications for WTL) but I can't get it populated now. I use the AddString method but nothing is going into the dropdown list.
Any ideas?
Thanks,
Clint
|
|
|
|
|
Any ideas?
No, this is weird. I use CComboBox:AddString() with no problems at all. Only thing I can think of is maybe you're messing around with the CBS_HASSTRINGS flag or some other comobox style that shouldn't be there.
I suggest you post a (distilled) snippet of code so that we can take a look at it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I tried everything in another app and it worked so I'll just try and figure it out.
Thanks for your help.
BTW: Have you done anything with custom drawn trackbars and comboboxes?
I have successfully created Ownerdrawn buttons but my trackbars and comboboxes
aren't working at all.
Thanks,
Clint
|
|
|
|
|
With 2 ListBoxes in one DialogBox, how can I change the selected rows in one of them to the other?
|
|
|
|
|
Use GetSelItems() to determine what's selected in listbox #1. Then use SetSel() to select those indices in listbox #2. Listbox 2 should have >= the number of items in listbox #1.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I would like to capture when the user hits the return key when an item in the listbox is selected. However, it would seem that CListBox::VKeyToItem() captures most keystrokes, but only provides an irritating "beep" when I hit return.
What I would like to do is to have the enter key register like a LBN_DBLCLK. Even if CListBox::VKeyToItem() did accept the return key, would it even be possible to have it enable items outside of the CListBox derived class I created?
Any help is greatly appreciated. Thanks in advance.
|
|
|
|
|
Does your list box have the style LBS_WANTKEYBOARDINPUT? If so, OnVKeyToItem() should look something like this:
save status of base class CWnd::OnVKeyToItem() call;
get coords of index of item;
post WM_RBUTTONDBLCLK using those coordinates;
return status;
/ravi
"There is always one more bug..."
ravib@cadence.com
http://www.ravib.com
|
|
|
|
|
Yes, I have LBS_WANTKEYBOARDINPUT. But, it does not seem that OnVKeyToItem is called when the enter key is hit. That is where I am having a major problem. Thanks, though.
|
|
|
|
|
I am working on a dialog that needs to recieve mouse events when I am outside it. In the past I had used a timer in order to call SetCapture when the mouse left the Window, but I felt that was a bit ugly, so this time I tried using WindowFromPoint and passing on messages to windows outside or contained by my own if they were not the ones I was wanting to capture. I found I had to write specific code to press my Close button and I cannot move my dialog. My first approach worked much better, but I always feel that a contant timer == a kludge. Should I just shut up and use the way that works fine, or is there a third, better option ( or maybe something I am missing with option two ) ? I am passing on client and non client mouse events and they work for my child windows, but while Spy++ tells me the messages are being passed to my frame/button, they don't work.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
A couple of ideas spring to mind;
1. How about the TrackMouseEvent function, with an article from Paul Dilascia in MSJ here.
2. What about a system-wide hook? Can't seem to find the link for this right now but I'm sure you'll be able to find it in MSDN - it's a bit late and I'm off to bed now .
Additionally, this might be interesting, another MSJ article. So I like MSJ/MSDN Magasine ok ! (or at least parts of it).
--
Andrew.
|
|
|
|
|
I did something similar with a hook. theres code on cp, or email me for mine.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
How can I read out the current used browser and its path? Where does I find it in the Regestry?
|
|
|
|
|
We have a moderately large project - 100+ classes. Is it reasonable, style-wise, to have each .cpp file include just stdafx.h and something like everything.h - where everything.h would include - in the proper order - all .h files in the project?
It seems to make my life much easier. But would the gods of style frown on me?
J
|
|
|
|
|
If you want to include everything.h in every cpp file, why not just include everything.h in stdafx.h (will speed up compiles). Ahh you say, "but then stdafx will get rebuilt everytime I make a change to a single header file". Yes, but then every file will be rebuilt any way.
Include only the header files you need in the cpp file, do not include extra unneed stuff, it will only slow you down. IMHO.
---
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
The trouble is, with such a large project, the include chain gets huge. For instance, file A.cpp requires A.h and B.h. But B.h requires C.h, D.h and E.h. And D.h requires, blah blah.
So A.cpp ends up including almost every header anyways.
I understand about the slowing down bit, but maybe it's worth a bit of a delay in compiling to have more clarity?
I dunno. But thanks for your opinion.
J
|
|
|
|
|
Clarity is nice, but if it's really a large project, the compile time will take forever. The best way to be really clear about the project about what headers belong in a class is to lay it out on paper.
Good programmers could excel in accounting if they wanted to!
|
|
|
|
|
I often put the includes in the headers themselves, so if A.h is dependent on B.h the #include "A.h" statement would appear in the beginning of B.h. When all the headers are protected by the
#if !defined(_some_unique_preprocessor_symbol)
#define(_some_unique_preprocessor_symbol)
class Myclass : public......
#endif
they'll only get compiled once anyway.
Of course, you can get into problems with finding the right include order and with circular includes, but in my experience this not too common.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
It seems to make my life much easier. But would the gods of style frown on me?
F*ck the gods of style. The problem is that your compile time will grow exponentially and when your project will grow further, the built time will be unacceptably slow and each small change will cause a rebuild.
You're entering the realm of physical (as opposed to logical) design here - I'd suggest reading 'Large Scale C++ Software Design' by John Lakos.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm aware of the compile-time issues... actually arranging it this was decreased compile time.
Perhaps a better way would be to have the required headers included in the header files themselves?
I've just ordered the book you suggested, but could you recommend a better tactic for me to consider while it ships?
Thanks for the input.
J
|
|
|
|
|
actually arranging it this was decreased compile time.
You're kidding, aren't you? Could you post your everything.h file?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Despite the fact that there's absolutely nothing of interest to any of our competitors in our stdafx.h file, posting it would likely be a breach of my contract and hence a Bad Thing(TM).
But no, I'm not kidding. Before I moved everything around, there were about a dozen includes in each file in the project (header and source). So it probably ended up including everything anyways... But one post recommend I put everything in the stdafx.h to take advantage of the MS precompiled header stuff, and holy crap, our build time jumped from about 4 minutes to about 40 seconds.
And of course now, when I make even minor changes to one of the headers, it has to recompile everything.
I understand now style-wise that it's not a good idea, and I'm really looking forward to reading that book you recommended (the reviews make it sound like it's the book I've been looking for for a few years). But could you post a suggested alternative?
It looks like I have 3 options:
1) Put everything in the stdafx.h file and suffer the long and finicky builds.
2) Have each source file include the files that it needs (in the order it needs them) and suffer from each source file having potentially dozens of includes that all have the be in the right order. Build times would be more reasonable.
3) Have each header file have its own includes for specific files that it needs. Have each source file include what it needs above and beyond what comes in through the includes in the included headers. This is clearer than 2 and faster than 1, but it's not as pretty as I would like.
Can it get prettier?
J
|
|
|
|
|
I see where the speedup comes from. However, your first post suggested that you had two files - stdafx.h and everything.h. I thought that you've just created one large non-precompiled header and included it everywhere. Well, this would be a disaster
The first thing to do is to check if you actually need all #includes in .h or even .cpp files. You can reduce interdependencies by using forward declarations whenever possible instead of #includes. In the end of the day you'll probably end with option (2).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I had similar problem (I am still having it...).
I merge files, that I don't change any longer, or which are change very rarely. For example, I create one header file and one implementation file with 10 classes. Compiles faster, takes less time to operate on and load the project. Though it is hard to get used to it.
|
|
|
|