|
A customer emailed today asking why a combo box in our program sorted like this:
Item1
Item10
Item2
etc
Our combo box sorts alphabetically and it's a field of names which generally wouldn't have numbers in it.
In other words, they expect "Item10" to follow "Item2" which makes intuitive sense but seems to be difficult to program for.
Has anyone ever seen a combo box that sorts alphabetically and numerically, in any program? Any ideas on how to reliably do that? Is this a known problem with a known algorithm?
|
|
|
|
|
Yeah, its a pain isn't it. Happens in all sorts of places.
Try using this http://sourcefrog.net/projects/natsort/[^] and then manualy inserting the items.
You could just wrap the comparison in a std::less or pass it to qsort.
Ryan.
|
|
|
|
|
Ahh! Outstanding link, thank you very much!
Cheers!
|
|
|
|
|
The simple solution is to make sure everything is in the form item001, item010, item283, like so - then it will work.
|
|
|
|
|
Yes, of course!
Thanks for pointing that out, I should have thought of it before.
|
|
|
|
|
Make every item in same string length, for example, populate your combo box like this:
CString sItem;
for (int i = 0; i < 100; i++)
{
sItem.Format(_T("Item%03d"), i + 1);
m_wndCombo.AddString(sItem);
}
Then items will be sorted in the way you desired.
|
|
|
|
|
Normally yes, but in this case the users enter whatever they want, it's a list of their clients and so I have no control over what they type in.
|
|
|
|
|
|
Ian Darling wrote:
StrCmpLogicalW is your friend.
Ahh! Didn't know about that one, thanks!
Unfortunately it's XP or above only I'm afraid, but will be most useful in future when we can weed people off of w98/wme/wnt4
Cheers!
|
|
|
|
|
Hi,
It's a newbie question. The SDI application show title "Untitled-Generator" where Generator is the name of the application. Now I want it show a different name and also want to change the name of the generated exe to that name. How do I do that without creating a new application with that name?
|
|
|
|
|
CDocument has a member called SetTitle.
|
|
|
|
|
Didn't read the question very carefully - The name of the app is in the resource string table - look there for a string with lots of \n's in it and change that whereever you see the old name. To change the exe, go into the Project Settings for the compiler and change the output file name for Debug and Link. Make sure that it is selected for both Debug and Release versions.
|
|
|
|
|
To change the name of the generated .exe goto Project > Settings > Link, and change the name in the Output file name edit box. I believe the string table can be used to change the internal name of the application so that it compiles a different app title (but if wanted to do this in code you can use CDocument SetTitle).
|
|
|
|
|
Hi,
I wanted to change the VC++ generated small MFC icon on the top left hand corner of my application. I changed the icon in IDR_MAINFRAME, but that only changed the icon in the About Box. Please tell me how to change that Icon?
|
|
|
|
|
When you open the icon in the resource editor, click on the "Device" combo box. Select the "Small (16x16)" option and modify that.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
|
Hi
I've Installed Platform SDK (Nov 00) in order to use some new win abilities in win 2k, like transparent windows and etc.
I Installed the SDK, and added it's directories to the 'direcories' tab in the options dlg of VC6. After that I still can't use the new functions (like SetLayeredWindowAttributes())... what can be the reason?
I'm using VC 6 and Win XP.
thanks.
|
|
|
|
|
What error message are you getting?
|
|
|
|
|
define _WIN32_WINNT as a value bigger or equal than 0x0500!
read definition of SetLayeredWindowAttributes in WinUser.h!
Don't try it, just do it!
|
|
|
|
|
|
In my SDI application, I have 2 tree controls in a formview, which can be selected by tab control. On tabchange(), I select the root of the tree in which I switched. But, in that case whole tree becomes grayed. I can click on the grayed tree to see the items.
Following is the code, Please Help!!
if (m_TabCtrl.GetCurSel( ) ==1 )
{
m_TreeCtrl2.SelectItem (m_TreeCtrl2.GetRootItem());
}
if (m_TabCtrl.GetCurSel( ) ==0 )
{
m_TreeCtrl1.SelectItem (m_TreeCtrl1.GetRootItem());
}
|
|
|
|
|
Hi
Folks i am here with a problem
I did the followin things in my SDI VC application(MFC exe with default App wizrad options)
1.Created a Dialog Resource with a ComboBox(Attached a Control Variable to that m_ctrlCombo)
,attached a new class to it ( CTestDlg ).
2.Created object of CTestDlg in view class in OnLButtonDown()
[code]
void CTestView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CTestDlg dlg;
dlg.m_ctrlCombo.AddString("Alpha");
dlg.m_ctrlCombo.AddString("Beta");
dlg.DoModal();
CView::OnLButtonDown(nFlags, point);
}
[/code]
The Problem is that when i run the application and OnLButtonDown() Function is invoked
.I get a debug assetion failure
* "File: afxwin2.inl
Line 735 "
when i ignore it two times the Dialog is shown but no string attached to the comboBox
Plz help me out Folks to solve this.
Thanx in advance.
|
|
|
|
|
jinbabaj wrote:
dlg.m_ctrlCombo.AddString("Alpha");
dlg.m_ctrlCombo.AddString("Beta");
This should be in the InitDialog method of the dialog.
The assert pops because the dialog is not CREATED, only constructed, and will be created in the DoModal method.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
|
Hey..
I wanted to configure Modem settings like
modem speed,parity,data bits,stop bits,"wait for dial tone before dialing" etc. programmtically.
I would also like to set some DUN settings like "Log on to network" and "Allow unsecured password" etc.
Advanced Thanks for any code, suggestions, clues or referrences...
|
|
|
|