Click here to Skip to main content
15,917,604 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralI need help about how to use OpenSSL library. Pin
Artem Moroz8-Nov-03 11:39
Artem Moroz8-Nov-03 11:39 
GeneralRe: I need help about how to use OpenSSL library. Pin
Johnny ²9-Nov-03 3:37
Johnny ²9-Nov-03 3:37 
GeneralRe: I need help about how to use OpenSSL library. Pin
cperdana28-Mar-10 20:00
cperdana28-Mar-10 20:00 
GeneralLonghorn programming and WinFX Pin
Snyp8-Nov-03 10:03
Snyp8-Nov-03 10:03 
GeneralI want to open NEXT or PREV file. with button control Pin
gaesabal8-Nov-03 8:58
gaesabal8-Nov-03 8:58 
GeneralRe: I want to open NEXT or PREV file. with button control Pin
Antti Keskinen8-Nov-03 10:44
Antti Keskinen8-Nov-03 10:44 
QuestionHow do I handle Single and Double Mouse Clicks? Pin
jasonmgeorge8-Nov-03 8:30
jasonmgeorge8-Nov-03 8:30 
AnswerRe: How do I handle Single and Double Mouse Clicks? Pin
Antti Keskinen8-Nov-03 9:58
Antti Keskinen8-Nov-03 9:58 
GeneralRe: How do I handle Single and Double Mouse Clicks? Pin
jasonmgeorge8-Nov-03 10:33
jasonmgeorge8-Nov-03 10:33 
GeneralRe: How do I handle Single and Double Mouse Clicks? Pin
Antti Keskinen8-Nov-03 11:06
Antti Keskinen8-Nov-03 11:06 
AnswerRe: How do I handle Single and Double Mouse Clicks? Pin
Michael Dunn8-Nov-03 14:30
sitebuilderMichael Dunn8-Nov-03 14:30 
GeneralBITMAPV4HEADER & BITMAPV5HEADER Pin
John R. Shaw8-Nov-03 7:34
John R. Shaw8-Nov-03 7:34 
GeneralRe: BITMAPV4HEADER & BITMAPV5HEADER Pin
J. Dunlap8-Nov-03 13:22
J. Dunlap8-Nov-03 13:22 
GeneralWindows Address Book Pin
PJ Arends8-Nov-03 7:17
professionalPJ Arends8-Nov-03 7:17 
GeneralRe: Windows Address Book Pin
cmk8-Nov-03 9:45
cmk8-Nov-03 9:45 
GeneralRe: Windows Address Book Pin
PJ Arends9-Nov-03 6:58
professionalPJ Arends9-Nov-03 6:58 
GeneralRe: Windows Address Book Pin
Peter Molnar8-Nov-03 9:45
Peter Molnar8-Nov-03 9:45 
GeneralRe: Windows Address Book Pin
PJ Arends9-Nov-03 6:59
professionalPJ Arends9-Nov-03 6:59 
Questionhow to find the number of same items in two STL vectors Pin
hesham_16820018-Nov-03 6:47
hesham_16820018-Nov-03 6:47 
AnswerRe: how to find the number of same items in two STL vectors Pin
ZoogieZork8-Nov-03 8:03
ZoogieZork8-Nov-03 8:03 
GeneralSend Sms using visaul c++ 6 Pin
nolanl8-Nov-03 3:04
nolanl8-Nov-03 3:04 
GeneralRe: Send Sms using visaul c++ 6 Pin
Peter Molnar8-Nov-03 5:28
Peter Molnar8-Nov-03 5:28 
GeneralRe: Send Sms using visaul c++ 6 Pin
nolanl9-Nov-03 23:31
nolanl9-Nov-03 23:31 
GeneralCButton declaration Pin
Ahmed Galal8-Nov-03 2:30
Ahmed Galal8-Nov-03 2:30 
GeneralRe: CButton declaration Pin
Antti Keskinen8-Nov-03 12:05
Antti Keskinen8-Nov-03 12:05 
Because of the way MFC works:

1. Construct an object you desire in the application. This can be anything from CButton to CPen, a CEdit or a CListBox, no matter. You can construct it statically (adding a static member to your parent class definition) or dynamically (by using a static pointer with the 'new' operation)

2. When the object is constructed, call it's 'Create' member method to create the underlying Windows object, and bind it to this MFC object.

3. When you no longer need the Windows object, call 'DeleteObject' to destroy it.

4. When you no longer need the MFC object, either let it pass out of scope so it's destructor is called (static members) or call 'delete' to release dynamically reserved memory.

Now, as for the code analysis you posted:

You created a CButton static object in the CView::OnCreate handler. This means that the MFC object is constructed. If you call the 'Create' member function, the underlying Windows object is created as well. When the handler call ends, the CButton destructor gets called, and it's existence straightforwardly ends.

You should go to the local library and pick up an MFC programming book. Knowledge in Windows programming also helps. This book would be able to clarify the functionality of MFC to you in detail, so you can get a better grasp of what it actually is and how it is used.

CodeProject sports a collection of good articles as well:
-Nishant S.'s excellent 'MFC under the hood' article http://www.codeproject.com/cpp/mfcprogflow.asp[^].
-Mehdi Mousavi 'Win32 vs MFC, part I' http://www.codeproject.com/cpp/mfc_architecture.asp[^].
-Joseph M. Newcomer with 'Attaching and Detaching objects' http://www.codeproject.com/cpp/attachdetachobj.asp[^].

You can find more from the 'General' and 'Beginners' sections of General -> C++/MFC area. Happy browsing Smile | :)

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.