|
Member 2603772 wrote: If you do not throw, then why bother trying to catch, which is what the previous items advocate?
Not using exception specifications doesn't mean you are guaranteeing that your code doesn't throw an exception - it's the reverse of that - you are making no guarantees about whether your code throws exceptions or not. If a piece of code you're calling has no exception specification, assume that it may throw *any* exception. Only handle exceptions if there's some action you can perform that fixes what caused the exception. Any other exception should be allowed to terminate the application - if you don't know how to fix what caused the exception, then you've got problems.
Member 2603772 wrote: If exception specifications are bad why does C++ support them?
They're not bad per se. The point is that C++ doesn't enforce them or (really) take any notice of them. That means that compilers won't verify that they're correct, so they're liable (like code comments) to become inaccurate as you change the code they describe, because you probably won't remember to change the exception specification.
This article[^] by Herb Sutter may help to make his view on exception specifications clearer?
|
|
|
|
|
Maybe this article[^] helps you understand the exception specifications and why they are not a good idea.
|
|
|
|
|
Dear All,
I just started to use MFC library together with Visual Studio 2008 to wrap around my
mathematical engine which I build as a console application.
I hope my question will be easy to answer. I have CListBox object which I fill time to time with error messages in catch block:
....
catch (std::exception& ex)
{
std::string str = ex.what();
m_List.AddString(str.c_str() );
}
....
Sometimes, error messages are longer then physical width of CListBox object and as a result truncated.
As far as I see, CListBox object does not have property in "Property list" to explicitly specify string/word wrapping. There are few properties such as "Multicolumn", "Horizontal Scroll", "Disable No Scroll" which does not help me to make it possible to view all length of error messages.
I am sure it must be easy way to do it. I hope someone will have some suggestions/comments about it issue.
Thank you in advance,
nuclph.
|
|
|
|
|
nuclph wrote: I am sure it must be easy way to do it
The easy way is to use a different control. Think about it - what would it mean to word-wrap in a list - is the wrapped text the same or different items than the first bit of the line?
For what you're doing, I'd use a rich edit control, a) so I could specify a monospaced font like courier easily, and b) it's got this[^] useful method.
|
|
|
|
|
Stuart is quite right - a multiline list control would be odd.
You could implement an owner draw one, and make each entry take two lines, with some sort of visual cue - but that would be hard work - and a waste if you commonly have a small amount of text for each entry.
Alternately, you could use a tooltip for your CListBox.
Read:
http://msdn.microsoft.com/en-us/magazine/dvdarchive/cc301416.aspx[^]
and then go to
http://www.dilascia.com/PixieDoc.htm#CListBoxTipHandler[^]
for code. All of Paul DiLascia's work is worth a look see. I learned loads from him when I started out.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Iain Clarke wrote: All of Paul DiLascia's work is worth a look see. I learned loads from him when I started out.
Indeed! I too learned truck loads from his articles. He died the night of September 3rd, 2008[^].
|
|
|
|
|
Wow, that was news to me. I just assumed he'd made his piles from early microsoft shares (or from bribes to answer particular reader questions) and had retired to Tahiti.
As I was largely working alone, he and Matt Pietrek were my MFC teachers.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Dear All,
I want to add the special character "&" into my label box, but when I add this, it takes as "_". I know that putting "&" before a character makes the "_" as a shortcut for Alt key.
But I want to include "&" to be displayed in my label box. Is there any way for this ?
Thanks in advance.
Bhanu
|
|
|
|
|
Try with a double &, only one will be displayed.
|
|
|
|
|
Thank you for your kind help. It is working...
|
|
|
|
|
Hallo all,
I have used a List box control and it showing some files full path. I want to show this path one by one when it find out like "Searching in xp". But it display all path at a time. Can any one help me.
Thanks
Regards
saheen
|
|
|
|
|
Shaheen.India wrote: I have used a List box control and it showing some files full path. I want to show this path one by one when it find out like "Searching in xp". But it display all path at a time. Can any one help me.
Have you tried using DlgDirList[^]?
|
|
|
|
|
|
Do you mean that you run a loop looking for the files, when you find one you add the path to the list, but the list only gets redrawn once your loop is done thus all your hits appear at once? If so, you have 3 options i can think of right now:
1. do the search in a different thread and send/post your hits towards the GUI thread
2. do your search with a timer
3. do your search in idle-time (when your GUI thread has no messages to process)
p.s: You could also try simply forcing your list to be redrawn in your loop with e.g. using RedrawWindow, but that would be an ugly solution.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for your reply. Yes, I have used it in loop, that's why the problem arise
|
|
|
|
|
Another option you can do is within your loop, when you find a file you are most likely doing
m_ListBox->AddString(xxxx)
Immediately after you do the AddString, you can add
m_ListBox->UpdateWindow() and that will cause the list box to show the new data.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi,
I want to launch outlook using ShellExecuteEx and I am able to launch it. But I want to pass file (mydoc.doc) as a parameter to it. So that it will open an outlook evelop and attach this file to it.
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = NULL;
shExecInfo.lpFile = "OutLook";
shExecInfo.lpParameters = "C:\\test\\mydoc.doc";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_MAXIMIZE;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
Please let me know what wrong with this code.
Thanks
SNI
|
|
|
|
|
Does it work if you simply run outlook with a doc parameter from a console or using RUN in start menu? Maybe you need to specify other parameters to let Outlook know what you want it to do with that doc.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Thanks for reply. But I tried with other parameters but it is failing and giving following msg
"The command line argument is not valid. Verify the switch you are using." Is there any switch needs to be provided while specifying the file name.
SNI
|
|
|
|
|
Check out here[^], it says, the command line argument for attaching a file is /a <path to file>
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
I would like to make it so that when the cursor is over my window it has a custom look. How can I achieve this with win32?
Thanks,
Steve
|
|
|
|
|
One way is to handle the WM_SETCURSOR[^] message. A different way would be to specify your own cursor handle when registering a window class.[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
wibblewoo wrote: I would like to make it so that when the cursor is over my window it has a custom look. How can I achieve this with win32?
Using cursors![^]
|
|
|
|
|
Oh God I don't know how I didn't find that when I was looking.
Thanks.
|
|
|
|
|
wibblewoo wrote: Oh God I don't know how I didn't find that when I was looking.
MSDN has an interesting set of "Using xxxx" series. If interested type in "Using" into the index edit box and you'll see a bunch of articles.
|
|
|
|