|
Thanks.
I use
exit(-1); after the message box. it works.
if (npoints>32768) {MessageBox("The sampling time interval is too small. Please select a larger sampling interval.");
exit(-1);
}
|
|
|
|
|
mrby123 wrote: I use
exit(-1)...
To exit a Windows GUI application?
Not a good choice.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
mrby123 wrote: Please select a larger sampling interval.
That message does not make sense if your app is exiting anyway.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
When you program suddenly stop, you may want to inform the use what happen.
Otherwise, the use feels not good.
|
|
|
|
|
I agree, but then you should choose a more accurate message; maybe "next time you run this program, please enter ...".
Although I still think it is rather rude to stop a program just because the interactive user entered something you did not like; you should allow for another chance.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I agree with you, it is better to give user a chance to correct.
I wish to find an interactive message box to allow user to inter a correct value for the parameter.
Do anyone know how to program an interactive dialogue box?
Thanks again
|
|
|
|
|
Assuming you're using MFC...
If (IDYES == MessageBox(_T("Are you sure you want to quit"), _T("Confirm Exit"), MB_YESNO))
{
PostQuitMessage(0);
}
|
|
|
|
|
you may want to implement this pseudo-code:
string s="Please enter a number in the range [a,b]"
for(;;) {
int n=NumericInputBox.Show(s);
if (n==-1) Application.Exit();
if (n>=a && n<=b) break;
s="Sorry, "+n+" is not valid as it is not in the range [a,b]; please try again now (or enter -1 to quit)";
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi Thanks. I will try it. Another Key is to make sure the app can catch the new value entered in the dialogue box.
Thanks for any specific instructions.
|
|
|
|
|
Well, maybe you should just "return" from the current flow of execution and let the user enter a new interval instead of just closing the application!!
something like :
while (sample not good )
{
enter sampling.
compute value.
validate value.
}
M.
Watched code never compiles.
|
|
|
|
|
I am running MFC C++ application.
Your suggestion is good. I do not know which dialoge box should I use to do such interaction.
Thanks again
|
|
|
|
|
Hi,
As you're using an MFC app look up Dialog Data Exchange (DDX) and Dialog Data Validation (DDV). Between the pair of them you can specify allowed ranges for field in a dialog box and give the user a message if they enter something that's out of the range. Out of the box it's a bit clunky but works okay with a bit of tender loving care.
So if you've got an edit control with the sampling interval in milliseconds (IDC_SAMPLE_INTERVAL) and you want the user to be able to enter something between 10 and 1000ms, you overide DoDataExchange in your dialogue box class as something like:
void CSampleDlg::DoDataExchange( CDataExchange *pDX )
{
CDialog::DoDataExchange( pDX );
DDX_Text( pDX, IDC_SAMPLE_INTERVAL, sample_interval_ );
DDV_MinMaxInt( pDX, sample_interval_, 10, 1000 );
}
where sample_interval_ is the data member containing your er, sample interval.
If the entered interval isn't between 10 and 1000 MFC displays an message box and lets the user choose to abandon the edit or try again.
Cheers,
Ash
PS: Using exit() in a C++ program can be a bad idea one main reason - destructors aren't run for any objects. If those objects are managing a system global resource then that resource can leak. It can also mean that files aren't flushed and closed properly and may not have the contents you expect.
On the other hand exit() can be a quick way to bail out of a misbehaving program with a long shutdown time if that shutdown time is due to a large number of or slow destructors. This is generally regarded as being pretty vile by most C++ experts and only used as a desperate measure.
|
|
|
|
|
a nice program would check the range and ask for a proper value, before saving the value.
-> "Please enter a valid value or quit"
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
It's the icon at the top-left that by default is MFC. The resource file for the icon is res\main.bmp
It is a 26x26 32-bit bitmap. For the icon I have a png file that has transparency. My problem is how to change the icon while preserving the transparency of my original png. Since by default the bitmap is 32-bit I assume it supports transparency, but when I saved my icon as 32-bit bitmap from photoshop, the new icon simply wasn't displayed. If I save it as a 24-bit bitmap it is shown but there's no transparency of course, which is a big problem.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: the new icon simply wasn't displayed - how do you mean that? It crashed? It was there but was fully transparent? Are you sure your 32 bit BMP had anything on its alpha channel?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
No, no, it didn't crash. I meant that visually it wasn't there. There seemed to be something that was a bit whiter where the icon should have been, but overall the "jewel" was an empty circle with no icon inside it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Check the alpha channel of your BMP, maybe it's empty...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
My problem is solved now after some googling, thanks to this free tool[^] by Adam Najmanowicz which converts png files to 32-bit bitmaps while preserving transparency. It works great now
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
I have a C++ native Win32/MFC app which uses a structured exception handler. When the handler is invoked, I'd like to be able to create a crash dump file to allow the user to submit it for analysis.
I'd like to, from within code, create the dump file and I need to do it under both WinXP and Win7.
Then if a user is experiencing a crash, they can enable this as an option and then send us the crash dump file which gets written.
Any ideas?
|
|
|
|
|
How about this[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
awesome! Thank you for the link. I'm going to give that a try.
|
|
|
|
|
Is it possible to get the WinInet interface reference of a browser, IE or firefox
Regards
Rajmohan
|
|
|
|
|
Not sure what you mean by WinInet interface for IE.
But you can check out BHOs and some interface you can get from IE like IWebBrowser2 , IHTMLDocument2 , IHTMLElement etc.
|
|
|
|
|
Thank you so much for your response. Actually I was able to get the IWebrowser2 and IHTMLDocument2 for internet explorer. My aim was to get these type of helper objects to assist Firefox, Since firefox is using WinInet dll ( I was able to find with some tool) I queried about WinInet.
Regards
Rajmohan
|
|
|
|
|
How to load PNG image on the dialog using the Resource ID of the PNG imqage.
|
|
|
|