|
This is a common problem with listbox types that sort on string values and do not take account of numbers. I think the only way to get your items in the correct order is to sort them manually and then add them to an unsorted combobox.
It's time for a new signature.
|
|
|
|
|
For a fixed owner draw combo box, handle WM_COMPAREITEM of parent dialog. Or create your own CComboBox derived class and over-ride CComboBox::CompareItem(). Implement your comparison logic there
CComboBox::CompareItem
WM_COMPAREITEM Message
|
|
|
|
|
In addition to the above suggestions, I offer the following.
If you don't mind the items of the combo box items look a bit different, and also you know the maximum width of the numbers, you can pad the items with leading zeros. This way, with the "sort" property set to true, the items will sort correctly.
For example, if you know the maximum width will be two, then format the items like this: 02, 09, 11, 10, etc.
Hope this helps.
|
|
|
|
|
I have a toolbar that can be dynamically floated. It is then in a window with a close button. How do I reopen it if it has been closed? Alternatively, how do I remove the close button.
Haakon S.
|
|
|
|
|
Add a menu item and handler in your CMainFrame class
void CMainFrame::OnViewMyToolbar()
{
if (m_wndMyToolBar.GetSafeHwnd() != NULL)
{
ShowControlBar(&m_wndMyToolBar, !m_wndMyToolBar.IsWindowVisible(), TRUE);
RecalcLayout();
}
}
void CMainFrame::OnUpdateViewMyToolbar(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_wndMyToolBar.GetSafeHwnd() != NULL && m_wndMyToolBar.IsWindowVisible() ? 1 : 0);
}
|
|
|
|
|
Thank you very much, Niklas. ShowControlBar was the key. I kept trying ShowWindow.
Too little research from my side, I should have managed to find out
But again, thanks for pointing in the right direction.
Best regards Haakon S.
|
|
|
|
|
Hi,
I am having a console application. Its a hidden application.I want to close that application.But still it remains in the task manager,its not getting closed.
Im using following code :
CWnd * cWindow = FindWindow("Afx:400000:8:10011 :4604cf", NULL);
::SendMessage(cWindow->m_hWnd, WM_QUIT, (WPARAM) 0, (LPARAM) 0);
Can anyone please tell me where is the error?
Thanks,
|
|
|
|
|
Why don't you send WM_CLOSE ?
See "Terminating Windows-Based Application from Another App".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How to get class id for a hidden application
|
|
|
|
|
Normal console applications do not have a message loop.
It is not message driven.
It just starts executing the main function until the main function returns.
So you cannot send it a windows message.
So if the application is running, it should be either waiting on a wait object or waiting for input or running in a loop.
So you need to tell us what exactly is going on here.
|
|
|
|
|
That console application acts as a watcher. It will open another application.If that application gets crashed,the watcher will again reinvoke that application.While closing the application,that application will close that watcher too.
|
|
|
|
|
OK. Now what I want to know is how the watcher is watching the other application.
Does it wait on the process handle?
Or is it checking for the process existence in a loop?
|
|
|
|
|
it will check that application in a loop
|
|
|
|
|
That is not a very good design.
This is how I would do it.
Start a loop with a flag condition.
Use CreateProcess or any other API that returns a handle to the newly created process.
Use WaitForSingleObject on the process handle.
When WaitForSingleObject returns, use GetExitCodeProcess on the process handle.
In the watched application, you can return an arbitrary value (eg. 15243) for normal shutdown.
So if GetExitCodeProcess returns the arbitrary value, set the flag so that the control comes out of the loop and the watcher also exits.
|
|
|
|
|
|
Hi,
I want to put all my 3 classes (cpp and .h file) in a dll file. I tried using MFC ext dll but to use this dll, I have to use .h file of every class.
How can I avoid that i.e. how to avoid attaching the 3 .h files?
|
|
|
|
|
You can declare all 3 or more classes in a single .h file.
In this case you will only need to include one .h file.
So put all #include statements in a .h file of your own.
Then you can use the single .h file that you created.
|
|
|
|
|
It depends what you mean by "attaching." If you mean how do I write a library which doesn't require inclusion of multiple files then do what super suggested, put them all in a file called libwhatever.h and then users of your library only have to include that one file. On older systems and big projects this can slow compilation down mightily so only do it if you really need to.
However, what you should generally do is come up with minimal include files that only contain what's absolutely necessary to use that class. There's absolutely nothing wrong with users having to include multiple files to use library facilities - we do it all the time for the standard library for instance. It's not uncommon to see seven or eight standard library headers in an implementation file - one file per concept used. On the other hand if you write a class declaration and have that many includes in the header there's probably something wrong and you're heading for design coupling and build dependency hell.
"Exceptional C++" by Herb Sutter has got loads of good advice on how to write include files. Go to your local library/used technical book store/mug someone and get a copy, it's well worth the cost or prison sentence.
Cheers,
Ash
|
|
|
|
|
how to convert from wchar_t to wstring??
|
|
|
|
|
The basic_string class which constructs the wstring object has multiple overloaded constructors to do this.
To construct wstring from a single wchar_t character do the following -
wchar_t Char = L'A';
std::wstring strChar(1, Char);
Here 1 is the repeat count of Char s to be added to wstring .
To construct wstring from an array of wchar_t characters it is more straight forward -
wchar_t* Array = L"Hello";
std::wstring strArray(Array);
|
|
|
|
|
I am programming a console player that plays audio files. I have been able to write the program such that it can now play PCM .wav files. I have also programmed it such that it can decode .mp3 audio files to PCM using libmad and it plays well. I now want to the program to also play non-PCM wave files. I'm sure this will have to be decoded to PCM format but I don't know how this is done. Could anyone help me with how to do this, or a link to books or tutorials useful? Thanks in advance.
|
|
|
|
|
i remember, there is a tool called SOX, which does the conversion from non-PCM(for example, GSM) to PCM. it is a command line tool.
if you search for it, you may get it.
also you may get its open source, if you search more.
all the best.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
I just downloaded the SOX source code. Do you please remember or have a sample project that demonstrates its use? There is an example1 file in the folder but it is not documented which will make it difficult for me to understand how it is used. Thanks.
|
|
|
|
|
if you have an exe file, then this is how, it can be used from the command line.
sox nonpcm.WAV -s -r 16000 PCM.wav
let me know if you have any issues.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
I have the the intent to use it later in a GUI application after understanding its use. This will mean that I will need to understand how it works that is why I need sample applications or tutorials that explains how it is used.
|
|
|
|