|
Luc Pattyn wrote: the big try-catch is great as a fall-back, to exit gracefully with a log;
but it is no substitute for the regular try-catch blocks you should implement at
critical points in the code.
I Know. My "I don't know if it is a good idea" was about that.
Luc Pattyn wrote: Also it only catches exceptions in the main thread. So there is a lot more to it to get
it right.
he may repeat the pattern in all program threads.
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
|
|
|
|
|
CPallini wrote: he may repeat the pattern in all program threads.
and in all callback functions/methods (e.g. timer ticked, serialport datareceived),
requiring the implementation of an exception tracing mechanism, so the info does not
get lost.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
I make a guess: he is not developing a OS from scratch...
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
|
|
|
|
|
CPallini wrote: I make a guess: ...
I'm not a guessing guy, and the OP explicitly asked how to catch all possible exceptions,
hence...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: I'm not a guessing guy
Well, I will not keep going at your limitations...
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
|
|
|
|
|
|
Exceptions depednds to your program,what's your code?
|
|
|
|
|
Every time I used TextOut (e.g. TextOut(dc,20,20,S,strlen(S)); ) with Borland C++ 4.52 under Windows 95 or Windows 98, the position of the text (in the second & third args) was relative to the window that the calling application was running in. But with Visual C++ under Windows Vista the text is positioned (here, at (20,20)) relative to the whole screen. This is a nuisance. What is happening? How can I position the text relative to my application's window?
modified on Saturday, April 12, 2008 9:01 AM
|
|
|
|
|
I dont know why the phenomenon happens, anyway ClientToScreen [^] function maybe useful.
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
|
|
|
|
|
TextOut() in the context you show is a Windows API - it shouldn't vary between compilers.
It could vary between Windows versions, but that would break a lot of apps.
The problem is your DC. The device context determines where the text goes, based on how the DC
was acquired, its mapping mode, its text alignment settings, etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I made the device context using ordinary familiar GetDC(hwnd) .
|
|
|
|
|
Then hwnd must have been NULL.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi!
I know this may looks a little funny! But when I use CDialog::EndDialog to terminate my dialog based app, the main window (dialog) disapears well, but when looking at Task Manager, I found it already running!
Can U help me PLS?
|
|
|
|
|
Hi,
If you have other threads running, the app will wait for them to terminate, unless they
are set to be background threads.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Thanks 4 Ur reply!
I've not made any thread myself;
Is it possible for MFC classes to create threads by themselves? (Specially I used CRecordset frequently in my app!)
Thanks 4 Ur attention!
|
|
|
|
|
Usef Marzbani wrote: Is it possible for MFC classes to create threads by themselves?
I don't know, it could be. If so, it must be documented, and the doc should tell you what
to do about it, say call Close(), Stop() or whatever is appropriate.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
EndDialog() may be the wrong method for shutting down your app.
It depends on how and where you create the main dialog. Is it modal or modeless?
Where in the code do you create it?
CDialog::EndDialog is for modal dialogs. That means your main dialog needs to be created modal.
When control returns from the modal dialog, your app needs to exit. It should be something like this:
BOOL CMyApp::InitInstance()
{
CMyMainDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
return FALSE;
} If you return TRUE from InitInstance(), that would cause the behavior you're seeing, since the app
would still be running but the dialog would be gone.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Your My(Perfect & Hero)
Thank you!
|
|
|
|
|
Or you can use of PostQuitMessage.
|
|
|
|
|
hi
i need to write the € sign (currency in europe) to a file.
i have some text in a std::wstring which includes a €-sign. if i put the text in the stream any following letter after the euro sign won't receive the output file.
i tried to solve the problem by replacing the sing with the unicode sequence, but with no positivie result
<br />
<br />
#include "stdafx.h"<br />
#include <fstream><br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
std::wstring s = L"Hello World, i own 20 \u20AC hurray!";<br />
std::wofstream out(L"C:/euro.dat", std::ios::binary);<br />
out<<s.c_str();<br />
return 0;<br />
}<br />
</fstream>
my outfile euro.dat contains for this example "Hello World, i own 20 " anything after is missing.
i figured out that if i use std::string it works(why ever), but i would prefer a soloution that supports std::wstring. anyone has a idea how to make things running with wstring ?
|
|
|
|
|
See here [^].
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
|
|
|
|
|
|
Hi all,
I want to pass a CString parameter through ShellExecute() api to my exe..
I am doing this using this code:-
CString CurrentPath = _T("C:\\test\\test.ini");
ShellExecute(NULL,_T("open"),CurrentPath,NULL,NULL,SW_SHOW);
My problem is i don't know how to access this parameter in my exe.
Can anybody tell me how to do so??
Thanks in advance
|
|
|
|
|
I see no exe in the above code.
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
|
|
|
|
|
sorry i posted wrong code
CString CurrentPath = _T("C:\\test.exe");
CString para = _T("c:\\test.ini");
ShellExecute(NULL,_T("open"),CurrentPath,para ,NULL,SW_SHOW);
what i want is i want to access para value in my test.exe code
|
|
|
|