|
!!!
Yours Truly, The One and Only!
|
|
|
|
|
What is DEP and how to write DEP compatible program?
Amar.
|
|
|
|
|
|
I have a form which is inherited from CDialog.It can be resizing.
Now I want to set its minimum size (300, 200). It couldn't be smaller than (300, 200). How to do it with MFC 6.0.
Thanks in advance.
|
|
|
|
|
Add a message map entry for WM_GETMINMAXINFO and override ...
afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI );
lpMMI->ptMinTrackSize.x = 300
lpMMI->ptMinTrackSize.y = 200;
|
|
|
|
|
Off the top of my head, you should be able to do it by handling WM_GETMINMAXINFO / CWnd::OnGetMinMaxInfo.
Iain.
|
|
|
|
|
Hi,
My application has dependency with lib files.
For db access and other related things there is one lib.
I'm trying to use a retry logic when db connection fails.
The retry logic is implemented in the application.
When a CDBException occurs, it is propagated using throw.
In some functions there is AfxThrowDBException. The problem is in some functions the exception pointer is deleted.
For eg: catch(CDBException* e) {e->Delete();}
So when the throw is propagated, and in the next(need not be immediate outer) catch block if again e is used, i'm getting unhandled exception.
Should I check all the CDBException and remove e? Or is there any other alternative for this?
Thanks and Regards,
sanju.
|
|
|
|
|
why throwing a pointer rather than a reference ?
|
|
|
|
|
What is the advantage of using a reference?
|
|
|
|
|
no need for delete dude !!
|
|
|
|
|
Are you talking about rethrowing a reference to the CDBException pointer or throwing an object
reference?
If throwing an object reference to an object that isn't static - can the object go out of scope
before the exception is caught?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
check what i'm doing in my VisualCalc Parser[^]... full of exceptions references. and it works perfectly well...
|
|
|
|
|
How are you catching the exception in more than one place? If you're rethrowing it then you
shouldn't delete it before doing so. Only the final handler should delete the object.
Unless I'm missing something...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
My exact thoughts .. for all piratical purposes the exception has been handed inside the catch block and the propagation stops there!
What remains is how the code execute after this point!
Also as someone said, it's better to throw the object on the stack rather than on the heap and have to deleted it after!
|
|
|
|
|
I had to reread the docs about stack-based exception objects to refresh my mind on the scope of
those objects when they're thrown (see my question to toxcct).
A copy is made if it's caught by value - that's what I forgot
_NightOwl_ wrote: What remains is how the code execute after this point!
"If a matching catch handler is found, and it catches by value, its formal parameter is
initialized by copying the exception object. If it catches by reference, the parameter is
initialized to refer to the exception object. After the formal parameter is initialized, the
process of unwinding the stack begins. This involves the destruction of all automatic objects
that were constructed (but not yet destructed) between the beginning of the try block associated
with the catch handler and the exception's throw site. Destruction occurs in reverse order of
construction. The catch handler is executed and the program resumes execution following the last
handler (that is, the first statement or construct which is not a catch handler). "
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Mark, yes a copy is always made for all automatic types when passing it around, in fact a copy is made when the object is thrown and placed onto the stack
you just have to vision the exception floating up and backwards through the call chain! Once it's caught by a handler, execution will continue as you found out at the very next statement outside the scope of the catch block. Using a reference means one extra step is spared of not having to copy the exception off the stack and into the catch handler parameter.That slipped my mind till your last note reminded me! and I see your earlier confusion about an object going out of scope before use
|
|
|
|
|
Great description!
Thank you!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Hi everybody!
I've got a big problem. It would be nice if someone could help me. Thanking you in advance.
I have created 4 tab windows as normal dialog boxes, then I can link those dialogs to the Tab control (using the code given at this website:http://www.codeproject.com/tabctrl/SimpleTab.asp.
In each dialog box, I've got some child controls like : Edit box, check box, button, combo box...
Now, I really want to read data, or to get data , even to exchange data between the different dialogs. How can I make it?
Thanks for your answer anyway.
stephane (Mechanical Ingineer, get starting with VC++, MFC)
|
|
|
|
|
p1 = new CTabPageOne();
p1->Create(IDD_DIALOG_PAGE1,m_ctrlTAB.GetWindow(IDD_DIALOG_PAGE1));
p2 = new CTabPageTwo();
p2->Create(IDD_DIALOG_PAGE2,m_ctrlTAB.GetWindow(IDD_DIALOG_PAGE2));
You have in your main dialog two pointers to your 2 tabs.
So you have a lot of possibilities to exchange data.
For example if you enter a text in a Textbox in Tab1, it should be also entered in Tab2 :
The Main Dialog has the pointers to the Tabs, and each Tab has a pointer to his parent (the Main Dialog)
Now you can make it like this :
CString str;
this->textbox1.GetWindowText(str);
Home->p2->SetValueIntoBox1(str);
where you have a function at tab 2 called CTabPageTwo::SetValueIntoBox1(CString val) which stores
the text into the textbox 1
You even can make a Data-structure which carries all the date to exchange ...
Good luck
Regards
|
|
|
|
|
Hi baerten!
Thanking you for your answer. I try right now.
Best Regards
stephane
|
|
|
|
|
Hello Guys,
i am Vishwanath Patil. i was previously worked on networking technologies SNMP. but now i am working on VC++ and MFC. so i am completely new to these technologies, so i want to learn about these technologies. so if any one who has some good books or sites where it will help for beginners then please replay me.
thanks,
Vishu,
Software Developer,
Target Corporation,
Bangalore.
|
|
|
|
|
MFC is kind of dead compared to a few years ago ( not that it's absolutely dead, of course ). This is probably the best site to ask MFC questions. As far as books go, I'd think you'd find a lot of used books on ebay cheap, for the same reason.
Depending on your background ( do you already know C++ ? ), you may find that downloading MFC articles from this site and experimenting with them is a good place to start. If you don't know C++, learn C++ first, then learn MFC on top of that. What books are good for C++ depends again on your background. If this is your first language, I'd start slow with something like 'teach yourself C++ in 24 hours'. If you have a background in other languages, you may be able to jump right into 'The C++ programming language' by Bjarne Stroustrup.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i know C++, i already did two projects using c++
Vishwa,
Software Developer
Target Corporation,
Bangalore
|
|
|
|
|
There are a lot of good book about VC++/MFC programming, for instance, have a look at
Jeff Prosise's one [^].
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.
|
|
|
|
|