home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / mfcfaq13.zip / MFC_FAQ1.TXT < prev   
Text File  |  1995-08-31  |  189KB  |  4,643 lines

  1.  
  2.  
  3.  
  4.                   Microsoft Foundation Classes (MFC)
  5.                       Frequently Asked Questions
  6.                    Scot Wingo (scot_wingo@msn.com)
  7.                               Version 1.3
  8.                           Last updated: 8/29/95
  9.  
  10. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  11.                            *Version 1.3 Note*
  12.  
  13. Now that Windows 95 has settled down somewhat (did everyone see Billg
  14. at least 5 times on TV?), it's that time again! Yep, version 1.3 of
  15. the MFC FAQ is ready!! This version has loads of new material.  Some
  16. highlights->  
  17.  
  18.   * 14. STUMPERS!: 1.3 introduces a new section into the FAQ.  This
  19.     section contains some really hard MFC questions that people have
  20.     asked, but don't have answers to.  The first person to answer the
  21.     question will get their name permanently in the FAQ and plus will just
  22.     feel better about helping out the stumped person.
  23.  
  24.    *6.2.9.  How do I change the background color of a BUTTON???
  25.    *6.2.11.  How do I get to the CEdit in a combobox?
  26.    *6.3.9.  How do I change the captions of a CPropertyPage?
  27.    *11.23.  How do I handle my own registered messages?
  28.  
  29. To participate in the "Instant-FAQ (TM)" program for the next release,
  30. just send your email address to me at: scot_wingo@msn.com and I'll add
  31. you for free.  We at MFC FAQ headquarters aim to please!!  (In other
  32. words, it's like a free MFC FAQ subscription, this is NOT a mailing
  33. list or listserver.)
  34.  
  35.                       * MFC FAQ Quote of the Month *
  36.  
  37.   "At 2:00am, reaching for that twelfth cup of coffee, rubbing my
  38.    sore, red eyes with the deadline approaching rapidly, it is a great
  39.    feeling to glance over at the MFC-FAQ and see that someone else has
  40.    already solved a problem that I just encountered. Much thanks. "
  41.    -spolyak@interaccess.com
  42.  
  43.                            ** VC++/MFC 4.0 **
  44.  
  45. At MFC FAQ headquarters the buzz about VC++ 4.0/MFC 4.0 is
  46. overwhelming.  We're planning a special edition (version 2.0) of the
  47. MFC FAQ simultaneously with the announcement and release of VC++ 4.0!
  48. You'll find all the COOL 4.0 information here the second it is
  49. available, so stay tuned. 
  50.   
  51. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  52.  
  53. Copyright
  54. ---------
  55.   This document is compilation Copyright (c) 1995 by Scot Wingo.  It
  56.   may be freely copied and/or distributed in its entirety as long as this
  57.   copyright notice is not removed.  It may not be sold for profit or
  58.   incorporated into commercial products without the author's written
  59.   permission.  [Compilation copyright means that you can freely use
  60.   individual sections of this document, but any significant collection of
  61.   sections is subject to the copyright. Hey, I may want to turn this
  62.   into a book or a movie some day!]
  63.  
  64.   This FAQ is in no way connected with Microsoft.  It contains some
  65.   answers to frequently asked questions about their products.  The
  66.   author in no way guarantees that any of these answers are correct.
  67.   This is just a collection of information posted to public on-line
  68.   forums to help the average MFC programmer. [In other words, please
  69.   don't sue me. ]
  70.  
  71.   [Note: If you are not using a fixed font, the tables and other
  72.    formatting of this FAQ will not look correct.  Courier 12 works well
  73.    for me.] 
  74.  
  75.                           Table of Contents
  76.                           =================
  77.  
  78. Key:
  79.    % - Indicates serious revision since version 1.2
  80.    * - Indicates something entirely new and exciting since version 1.2
  81.  
  82. 1.  MFC FAQ Info and Credits
  83.  %1.1.  How do I get this FAQ?
  84.         - "Instant-FAQ (TM)"
  85.   1.2.  What's the goal of this FAQ?
  86.   1.3.  Why are you doing this?
  87.   1.4.  How can I contribute!?!
  88.  %1.5.  Credits
  89.   1.6.  How is this different than the MSVC MFC FAQ?
  90.   1.7.  What other languages is this FAQ translated to?
  91.     1.7.1.  Japanese version of MFC FAQ
  92.  
  93. 2.  Where to go for Juicy MFC Information
  94.   2.1.  Microsoft
  95.     2.1.1.  MSVC and MSVC Subscription
  96.     2.1.2.  Microsoft Developers Network (MSDN)
  97.     2.1.3.  Knowledge databases
  98.     2.1.4.  Microsoft Software Library 
  99.   2.2.  Internet
  100.     2.2.1.  World Wide Web pages
  101.    %2.2.2.  Mailing lists
  102.     2.2.3.  Usenet news groups
  103.     2.2.4.  Other FAQs of interest
  104.     2.2.5.  FTP sites
  105.    *2.2.6.  The MFC FAQ FTP Archive!
  106.   2.3.  CompuServe
  107.   2.4.  Printed matter
  108.    %2.4.1.  Magazines and journals
  109.    %2.4.2.  Books on MFC
  110.     2.4.3.  Cool MFC Articles
  111.   2.5.  Trade shows
  112.   2.6.  User's groups
  113.   2.7.  Technical Support
  114.  
  115. 3. A Brief History of MFC (Answers to questions about MFC/MSVC versions)
  116.   3.1.  How do I know what version of MFC I have?
  117.   3.2.  Pre-MFC 1.0
  118.   3.3.  MFC 1.0
  119.   3.4.  MFC 2.0
  120.   3.5.  MFC 2.1
  121.   3.6.  MFC 2.5
  122.     3.6.1.  MFC 2.51
  123.     3.6.2.  MFC 2.52
  124.     3.6.3.  MFC 2.52b
  125.   3.7.  MFC 3.0
  126.   3.8.  MFC 3.1
  127.   3.9.  MFC 3.2
  128.   3.10.  MFC 4.0
  129.   3.11.  Table of MFC releases
  130.  
  131. 4.  Generic Class Questions
  132.   4.1.  CException - Exceptions and exception handling.
  133.     4.1.1.  How do I throw a CUserExeception derived exception?
  134.  
  135. 5.  GDI Class Questions
  136.   5.1.  CDC
  137.     5.1.1.  How to I create a CDC from a HDC?
  138.   5.2.  CBitmap
  139.     5.2.1.  How do I read a 256-color bitmap file from disk?
  140.  
  141. 6.  Window, Control, and Dialogs Class Questions
  142.   6.1.  Windows
  143.     6.1.1.  How can I use a custom icon for a window?
  144.     6.1.2.  How do I change the styles for a window that's created by MFC?
  145.     6.1.3.  How do I get the minimal size of a window using MFC?
  146.     6.1.4.  How do I change a Window's title?
  147.     6.1.5.  How do I get rid of 'Untitled' in my main window caption?
  148.    *6.1.6.  How do I maximize my MDI child?
  149.    *6.1.7.  Why does focus go nutso with a CSplitterWnd?
  150.   6.2.  Controls 
  151.     6.2.1.  How do I get a CControl pointer from a Dialog Template?
  152.     6.2.2.  How do I subclass a control using MFC?
  153.     6.2.3.  Why do I get an ASSERT when I subclass a control?
  154.     6.2.4.  How do I validate the contents of a control when it loses focus?
  155.     6.2.5.  How do I enable/disable a bank of checkboxes?
  156.     6.2.6.  How do I change the background color of a control?
  157.    *6.2.7.  How do I trap the <enter> key for my control?
  158.    *6.2.8.  How can I DDX with a multiple selection listbox?
  159.    *6.2.9.  How do I change the background color of a BUTTON???
  160.    *6.2.10.  Why isn't CEdit putting things on separate lines?
  161.    *6.2.11.  How do I get to the CEdit in a combobox?
  162.   6.3.  Dialogs
  163.     6.3.1.  How do I center my dialog?
  164.     6.3.2.  How do I get the 'old style' common dialogs on win95?
  165.     6.3.3.  How do I subclass a win95 common dialog?
  166.     6.3.4.  CDialog::Create fails, what could be wrong?
  167.     6.3.5.  How do I create a toolbar/statusbar in a dialog?
  168.     6.3.6.  Why isn't my CDialog::PreCreateWindow getting called?
  169.     6.3.7.  How do I embed a common dialog in a property page?
  170.     6.3.8.  Why can't I DDX/DDV to initialize my CDialog controls?
  171.    *6.3.9.  How do I change the captions of a CPropertyPage?
  172.    *6.3.10.  How do I trap F1 in my dialog?
  173.   6.4.  Control bars, status bars, toolbars, dialog bars.  
  174.     6.4.1.  How do I add a combobox to my toolbar?
  175.     6.4.2.  How do I update the text of a pane in a status bar?
  176.    %6.4.3.  How do I make my CToolBar customizable at run-time?
  177.     6.4.4.  How do I turn off the toolbar or status bar?
  178.     6.4.5.  How do I create a toolbar/statusbar in a dialog?
  179.   6.5.  Menus
  180.     6.5.1.  How do I get a pointer to the menu bar in a MDI app?
  181.     6.5.2.  How do I implement a right-mouse popup-menu?
  182.     6.5.3.  How do I dynamically change the mainframe menu?
  183.     6.5.4.  How do I 'attach' a menu to a window's creation/destruction?
  184.   6.6. Windows Common Controls (a.k.a. Windows 95 controls)
  185.    %6.6.1.  Can I use these controls under NT or Win32s?
  186.     6.6.2.  Where's a demo of this wickedly cool controls?
  187.     6.6.3.  How do you handle NM_DBLCLK for a CListCtl?
  188.  
  189. 7.  Documents, Views and Frame Class Questions
  190.   7.1.  Views
  191.     7.1.1.  How do I size a view?
  192.    %7.1.2.  How do I size a CFormView?
  193.     7.1.3.  How do I use new views with a doc template?
  194.     7.1.4.  How do I change the background color of a view?
  195.     7.1.5.  How do I get the current View?
  196.     7.1.6.  How do I create multiple views on one document?
  197.     7.1.7.  How do I get all the views in an MDI app?
  198.    *7.1.8.  How do I make a CScrollView "mouse scrollable"?
  199.   7.2.  Documents
  200.     7.2.1.  Do I have to use the Document/View architecture?
  201.     7.2.2.  How do I get the current Document?
  202.     7.2.3.  When are documents destroyed?
  203.     7.2.4.  How do I create multiple documents?
  204.     7.2.5.  How do I get a list of open documents?
  205.  
  206. 8.  OLE Class Questions
  207.   8.1.  Structured Storage
  208.     8.1.1.  When I upgraded, I could not read my files generated by
  209.             the old version of MFC.  What do I do?
  210.   8.2.  OLE Controls (previously called OCX's)
  211.     8.2.1.  What is an OLE control?
  212.     8.2.2.  How do I write OLE controls?
  213.     8.2.3.  What versions of MFC support OLE control containment?
  214.  
  215. 9.  WOSA Class Questions
  216.   9.1.  CRecordSet
  217.     9.1.1.  When I add a CRecordSet class, I get tons of linker errors..
  218.   9.2.  WinSock
  219.     9.2.1.  I'm having problems with CSocket blocking, what's up?
  220.  
  221. 10.  DLL and Build Questions
  222.    10.1.  Do I need a CWinApp object in a DLL?
  223.    10.2.  How should I define the WEP in an MFC DLL?
  224.    10.3.  How do I build an 'extension DLL'?
  225.   *10.4.  How can I manage resources in a resource only DLL and still
  226.           benefit from ClassWizard?
  227.  
  228. 11.  MFC Tips, Tricks, and Caveats (a.k.a Miscellaneous)
  229.    11.1.  What's the best way to convert my C Windows App to MFC?
  230.    11.2.  Why is my MFC application running really slow?
  231.    11.3.  How can I create an application that is initially maximized?
  232.    11.4.  How do I enable TRACE macros in my applications?
  233.    11.5.  How do I perform background processing in my application?
  234.    11.6.  How do I send a message to another thread?
  235.    11.7.  Does Microsoft use MFC in their products? Which ones?
  236.   %11.8.  How do I limit my MFC application to one instance?
  237.    11.9.  How do I get my MFC app to use the Registry on Win32?
  238.    11.10.  How do I programmatically terminate my MFC application?
  239.    11.11.  What's the difference between IMPLEMENT_DYNAMIC,
  240.            IMPLEMENT_DYNCREATE and IMPLEMENT_SERIAL?
  241.    11.12.  How can I declare an abstract base class to be IMPLEMENT_SERIAL?
  242.    11.13.  What is afx.inl and afxwin1.inl, etc..?
  243.    11.14.  Is MFC available on the Macintosh?
  244.    11.15.  Is MFC available on OS/2?
  245.    11.16.  Is MFC available on UNIX/Motif?
  246.    11.17.  How should I learn/start learning MFC?
  247.    11.18.  What DLLs should I distribute with my MFC app?
  248.   *11.19.  How do I intercept WM_SETTEXT messages
  249.   *11.20.  I can't create an instance because of DECLARE_DYNCREATE!
  250.   *11.21.  What the heck is this _T() thing I keep seeing?
  251.   *11.22.  How do I use CMemoryState?
  252.   *11.23.  How do I handle my own registered messages?
  253.  
  254. 12.  Wizard Questions
  255.    12.1.  How can I change the AppWizard options I selected for my application?
  256.  
  257. 13.  Visual C++ Questions  
  258.    13.1.  Windows 95 questions
  259.       13.1.1.  I'm running MSVC 2.0 and I can't get Windows 95 look in
  260.                my dialogs, what's wrong?
  261.       13.1.2.  When I compile under Windows 95, it flashes in and out of
  262.                DOS mode.
  263.       13.1.3.  Can MSVC 1.50 or 2.0 be used for Windows 95?
  264.    13.2.  Configuration questions
  265.       13.2.1.  What are the memory requirements for MSVC?
  266.       13.2.2.  How can I get MSVC 2.1, I can't find it in stores?
  267.       13.2.3.  Should I run under Win 95 or NT?
  268.       13.2.4.  How do I set the include/lib/exe directories?
  269.       13.2.5.  I can't compile any programs!  Help!
  270.       13.2.6.  Can I setup a project to search different paths for source?
  271.       13.2.7.  How do I build a browser file for all of MFC?
  272.    13.3.  Language feature questions
  273.       13.3.1.  Does MSVC support templates and exception handling?
  274.       13.3.2.  Does MSVC support STL?
  275.       13.3.3.  Does MSVC support RTTI?
  276.    13.4.  Religious questions
  277.       13.4.1.  Which is better OWL or MFC, BC++ or MS MSVC?
  278.       13.4.2.  Should I use Visual C++ or Visual Basic?
  279.       13.4.3.  MFC philosophy (from a microsoftie!)
  280.    13.5.  Advanced Visual C++ tips and tricks
  281.       13.5.1.  How do I see the MSVC 'Easter Eggs'?!
  282.       13.5.2.  What are the command line options to MSVC?
  283.       13.5.3.  How to change the color of ClassWizard generated code!
  284.       13.5.4.  Ten cool things you can do in the VC++ editor.
  285.      *13.5.5.  How do I speed up VC++ compiles?
  286.      *13.5.6.  Make all MFC keywords a different color!
  287.    13.6.  Miscellanous Visual C++ questions
  288.       13.6.1.  What are all these files that MSVC is creating?!
  289.  
  290. *14.  STUMPERS!
  291.  
  292. %15.  Third Party MFC Products/Reviews
  293.  
  294. %16.  MFC FAQ Revision History 
  295.  
  296. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  297.  
  298. 1.  MFC FAQ Info and Credits
  299. =============================
  300.    The MFC FAQ maintainer can be contacted via the following:
  301.    Internet: scot_wingo@msn.com
  302.    My URL is: http://www.unx.com/~scot
  303.    CompuServe: >INTERNET: scot_wingo@msn.com, or 75463,2146
  304.    Microsoft Network: scot_wingo
  305.  
  306.    I welcome any comments, criticisms or suggested additions for the
  307.    FAQ.
  308.  
  309. ---------------------------------------------------------------------------
  310.  
  311. 1.1.  How do I get this FAQ?
  312. ============================
  313.    Hey, this is one of those chicken and egg questions, if you're reading 
  314.    this you already have the FAQ.  But seriously, the MFC FAQ is put
  315.    out just about monthly, so chances are you are reading an old and
  316.    stale version, instead of the fresh and fancy latest version.  If
  317.    you want to make sure you have the latest version:
  318.  
  319.    * "Instant-FAQ (TM)" - If you'd like to have a copy of any new MFC FAQ
  320.      releases emailed right to your front door, just send me an email via
  321.      scot_wingo@msn.com and I'll add you to the 'subscription'.  No cost
  322.      or anything, just another FAQ service.
  323.  
  324.      "Why wait for the announcements and then go get the FAQ yourself,
  325.      use "Instant-FAQ (TM)"
  326.  
  327.      "Instant-FAQ(TM) changed my life!!!  I no longer have to wait for
  328.      months for the latest FAQ.  It's just waiting in my email box the
  329.      second it's released, no fuss no muss! Thanks Instant-FAQ(TM)"
  330.      -Anonymous Instant-FAQ(TM) participant. 
  331.  
  332.      [All restrictions apply in states that do not allow Instant-FAQ
  333.       service, please see your local MFC FAQ dealer for details.]
  334.  
  335.    * The latest version can be downloaded from:
  336.        ftp://www.unx.com/pub/mfc_faq/mfc_faqXX.txt
  337.      or for you ZIP lovers:
  338.        ftp://www.unx.com/pub/mfc_faq/mfc_faqXX.zip
  339.      Where XX represents the latest version.
  340.  
  341.    * This FAQ is also available on the World Wide Web.
  342.      http://www.unx.com/~scot/mfc_faq.html
  343.  
  344.    * The FAQ also is on CompuServe in the MSMFC forum, Developer
  345.      exchange download section, and the file name is MFC_FAQXX.TXT and
  346.      MFC_FAQXX.ZIP. Where XX is the version number 
  347.  
  348.    * Sadly, I can not email the FAQ to you because of my current workload.  
  349.      Don't despair, even if you do not have ftp access, you can get the
  350.      FAQ automatically emailed by following these directions:
  351.  
  352.      1. Send the following email to: ftpmail@decwrl.dec.com:
  353.  
  354.         connect landru.unx.com
  355.         chdir pub/mfc_faq
  356.         ascii
  357.         get mfc_faq13.txt
  358.         quit
  359.  
  360.      2. The subject does not matter.
  361.   
  362.      3. Wait a couple of hours and Viola!  The FAQ should be waiting
  363.         in your mailbox. 
  364.  
  365.      If you send me an email asking for the FAQ, I'll just put you on
  366.      Instant-FAQ(tm) and you'll get the next version instead.
  367.  
  368.    * An announcement of a new FAQ release is posted to the usenet newsgroups:
  369.      comp.os.ms-windows.programmer.controls
  370.      comp.os.ms-windows.programmer.graphics
  371.      comp.os.ms-windows.programmer.mfc <coming soon!>
  372.      comp.os.ms-windows.programmer.misc
  373.      comp.os.ms-windows.programmer.ole
  374.      comp.os.ms-windows.programmer.tools
  375.      comp.os.ms-windows.programmer.win32
  376.      comp.lang.c++
  377.  
  378.      and to the CompuServe MSMFC forum.
  379.  
  380.    * There's also an announcement on the mfc mailing list. (See Section 2.2.2.)
  381.    
  382.  
  383. ---------------------------------------------------------------------------
  384.  
  385. 1.2.  What's the goal of this FAQ?
  386. =================================
  387.    The goal of this FAQ is to be a clearing house for answers to MFC
  388.    questions commonly asked on primarily the usenet newsgroups but also
  389.    some stuff that gets asked on CompuServe may be included.  I'm hoping
  390.    not to duplicate the great documentation out there, the tech notes, 
  391.    MSDN, etc..  Hopefully you will look there first and then use this FAQ
  392.    as your last resort.  The FAQ will be much more interesting if you
  393.    check those resources first, then we won't have to cover 'the basics'.
  394.  
  395.    Right now the FAQ is in raw ASCII format (lowest common denominator),
  396.    but maybe some day, I'll turn it into a help file if there's enough
  397.    interest for it.
  398.  
  399.    I'm trying to load the FAQ up with good phone numbers,
  400.    CODE-CODE-CODE!,  URLs and email addresses of places to call.  I'm
  401.    putting 800 numbers first, and then the US number second.
  402.    International folks hate it when there are only 800 numbers, so if you
  403.    want a phone number in the FAQ, please send me both.
  404.  
  405. ---------------------------------------------------------------------------
  406.  
  407. 1.3.  Why are you doing this?
  408. =============================
  409.    I keep seeing the same posts and they're driving me insane!!! But
  410.    seriously, I started the MFC FAQ when I had gobs of free time and was
  411.    trying to get really totally submerged in MFC.  I figured, what better
  412.    way to get submerged, than to manage the FAQ.
  413.  
  414.    I'm also working on a top-secret MFC project and this is a good way
  415.    for me to learn more about MFC and what MFC folks are having a hard
  416.    time with.
  417.  
  418. ---------------------------------------------------------------------------
  419.  
  420. 1.4.  How can I contribute!?!
  421. =============================
  422.    Good question!  You can send me an email with your frequently asked
  423.    question and answer and I'll stick it right in the FAQ.  It's that
  424.    easy, I'll even make sure you get credit for that entry.  Please remember
  425.    to tell me what section of the FAQ you would like your FAQ added to.
  426.  
  427.    Also, if you search for the word 'TODO' that indicates there is
  428.    some information I need to fill in and would really like your help
  429.    with..
  430.  
  431. ---------------------------------------------------------------------------
  432.  
  433. 1.5.  Credits
  434. ==============
  435.    I borrowed the format from Tom Haapanen's Windows Programmers FAQ, so
  436.    I'm eternally indebted to him for that.  Tom also knew the exact dates
  437.    of all MFC releases practically down to the second ;->
  438.  
  439.    I'd also like to use this space to thank some of the folks that always
  440.    try and help out people on the usenet groups:
  441.  
  442.    Chris Marriott - He has the highest bandwidth of darn good answers
  443.    I've ever seen. 
  444.  
  445.    Mike Blaszczak - A Microsoftie that reads netnews and gives great
  446.    answers! (See section 2.4.2 for info about his book!)  If anybody knows
  447.    how to pronounce his name, let me know..
  448.  
  449.    And of course thanks to everyone in the Microsoft MFC/MSVC group that
  450.    made MFC the phenomenon it is today:  Scott Randall, Jim McCarthy, Dean
  451.    McCrory, etc.., etc..
  452.  
  453.    These folks have given me lots of great feedback on the FAQ and get
  454.    a big round of applause!
  455.  
  456.      o Jim B - jimb@turningpoint.com
  457.      o Niels Ull Jacobsen - null@diku.dk
  458.  
  459.    Individual FAQ contributions are usually near the FAQ.
  460.  
  461. ---------------------------------------------------------------------------
  462.  
  463. 1.6.  How is this different from the MSVC MFC FAQ?
  464. ==================================================
  465.    There is a MFC FAQ that comes with MSVC, this FAQ is different because:
  466.    A) It's not from Microsoft (so it has more dirt!)
  467.    B) The information here is gleaned from Usenet and CompuServe, where
  468.       their information is from technical support.  Hopefully the
  469.       Usenet/CompuServe folks ask better questions (they are
  470.       definitely cheaper ;-> )
  471.  
  472. ---------------------------------------------------------------------------
  473.  
  474. 1.7.  What other languages is this FAQ translated to?
  475. =====================================================
  476.  
  477. 1.7.1.  Japanese version of MFC FAQ
  478. -----------------------------------
  479.    I am coordinating efforts with Masahiko Funaki to have a Japanese
  480.    version of the FAQ.  He gets all changes so that he can maintain
  481.    the Japanese version.  He can be reached via email at: 'funa@hic.co.jp'.
  482.  
  483. ---------------------------------------------------------------------------
  484.  
  485.  
  486. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  487.  
  488. 2.  Where to go for Juicy MFC Information
  489. =========================================
  490.    Hopefully this FAQ is where you will look when all else fails.  This
  491.    section documents what else is out there and how to get your paws on it.
  492.  
  493. ---------------------------------------------------------------------------
  494.  
  495. 2.1 Microsoft
  496. =============
  497.    MFC comes with Microsoft's Visual C++, Watcom's C++, and Symantec's
  498.    C++ compilers.
  499.  
  500. 2.1.1 Visual C++ and Visual C++ subscription.
  501. -----------------------------------------
  502.    Microsoft sells Visual C++ in two flavors, a one-shot where you just 
  503.    get the most current release and a subscription where you receive a
  504.    years worth of updates for a little extra cash. See Section 3 for
  505.    the details of what MFC release is the latest and greatest.  Only
  506.    major versions are sold through outlets, so if you need a point
  507.    release, you need the subscription.
  508.  
  509.    NOTE:  There are TWO subscriptions out there.
  510.  
  511.    1. The Visual C++ subscription, which is the compiler/MFC, etc.. for a year.
  512.    2. The Microsoft Developer's Network subscription (See next section),
  513.       where you get some developer resources (no compiler/no MFC). It's
  514.       easy to get these confused.
  515.  
  516.    Prices fluctuate, so contact one of the compiler vendors for
  517.    information:
  518.  
  519.    * Microsoft
  520.      (800) 719-5577
  521.      (206) 936-8661
  522.      http://www.microsoft.com
  523.  
  524.    * Symantec:
  525.      (800) 628-4777
  526.      (408) 253-9600
  527.      http://www.symantec.com
  528.  
  529.    * Watcom
  530.      (800) 265-4555
  531.      (519) 886-3700
  532.      http://www.watcom.com
  533.  
  534.    There are also two programmer mail order houses that carry all of the
  535.    MFC supported compilers including the Visual C++ subscription:
  536.  
  537.    * Programmer's Paradise
  538.     (800) 445-7899
  539.     (908) 445-7899
  540.  
  541.   * The Programmer's Shop
  542.     (800) 421-8006
  543.     (617) 740-2510
  544.  
  545. ...........................................................................
  546.  
  547. 2.1.2 Microsoft Developers Network (MSDN)
  548. -----------------------------------------
  549.    Another great investment is the Microsoft Developers Network (MSDN),
  550.    which is a quarterly subscription set of CDROMs that contains all of the
  551.    information you can imagine about the Microsoft developer products,
  552.    including MFC.  There are two levels, level one gets you the CDs that
  553.    have all the developer tool information.
  554.  
  555.    Level 1: MSDN "Development Library" - This is a single disc which
  556.             contains an absolute wealth of useful developer 
  557.             information.  Such as:
  558.  
  559.             o Technical Articles (VC++ 1.0-2.0, C/C++, Windows, etc)
  560.             o Sample Code (Book & Magazine Samples, Product Samples
  561.               covering everything from MFC to SDK, etc.)
  562.             o Backgrounders and White Papers (including MFC 2.5 & 3.0)
  563.             o Specifications (Plug and Play, TAPI, Unicode, Winsock, etc)
  564.             o Knowledge Base and Bug Lists
  565.             o Books & Periodicals (MSJ, Dr. Dobb's, MS Press Books, etc)
  566.             o Product Docs (Word, Excel, VC++, MFC Migration Guide, etc)
  567.             o SDK's & DDK's (Win32 SDK, Telephony SDK, Speech API, etc)
  568.             o Product Tools and Utilities (Winsock, UI Guide, etc)
  569.             o Unsupported Tools and Utilities (Self Study Modules, etc)
  570.             o Conference and Seminar Papers (DevCast IV & V, Tech*Ed, etc)
  571.  
  572.  
  573.      Level 2: MSDN "Development Platform" (July '95 Release).
  574.               The full set is currently 19 discs containing:
  575.  
  576.             o Discs 1-4 (U.S. "Core" Pack):  U.S. Windows NT Service
  577.               Packs, Windows Versions (3.11, WFW 3.11), and SDK's, 
  578.               Windows NT 3.51 Workstation Retail and Checked Builds, 
  579.               Win32 SDK (Final Windows NT Components), MS DOS 6.22
  580.  
  581.             o Discs 5-16 (International Pack):  Intl. SDKs and Drivers
  582.               Intl. Windows NT Service Packs, Intl. Additional Windows
  583.               NT Service Packs and Windows 3.11 Versions, Windows 95
  584.               International Beta Releases (May 1995), Intl. Win 3.1 &
  585.               Windows for Workgroups 3.11, 
  586.                  -also-
  587.               International versions of Windows NT 3.5 Workstation: 
  588.               Available in:  German, French, Italian, Spanish, 
  589.               Dutch, Swedish, Norwegian, Finish, Danish, 
  590.               Traditional Chinese, Portuguese, Korean, Japanese 
  591.               and the Japanese Win32 SDK.
  592.  
  593.             o Discs 17-19 (Device Driver Kit):  Windows NT 3.5 DDK 
  594.               (Japanese), Windows NT 3.51 DDK, General DDK's
  595.  
  596.    Level two subscribers have the option of receiving around 20 CD's
  597.    each quarter with all the latest operating systems.  It even has the
  598.    operating systems in every language you can imagine! (Swahili NT,
  599.    gotta have it!)  If you want to have the latest and greatest, get
  600.    level 2.  If you can live with going to Egghead for operating systems,
  601.    and don't need the Swahili NT, level one should be good.  You also get
  602.    a pretty good newsletter every quarter or so.
  603.  
  604.    
  605.    There's a MSDN FAQ at: ftp.microsoft.com:/developr/msdn/faq
  606.    There's a MSDN Web at: http://www.microsoft.com/msdn/
  607.    There's a gopher at:   gopher://gopher.microsoft.com/1/msdn
  608.  
  609.    You can contact MSDN at:
  610.    (800) 759-5474
  611.    (303) 684-0914
  612.     msdn@microsoft.com
  613.  
  614.    Level 1: $195 ($275 CAN) per year
  615.    Level 2: $495 ($695 CAN) per year
  616.    Level 1 to Level 2 upgrades: $395 ($555 CAN) per year
  617.  
  618.    NOTE: This is NOT the Visual C++ subscription.  It is described in
  619.    section 2.1.1.  MSDN does not come with compilers or MFC, but does
  620.    come with SDKs (include files, libraries, etc..) and tons of other
  621.    developer related information.
  622.  
  623. ...........................................................................
  624.  
  625. 2.1.3 Knowledge Databases
  626. -------------------------
  627.    Microsoft support creates these knowledge databases that answer
  628.    frequently asked questions and sometimes have samples and stuff.  You
  629.    can get the knowledge databases from ftp.microsoft.com, CompuServe,
  630.    and they come on the MSDN (see section 2.1.2 above) CD-ROMs.
  631.  
  632.    There's a tool that lets you quickly search these.  Whenever I've tried
  633.    to find something here, I always end up with MFC 1.0 information
  634.    that's not very useful.  Your mileage may vary.
  635.  
  636.    http://www.microsoft.com/KB/indexes/visual_c.htm is the URL
  637.    for the MSVC knowledge databases.
  638.  
  639. ...........................................................................
  640.  
  641. 2.1.4.  Microsoft Software Library
  642. ----------------------------------
  643.    Microsoft maintains a giant library of samples, tools, and demos
  644.    called the Microsoft Software Library.  Here's how to find it on the
  645.    various electronic media->
  646.  
  647.    * CompuServe
  648.      GO MSL
  649.  
  650.    * Microsoft Download Service (MSDL)
  651.      Dial (206) 936-6735 to connect to MSDL
  652.  
  653.    * Internet (anonymous FTP)
  654.      ftp ftp.microsoft.com
  655.      Change to the SOFTLIB\MSLFILES directory
  656.  
  657.    - John Elsbree, elsbree@nwrain.com, programmer.misc, 6/24/95
  658.  
  659. ---------------------------------------------------------------------------
  660.  
  661. 2.2.  Internet
  662. ==============
  663.    Throw on some sunglasses, put the top down and take a cruise on that
  664.    big ole' information highway.  There's tons of great MFC information
  665.    at your finger tips (sorry billg), if you know where to look..
  666.  
  667. ...........................................................................
  668.  
  669. 2.2.1.  World Wide Web Pages
  670. ----------------------------
  671.  
  672.    Here are some URLs with MFC, or MFC related information:
  673.  
  674.    MFC/MSVC specific
  675.    -----------------
  676.    o http://www.microsoft.com -  Microsoft's WWW.
  677.    o http://www.microsoft.com/KB/indexes/visual_c.htm - MSVC KB
  678.    o http://www.unx.com/~stingray - MFC extensions company.
  679.  
  680.    Windows NT/95 specific
  681.    ----------------------
  682.    o http://www.bhs.com - Windows NT home page.
  683.    o http://biology.queensu.ca/~jonesp - Windows 95 home page.
  684.    o http://www.netex.net/w95/windows95 - More Windows 95 stuff
  685.  
  686.    C++ specific
  687.    ------------
  688.    o http://www.info.desy.de/user/projects/c++.html - Lots of C++ stuff.
  689.    o http://www.watcom.com/c/c.html - FAQ
  690.    o http://www.quadralay.com/www/CCForum/CCForum.html - C++ tutorials and
  691.      conversations.
  692.    o http://vinny.csd.mu.edu/learn.html - Whopping big list of books and
  693.      tutorials for C++.
  694.    o http://www.iftech.com/classes/vcpp/vcpp0.htm - Interface Technologies,
  695.      Inc. "Intro to MFC Programming with VC++ 1.5"
  696.    o http://www.solsem.com/Instructors.html - Info on Seminars for MFC 
  697.      and VC++, Windows 95, NT, etc.  
  698.    o http://execpc.com/~owl/cplus.html - On With Learning - Visual C++ 
  699.      Training Video Tapes
  700.    o http://www.yahoo.com/computers/languages/c_c__/ - Yahoo's Computer
  701.      Languages:  C/C++ Page with links to other resources
  702.  
  703.  
  704.    TODO ** Need more URLs!
  705.  
  706.    Lots of magazines are on the web, see section 2.4.1 for those URLs
  707.  
  708. ...........................................................................
  709.  
  710. 2.2.2.  Mailing lists
  711. ---------------------
  712.    As far as I can tell, there's only one mailing list, mfc-l. It's a
  713.    great mailing list, with many Microsofties that lurk and answer. To
  714.    subscribe send an email to listserv@netcom.com with the message:
  715.  
  716.    subscribe mfc-l
  717.  
  718.    David Elliott (dce@netcom.com), started and manages this list. Thanks
  719.    for setting it up David!!
  720.  
  721.    **Note, this list has high bandwidth and has just become moderated,
  722.    hopefully that will help.
  723.  
  724. ...........................................................................
  725.  
  726. 2.2.3.  Usenet Newsgroups
  727. ---------------------------
  728.    You can get to Usenet groups through the Internet, or through many of
  729.    the on-line services these days.  Unfortunately, there is not a MFC
  730.    specific newsgroup, but most of the Windows programming groups are
  731.    full of MFC questions.  Here's a quick rundown of where you can go for
  732.    MFC conversations, in order of MFC content:
  733.  
  734.    * comp.os.ms-windows.programmer.tools -
  735.      This is where most of the MFC stuff happens, it IS a tool after all. 
  736.  
  737.    * comp.os.ms-windows.programmer.misc -
  738.      Give it a shot, lots of noise here, but usually good noise.
  739.  
  740.    * comp.os.ms-windows.programmer.win32 -
  741.      I like this group, doesn't seem to crowded, people know what's going
  742.      on, I guess because they're already into win32.
  743.  
  744.    * comp.os.ms-windows.programmer.ole -
  745.      An occasional thread about some of the OLE classes pops up here.
  746.  
  747.    * comp.lang.c++ -
  748.      This is suppose to be for C++ language issues, but people are always
  749.      posting about MSVC and MFC here.  This group is really frustrating
  750.      to read, I recommend staying away.  There's about a 100000:1 noise
  751.      ratio on here.
  752.  
  753. ...........................................................................
  754.  
  755. 2.2.4.  Other FAQs of interest
  756. ------------------------------
  757.  
  758.    * Windows FAQ - Maintained by Tom Haapanen.
  759.      ftp.metrics.com:~/faq
  760.      Explains lots of great stuff about Windows that you won't find here.
  761.  
  762.    * Windows Programming FAQ - Maintained by Tom Haapanen.
  763.      ftp.metrics.com:~/faq
  764.      Awesome Windows Programming FAQ. 
  765.  
  766.    * C++ FAQ - Maintained by Marshall Cline.
  767.      ftp to  rtfm.mit.edu:/pub/usenet/comp.lang.c++, also on comp.lang.c++
  768.      This is an awesome FAQ, answers every C++ question you'd ever
  769.      conceive of.  It's not specific to MSVC so be careful, some behavior
  770.      could be different. 
  771.  
  772.    * WinHelp FAQ - Maintained by Pete Davis
  773.      Posted regularly to comp.os.ms-windows.programmer.winhelp
  774.      If you have a question about the Windows help system, this is for
  775.      you.
  776.  
  777.    * Windows NT FAQ - Maintained by Adam Hamilton
  778.      Posted to comp.os.ms-windows.nt.misc?
  779.      Pretty good, lots of networking stuff in there.
  780.  
  781.    * Portable GUI (PIGUI) FAQ - Maintained by Wade Guthrie
  782.      (wade@nb.rockwell.com).  Yes MFC is cross-platform, this FAQ describes
  783.      it better than we can ever hope to here.  Should be accessible via
  784.      rtfm.mit.edu it's the comp.windows.misc newsgroup FAQ.
  785.  
  786. ...........................................................................
  787.  
  788. 2.2.5.  FTP sites
  789. -----------------
  790.    There's not much MFC code out there.  You can check out these sites:
  791.  
  792.    * ftp.microsoft.com - Has all the knowledge databases and a couple of
  793.      MFC specific things.  Check out the software library too (softlib).
  794.  
  795.    * ftp.cica.indiana.edu - pub/pc/win3/progrmr
  796.  
  797.    * wuarchive.wustl.edu - Good site, don't know about MFC stuff.
  798.      pub/win3/progrmmr
  799.  
  800.    * ftp.uu.net - /vendors/microsoft has some developer support things
  801.      that are on both ftp.microsoft.com and CompuServe.  Microsoft seems to
  802.      be moving away from here.
  803.  
  804.    * oak.oakland.edu - (SimTel Mirror) SimTel/win3/pgmtools
  805.  
  806.    If you don't have Internet access, you can order CDROMs with these
  807.    entire archives from Walnut Creek.  Call (800) 786-9907 or (510)
  808.    947-5996 for more information.
  809.  
  810. ...........................................................................
  811.  
  812. 2.2.6.  The MFC FAQ FTP Archive!
  813. --------------------------------
  814.   We've started a MFC FAQ FTP archive.  This archive contains MFC
  815.   samples that illustrate FAQs.
  816.   ftp://www.unx.com/pub/mfc_faq/archive
  817.  
  818.   To submit a sample, upload it into the mfc_faq/incoming directory
  819.   and send an email to scot_wingo@msn.com explaining the submission. 
  820.  
  821.   Currently the MFC FAQ FTP Archive contains:
  822.  
  823.   * multdocs.zip - Shows how to have multiple CDocuments.
  824.   * multview.zip - Shows how to have multiple views.
  825.   * onetime.zip - How to restrict your application to one instance.
  826.   * dlgcbr.zip - How to put controlbars in your dialogs.
  827.   * TODO -
  828.  
  829. ---------------------------------------------------------------------------
  830.  
  831. 2.3.  CompuServe
  832. ================
  833.    CompuServe, in my opinion, is by far the best resource for MFC
  834.    information.  The MSMFC forum is dedicated to MFC discussions and has
  835.    downloads that you can't even begin to find anywhere else.  Here's
  836.    some other CompuServe forums of interest:
  837.  
  838.     MFC                             GO MSMFC
  839.     Windows                         GO MSWIN
  840.     Win32                           GO MSWIN32
  841.     Windows NT                      GO WINNT
  842.     Software Library                GO MSL
  843.     Languages (C++)                 GO MSLANG
  844.     Microsoft Developer Network     GO MSDN
  845.     Microsoft Developer Services    GO MSDS
  846.     Microsoft Press                 GO MSP
  847.     Stingray Software               GO STINGRAY
  848.  
  849.    For more information about CompuServe call:
  850.    (800) 487-4838
  851.    (614) 457-8650
  852.  
  853. ---------------------------------------------------------------------------
  854.  
  855. 2.4.  Printed Matter
  856. =====================
  857.  
  858. 2.4.1.  Magazines and journals
  859. ----------------------------
  860.  
  861.    I've tried to list these in order of MFC content.  The ones first have
  862.    the most MFC content with the ones last having the least.  Even though
  863.    they don't directly cover MFC, most of the Windows programming
  864.    magazines are still pretty valuable. Any of these that I've read, I
  865.    put comments with.  If you'd like to comment, email me and I'll throw
  866.    it in here. 
  867.  
  868.    * Visual C++ Developer
  869.      Pinnacle Publishing ($149/yr)
  870.      (800) 788-1900
  871.      (206) 251-1900
  872.      My favorite, very meaty, lots of MFC coverage, diskette with each
  873.      issue.
  874.  
  875.    * Visual C++ Professional
  876.      Oakley Publishing   ($149/yr)
  877.      (800) 234-0386
  878.      (503) 747-0800
  879.      Similar to above, but just a smidge less MFC.
  880.  
  881.    * Inside Microsoft Visual C++
  882.      The COBB Group  ($69/yr)
  883.      (800) 223-8720
  884.      (502) 493-3300
  885.      Similar to above, but even less MFC.  Lot's of stuff about the
  886.      compiler, etc..
  887.  
  888.    * Microsoft Systems Journal (MSJ)
  889.      Miller Freeman Inc.
  890.      (800) 666-1084
  891.      (303) 678-0439
  892.      http://www.mfi.com/msj
  893.      About 1 MFC article every 2 months
  894.  
  895.    * Windows Tech Journal
  896.      Oakley Publishing
  897.      (800) 234-0386
  898.      (503) 747-0800
  899.      Same as above.
  900.  
  901.    * C++ Report
  902.      SIGS Publications
  903.      (800) 361-1279
  904.      (212) 242-7447
  905.      ** These guys now have a couple of MFC columnists.  One of them is
  906.      amazingly handsome too!!
  907.  
  908.    * Windows/DOS Developers Journal
  909.      R+D Publications
  910.      (913) 841-1631
  911.      Same as above.
  912.  
  913.    * PC Techniques
  914.      Coriolis Group
  915.      (602) 483-0192
  916.      http://www.coriolis.com
  917.      Same as above.
  918.  
  919.    * Dr. Dobbs 
  920.      Miller Freeman Inc.
  921.      (800) 456-1215
  922.      (303) 678-0439
  923.      http://www.ddj.com
  924.      About one MFC article every 3-4 months, maybe.
  925.  
  926.    * C/C++ Users Journal
  927.      R+D Publications
  928.      (913) 841-1631
  929.      Not much MFC specific stuff at all, language-y articles.
  930.  
  931. ...........................................................................
  932.  
  933. 2.4.2. Books on MFC
  934. -------------------
  935.    There's tons of books on Visual C++, but not many of them go into
  936.    the details about MFC.  Here's a list of books that are over 50%
  937.    oriented towards MFC (e.g. don't have pages of screenshots of compiler
  938.    options dialogs and the MSVC IDE)
  939.  
  940.    * Microsoft Visual C++ Documentation Set
  941.      Microsoft Press
  942.      (800) MSPRESS
  943.      (416) 293-8464
  944.      o Volume 2: Programming with MFC and Win32 ($27)
  945.        ISBN 1-55615-802-5
  946.      o Volume 3: MFC Library Reference ($45)
  947.        ISBN 1-55615-801-7
  948.      These come in the on-line docs, but nice to have printed versions of them.
  949.      If you are going to do MFC programming, volume 2 is a 'must have'
  950.  
  951.    * Inside Visual C++, Second Edition
  952.      Microsoft Press ($40)
  953.      David J. Kruglinski (Ex-Microsoftie)
  954.      ISBN: 1-55615-661-8
  955.  
  956.      # Sounds like it would be Visual C++ specific, but this is the 'Petzold
  957.        of MFC programming.  In other words, it's a 'must have' (along
  958.        with volume 2 of the printed docs.  If you can't afford both,
  959.        stick with volume 2 on-line and get this one)
  960.        **Note, this does not have Win32 coverage, yet.
  961.        -scot_wingo@msn.com
  962.  
  963.      # The best MFC book that I know of is "Inside Visual C++" by David
  964.        Kruglinski. Despite the name, this is primarily an MFC book.
  965.        -Chris Marriott, chris@chrism.demon.co.uk, programmer.graphics, 6/15/95
  966.  
  967.    * The Revolutionary Guide to Win32 Programming with MSVC
  968.      WROX Press ($45),  June 1995
  969.      Mike Blaszczak 
  970.      ISBN: 1-874416-47-8
  971.  
  972.      # I just finished reading this one.  As the title indicates, it's
  973.        Win32 specific.  I also think it's a little too advanced for
  974.        beginners.  If you're into Win32 (Win 95) programming, it has
  975.        really good chapters on those classes.  Also comes with a neato
  976.        poster!  Chapter 9 on DLLs is best coverage of that material, ever.
  977.        -scot_wingo@msn.com
  978.  
  979.      # If you understand C++ and _some_ windows programming this is a
  980.        great book to learn MFC. 
  981.        -Shelley Lambert, reach@ee.mcgill.ca, programmer.tools, 6/18/95
  982.  
  983.      # It is the best book on Win95 programming I have found.
  984.        -Gary Coombs, N40JW@News.Radio.Org, programmer.win32, 6/19/95
  985.  
  986.    * Writing Windows Applications with MFC
  987.      M+T Books ($40)
  988.      Bryan Waters
  989.      ISBN: 1-55851-379-5
  990.  
  991.      # At first I thought it was too beginner, but the last 5 chapters kick
  992.        butt. Lots of info on MFC internals, exception handling, and topics
  993.        not covered elsewhere.  Good for someone new to Windows and MFC
  994.        programming.
  995.  
  996.    * Visual C++ How-To: The Definitive MFC Problem Solver
  997.      Waite Group Press ($40) Apr-95, 570 pages
  998.      Info:  http://www.dnai.com/waite/
  999.      (800) 788-3123
  1000.      (510) 658-3453
  1001.      Scott Stanfield, Ralph Arveson, 
  1002.      Alan Light & Mickey Williams
  1003.      Includes a CD-ROM
  1004.      ISBN 1-878739-82-4
  1005.  
  1006.       # I can tell you that its a real good book for what its intended to be.
  1007.        Which is, sort of like your FAQ.  It comes with a CD and has little
  1008.        tidbits like: 
  1009.  
  1010.        1.) How to animate an icon.  I adapted this a bit to figure out how to
  1011.        change icons (in an MDI on the fly).
  1012.  
  1013.        2.) How to detect multiple instances of a Windows app and pull the
  1014.        other one to the top of the Z-order.  This is a perennial Usenet
  1015.        question and I pulled the code and had it working first time.
  1016.  
  1017.        3.) How to put a bitmap on the main client window of a MDI app.
  1018.        Again, a nasty little thing to figure out on your own, but given good
  1019.        directions, quite easily done from the book.
  1020.  
  1021.        The CD is also broken out between those that are using VC 1.5 versus 2.0.
  1022.    
  1023.      # Like other Waite Group "How-To" programming books, this one is
  1024.        in "Cookbook" or FAQ format.  You read the table of contents for
  1025.        the functionality you are looking for, and the associated chapter
  1026.        contains the code to implement it.
  1027.  
  1028.        Topics include:  Document and View, Status Bars and Toolbars, 
  1029.                         Controls, Multimedia, Bitmaps and Icons, Dialogs
  1030.                         OLE and DDE, System and a FAQ of short tips
  1031.     
  1032.        Many new classes are given here which all supplement the MFC in a
  1033.        fairly logical manner.  Some of the chapters which were of interest
  1034.        to me were:
  1035.  
  1036.            2.1 - Put the current time in the status bar
  1037.            2.3 - Add a status bar to my Views
  1038.            2.4 - Display Progress information in the status bar
  1039.            4.1 - Preview an AVI file using the common file dialog
  1040.            4.3 - Play AVI files in a CView
  1041.            4.4 - Play large WAV files
  1042.            4.6 - Create 3D animation using OpenGL and MFC
  1043.            5.5 - Smoothly animate bitmaps
  1044.            6.6 - Write customized DDX/DDV routines
  1045.            8.3 - Localize MFC applications using resource DLLs
  1046.            8.5 - Make multiple inheritance work in MFC
  1047.            And many tidbits from the FAQ...
  1048.  
  1049.        I like the cookbook format which allows me to glue in specific
  1050.        functionality on demand.  I found this book to be fairly helpful
  1051.        in that regard.  I look forward to Volume II ;-)
  1052.        -cntrline@winnet.com via email, 7/15/95
  1053.  
  1054.    * Visual C++ 2: Developing Professional Applications in Windows 95 and
  1055.      Windows NT using MFC
  1056.      Marshall Brain and Lance Lovette
  1057.      Prentice Hall
  1058.      ISBN: 0-13-305145-5
  1059.      Should be out end of June 1995
  1060.      TODO: Find comments on this book.
  1061.  
  1062.    * Animation Techniques in Win32
  1063.      Nigel Thompson
  1064.      Microsoft Press  (Early 1995)
  1065.      ISBN: 1-55615-669-3
  1066.         At first glance, I ignored this book on the shelves, however, when
  1067.         I finally picked it up, it used MFC completely throughout.  A very
  1068.         good book on doing graphics with MFC.
  1069.         -jdc@biosym.com, John Clark, via email 6/6/95
  1070.  
  1071.    * Teach Yourself Microsoft Foundation Class Library Programming in 21 Days
  1072.      Robert Shaw
  1073.      SAMS ($30)
  1074.      ISBN: 0-672-30462-7
  1075.      -bossi@hp2.sm.dsi.unimi.it (Giuliano Bossi) no review.
  1076.  
  1077.        # I find "Teach Yourself Visual C++ in 21 Days" a good reference, since
  1078.        it is set up to cover a small group of features each "day", so you can
  1079.        quickly go to a subject area, and get a from-scratch description of it
  1080.        and how to use it.  However, the author is not strong on using the VC
  1081.        IDE, claiming that "you have to write this code yourself the first few
  1082.        times, so you better appreciate what AppStudio and ClassWizard are
  1083.        doing behind the scenes."  I'd prefer the approach where we use the
  1084.        tools at hand, and then map out what those magic MESSAGE_MAP macros
  1085.        are really doing.
  1086.        -Paul.McGuire@SEMATECH.Org, email, 7/11/95
  1087.  
  1088.    * MS Foundation Class Primer: Prog Windows 3 & Windows NT w/MFC 
  1089.      Jim Conger
  1090.      The Waite Group Press ($32) Mar-93, 830 pages
  1091.      ISBN: 1-878739-31X 
  1092.      -jalvarez@uno.com
  1093.  
  1094.       # The best MFC book that I've seen that DOESN'T use VC++ Wizards is
  1095.         "Microsoft Foundation Class Primer" 
  1096.         -stasic@news.dorsai.org, ED, programmer.misc, 6/24/95
  1097.  
  1098.       # This book is a good intro for people new to MFC, but it's
  1099.         getting pretty dated.  This book was written during the time 
  1100.         of MS C++ 7.0, and some of the newest functionality just isn't 
  1101.         covered (for obvious reasons ;), which can confuse a newbie.  
  1102.         At any rate, it's still makes pretty good book for someone 
  1103.         looking for the basics.
  1104.         -cntrline@winnet.com, email, 7/15/95
  1105.  
  1106.    * Master Visual C++ 2,2/E w/CD-ROM  (covers MFC 3.0 library) 
  1107.      Howard W. Sams & Company ($ 50) Jan-95, 1183 pages
  1108.      Gurewich & Gurewich
  1109.      ISBN: 0-672305-321 
  1110.      -jalvarez@uno.com
  1111.  
  1112.        # I picked up a copy of "Master Visual C++" specifically for its
  1113.        coverage of creating custom VBX's.  This is not covered in Kuglinski's
  1114.        "Inside Visual C++" nor in "Teach Yourself Visual-C++ in 21 Days".
  1115.        "Master Visual C++" is just my speed, since I am a dabbler who does
  1116.        not read instructions or tutorials, just jumps in over my head, then
  1117.        starts looking for the routine calls I overlooked.  Similar to the
  1118.        Heavy Metal book, this book could have been squeezed down to about 1/3
  1119.        the size, but here that is not the point.  Each example starts with a
  1120.        demo of the finished product, then goes through the steps
  1121.        descriptively, then goes through the steps again with the code.  My
  1122.        little VBX was done in a day an a half, and I have a much better feel
  1123.        for the ins and outs of this process.
  1124.        -Paul.McGuire@SEMATECH.Org, email, 7/11/95
  1125.  
  1126.    * Heavy Metal Visual C++ Programming
  1127.      Steve Holzner
  1128.      Brady Publishing
  1129.      ISBN 1-56884-196-5
  1130.  
  1131.      # Hate to disagree, but I find this book disappointing. The reason is, I
  1132.        felt like being treated as a semi-idiot when reading the book. Don't get
  1133.        fooled by its number of pages -- it could have been easily reduced to
  1134.        half of its size, if the author knew how to list the code efficiently.
  1135.        Furthermore, there are too many misprints in the version I have.
  1136.        -Huayong (yang@math.umass.edu), programmer.tools, 6/18/95
  1137.  
  1138.      # The rule of thumb is never buy Holzner's book. His book only
  1139.        leads you the the door. You can't find practically useful
  1140.        examples. Almost every updated vesion is the same.
  1141.        -Runhong (chen@nice3.ne.rpi.edu), programmer.tools, 6/18/95
  1142.  
  1143.  
  1144.     * Programming the Windows 95 User Interface
  1145.       Microsoft Press
  1146.       ISBN 1-55615-884-X    
  1147.       Nancy Cluts (Due out August '95)
  1148.    
  1149.       NOTE: Microsoft Developer Network Developer Library contains the
  1150.             complete preliminary draft of this wonderful work, along with
  1151.             all the source code to the examples, with *BOTH* Win32 and MFC
  1152.             source!  Chapters cover all of the controls and features 
  1153.             necessary for Windows 95 development!  I've got mine on order,
  1154.             and I also printed it all out!  Anybody interested in looking
  1155.             at the first draft, it's on the July '95 MSDN Developer Library
  1156.             In:   
  1157.             \Books and Periodicals\Programming the Windows 95 User Interface
  1158.             -cntrline@winnet.com, email, 7/15/95
  1159.  
  1160.      * Visual C++ Power Toolkit
  1161.        Ventana Press ($50), 1995, 785 pages
  1162.        Info:  http://www.vmedia.com/vc++.html
  1163.        (919) 942-0220
  1164.        Richard Leinecker, Jamie Nye
  1165.        Includes a CD-ROM
  1166.        ISBN 1-56604-191-0
  1167.  
  1168.       # YACTB = Yet Another Cookbook Type Book.  Although this book tries to be
  1169.         a sourcebook for programmers by giving many new classes and clever
  1170.         code, it just isn't laid out as logically as other books I've seen
  1171.         recently (see: "Visual C++ How-To" listing).
  1172.  
  1173.         This book covers a lot of topics, such as: Customizing the 
  1174.         Interface, Animation, Screen Effects, Music & Sound, 
  1175.         Advanced Animation, Data Compression, OLE 2.0, Communications and
  1176.         Scanner Input (Using TWAIN).
  1177.  
  1178.         I haven't found this book to be as useful as other books for my
  1179.         purposes yet, but it does include a lot of new Classes which may
  1180.         prove useful for other programmers.
  1181.         -cntrline@winnet.com, email, 7/15/95
  1182.  
  1183.       # I just grabbed this one and at first glance it looked really
  1184.         useful, then I started reading it and BLECH!  The author's writing is,
  1185.         well, it's not so great.  Also, the classes are sloppy and show no OO
  1186.         design at all.  The author's comment is "I'm not hungarian, so
  1187.         why should I name variables like one".  Can't say I recommend
  1188.         this one.
  1189.         -scot_wingo@msn.com
  1190.  
  1191.    * The following are rumored to be coming out RSN (Real soon now)
  1192.      * MFC 3.0 Bible - The Waite Group ($45)
  1193.      * MFC Internals - AW George Shephard and Scot Wingo
  1194.      * Extending MFC - AW David Shmitt?
  1195.      * Visual Programming - Richard Hale Shaw
  1196.      * Programming Windows 95 with MFC, Microsoft Press, Jeff Prosise
  1197.      * Waite Group MFC book (title unkown!) Don Kiely, donkriely@crn.com
  1198.  
  1199. ...........................................................................
  1200.  
  1201. 2.4.3. Cool MFC Articles
  1202. ------------------------
  1203.    There's probably a million 'good' MFC articles out there, but this
  1204.    section is for the ultra-hip, totally-swinging, must-have,
  1205.    gotta-read MFC articles.  If you submit an article for this
  1206.    section, please include all the 'volume' information and a short
  1207.    paragraph about why it's so damn cool!  [Note if you have questions
  1208.    about the magazines or MSDN mentioned below, see sections: 2.4.1
  1209.    and 2.1.2]
  1210.  
  1211.    * "Fun with MFC: 33 Tips to Help You Get the Most Out of ..."
  1212.      -Paul DiLascia, MSJ, November 1993, Volume 8, Number 11
  1213.  
  1214.      # This is my A#1 MFC article of all time.  Even though this
  1215.        article is 2 years old, it has principals and ideas that are
  1216.        extremely valuable to today's MFC programmer.  Good news is
  1217.        that it's on MSDN in their MSJ archives!  You can also find
  1218.        this gem under books online: Extensions: articles/Technical
  1219.        Articles/Fun with MFC: 33 Tips.
  1220.        -scot_wingo@msn.com
  1221.  
  1222.    * Scott Randall has a great little article that you can find right
  1223.      on your Visual C++ 2.x in Books Online.  It's under Extensions:
  1224.      articles/Technical Articles/Tools for using MFC 2.0.  Describes
  1225.      the philosophy behind the VC++ Wizards. 
  1226.  
  1227.    * "Meandering Through the Maze of MFC Message and Command Routing"
  1228.      -Paul DiLascia, MSJ, July 1995, Volume 10, Number 7
  1229.  
  1230.      # Best explanation of messages ever, a MFC FAQ "must-read".
  1231.  
  1232.    * "Rewriting the MFC Scribble Program Using an OOD Approach"
  1233.       -Allen Holub, MSJ, August 1995, Volume 10, Number 8
  1234.  
  1235.       # Not my favorite article, but 'DID' stir up lots of talk on
  1236.         most MFC forums.  Any article that generates this much noise
  1237.         has to be good.
  1238.  
  1239.    * "Self Decorating Pages"
  1240.      -David A. Schmitt, Windows Tech Journal, July 1995
  1241.  
  1242.    * "Dad, Can I Drive the Printer Tonight?"
  1243.      -David A. Schmitt, Windows Tech Journal, August 1995
  1244.      # This series of articles is pretty good, especially if you are
  1245.        into printing.
  1246.  
  1247.    * "Plunge into MFC's User Interface"     
  1248.      -Scot Wingo, Windows Tech Journal, August 1994
  1249.      # WOW!  This guy is the best!
  1250.  
  1251.  * Coming in September:
  1252.      C++ Report, SIGS Publications,
  1253.      "A Brief History of MFC" - recaps section 3 of this FAQ and
  1254.      throws in some new information.
  1255.  
  1256.    TODO: Get more good article pointers.
  1257.  
  1258. ---------------------------------------------------------------------------
  1259.  
  1260. 2.5.  Trade shows
  1261. ================
  1262.  
  1263.    * MFC Professional Developers Conference
  1264.      Microsoft
  1265.      (800) 206-3000
  1266.      (612) 550-6340
  1267.      First one was in early June 1995.
  1268.   
  1269.    * Software Development (East and West)
  1270.      Miller Freeman
  1271.      (415) 905-2222
  1272.      http://www.mfi.com
  1273.      tloftus@mfi.com
  1274.  
  1275.      This is where Microsoft unveils the latest MSVC technology, they
  1276.      have a big booth and last year had a problem solving area.  Many
  1277.      Microsofties also give talks on MFC, some free, some part of the
  1278.      program.
  1279.  
  1280.      There are two Software Development shows a year.  The West show is
  1281.      held in San Francisco in Spring and the East show is held in
  1282.      Washington, D.C. in the Fall. The West show is bigger.
  1283.  
  1284.    * VBITS MFC Companion Conference
  1285.      (800) 848-5523
  1286.      Fawcette Publications puts on a Visual Basic show called VBITS, they
  1287.      are starting to put on MFC tracks too.
  1288.  
  1289.      TODO - Comments anyone?  I heard it was slow this year in NYC.
  1290.  
  1291.    * WinDev
  1292.      (508) 649-4200
  1293.      A Boston show, last held in June 12-16, 1995.  It's put on by Boston
  1294.      University and has a MFC/C++ track in addition to other MFC related
  1295.      talks.
  1296.      TODO - Anyone have comments on this?
  1297.  
  1298. ---------------------------------------------------------------------------
  1299.  
  1300. 2.6.  Users Groups
  1301. ===================
  1302.    I don't know of any MFC specific user's groups, but there are some
  1303.    really good C++ user's groups that have some MFC content in their
  1304.    programs.  The NW C++ User's group has a really nice email newsletter
  1305.    that anybody can subscribe to by emailing cpp@netcom.com.  Here's the
  1306.    contact information for the known C++ User's groups->
  1307.  
  1308.    |--------------------------------------------------------------|
  1309.    | Area              Contact Name       Contact Email           |
  1310.    |--------------------------------------------------------------|
  1311.    | New York, NY     | Saul Rosenberg  | Rosenberg@decus.org     |
  1312.    | Redmond, WA      | Steve Shimeall  | steves@amc.com          |
  1313.    | San Jose, CA     | Gene Paymar     | epaymar@hooked.net      |
  1314.    | Santa Clara, CA  | Marian Corcoran | mcorcora@ix.netcom.com  |
  1315.    | Tucson, AZ       | Martin Lapidus  | lascaux@primenet.com    |
  1316.    | North West       | Robin Rowe      | cpp@netcom.com          |
  1317.    |--------------------------------------------------------------|
  1318.  
  1319. ---------------------------------------------------------------------------
  1320.  
  1321. 2.7.  Technical Support
  1322. =======================
  1323.  
  1324.    * Microsoft MSVC Technical Support
  1325.     (206) 635-7007
  1326.  
  1327. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1328.  
  1329. 3.  A Brief History of MFC
  1330. ==========================
  1331.    I constantly see postings from folks confused about what version to
  1332.    use where, etc..  So this history kind of explains where MFC has been
  1333.    and where it's going.
  1334.    [This is the history as I remember it.  If you have any details that
  1335.    you can fill in, release dates, inside info, etc.. Let me know!]
  1336.  
  1337.    To understand the MFC releases, you need to realize that there are 16
  1338.    and 32-bit releases of MFC.  16-bit releases call Win16 and run on
  1339.    Windows 3.1 and 3.11 (Windows for Workgroups)
  1340.  
  1341.    The 32-bit releases call Win32 and run on Windows NT and Windows 95
  1342.    (and can run on Windows 3.1 with Win32s, but it still calls Win32)
  1343.  
  1344.    Skip to section 3.10 for a quick table of releases if you want to skip
  1345.    the long descriptions of each release.
  1346.  
  1347.    In each section, the new classes added to MFC are highlighted.  It's
  1348.    nearly impossible to do cool class diagrams in ASCII, so their
  1349.    hierarchy is just shown by indentation.  I've also left CObject out of
  1350.    most of the hierarchies for brevity.  You can pretty much assume that
  1351.    CObject is a parent of most of the classes except things like CString,
  1352.    etc. 
  1353.  
  1354. ---------------------------------------------------------------------------
  1355.  
  1356. 3.1.  How do I know what version of MFC I'm using?
  1357. ==================================================
  1358.    Check the top of the MFC header file afxver_.h (lives in
  1359.    mfc\include\afxver_.h). Older versions use afxver.h.  In there you
  1360.    will see a #define for _MFC_VER. 
  1361.  
  1362.    This is the hex version of the MFC release with this key:
  1363.  
  1364.    0x0250
  1365.       |||_____________ Point release ( very minor)
  1366.       ||______________ Minor number
  1367.       |_______________ Major number
  1368.  
  1369.  
  1370.   So in this example, the MFC release is 2.5.0.
  1371.  
  1372. ---------------------------------------------------------------------------
  1373.  
  1374. 3.2.  Pre-MFC 1.0
  1375. =================
  1376.    In the beginning, Microsoft created a group called the AFX group
  1377.    (stands for (A)pplication (F)ramework(X)).  This group probably was
  1378.    created to come out with an OWL competitor, since Borland C++ was
  1379.    doing pretty well.  They came up with a class library that presented a
  1380.    very high abstraction from the Windows API, kind of like OWL does.
  1381.    [Note: The group was actually formed before OWL 1.0 according to
  1382.    elsbree@nwrain.com ]
  1383.  
  1384.    Legend has it that they then went and tried writing applications with
  1385.    it for a couple of months and found that it was just too far removed
  1386.    from the Windows API.  They couldn't leverage any knowledge of
  1387.    Windows and most of these guys were die hard Windows API hackers.
  1388.  
  1389.    Legend also has it that at this point they scrapped the ENTIRE AFX
  1390.    class library, and then worked on what would become MFC 1.0...  You
  1391.    can still see remnants of the AFX days, many of the source files have
  1392.    afx prefixes and lots of macros in MFC today still have AFX in them.
  1393.  
  1394.    The AFX group was actually responsible for two things: the MFC library
  1395.    and the IDE's support for MFC (namely, the resource editor and the
  1396.    wizards). The AFX name was dropped in April 1994, and the group's
  1397.    members simply became part of smaller teams within the Visual C++
  1398.    group. One of those smaller teams is today's MFC team.
  1399.  
  1400.    I've also heard rumors that MFC was once called the MS Fulcrum Classes.
  1401.  
  1402. ---------------------------------------------------------------------------
  1403.  
  1404. 3.3.  MFC 1.0
  1405. =============
  1406.    This release was simultaneously released with Microsoft C/C++ 7.0 in
  1407.    early 1992.  It provided a very thin abstraction over the Windows API.
  1408.    This initial release did not have any of the document view
  1409.    architecture we know and love today, however it did lay the foundation
  1410.    by introducing CObject, MFC persistence via CArchive and many other
  1411.    features still heavily used in MFC today.  This was a 16-bit release
  1412.    released in 03/92.
  1413.  
  1414.    A 32-bit version of MFC 1.0 was released in July 1993, together with
  1415.    Windows NT 3.1 and the final Win32 SDK.  The files there are dated
  1416.    93-07-24.  The Win32 SDK did not include Visual C++ or the MFC 2.x.
  1417.  
  1418.   MFC 1.0 introduced these classes:
  1419.  
  1420. General:
  1421.   CObject
  1422.      CWinApp
  1423.      CMenu
  1424.   CArchive
  1425.   CDumpContext
  1426.   CRuntimeClass
  1427.   CMemoryState
  1428.   CFileStatus
  1429.   CString
  1430.   CTime
  1431.   CTimeSpan
  1432.   CPoint
  1433.   CRect
  1434.   CSize
  1435.  
  1436. Exceptions:
  1437.   CException
  1438.      CMemoryException
  1439.      CNotSupportedException
  1440.      CArchiveException
  1441.      CFileException
  1442.      CResourceException
  1443.  
  1444. File Services:
  1445.   CFile
  1446.      CStdioFile
  1447.      CMemFile
  1448.  
  1449. Collections:
  1450.   CByteArray
  1451.   CWordArray
  1452.   CDWordArray
  1453.   CPtrArray
  1454.   CObArray
  1455.   CStringArray
  1456.   CPtrList
  1457.   CObList
  1458.   CStringList
  1459.   CMapWordToPtr
  1460.   CMapWordToOb
  1461.   CMapPtrToWord
  1462.   CMapPtrToPtr
  1463.   CMapStringToPtr
  1464.   CMapStringToOb
  1465.   CMapStringToString
  1466.  
  1467. Graphics:
  1468.   CDC
  1469.      CClientDC
  1470.      CWindowDC
  1471.      CPaintDC
  1472.      CMetaFileDC
  1473.   CGdiObject
  1474.      CPen
  1475.      CBrush
  1476.      CFont
  1477.      CBitmap
  1478.      CPalette
  1479.      CRgn
  1480.  
  1481. Windows Support:
  1482.    CWnd
  1483.     CFrameWnd
  1484.        CMDIChildWnd
  1485.     CMDIFrameWnd
  1486.     CDialog
  1487.        CModalDialog
  1488.     CStatic
  1489.     CButton
  1490.     CEdit
  1491.     CListBox
  1492.     CComboBox
  1493.     CScrollBar
  1494.  
  1495. ---------------------------------------------------------------------------
  1496.  
  1497. 3.4.  MFC 2.0
  1498. =============
  1499.    MFC 2.0 was a 16-bit release that shipped with Visual C++ 1.0.  It
  1500.    added the Document/View framework on top of MFC 1.0 and also added OLE
  1501.    1.0 classes, message maps and common dialog classes.  This was a
  1502.    16-bit release released on 02/93
  1503.  
  1504.    MFC 2.0 introduced these classes:
  1505.  
  1506. General:
  1507.   CCreateContext
  1508.   CPrintInfo
  1509.   CDataExchange
  1510.   CCmdUI
  1511.  
  1512. Exceptions:
  1513.   CFileException
  1514.   COleException
  1515.  
  1516. Dialogs:
  1517.   [Note CModalDialog was nuked and functionality moved to CDialog, you
  1518.    can still see a #define CModalDialog CDialog in the header files]
  1519.   CDialog [not introduced here, but revamped to be a base for common dlgs]
  1520.      CFileDialog
  1521.      CColorDialog
  1522.      CFontDialog
  1523.      CPrintDialog
  1524.      CFindReplaceDialog
  1525.  
  1526. Windows Support:
  1527.    [Just new derivatives of CButton/CEdit and VBX class.]
  1528.    CButton
  1529.       CBitmapButton
  1530.    CEdit
  1531.       CHEdit
  1532.          CBEdit
  1533.    CVBControl
  1534.  
  1535. Document Architecture:
  1536.      CCmdTarget
  1537.       CWinApp [Moved in hierarchy, use to be derived from CObject]
  1538.       CDocTemplate
  1539.          CSingleDocTemplate
  1540.          CMultiDocTemplate
  1541.       CDocument
  1542.          COleDocument
  1543.             COleClientDoc
  1544.             COleServerDoc
  1545.  
  1546. Views:
  1547.    CView
  1548.       CScrollView
  1549.          CFormView
  1550.       CEditView
  1551.  
  1552. Control Bars:
  1553.    CControlBar
  1554.       CToolBar
  1555.       CStatusBar
  1556.       CDialogBar
  1557.    CSplitterWnd
  1558.  
  1559. OLE 1.0 Classes:
  1560.    COleServer
  1561.       COleTemplateServer
  1562.    CDocItem
  1563.       COleClientItem
  1564.       COleServerItem
  1565.  
  1566. ---------------------------------------------------------------------------
  1567.  
  1568. 3.5.  MFC 2.1
  1569. =============
  1570.    MFC 2.1 shipped with Visual C++ 1.1 for NT, it was basically a Win32
  1571.    port of MFC 2.0.  It was a 32-bit release that was released on
  1572.    08/93.
  1573.  
  1574.    MFC 2.1 did not introduce any new classes.
  1575.  
  1576. ---------------------------------------------------------------------------
  1577.  
  1578. 3.6.  MFC 2.5
  1579. =============
  1580.    MFC 2.5 shipped with Visual C++ 1.5.  It introduced the OLE 2 and ODBC
  1581.    classes.  It was the last 'official' 16-bit release.
  1582.  
  1583.    Released in 12/93
  1584.  
  1585.    MFC 2.5 introduced these classes:
  1586.  
  1587. General: [OLE and DB related]
  1588.    CFieldExchange
  1589.    COleDataObject
  1590.    COleDispatchDriver
  1591.    CRectTracker
  1592.  
  1593. Exceptions: [OLE and DB exceptions]
  1594.    COleException
  1595.       COleDispatchException
  1596.    CDBException
  1597.  
  1598. Files: [New OLE File support]
  1599.    CFile
  1600.       COleStreamfile
  1601.  
  1602. Dialogs: [New OLE Dialogs]
  1603.    CDialog
  1604.       COleDialog
  1605.          COleInsertdialog
  1606.          COleChangeIconDialog
  1607.          COlePasteSpecialDialog
  1608.          COleConvertDialog
  1609.          COleBusyDialog
  1610.          COleLinksDialog
  1611.             COleUpdateDialog
  1612.  
  1613. Windows Support: [Some OLE additions]   
  1614.    CFrameWnd
  1615.       COleIPFrameWnd
  1616.    CControlBar
  1617.       COleResizeBar
  1618.  
  1619. Document Architecture:  [Significant classes added for OLE here.]
  1620.    CCmdTarget
  1621.       COleObjectFactory
  1622.          COleTemplateServer
  1623.       COleDataSource
  1624.       COleDropSource
  1625.       COleDropTarget
  1626.       COleMessageFilter
  1627.       CDocument
  1628.          COleDocument
  1629.             COleLinkingDoc
  1630.                COleServerDoc
  1631.       CDocItem
  1632.          COleClientItem
  1633.          COleServerItem
  1634.  
  1635. Views: [New view for DB support]
  1636.    CView
  1637.       CScrollView
  1638.          CFormView
  1639.             CRecordView
  1640.  
  1641. ODBC/Database Classes:
  1642.    CDatabase
  1643.    CRecordSet
  1644.    CLongBinary
  1645.  
  1646. ...........................................................................
  1647.  
  1648. 3.6.1. MFC 2.51
  1649. ----------------
  1650.    A point release to 2.5 (16-bit) that was a bug fix release.  Shipped
  1651.    with MSVC 2.0 in 9/94 with MFC 3.0 (32-bit).
  1652.  
  1653. ...........................................................................
  1654.  
  1655. 3.6.2. MFC 2.52
  1656. ----------------
  1657.    A point release to 2.5 (16-bit) that added some of the MFC 3.0
  1658.    features such as property sheets, Winsock and MAPI support.
  1659.    Shipped with MSVC 2.1 in 1/95 with MFC 3.1 (32-bit).
  1660.  
  1661.    NOTE: This is only available via the MSVC Subscription.
  1662.  
  1663. Classes added in 2.52:
  1664.    CSocket
  1665.    CAsyncSocket
  1666.    CSocketFile
  1667.    CPropertyPage
  1668.    CPropertySheet
  1669.  
  1670. MAPI:
  1671. [Note that MAPI support was added to CDocument, no new classes]
  1672.    CDocument::OnFileSendMail
  1673.    CDocument::OnUpdateFileSendMail
  1674.    COleDocument::OnFileSendMail
  1675.  
  1676. ...........................................................................
  1677.  
  1678. 3.6.3.  MFC 2.52b
  1679. ----------------
  1680.    [Excerpt from the 2.52b rel notes]
  1681.    Visual C++ 1.52b includes the industry-standard Microsoft
  1682.    Foundation Class Library (MFC) version 2.52b. Besides classes for OLE
  1683.    and database, this version includes classes for OLE control
  1684.    development. 
  1685.  
  1686.    Bugs Fixed in Visual C++ 1.52b
  1687.  
  1688.    Visual C++ 1.52b fixes a number of bugs from Visual C++ 1.5. Of
  1689.    particular interest to most developers are the following bug fixes: 
  1690.  
  1691.    MFC 2.52b
  1692.  
  1693.    Error L2025 occurred on CWnd::DoDataExchange.
  1694.    This bug has been corrected. See Microsoft Knowledge Base article
  1695.    Q120152 for more information. 
  1696.  
  1697.    CArchive::ReadObject sometimes caused an assertion in a CPtrArray
  1698.    object because CPtrArray can hold a maximum object size of 16K in a
  1699.    large memory model application. CArchive did not take the memory model
  1700.    into account; since CArchive enforced a 32K limit, objects of 32K
  1701.    could be written but an assertion was generated if CArchive read in
  1702.    more than 16K. 
  1703.    This bug has been corrected.
  1704.  
  1705.    There was a memory leak in 16-bit AUX_DATA.
  1706.  
  1707.    The three pens used in the class CPropertySheet were leaking. See
  1708.    Microsoft Knowledge Base article Q128604 for more information. 
  1709.  
  1710.    The CArchive buffer pointer could wrap around the end of a segment unintentionally.
  1711.    This bug has been corrected.
  1712.  
  1713.    If AfxSockInit failed, applications sometimes produced a General
  1714.    Protection Fault. 
  1715.    This bug has been corrected. See Microsoft Knowledge Base article
  1716.    Q130653 for more information. 
  1717.  
  1718.    The MAPISendMail dialog did not stay modal.
  1719.    This bug has been corrected.
  1720.  
  1721.    Source file DLGPROP.CPP had non-near data. This could prevent
  1722.    applications from being able to run multi-instance. 
  1723.    This bug has been corrected.
  1724.  
  1725. ---------------------------------------------------------------------------
  1726.  
  1727. 3.7.  MFC 3.0
  1728. =============
  1729.    MFC 3.0 shipped with Visual C++ 2.0 in 9/94.  It introduced docking
  1730.    toolbars, property sheets and template based collection classes.  This
  1731.    was the first release in the MSVC subscription, it was a 32-bit release.
  1732.  
  1733.    Classes added in MFC 3.0:
  1734.  
  1735. Tabbed Dialog Support:
  1736. CWnd
  1737.   CPropertySheet
  1738.   CDialog
  1739.      CPropertyPage
  1740.  
  1741. ---------------------------------------------------------------------------
  1742.  
  1743. 3.8.  MFC 3.1
  1744. =============
  1745.    MFC 3.1 shipped with Visual C++ 2.1 in 1/95.  It introduced MAPI,
  1746.    WinSock and Windows Common Controls.  The MFC toolbar, status bar,
  1747.    etc.. still live in MFC. This is the latest release out.  It is a
  1748.    32-bit release. 
  1749.  
  1750.    NOTE: Only available via MSVC subscription.
  1751.  
  1752.    Classes added in MFC 3.1: 
  1753.  
  1754. MAPI:
  1755. [Note that MAPI support was added to CDocument, no new classes]
  1756.    CDocument::OnFileSendMail
  1757.    CDocument::OnUpdateFileSendMail
  1758.    COleDocument::OnFileSendMail
  1759.  
  1760. Windows Common Controls Classes: [All of these are CWnd derived]
  1761.    CAnimateCtrl
  1762.    CHeaderCtrl
  1763.    CHotkeyCtrl
  1764.    CImageList
  1765.    CListCtrl
  1766.    CProgressCtrl
  1767.    CSliderCtrl
  1768.    CSpinButtonCtrl
  1769.    CStatusBarCtrl
  1770.    CTabCtrl
  1771.    CToolBarCtrl
  1772.    CToolTipCtrl
  1773.    CTreeCtrl
  1774.  
  1775. WinSock Support:
  1776.    CAsyncSocket
  1777.       CSocket
  1778.  
  1779. ---------------------------------------------------------------------------
  1780. 3.9.  MFC 3.2
  1781. =============
  1782.    MFC 3.2 shipped with Visual C++ 2.2 via the subscription in
  1783.    mid/late July. It is a 32-bit release.  Includes a  2.52b 16-bit
  1784.    release update. 
  1785.  
  1786.    [here's an excerpt from the release notes]
  1787.  
  1788.    Support for Windows Common Controls in USRDLLs. In order to use the
  1789.    MFC Windows Common Control classes you must link in the appropriate
  1790.    static libraries, as shown in the following table: 
  1791.  
  1792.    Library      Target
  1793.    DAFXCC.LIB   Release version
  1794.    DAFXCCD.LIB  Debug version
  1795.    DAFXCCU.LIB  Release Unicode version
  1796.    DAFXCCUD.LIB Debug Unicode version
  1797.  
  1798.    Updated MFC Common Control classes that work with those controls
  1799.    that have been recently released in Windows NT 3.51 and those that
  1800.    will be available in Windows 95 and a future version of Win32s.
  1801.  
  1802.    Improved common control documentation that is more complete and
  1803.    reflects changes since the first implementation.  
  1804.  
  1805.    New MFC sample applications
  1806.    ---------------------------
  1807.     NOTEPAD +   Notepad+ is an enhanced version of Notepad.  The
  1808.                 enhancements are mainly from questions our customers
  1809.                 have been asking. 
  1810.   
  1811.     SAVER       Saver is a screen saver written using MFC.  It
  1812.                 "morphs" the text "MFC" to the text "C++".
  1813.  
  1814.     OLEVIEW     The OLEVIEW sample is very similar to the OLE2VIEW.EXE
  1815.                 applet provided in \MSVC20\BIN. The sample illustrates
  1816.                 how to implement OLE Object viewers through custom OLE
  1817.                 interfaces. These custom interfaces are implemented in
  1818.                 IVIEWERS.DLL
  1819.  
  1820.     BATCH       BATCH is an MDI application that lets you compress
  1821.                 different AVI (Audio Video Interleaved) files in
  1822.                 different ways. 
  1823.  
  1824.     WORDPAD     WORDPAD illustrates use of the CRichEditCtrl and
  1825.                 CRichEditView classes, which encapsulate the new Rich
  1826.                 Edit common control.
  1827.  
  1828.  
  1829.    These samples are located in the SAMPLES\MFC directory of your
  1830.    Visual C++ installation. 
  1831.  
  1832.    Updated Win32 SDK components
  1833.    ----------------------------
  1834.    With the release of Windows NT 3.51 and the upcoming release of
  1835.    Windows 95, the Win32 SDK has been updated to support both of these
  1836.    operating systems. Changes include new header files, new import
  1837.    libraries, and additional documentation. Visual C++ 2.2 includes the
  1838.    latest header files, import libraries and Win32 API documentation to
  1839.    support writing Windows NT- and Windows 95-compatible applications. 
  1840.  
  1841. ---------------------------------------------------------------------------
  1842.  
  1843. 3.10.  MFC 4.0
  1844. ==============
  1845.    Rumor has it that MFC 4.0 will be part of MSVC 4.0 (they are finally
  1846.    going to get the numbers in synch) to ship shortly after Windows 95
  1847.    ships (9/95).  The MFC status bar, toolbars, property dialog and
  1848.    other UI classes will be rewritten to use the Windows 95 common
  1849.    controls. There will be other Windows 95 enhancements as well and much
  1850.    better OLE control support too!  Just heard that there will be some
  1851.    new database classes based on the Jet Engine <Access DB engine> and
  1852.    something called message reflection, so you can stop messages from
  1853.    bouncing up to parents if you want to grab them all.
  1854.  
  1855.    Classes added in MFC 4.0: <Heard about these through the grapevine>
  1856.       CSynchronize
  1857.       CMutex
  1858.       CEvent
  1859.       CMultiLock
  1860.       CShellNew - Windows 95 
  1861.    
  1862.    **NOTE: This has not been released yet, MFC 3.2/MSVC 2.2 is the latest
  1863.      release with MFC 4.0/VC++ 4.0 due out in September.
  1864.  
  1865. ---------------------------------------------------------------------------
  1866.  
  1867. 3.11.  Table of MFC releases
  1868. ============================
  1869.    ** Hint, MFC releases are always MSVC release - 1. This is because MFC
  1870.       1.0 came out with MS C 7.
  1871.  
  1872.    MFC Rel     MSVC Release  16 or 32 bit Notes
  1873.    ---------------------------------------------------------------------------
  1874.    1.0         <C/C++ 7.0>    16          Just thin Windows coverage
  1875.    2.0         1.0            16          Document/Views added
  1876.    2.1         1.1 for NT     32          First 32-bit release for NT
  1877.    2.5         1.5            16          OLE/ODBC, last 16-bit release
  1878.    2.51        2.0            16          Bug fixes.
  1879.    2.52        2.1            16          Adds prop sheets to 2.5
  1880.    2.52b       2.2            16          Shipped in July '95, bug fixes
  1881.    3.0         2.0            32          Property sheets, dock toolbars
  1882.    3.1         2.1            32          Winsock/MAPI, Win commcntrls
  1883.    3.2         2.2            32          Shipped in July '95, more commcntrls
  1884.    4.0         4.0            32          Not out yet, Win 95, OLE Control container
  1885.  
  1886. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1887.  
  1888. 4. Generic Class Questions
  1889. =========================
  1890.  
  1891. 4.1. CException - Exceptions and exception handling.
  1892. ----------------------------------------------------
  1893.  
  1894. 4.1.1.  How do I throw a CUserException derived exception?
  1895. ----------------------------------------------------------   
  1896.    When I try to catch a derived exception I get the following error: 
  1897.    error C2039: 'classCMyException' : is not a member of
  1898.    'CMyException' 'classCMyException' : undeclared identifier
  1899.    'IsKindOf' : cannot convert parameter 1 from 'int*' to 'const
  1900.     struct CRuntimeClass*' 
  1901.  
  1902.    You need to make your CMyException class dynamically creatable 
  1903.    using the DECLARE_DYNAMIC() and IMPLEMENT_DYNAMIC() macros.  The
  1904.    CATCH macro expects to be able to access run-time information about
  1905.    the thrown class.
  1906.    -blaszczak@bix.com, Mike B, 6/5/95, comp.os.ms-windows.programmer.misc
  1907.  
  1908. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1909.  
  1910. 5. GDI Class Questions
  1911. ======================
  1912.  
  1913. 5.1. CDC
  1914. ========
  1915.  
  1916. 5.1.1. How do I create a CDC from a HDC?
  1917. ----------------------------------------
  1918.    Sometimes the Windows API will just give you a handle to a DC and
  1919.    you might want to create a CDC from that.  On example is
  1920.    owner-drawn lists, combos and buttons.  You will receive a draw
  1921.    item message with a hDC.  Here's some code to turn that hdc into
  1922.    the more familiar CDC.
  1923.  
  1924.    void MyODList::DrawItem(LPDRAWITEMSTRUCT lpDrawItem)
  1925.    {
  1926.  
  1927.        CDC myDC;
  1928.        myDC.Attach(lpDrawItem->hDC);
  1929.  
  1930.        //Do more stuff here
  1931.  
  1932.        //If you don't detach, it will get deleted and windows will
  1933.        //not be happy if you delete it's dc..
  1934.  
  1935.        myDC.Detach();
  1936.    }
  1937.    You can use this technique for any of the other MFC class/ Windows
  1938.    handle pairs too.
  1939.  
  1940.    Another approach is to call the CDC FromHandle method:
  1941.  
  1942.    CDC * pDC = CDC:FromHandle(lpDrawItem->hDC);
  1943.  
  1944.    It's not clear which is 'better', FromHandle is less error prone
  1945.    because you do not have to remember to 'detach'.
  1946.    -jmccabe@portage1.portup.com (Jim McCabe) 6/5/95
  1947.  
  1948. ---------------------------------------------------------------------------
  1949.  
  1950. 5.2. CBitmap
  1951. ============
  1952.  
  1953. 5.2.1. How do I read a 256 color bitmap file from disk?
  1954. ------------------------------------------------------
  1955.  
  1956.    Currently, MFC does not contain direct support for reading and
  1957.    displaying DIBs or BMPs. However, there are a number of sample
  1958.    applications that illustrate just how to do this. 
  1959.  
  1960.    The first sample is the MFC sample application DIBLOOK. The
  1961.    MULTDOCS sample uses the same source code provided by DIBLOOK to read
  1962.    and display DIBs and BMPs. 
  1963.  
  1964.    Two other examples provided with Visual C++ are the SDK samples
  1965.    DIBVIEW and SHOWDIB. 
  1966.   - Question posted on comp.lang.c++, 6/5/95, found this in MS FAQ, 6/25/95
  1967.  
  1968. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  1969.  
  1970.  
  1971. 6. Window, Control, and Dialogs Class Questions
  1972. ===============================================
  1973.  
  1974. 6.1. Windows
  1975. ============
  1976.  
  1977. 6.1.1.  How can I use a custom icon for a window?
  1978. -------------------------------------------------
  1979.    The Microsoft Foundation Class Library stores icons for the main
  1980.    frame window and the MDI frame window as resources. The icon with
  1981.    resource ID AFX_IDI_STD_MDIFRAME is the icon for the MDI frame
  1982.    window, and the icon with resource ID AFX_IDI_STD_FRAME is the icon
  1983.    for the main frame window. To replace these icons in your
  1984.    application, add an icon to your resources file with the
  1985.    appropriate ID.
  1986.    
  1987.    The application specifies the icon for a view in an MDI child
  1988.    window when it creates the template. The application uses the icon
  1989.    with the specified resource ID when the user minimizes the MDI
  1990.    child window that contains the corresponding view.
  1991.    
  1992.    This technique allows you to specify one icon for the application
  1993.    to associate with these windows. Windows also supports dynamically
  1994.    painting a minimized window. To do this with MFC, use
  1995.    AfxRegisterWndClass() to register a window class with a NULL icon
  1996.    handle. Override the PreCreateWindow() function in the window class
  1997.    for the dynamically painted icon and copy the name returned by
  1998.    AfxRegisterWndClass() into the lpszClassName member of the
  1999.    CREATESTRUCT. This creates the window using the class that has a
  2000.    NULL icon. When the user minimizes this window, the icon receives
  2001.    WM_PAINT messages that it can process to display information
  2002.    appropriately. To do so, override the OnPaint() message handler and
  2003.    call the IsIconic() function to see if the window is minimized. If
  2004.    so, create a CPaintDC object and use it to draw on the icon. If the
  2005.    window is not minimized, call the base class version of OnPaint()
  2006.    to update the window normally.
  2007.    -MSVC Knowledge Base 6/4/94
  2008.  
  2009. ...........................................................................
  2010.  
  2011. 6.1.2. How do I change the styles for a window that's created by MFC?
  2012. ---------------------------------------------------------------------
  2013.    To change the default window attributes used by a framework
  2014.    application created in AppWizard, override the window's
  2015.    PreCreateWindow() virtual member function. PreCreateWindow()
  2016.    allows an application to access the creation process normally
  2017.    processed internally by the CDocTemplate class. The framework
  2018.    calls PreCreateWindow() just prior to creating the window. By
  2019.    modifying the CREATESTRUCT structure parameter to
  2020.    PreCreateWindow(), your application can change the attributes
  2021.    used to create the window.
  2022.  
  2023.    The CTRLBARS sample application, provided with the Microsoft
  2024.    Foundation Class Library version 2.0, demonstrates this
  2025.    technique to change window attributes. Note that depending on
  2026.    what your application changes in PreCreateWindow(), it may be
  2027.    necessary to call the base class implementation.
  2028.  
  2029.    For more information, see MSVC knowledge base article Q99847.
  2030.    -MSVC Knowledge Base 6/7/95
  2031.  
  2032. ............................................................................
  2033.  
  2034. 6.1.3.  How do I get the minimal size of a window using MFC?
  2035. ------------------------------------------------------------
  2036.    Write a handler for WM_GETMINMAXINFO.
  2037.    -blaszczak@BIX.com, Mike Blaszczak, 6/12/95 via programmer.misc
  2038.  
  2039. ............................................................................
  2040.  
  2041. 6.1.4.  How do I change a Window's title?
  2042. -----------------------------------------
  2043.   AfxGetApp()->m_pMainWnd->SetWindowText("My Window Title");
  2044.                       -or-
  2045.   AfxGetMainWnd()->SetWindowText ( "My Own Title" ) ;
  2046.    -aj536@freenet.toronto.on.ca, mfc-l, 7/9/95
  2047.  
  2048. ............................................................................
  2049.  
  2050. 6.1.5.  How do I get rid of 'Untitled' in my main window caption?
  2051. -----------------------------------------------------------------
  2052.    Override the PreCreateWindow function in your MainFrame class and
  2053.    do the following in it..
  2054.         cs.style &= ~FWS_ADDTOTITLE ;
  2055.  
  2056.    You can also set the initial window position (cs.x, cs.y, cs.cx,
  2057.    cs.cy) this way and change your class (cs.lpszClass) this way! 
  2058.  
  2059.    Remember to call CFrameWnd::PreCreateWindow at the end...
  2060.    -netninja@svpal.org, programmer.misc, 7/29/95
  2061.  
  2062. ............................................................................
  2063.  
  2064. 6.1.6.  How do I maximize my MDI child?
  2065. ---------------------------------------
  2066.  
  2067.    void CMainFrame::ActivateFrame(int nCmdShow) 
  2068.    {
  2069.        if (!m_bActivated) {
  2070.          m_bActivated = TRUE;
  2071.          nCmdShow = SW_SHOWMAXIMIZED;
  2072.        }       
  2073.        CFrameWnd::ActivateFrame(nCmdShow);
  2074.    }
  2075.   
  2076.    where m_bActivated is a member variable of your frame object.
  2077.    -duane@anasazi.com, programmer.win32, 8/3/95
  2078.  
  2079. ............................................................................
  2080.  
  2081. 6.1.7.  Why does focus go nutso with a CSplitterWnd?
  2082. ----------------------------------------------------
  2083.    <<< Whenever I move the splitter bar, the I-beam cursor in my edit
  2084.    control goes away. I have to click again in the edit control to get 
  2085.    back the cursor.>>> 
  2086.  
  2087.    The following Knowledge Base Article (GO MSKB on CIS) explains the
  2088.    focus problem associated with splitter windows and a couple of
  2089.    work-arounds to the problem. This may be of help to you. 
  2090.  
  2091.    ID: Q108434
  2092.    FIX: CSplitterWnd Class Does Not Handle All Focus Cases
  2093.  
  2094.   -Ramesh, NetQuest., MSMFC, 8/3/95
  2095.  
  2096. ----------------------------------------------------------------------------
  2097.    
  2098. 6.2. Controls
  2099. =============
  2100.  
  2101. 6.2.1.  How do I get a CControl from a Dialog Template?
  2102. -------------------------------------------------------
  2103.    You can get a pointer to a control from a already created dialog
  2104.    control by doing a simple typecast of the results from GetDlgItem.
  2105.    Here's an example that creates a CButton from a checkbox with ID
  2106.    IDC_CHECK1.
  2107.    
  2108.     void my_function(CDialog * pDialog)
  2109.     {
  2110.        
  2111.        CButton * pButton = (CButton *)pDialog->GetDlgItem(IDC_CHECK1);
  2112.     
  2113.        ASSERT(pButton != NULL);
  2114.        pButton->SetCheck(m_bShowState);
  2115.     }
  2116.  
  2117.     Note that it's always safer to check for the validity of the
  2118.     results from GetDlgItem.
  2119.    -scot_wingo@msn.com, 6/1/95
  2120.     
  2121. ............................................................................
  2122.  
  2123. 6.2.2.  How do I subclass a control using MFC?
  2124. ----------------------------------------------
  2125.    Read the documentation on SubClassDlgItem.  Here's an example of
  2126.    how to call it:
  2127.  
  2128.    BOOL CMyDialog::OnInitDialog()
  2129.    {
  2130.         //Do your subclassing first.        
  2131.         m_MyControl.SubClassDlgItem(ID_MYCONTROL, this);
  2132.  
  2133.         //Let the base class do its thing.
  2134.         CDialog::OnInitDialog();
  2135.  
  2136.         // Perhaps do some more stuff
  2137.         
  2138.         // Be sure to call Ctl3d last, or it will cause
  2139.         // assertions from multiple subclassing.
  2140.         
  2141.         Ctl3dSubclassDlg(m_hWnd, CTL3D_ALL);
  2142.    }
  2143.    -Mike Williams, mikew@marlin.ssnet.com, mfc-l 6/1/95
  2144.  
  2145. ...........................................................................
  2146.  
  2147. 6.2.3.  Why do I get an ASSERT when I subclass a control?
  2148. ---------------------------------------------------------
  2149.    Make sure that you subclass the control BEFORE you call
  2150.    Ctl3dSubclassDlg, if the 3-d control DLL is loaded first, it will
  2151.    already have subclassed your controls and you will get an assert.
  2152.    - Mike Williams, mikew@marlin.ssnet.com, mfc-l 6/1/95
  2153.  
  2154. ...........................................................................
  2155.  
  2156. 6.2.4.  How do I validate the contents of a control when it loses focus?
  2157. ------------------------------------------------------------------------
  2158.    NOTE: This is in the Microsoft Software Library.
  2159.  
  2160.    The FCSVAL sample application was created to show how an
  2161.    application can do control-by-control validation in a dialog box. 
  2162.  
  2163.    The application itself is just a modal dialog box displayed by the
  2164.    CWinApp::InitInstance(). After displaying the dialog box,
  2165.    InitInstance() simply quits the application.  
  2166.  
  2167.    The important part of the sample takes place in the dialog-box
  2168.    class implementation: There are two edit controls. The first takes
  2169.    input of an integer between 1 and 20. The second takes a character
  2170.    string as input with length less than or equal to 5. When you Tab or
  2171.    mouse-click from control to control within the displayed dialog box,
  2172.    the contents of the control that is losing focus are validated. 
  2173.  
  2174.    The CFocusDlg Class
  2175.  
  2176.    The application's functionality centers around the CFocusDlg class
  2177.    and its implementation of four message handlers (discussed below).
  2178.    Normal data exchange (DDX) and validation (DDV) using the routines
  2179.    provided by MFC take place in OnInitialUpdate(), when the dialog box
  2180.    is first displayed, and when the user chooses the OK button to accept
  2181.    the input. This is default behavior provided by ClassWizard when
  2182.    member variables are connected to dialog-box controls and can be
  2183.    examined in the dialog class DoDataExchange() function. 
  2184.  
  2185.    Validating control contents when switching focus from one control
  2186.    to the next is done by handling the EN_KILLFOCUS notification sent by
  2187.    the edit control that is losing focus. The idea here is to check the
  2188.    contents and, if they are not valid, to display the message box,
  2189.    inform the user, and then set the focus back to the control from which
  2190.    it came. Unfortunately, some difficulties arise when trying to set the
  2191.    focus (or display the message boxes) within a killfocus message
  2192.    handler. At this point, Windows is in an indeterminate state as it is
  2193.    moving focus from one control to the other. This is a bad place to do
  2194.    the validation and SetFocus() call. 
  2195.  
  2196.    The solution here is to post a user-defined message to the dialog
  2197.    box (parent) and do the validation and SetFocus() there, thus waiting
  2198.    for a safer time to do the work. (See "CFocusDlg::OnEditLostFocus()"
  2199.    in the file FOCUSDLG.CPP and "WM_EDITLOSTFOCUS user-defined message"
  2200.    in the file FOCUSDLG.H.) 
  2201.  
  2202.    Another thing you will notice about this function is that it uses
  2203.    TRY/CATCH to do the validation. The provided DDX/DDV routines throw
  2204.    CUserExceptions when failing to validate or load a control's data. You
  2205.    should catch these and do the SetFocus() in the CATCH block. 
  2206.  
  2207.    Note: This sample has other cool stuff, but this is the major one
  2208.    I've seen asked about on the net.
  2209.    -MS FAQ, 6/25/95
  2210.  
  2211. ...........................................................................
  2212.  
  2213. 6.2.5.  How do I enable/disable a bank of checkboxes?
  2214. -----------------------------------------------------
  2215.    I don't know about a magic way to do this using a single HWND, but there
  2216.    is a simple and self-documenting technique that I've been using for a
  2217.    long time.  You can make a routine that accepts an array of UINTs (your
  2218.    control IDs) and a visibility flag.
  2219.  
  2220.    This function can be a stand-alone function, or you can put it inside a
  2221.    class.  I have been collecting little utility functions like this and keep
  2222.    them in a CDialogBase class -- when I create a new dialog box in ClassWizard,
  2223.    I fix up the code to derive from CDialogBase instead of CDialog.
  2224.   
  2225.    For example, the function might look like this:
  2226.  
  2227.    void CDialogBase::ShowControls(UINT* pControls, UINT cControls, BOOL fVisible)
  2228.    {
  2229.        for (UINT uIndex = 0; uIndex < cControls; uIndex++)
  2230.        {
  2231.            CWnd* pwnd = GetDlgItem(pControls[uIndex]);
  2232.            if (pwnd)
  2233.            {
  2234.                pwnd->ShowWindow(fVisible ? SW_SHOW : SW_HIDE);
  2235.                pwnd->EnableWindow(fVisible);
  2236.            }
  2237.        }
  2238.    }
  2239.  
  2240.    Then later, often in your OnInitDialog handler, you can call this
  2241.    function with your control group:
  2242.  
  2243.    #define SIZEOF_ARRAY(a) (sizeof(a) / sizeof(a[0]))
  2244.    {
  2245.        static UINT aGroup1[] = { DLG_CHBOX1, DLG_CHBOX2, DLG_STATIC1 };
  2246.        static UINT aGroup2[] = { DLG_LABEL2, DLG_LABEL7 };
  2247.  
  2248.        ShowControls(aGroup1, SIZEOF_ARRAY(aGroup1), TRUE);
  2249.        ShowControls(aGroup2, SIZEOF_ARRAY(aGroup2), FALSE);
  2250.    }
  2251.  
  2252.    You can find many uses for these control arrays later too...
  2253.    (Changing fonts in a series of controls, etc...)  Good luck,
  2254.    -jmccabe@portage1.portup.com, mfc-l, 7/18/95
  2255.  
  2256. ...........................................................................
  2257.  
  2258. 6.2.6.  How do I change the background color of a control?
  2259. ----------------------------------------------------------
  2260.    Your dialog can trap the WM_CTLCOLOR message, look up the MFC help
  2261.    file notes for CWnd::OnCtlColor().  Before a control is about to paint
  2262.    itself, the parent window receives a chance to set its own default
  2263.    text color and background brush. 
  2264.    -jmccabe@portage1.portup.com, mfc-l, 7/18/95
  2265.  
  2266.    Also check out the MS KB article  ID: Q117778
  2267.    TITLE: Changing the Background Color of an MFC Edit Control
  2268.    -Ramesh, MSMFC, 7/19/95
  2269.  
  2270. ...........................................................................
  2271.  
  2272. 6.2.7.  How do I trap the <enter> key for my control?
  2273. -----------------------------------------------------
  2274.    Handle WM_GETDLGCODE and return the appropriate value.  Remember that
  2275.    the listbox (or any other control) can only handle keyboard input when
  2276.    it has the focus.
  2277.    -joej@golddisk.com, programmer.misc, 8/21/95, programmer.misc
  2278.  
  2279. ...........................................................................
  2280.  
  2281. 6.2.8.  How can I DDX with a multiple selection listbox?
  2282. --------------------------------------------------------
  2283.    Download MLBDDX.ZIP from the MSMFC library on CIS. You'll get all
  2284.    the necessary code. When the dialog closes, a provided CStringList
  2285.    will be filled with the selected items. Freeware. 
  2286.    -Patrick Philippot, CIS email, 8/3/95
  2287.  
  2288. ...........................................................................
  2289.  
  2290. 6.2.9.  How do I change the background color of a BUTTON???
  2291. -----------------------------------------------------------
  2292.  
  2293.    NOTE: THE METHOD IN 6.2.6 WILL NOT WORK FOR BUTTONS!
  2294.  
  2295.    If you want to change the color of a dialog button, you have to use
  2296.    owner-draw button. (you can use bitmap buttons) Changing the color
  2297.    through  OnCtlColor() will not work for buttons. 
  2298.  
  2299.    The following Knowledge Base  articles (GO MSKB on CIS) may be of help to you.
  2300.  
  2301.    ID: Q32685
  2302.    TITLE: Using the WM_CTLCOLOR Message
  2303.  
  2304.    ID: Q64328
  2305.    SAMPLE: Owner-Draw: 3-D Push Button Made from Bitmaps with Text
  2306.  
  2307.    This article explains sample code for a owner-draw button.
  2308.    -Ramesh, NetQuest., MSMFC, 8/3/95
  2309.  
  2310. ...........................................................................
  2311.  
  2312. 6.2.10.  Why isn't CEdit putting things on separate lines?
  2313. ----------------------------------------------------------
  2314.   Make sure that the lines are separated with \r\n, not just \n.
  2315.   -sutor@watson.ibm.com, mfc-l, 8/7/95
  2316.  
  2317. ...........................................................................
  2318.  
  2319. 6.2.11.  How do I get to the CEdit in a combobox?
  2320. -------------------------------------------------
  2321.    CComboCox combo;
  2322.    CEdit edit;
  2323.  
  2324.    // combobox creation ...
  2325.    // ...
  2326.  
  2327.    POINT tmpPoint = {1,1};
  2328.    edit.SubclassWindow( combo.ChildWindowFromPoint(tmpPoint)->GetSafeHwnd());
  2329.    -jahans@slb.com, mfc-l, 8/25/95
  2330.    
  2331. ---------------------------------------------------------------------------
  2332.  
  2333. 6.3.  Dialogs
  2334. ============
  2335.  
  2336. 6.3.1. How do I center my dialog?
  2337. ---------------------------------
  2338.    Use the CWnd::CenterWindow method accomplish this.  I usually put
  2339.    it in my OnInitDialog overloaded function.  Since CDialog is an
  2340.    ancestor of CWnd, you can call the method directly->
  2341.  
  2342.    BOOL CMyDialog::OnInitDialog()
  2343.    {
  2344.       //Perform any other dialog initialization up here.
  2345.  
  2346.       CenterWindow();
  2347.  
  2348.       return TRUE;
  2349.    }
  2350.    - scot_wingo@msn.com, 6/1/95.
  2351.  
  2352. ...........................................................................
  2353.  
  2354. 6.3.2.  How do I get the 'old style' common dialogs on win95?
  2355. -------------------------------------------------------------
  2356.    MFC detects if it is running on Win95, and if so, replaces the 
  2357.    standard FileOpen Dialog with an explorer version of the FileOpen
  2358.    Dialog.   You can prevent MFC  from using this "explorer" version by
  2359.    adding the following line to your CFileDialog derived  class
  2360.    constructor:   m_ofn.Flags &= ~OFN_EXPLORER;
  2361.    -andyd@andyne.on.ca (Andy DeWolfe), via programmer.win32, 5/10/95
  2362.  
  2363. ...........................................................................
  2364.  
  2365. 6.3.3.  How do I subclass a win95 common dialog?
  2366. ------------------------------------------------
  2367.    You can do it but Microsoft has made it much more difficult in
  2368.    Win95.  You need to create a "child dialog template" (with the
  2369.    WS_CHILD style) and set it to m_ofn.lpTemplateName (making sure
  2370.    m_ofn.hInstance is set to your app instance). This template must
  2371.    *only* contain the controls that you are adding to the dialog (ie. NOT
  2372.    the whole dialog with the standard controls  duplicated as in Win3.x).
  2373.  
  2374.    When the dialog is invoked, your template will appear (by default)
  2375.    below the regular file dialog controls.  If you put a static control
  2376.    with id stc32 (defined in include\dlgs.h), the common dialog code will
  2377.    rearrange things so that the original controls will appear wherever
  2378.    your put the stc32 control (you don't have to size it to match - the
  2379.    common dlg code will do that for you). 
  2380.  
  2381.    You will need to supply m_ofn.lpfnHook and handle your additional
  2382.    controls through the hook proc.  Note that since the system puts your
  2383.    dialog template ON TOP of the normal dialog, MFC message routing won't
  2384.    get to your controls so you can't code them through a message map in
  2385.    your CFileDialog derivative.  If anybody has found a way around this,
  2386.    I'd love to hear it!! 
  2387.  
  2388.    This is very messy and Microsoft knows it.  They promise a fix in
  2389.    MFC 4.0.  
  2390.    -joej@golddisk.com, Joe Janakovic, via programmer.win32, 6/10/95
  2391.  
  2392. ...........................................................................
  2393.  
  2394. 6.3.4.  CDialog::Create fails, what could be wrong?
  2395. ---------------------------------------------------
  2396.    - Invalid HWND passed as a parent
  2397.    - Invalid dialog resource ID passed (be careful about numeric IDs
  2398.      vs. string IDs -- be careful with #define ID_MYDIALOG 0x1234 -- it is
  2399.      a "string" ID to the resource compiler). 
  2400.    - one or more controls on your dialog could not be created, usually
  2401.      because of the use of a custom control that was not registered. 
  2402.    - calling EndDialog during the OnInitDialog message (or some other
  2403.      handler called early in the game)! 
  2404.    - NULL HWND passed as parent when dialog has WS_CHILD style
  2405.  
  2406.    That's about all I can think of right now,
  2407.    -Dean McCrory, MSMFC, 6/16/95
  2408.  
  2409. ...........................................................................
  2410.  
  2411. 6.3.5.  How do I create a toolbar/statusbar in a dialog?
  2412. --------------------------------------------------------
  2413.    There's a sample in the Microsoft Software Library, DLGCBR, that
  2414.    demonstrates how to do this.
  2415.  
  2416.    Basically there's four steps, outlined and then coded below->
  2417.  
  2418.    To add a control bar to a dialog, you must create the control bar
  2419.    as usual, and then make room for the control bar within the client
  2420.    area of the dialog. For the control bar to function properly, the
  2421.    dialog must duplicate some of the functionality of frame windows. If
  2422.    you want ON_UPDATE_COMMAND_UI handlers to work for the control bars,
  2423.    you also need to derive new control bar classes, and handle the
  2424.    WM_IDLEUPDATECMDUI message. If your dialog is not the main window of
  2425.    your application, you will also need to modify its parent frame window
  2426.    to pass the WM_IDLEUPDATECMDUI message on to the dialog's control
  2427.    bars. 
  2428.  
  2429.  
  2430.    To make room for a control bar within the client area of the dialog,
  2431.    follow these steps in your dialog's OnInitDialog() function: 
  2432.    1. Create the control bars.
  2433.    2. Figure out how much room the control bars will take by using the
  2434.       reposQuery option of RepositionBars(): 
  2435.  
  2436.       CRect rcClientStart;
  2437.       CRect rcClientNow;
  2438.       GetClientRect(rcClientStart);
  2439.       RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,
  2440.                      0, reposQuery, rcClientNow);
  2441.  
  2442.    3. Move all the controls in your dialog to account for space used
  2443.       by control bars at the top or left of the client area. If your dialog
  2444.       contains a menu, you also need to account for the space used by the
  2445.       menu: 
  2446.  
  2447.       CPoint ptOffset(rcClientStart.left - rcClientNow.left,
  2448.       rcClientStart.top - rcClientNow.top);
  2449.       ptOffset.y += ::GetSystemMetrics(SM_CYMENU);
  2450.  
  2451.       CRect rcChild;
  2452.       CWnd* pwndChild = GetWindow(GW_CHILD);
  2453.       while (pwndChild) {
  2454.         pwndChild->GetWindowRect(rcChild);
  2455.         rcChild.OffsetRect(ptOffset);
  2456.         pwndChild->MoveWindow(rcChild, FALSE);
  2457.         pwndChild = pwndChild->GetNextWindow();
  2458.       }
  2459.  
  2460.    4. Increase the dialog window dimensions by the amount of space used
  2461.       by the control bars: 
  2462.  
  2463.       CRect rcWindow;
  2464.       GetWindowRect(rcWindow);
  2465.       rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
  2466.       rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
  2467.       MoveWindow(rcWindow, FALSE);
  2468.  
  2469.    5. Position the control bars using RepositionBars().
  2470.  
  2471.  
  2472.    To update the first pane of a status bar with menu item text, you
  2473.    must handle WM_MENUSELECT, WM_ENTERIDLE, and WM_SETMESSAGESTRING in
  2474.    your dialog class. You need to duplicate the functionality of the
  2475.    CFrameWnd handlers for these messages. See the CModelessMain class in
  2476.    the sample program for examples of these message handlers. 
  2477.  
  2478.    To allow ON_UPDATE_COMMAND_UI handlers to work for other status bar
  2479.    panes and for toolbar buttons, you must derive new control bar classes
  2480.    and implement a message handler for WM_IDLEUPDATECMDUI. This is
  2481.    necessary because the default control bar implementations of
  2482.    OnUpdateCmdUI() assume the parent window is a frame window. However,
  2483.    it doesn't do anything but pass the parent window pointer on to a
  2484.    function which only requires a CCmdTarget pointer. Therefore, you can
  2485.    temporarily tell OnUpdateCmdUI() that the parent window pointer you
  2486.    are giving it is a CFrameWnd pointer to meet the compiler
  2487.    requirements. Here's an example: 
  2488.  
  2489.      LRESULT CDlgToolBar::OnIdleUpdateCmdUI(WPARAM wParam,LPARAM lParam)
  2490.      {
  2491.       if (IsWindowVisible()) {
  2492.         CFrameWnd* pParent = (CFrameWnd*)GetParent();
  2493.         if (pParent)
  2494.            OnUpdateCmdUI(pParent, (BOOL)wParam);
  2495.       }
  2496.       return 0L;
  2497.      }
  2498.  
  2499.  
  2500.    To pass WM_IDLEUPDATECMDUI messages on to dialogs other than the
  2501.    main window, save dialog pointers in your frame window class and
  2502.    create a WM_IDLEUPDATECMDUI handler in that class. The handler should
  2503.    send the WM_IDLEUPDATECMDUI message on to the dialog child windows by
  2504.    using CWnd::SendMessageToDescendants(). Then perform default
  2505.    processing for the message within the frame window. 
  2506.    -MS FAQ 6/25/95
  2507.  
  2508. ...........................................................................
  2509.  
  2510. 6.3.6.  Why isn't my CDialog::PreCreateWindow getting called?
  2511. -------------------------------------------------------------
  2512.    PreCreateWindow does not get called when you create a dialog box.
  2513.    If you would like to init some data/controls for a dialog box you have
  2514.    to trap the OnInitDialog message and do you stuff there.
  2515.    PreCreateWindow is use to modify params for a window that you are
  2516.    creating.  
  2517.    -ewalker@tezcat.com, mfc-l, 7/12/95
  2518.  
  2519. ...........................................................................
  2520.  
  2521. 6.3.7.  How do I embed a common dialog in a property page?
  2522. -----------------------------------------------------------
  2523.    This question comes up frequently on the "MFC" forum of CompuServe
  2524.    and the simple answer - unfortunately - is that there is no way to do
  2525.    it :-( 
  2526.    -chris@chrism.demon.co.uk, programmer.win32, 7/12/95
  2527.  
  2528. ...........................................................................
  2529.  
  2530. 6.3.8.  Why can't I DDX/DDV to initialize my CDialog controls?
  2531. --------------------------------------------------------------
  2532.    You can't do anything with the dialog controls until your dialog is
  2533.    created - which doesn't happen until DoModal(). The standard way of
  2534.    overcoming the problems is to create member variables for the data,
  2535.    initialise them before calling DoModal and then transfer the values
  2536.    in OnInitDialog. Or perhaps in UpdateData(). Much like the
  2537.    ClassWizard member variables does it. 
  2538.  
  2539.    So have your dialog include a CStringList or CStringArray, put the
  2540.    values  for the listbox in that and transfer them to the listbox in
  2541.    OnInitDialog. [etc...] 
  2542.    -null@diku.dk, programmer.controls, 7/11/95
  2543.  
  2544.    Init your dialog in OnInitDialog. If neccessary pass a pointer to
  2545.    your document to the constructor of your dialog (and save it in a
  2546.    private/protected m_pDoc member). 
  2547.    -jhasling@gascad.co.at, programmer.controls, 7/11/95
  2548.  
  2549. ...........................................................................
  2550.  
  2551. 6.3.9.  How do I change the captions of a CPropertyPage?
  2552. --------------------------------------------------------
  2553.  
  2554.    You can change the label before adding the page to the property sheet
  2555.    in the following way.
  2556.  
  2557.    You have to derive a class from CPropertyPage and add a public function
  2558.    SetCaption which sets the caption.
  2559.  
  2560.    void CPage1::SetCaption(char *str)
  2561.    {
  2562.         m_strCaption = str; // m_strCaption is protected member of
  2563.                             //CPropertyPage
  2564.    }
  2565.  
  2566.    Now you can us the SetCaption() function in the following way.
  2567.  
  2568.  
  2569.    CMySheet my("My PropSheet");
  2570.    CPage1 p1;
  2571.    p1.SetCaption(str); // Setting the caption
  2572.    my.AddPage(&p1);
  2573.  
  2574.    CAnotherSheet newps("New Sheet");
  2575.    CPage1 p2;
  2576.    p2.SetCaption(newstr);
  2577.    newps.AddPage(&p2);
  2578.    my.DoModal();
  2579.   -Ramesh,  NetQuest., MSMFC 8/3/95
  2580.  
  2581. ...........................................................................
  2582.  
  2583. 6.3.10.  How do I trap F1 in my dialog?
  2584. ---------------------------------------
  2585.    The following Knowledge Base Article explains a way to trap the
  2586.    WM_KEYDOWN messages in the dialog box. 
  2587.  
  2588.    ID: Q117563,  TITLE: How to Trap WM_KEYDOWN Messages in a CDialog
  2589.  
  2590.    The next article explains how to provide context sensitive help in
  2591.    a dialog. It also points to sample code. 
  2592.  
  2593.    ID: Q110506, SAMPLE: Context Sensitive Help in a CDialog
  2594.  
  2595.    -Ramesh, NetQuest., MSMFC, 8/31/95
  2596.  
  2597. ---------------------------------------------------------------------------
  2598.  
  2599. 6.4. Control bars, status bars, toolbars, dialog bars.
  2600. =======================================================
  2601.  
  2602. 6.4.1.  How do I add a combobox to my toolbar?
  2603. ----------------------------------------------
  2604.    You can do this using the CToolBar::SetButtonInfo method.
  2605.    The MFC sample ctrlbars shows how to do this.  Basically you call
  2606.    SetButtonInfo with the resource ID of your combobox.  You might
  2607.    want to throw some separators in there too.
  2608.    -scot_wingo@msn.com, 6/1/95
  2609.  
  2610. ...........................................................................
  2611.  
  2612. 6.4.2.  How do I update the text of a pane in a status bar?
  2613. -----------------------------------------------------------
  2614.    By default, a CStatusBar pane is not enabled when the pane is
  2615.    created. To activate a pane, you must call the
  2616.    ON_UPDATE_COMMAND_UI() macro for each pane on the status bar and
  2617.    update the panes. Because panes do not send WM_COMMAND messages,
  2618.    you cannot use ClassWizard to activate panes; you must type the
  2619.    code manually. For example, suppose one pane has ID_INDICATOR_PAGE
  2620.    as its identifier and that it contains the current page number in a
  2621.    document. To make the ID_INDICATOR_PAGE pane display text, add the
  2622.    following to a header file (probably the MAINFRM.H file):
  2623.    
  2624.           afx_msg void OnUpdatePage(CCmdUI *pCmdUI);
  2625.           
  2626.    Add the following to the application message map:
  2627.  
  2628.           ON_UPDATE_COMMAND_UI(ID_INDICATOR_PAGE, OnUpdatePage)
  2629.  
  2630.    Add the following to a source code file (probably MAINFRM.CPP):
  2631.  
  2632.           void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
  2633.           {
  2634.              pCmdUI->Enable();
  2635.  
  2636.           }
  2637.           
  2638.    To display text in the panes, either call SetPaneText() or call
  2639.    CCmdUI::SetText() in the OnUpdate() function. For example, you
  2640.    might want to set up an integer variable m_nPage that contains the
  2641.    current page number. Then, the OnUpdatePage() function might read
  2642.    as follows: 
  2643.  
  2644.           void CMainFrame::OnUpdatePage(CCmdUI *pCmdUI)
  2645.           {
  2646.              pCmdUI->Enable();
  2647.              char szPage[16];
  2648.              wsprintf((LPSTR)szPage, "Page %d", m_nPage);
  2649.              pCmdUI->SetText((LPSTR)szPage);
  2650.  
  2651.           }
  2652.           
  2653.    This technique causes the page number to appear in the pane during
  2654.    idle processing in the same manner that the application updates
  2655.    other indicators. 
  2656.    - MSVC Knowledge Base 6/4/94
  2657.  
  2658. ...........................................................................
  2659.  
  2660. 6.4.3.  How do I make my CToolBar customizable at run-time?
  2661. -----------------------------------------------------------
  2662.    You might consider reading article "CToolBarCtrl :Handling
  2663.    Customization Notifications" in the Product Documentation of VC++
  2664.    2.1. 
  2665.  
  2666.    Here is the relevant extract :
  2667.    "A Windows toolbar common control has built-in customization
  2668.    features, including a system-defined customization dialog box, which
  2669.    allow the user to insert, delete, or rearrange toolbar buttons. The
  2670.    application determines whether the customization features are
  2671.    available and controls the extent to which the user can customize the
  2672.    toolbar. These customization features are available in the
  2673.    CToolBarCtrl class but not in the current CToolBar class.
  2674.  
  2675.    You can make these customization features available to the user by
  2676.    giving the toolbar the CCS_ADJUSTABLE style. The customization
  2677.    features allow the user to drag a button to a new position or to
  2678.    remove a button by dragging it off the toolbar. In addition, the user
  2679.    can double-click the toolbar to display the Customize Toolbar dialog
  2680.    box, which allows the user to add, delete, and rearrange toolbar
  2681.    buttons. The application can display the dialog box by using the
  2682.    Customize member function."
  2683.  
  2684.    - R.Rajendran (NetQuest), 76041.2245@compuserve.com,
  2685.      MSMFC Forum, May-9-95 
  2686.  
  2687.    If you want to make a standard MFC CToolbar customizable, you can
  2688.    download CUSBAR.ZIP from the MSMFC library on Compuserve.  This
  2689.    package implements CCustomTolbar, the run-time customizable toolbar
  2690.    and also provides the necessary user tools (customization dialog
  2691.    box including the code for a bitmapped listbox). Freeware.
  2692.    -Patrick Philippot, 8/3/95 via email on CSERVE
  2693.  
  2694. ...........................................................................
  2695.  
  2696. 6.4.4.  How do I turn off the toolbar or status bar?
  2697. ----------------------------------------------------
  2698.    You can turn the status bar off in any of your views (i.e. in the 
  2699.    OnViewStatusBar() method you describe above) with the following code:
  2700.  
  2701.    if( ((CMainFrame*)GetParent())->m_wndToolBar.IsWindowVisible() )
  2702.     GetParent()->SendMessage(WM_COMMAND, ID_VIEW_TOOLBAR, 0L);
  2703.    if( ((CMainFrame*)GetParent())->m_wndStatusBar.IsWindowVisible() )
  2704.     GetParent()->SendMessage(WM_COMMAND, ID_VIEW_STATUS_BAR, 0L);
  2705.  
  2706.    Use 1L instead of 0L for the SendMessage's lParam to turn the bars on.
  2707.    -JKBenjamin@aol.com via mfc-l, 5/16/95
  2708.  
  2709. ...........................................................................
  2710.  
  2711. 6.4.5.  How do I create a toolbar/statusbar in a dialog?
  2712. --------------------------------------------------------
  2713.   See section 6.3.5. of this FAQ
  2714.  
  2715. ---------------------------------------------------------------------------
  2716.  
  2717. 6.5. Menus
  2718. =======================================================
  2719.  
  2720. ---------------------------------------------------------------------------
  2721.  
  2722. 6.5.1.  How do I get a pointer to the menu bar in a MDI app?
  2723. ------------------------------------------------------------
  2724.    Q>I'm writing a MDI application and I have problems to get a pointer to the
  2725.      actual menu bar. The normal construction doesn't seem to work in MDI:
  2726.  
  2727.      CMenu *menu;
  2728.      menu = GetMenu()->GetSubMenu(0);
  2729.  
  2730.      How can I get a pointer to the menu bar to update the menu?
  2731.  
  2732.     A> AfxGetApp()->m_pMainWnd->GetMenu()->GetSubMenu(n)
  2733.     -mlinar@pollux.usc.edu, Mitch Mlinar, 6/8/95
  2734.  
  2735. ...........................................................................
  2736.  
  2737. 6.5.2.  How do I implement a right-mouse popup-menu?
  2738. ----------------------------------------------------
  2739.    //////////////////////////////////////////////////////////////////////
  2740.    // WM_RBUTTONDOWN handler.
  2741.    //
  2742.    // Trap this message and display the button properties popup menu.
  2743.    // The main frame receives the popup menu messages. This allows the
  2744.    // status bar to be updated with the help text.
  2745.    //
  2746.    /////////////////////////////////////////////////////////////////////// 
  2747.    void CAppButton::OnRButtonDown(UINT flags, CPoint point)
  2748.    {
  2749.     
  2750.       CMenu menu;
  2751.       CMenu *submenu;
  2752.          
  2753.       // load the menu
  2754.       menu.LoadMenu(IDR_LAUNCH); 
  2755.          
  2756.       // get the popup menu
  2757.       submenu = menu.GetSubMenu(0);
  2758.          
  2759.       // convert to screen coordinates
  2760.       ClientToScreen(&point);
  2761.                   
  2762.       // post the menu
  2763.       submenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,                  
  2764.                               point.x,
  2765.                               point.y,
  2766.                               AfxGetApp()->m_pMainWnd,NULL);
  2767.                   
  2768.    }
  2769.    -johnm@unipalm.co.uk, programmer.win32, 7/12/95
  2770.  
  2771. ...........................................................................
  2772.  
  2773. 6.5.3.  How do I dynamically change the mainframe menu?
  2774. -------------------------------------------------------
  2775.     CMenu newMenu;
  2776.     newMenu.LoadMenu (IDR_MENU1);
  2777.     AfxGetMainWnd()->SetMenu( &newMenu );
  2778.     AfxGetMainWnd()->DrawMenuBar();
  2779.     newMenu.Detach ();
  2780.     -Arun Rao, MSMFC, 6/27/95
  2781.  
  2782. ...........................................................................
  2783.  
  2784. 6.5.4.  How do I 'attach' a menu to a window's creation/destruction?
  2785. --------------------------------------------------------------------
  2786. {Note the original question talked about dialogs, but you can
  2787. interpolate this code to any kind of window that you want to have
  2788. change the menu.}
  2789.  
  2790.     One of the ways to do this is as follows -
  2791.  
  2792.     1. Declare a variable CMenu pNewMenu in one of the dialog class.
  2793.     2. Handle the WM_INITDIALOG and WM_CLOSE messages in the
  2794.        dialog class as follows.
  2795.     3. BOOL CMydlg::OnInitDialog()
  2796.        {
  2797.            CDialog::OnInitDialog();
  2798.  
  2799.            // Load the IDR_MYFRAME menu
  2800.            pNewMenu = new CMenu;
  2801.            pNewMenu->LoadMenu(IDR_MYFRAME);
  2802.            // Set the mainframe menu to mainframe.
  2803.            ((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
  2804.  
  2805.            return TRUE;
  2806.        }
  2807.      And
  2808.        void CMydlg::OnClose()
  2809.        {
  2810.            // Detach the previous HMenu handle from the object.
  2811.            pNewMenu->Detach();
  2812.            pNewMenu->LoadMenu(IDR_MAINFRAME);
  2813.            // Restore the mainframe menu.
  2814.            ((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
  2815.            CDialog::OnClose();
  2816.        }
  2817.      4. If there are other methods of closing the dialog (example-
  2818.         By clicking a button in the Dialog), then The code given
  2819.         above in OnClose handler, must be put in the button click
  2820.         handler.
  2821.      -Sanjeev Kumar, MSMFC, 6/23/95
  2822.  
  2823. ---------------------------------------------------------------------------
  2824.  
  2825. 6.6.  Windows Common Controls (a.k.a. Windows 95 controls)
  2826. =======================================================
  2827.  
  2828. ---------------------------------------------------------------------------
  2829.  
  2830. 6.6.1.  Can I use these controls under NT or Win32s?
  2831. ------------------------------------------------------------
  2832.    Windows NT 3.50 does not support the common controls, and will not
  2833.    in the future.  You must use Windows NT version 3.51 to gain the
  2834.    common controls.
  2835.    -blaszczak@BIX.com, mfc-l, 7/6/95
  2836.  
  2837.    Version 1.30 of Win32s supports the Common controls.
  2838.  
  2839. 6.6.2.  Where's a demo of this wickedly cool controls?
  2840. ------------------------------------------------------
  2841.    Check out the MFC sample, fire, it features most of the controls in
  2842.    action:  MSVC20\samples\mfc\fire.
  2843.    -scot_wingo@msn.com, 7/27/95
  2844. ...........................................................................
  2845.  
  2846. 6.6.3.  How do you handle NM_DBLCLK for a CListCtl?
  2847. ---------------------------------------------------
  2848.    BEGIN_MESSAGE_MAP(CListView, CView)
  2849.    ON_NOTIFY( NM_DBLCLK,ID_LISTCTRL,OnDblClick )
  2850.    END_MESSAGE_MAP()
  2851.  
  2852.    void CListView::OnDblClick(NMHDR* /*k*/, LRESULT* /*j*/) 
  2853.    {
  2854.       int nItem, nFlags;
  2855.       char szTest[80];
  2856.  
  2857.       nFlags = LVNI_SELECTED;
  2858.       nItem = m_ListCtrl->GetNextItem(-1, nFlags );
  2859.       if ( nItem != -1 )
  2860.       {
  2861.            sprintf( szTest, "Selected Item %d", nItem);
  2862.            AfxMessageBox(szTest);
  2863.       }
  2864.     }
  2865.     -spolyak@interaccess.com, mfc-l, 7/21/95
  2866.  
  2867. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  2868.  
  2869. 7. Documents, Views and Frame Class Questions
  2870. =============================================
  2871.  
  2872. ---------------------------------------------------------------------------
  2873.  
  2874. 7.1.  Views
  2875. ===========
  2876.  
  2877. 7.1.1. How do I size a view?
  2878. ----------------------------
  2879.    Normally, you can change the size of a window by calling
  2880.    MoveWindow(). In an application developed with the Microsoft
  2881.    Foundation Class (MFC) Library, the view window is a child window of
  2882.    the frame window that surrounds the view. To change the size of the
  2883.    view window, retrieve a pointer to the frame window of the view by
  2884.    calling GetParentFrame(), then call MoveWindow() to change the size of
  2885.    the parent. When the parent frame window changes size, it
  2886.    automatically changes the size of the view window to fit in the parent
  2887.    frame.
  2888.    -MSVC Knowledge Base. 6/4/94
  2889.  
  2890. ...........................................................................
  2891.  
  2892. 7.1.2. How do I size a CFormView?
  2893. ---------------------------------
  2894.    See MS Knowledge Base article Q98598 for a very long answer.
  2895.    Basically, you need to override OnInitialUpdate() in a CFormView
  2896.    derived class.  There's other details to deriving from CFormView
  2897.    that the article goes into.
  2898.    -MSVC Knowledge Base. 6/7/95
  2899.  
  2900.    In the view ClikethisView declaration:
  2901.        virtual void OnInitialUpdate();       
  2902.  
  2903.    In the ClikethisView code:
  2904.  
  2905.    void ClikethisView::OnInitialUpdate()
  2906.    {  
  2907.       // make the window the size of the main dialog
  2908.       CFormView::OnInitialUpdate();
  2909.       GetParentFrame()->RecalcLayout();
  2910.       ResizeParentToFit( /*FALSE*/ );
  2911.    }
  2912.    -andyr@gate.net, programmer.misc, 8/11/95
  2913.  
  2914. ...........................................................................
  2915.  
  2916. 7.1.3. How do I use new views with a doc template?
  2917. --------------------------------------------------
  2918.    In an application created with AppWizard, you have two options:
  2919.    change the derivation of the current view, or create a new view
  2920.    and use the new view in your MDI application along with the
  2921.    original view.
  2922.  
  2923.    To create a new view, use ClassWizard to create a new class
  2924.    derived from CView. After the class has been created, the steps
  2925.    to use the new view or to modify the view provided by App
  2926.    Wizard are the same.
  2927.  
  2928.    1. Modify the header file for the view class to change all
  2929.       references to CView to the name of the desired view class.
  2930.       In this example, the class is derived from CScrollView.
  2931.       Usually, this step involves changing the class the view
  2932.       class is derived from as follows:
  2933.  
  2934.       class CMyView : public CScrollView
  2935.  
  2936.    2. Modify the implementation file for the view class to change
  2937.       all references to CView to the name of the desired view
  2938.       class. This involves changing the IMPLEMENT_DYNCREATE line
  2939.       as follows:
  2940.  
  2941.       IMPLEMENT_DYNCREATE(CMyView, CScrollView)
  2942.  
  2943.       changing the BEGIN_MESSAGE_MAP as follows:
  2944.  
  2945.       BEGIN_MESSAGE_MAP(CMyView, CScrollView)
  2946.  
  2947.       and changing any other references to CView to CScrollView.
  2948.  
  2949.    3. No further modifications are required if you are modifying a
  2950.       view created by App Wizard. If you create a new view, find
  2951.       the AddDocTemplate() call in the CWinApp::InitInstance()
  2952.       function. The third parameter to AddDocTemplate() is
  2953.       RUNTIME_CLASS(CSomeView). To replace the current view with
  2954.       the new view class, change CSomeView to CMyView. In an MDI
  2955.       application, you can use multiple view types by adding a
  2956.       second AddDocTemplate() call that changes
  2957.       RUNTIME_CLASS(CSomeView) to RUNTIME_CLASS(CMyView).
  2958.  
  2959.       For more information, please see Knowledge Base article Q99562.
  2960.       -MSVC Knowledge Base 6/7/95
  2961.  
  2962. ...........................................................................
  2963.  
  2964. 7.1.4. How do I change the background color of a view?
  2965. ------------------------------------------------------
  2966.    To change the background color for a CView, CFrameWnd, or CWnd
  2967.    object, process the WM_ERASEBKGND message. The following code shows how:
  2968.  
  2969.    BOOL CSampleView::OnEraseBkgnd(CDC* pDC)
  2970.    {
  2971.      // Set brush to desired background color
  2972.      CBrush backBrush(RGB(255, 128, 128));
  2973.  
  2974.      // Save old brush
  2975.      CBrush* pOldBrush = pDC->SelectObject(&backBrush);
  2976.  
  2977.      CRect rect;
  2978.      pDC->GetClipBox(&rect);     // Erase the area needed
  2979.  
  2980.      pDC->PatBlt(rect.left, rect.top, rect.Width(),
  2981.                  rect.Height(), PATCOPY);
  2982.      pDC->SelectObject(pOldBrush);
  2983.      return TRUE;
  2984.    }
  2985.  
  2986. ...........................................................................
  2987.  
  2988. 7.1.5. How do I get the current View?
  2989. -------------------------------------
  2990.    The best thing to do is to pass the view along as a parameter.
  2991.    If this is impractical, you can get the view if you KNOW, that it is
  2992.    the currently active document and the currently active view. For
  2993.    details, see Microsoft KB, article Q108587, "Get Current CDocument or
  2994.    CView from Anywhere". In brief, use 
  2995.  
  2996.    (CFrameWnd*)(AfxGetApp()->m_pMainWnd)->GetActiveDocument()
  2997.    and 
  2998.    (CFrameWnd*)(AfxGetApp()->m_pMainWnd)->GetActiveView()
  2999.  
  3000.    to get the document and the view. It might be a good idea to wrap them
  3001.    in static functions in your CMyDoc and CMyView and check that they are
  3002.    of the correct RUNTIME_CLASS.
  3003.  
  3004.    If the view isn't the currently active view or if you can run OLE
  3005.    in-place, this won't work however.
  3006.    -null@diku.dk, Niels Ull Jacobsen, programmer.misc, 6/8/95
  3007.  
  3008. ...........................................................................
  3009.  
  3010. 7.1.6.  How do I create multiple views on one document?
  3011. -------------------------------------------------------
  3012.    The CDocTemplate::CreateNewFrame() function creates additional
  3013.    views of a document in an MDI application written with MFC.
  3014.  
  3015.    To call this function, specify a pointer to a CDocument object (the
  3016.    document for which the function will create a view) and a pointer to a
  3017.    frame window that has the properties to duplicate. Typically, the
  3018.    second parameter of this function is NULL. 
  3019.  
  3020.    When an application calls CreateNewFrame(), the function creates a
  3021.    new frame window and a view in the frame window. The frame window type
  3022.    and view type depend on the document template (CDocTemplate)
  3023.    associated with the document specified in the CreateNewFrame() call. 
  3024.  
  3025.    The CHKBOOK MFC sample application that ships with Visual C++ also
  3026.    demonstrates creating additional frames and views for documents.
  3027.    Check out CHKBOOK.CPP, the CChkBookApp::OpenDocumentfile() function.
  3028.  
  3029.    Another example of using CreateNewFrame() is the MULTVIEW sample
  3030.    application. Also, Dale Rogerson's article, "Multiple Views for a
  3031.    Single Document" located on the Microsoft Developer Network
  3032.    Development Library CD-ROM, which explains in detail how to add
  3033.    additional views to an existing document, is an excellent source of
  3034.    information. 
  3035.  
  3036.    CreateNewFrame() creates both a frame and a view; not only a view.
  3037.    If, for some reason, CreateNewFrame() does not quite address your
  3038.    situation, the source code for CreateNewFrame() is quite useful to
  3039.    demonstrate the steps required to create frames and views. 
  3040.    -MS FAQ with mods, 6/25/95
  3041.  
  3042. ...........................................................................
  3043.  
  3044. 7.1.7.  How do I get all the views in an MDI app?
  3045. -------------------------------------------------
  3046.    You need to use some functions which are undocumented:
  3047.  
  3048.       CDocument::GetFirstViewPosition(); // DOCCORE.CPP
  3049.       CDocument::GetNextView(); // DOCCORE.CPP
  3050.       CMultiDocTemplate::GetFirstDocPosition(); // DOCMULTI.CPP
  3051.       CMultiDocTemplate::GetNextDoc(); // DOCMULTI.CPP
  3052.  
  3053.    You'll also need to mess with the m_templateList member of CWinApp. 
  3054.    -blaszczak@Bix.com, mfc-l, 7/11/95
  3055.  
  3056. ...........................................................................
  3057.  
  3058. 7.1.8.  How do I make a CScrollView "mouse scrollable"?
  3059. -------------------------------------------------------
  3060.    Download AUTOSV.LZH from the MSMFC library on CIS. This code shows
  3061.    you how to implement a secondary message loop taking care of the
  3062.    mouse activity. Hooks are provided to customize the code. Freeware. 
  3063.    -Patrick Philippot, CIS email, 8/3/95
  3064.  
  3065. ----------------------------------------------------------------------
  3066.  
  3067. 7.2.  Documents
  3068. ---------------
  3069.  
  3070. 7.2.1.  Do I have to use the Document/View architecture?
  3071. ----------------------------------------------------
  3072.    MFC does not force you to use document/views.  Check out hello,
  3073.    mdi, and helloapp samples, they don't use it at all.  Most MFC
  3074.    features can be used in non-document/view applications.  You do
  3075.    lose features like print preview and of many OLE features when you
  3076.    don't go document/view.
  3077.    -scot_wingo@msn.com 6/7/95
  3078.  
  3079. ...........................................................................
  3080.  
  3081. 7.2.2. How do I get the current Document?
  3082. -----------------------------------------
  3083.    See section 7.1.5. for the details.
  3084.  
  3085. ...........................................................................
  3086.  
  3087. 7.2.3.  When are documents destroyed?
  3088. -------------------------------------
  3089.    In SDI applications, the document is deleted when the application
  3090.    exits.  In MDI applications, the document is deleted when the last
  3091.    view on the document is closed.  To help keep your document SDI/MDI
  3092.    compatible, you should delete the document's data in the virtual
  3093.    DeleteContents() function, not in the destructor.
  3094.    -Richard Hazenberg, drmcode@euronet.nl, programmer.misc, 6/24/95
  3095.  
  3096. ...........................................................................
  3097.  
  3098. 7.2.4.  How do I create multiple documents?
  3099. -------------------------------------------
  3100.    To add support for additional document types, you can create and
  3101.    register additional CMultiDocTemplate objects with your CWinApp
  3102.    derived object. This technique is illustrated in the MULTDOCS sample
  3103.    application. The general steps needed to add an additional document
  3104.    type to an MFC application are listed below: 
  3105.  
  3106.    1. Use AppWizard to create a new document class and a new view class.
  3107.    2. Use the Resource Editor to add a new resource string to support
  3108.       the new document class. For more information on the format of the
  3109.       document template string resource, see the topic How to Interpret a
  3110.       Document Template String. 
  3111.    3. Use the Resource Editor to add an additional icon and menu
  3112.       resource to the application. Note, the ID for each of these resources
  3113.       needs to be the same ID as the resource ID used for the document
  3114.       template string created in step 2. This ID is used by the
  3115.       CMultiDocTemplate class to identify the resources associated with the
  3116.       additional document type. 
  3117.    4. In the applications InitInstance() function, create another
  3118.       CMultiDocTemplate object and register it with the
  3119.       CWinApp::AddDocTemplate() function. For example: 
  3120.  
  3121.       CMultiDocTemplate* pDocTemplate2 = new CMultiDocTemplate(
  3122.        IDR_DOC2TYPE, RUNTIME_CLASS(CDoc2),
  3123.        RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CView2));
  3124.       AddDocTemplate(pDocTemplate2);
  3125.  
  3126.    5. And finally, add the custom serialization and painting code to
  3127.       your new document and view classes. 
  3128.      -MS FAQ, 6/25/95
  3129.  
  3130. ...........................................................................
  3131.  
  3132. 7.2.5.  How do I get a list of open documents?
  3133. ----------------------------------------------
  3134.    The code below demonstrates how to retrieve a list of pointers to
  3135.    all CDocuments that were created using a CDocTemplate object. 
  3136.  
  3137.    In the code below, CMyApp is derived from CWinApp. The variable
  3138.    m_templateList is a CPtrList object that is a member of CWinApp, and
  3139.    it contains a list of pointers to all of the document templates
  3140.    (CDocTemplates). The CDocTemplate functions GetFirstDocPosition() and
  3141.    GetNextDoc() are used to iterate through the list of documents for
  3142.    each document template. 
  3143.  
  3144.    Sample Code
  3145.  
  3146.    void CMyApp::GetDocumentList(CObList * pDocList)
  3147.    {
  3148.       ASSERT(pDocList->IsEmpty());
  3149.  
  3150.       POSITION pos = m_templateList.GetHeadPosition();
  3151.  
  3152.       while (pos){
  3153.          CDocTemplate* pTemplate = 
  3154.             (CDocTemplate*)m_templateList.GetNext(pos);
  3155.          POSITION pos2 = pTemplate->GetFirstDocPosition();
  3156.          while (pos2) {
  3157.             CDocument * pDocument;
  3158.             if ((pDocument=pTemplate->GetNextDoc(pos2)) != NULL)
  3159.                pDocList->AddHead(pDocument);
  3160.          }
  3161.      }
  3162.    }
  3163.  
  3164.    There are two public member functions of the CDocTemplate class that
  3165.    are not documented in the reference manual or the online help.
  3166.    However, these are public member functions defined in the CDocTemplate
  3167.    class and provide simple functionality for traversing the list of open
  3168.    documents. These functions operate as follows: 
  3169.  
  3170.    Function: virtual POSITION GetFirstDocPosition() const;
  3171.  
  3172.    Remarks:   Call this function to get the position of the first
  3173.               document in the list of open documents associated with
  3174.               the template.  
  3175.    Return Value:  A POSITION value that can be used for iteration with
  3176.                   the GetNextDoc member function. 
  3177.  
  3178.    Function: virtual CDocument* GetNextDoc(POSITION& rPosition) const;
  3179.      rPosition:  A reference to a POSITION value returned by a previous
  3180.                  call to the GetNextDoc or GetFirstDocPosition member
  3181.                  function. This value must not be NULL. 
  3182.  
  3183.    Remarks:   Call this function to iterate through all of the
  3184.               document template's open documents. The function
  3185.               returns the document identified by rPosition and then
  3186.               sets rPosition to the POSITION value of the next
  3187.               document in the list. If the retrieved document is the
  3188.               last in the list, then rPosition is set to NULL.  
  3189.  
  3190.    Return Value:  A pointer to the view identified by rPosition.
  3191.    -MS FAQ, 6/25/95
  3192.  
  3193. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3194.  
  3195. 8. OLE Class Questions
  3196. ======================
  3197.  
  3198. 8.1. Structured Storage/Compound Files
  3199. ======================================
  3200.  
  3201. 8.1.1.  When I upgraded, I could not read my files generated by
  3202.         the old version of MFC.  What do I do?
  3203. ---------------------------------------------------------------
  3204.    There may be an easier way, but here is how I did it:
  3205.  
  3206.    Use VERSIONABLE_SCHEMA and GetObjectSchema to identify the version.
  3207.    If old version, then it is stored in OLE 1.0 format.  To read this 
  3208.    format, first read a WORD and a CString (type and name info).  Next is 
  3209.    the OLE data itself (the hard part). Use the following steps:
  3210.  
  3211.    1) use StgCreateDocfile to create a temporary Compound File.
  3212.  
  3213.    2) use OleConvertOLESTREAMToIStorage to copy the data to the Compound 
  3214.       file, converting to OLE 2 format.
  3215.  
  3216.    3) call OleLoad using the IStorage to get an IUnknown pointer, then call 
  3217.       QueryInterface to set the COleClientItem::m_lpObject member, and set 
  3218.       m_nDrawAspect to DVASPECT_CONTENT.
  3219.  
  3220.     4) release the IUnknown pointer and the IStorage pointer
  3221.  
  3222.     5) The OleConvertOLESTREAMToIStorage code requires an OLESTREAM 
  3223.        implementation.  Copy the code from MSVC 1.0 MFC code.
  3224.  
  3225.     This actually works.  Theres some issues with messing with the schema 
  3226.     parameter, and I have not implemented writing OLE 1/MFC files.
  3227.  
  3228.     Code available on request.
  3229.     -ronjones@xnet.com, Ron Jones, via programmer.tools, 5/9/95
  3230.  
  3231. --------------------------------------------------------------------------
  3232. 8.2.  OLE Controls (previously called OCX's)
  3233. ============================================
  3234.  
  3235. 8.2.1.  What is an OLE control?
  3236. -------------------------------
  3237.     OLE controls are the 32-bit successor to 16-bit VBX controls.
  3238.     Instead of being stored in a plain DLL and having functional
  3239.     interfaces, OLE controls rely on OLE automation.  Hopefully this
  3240.     will make the interface more flexible and easier to use than VBXs.
  3241.     -scot_wingo@msn.com, 6/25/95
  3242.  
  3243. ...........................................................................
  3244.  
  3245. 8.2.2.  How do I write OLE controls?
  3246. ------------------------------------
  3247.     In VC++ 2.x, Microsoft released the CDK (OLE control developer
  3248.     kit), you use that kit and it's tools to write OLE controls.
  3249.     -scot_wingo@msn.com, 6/25/95
  3250.  
  3251. ...........................................................................
  3252.  
  3253. 8.2.3.  What versions of MFC support OLE control containment?
  3254. -------------------------------------------------------------
  3255.    To clarify the situation:
  3256.  
  3257.    VC++ 2.x can create OCX controls.
  3258.    VC++ 2.x does NOT yet have built-in "OCX container" support. That will
  3259.    be added in VC++ 4, due out this autumn. The only popular application
  3260.    I'm aware of which currently supports OCXs (albeit in only a limited
  3261.    way) is Access 2.
  3262.  
  3263.    The problem is that obviously the place you want OCX container support in
  3264.    MFC is in classes like "CDialog" and (possibly) "CWnd" or "CView". As I'm
  3265.    sure you know, OCX controls have to implement a LARGE number of OLE2
  3266.    interfaces, which makes the support code large.
  3267.  
  3268.    At present, OLE2 support in MFC happens in the "CCmdTarget" class, which
  3269.    is the base class from which ALL "application architecture" classes are
  3270.    derived. I guess the choice is to extend the OLE2 support in this class
  3271.    to include OCX support (which would make ALL apps using OLE2 a LOT larger),
  3272.    or to add OCX-specific support to certain specific classes such as
  3273.    CDialog. Either way, it's a major undertaking!
  3274.  
  3275.    -Chris Marriott, chris@chrism.demon.co.uk, programmer.tools, 6/24/95
  3276.  
  3277. TODO: Find out more about OLE control limitations/support in 4.0
  3278.  
  3279. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3280.  
  3281. 9. WOSA Class Questions
  3282. =======================
  3283.  
  3284. 9.1. CRecordSet
  3285. ---------------
  3286.  
  3287. 9.1.1.  When I add a CRecordSet class, I get tons of linker errors..
  3288. --------------------------------------------------------------------
  3289.   
  3290.    If you haven't told the AppWizard to use Database Support when you
  3291.    created your project, the AppWizard doesn't include the database
  3292.    headers.  If you add "#include <afxdb.h>" in your stdafx.h,
  3293.    CRecordSet will be "legalized".
  3294.    Then open the Linker Options window and add the library: "odbc".
  3295.    This avoids tons of linker errors.
  3296.    -bessler@highland.swb.de (Wolfgang Bessler) 06/05/95, comp.lang.c++
  3297.  
  3298. --------------------------------------------------------------------------
  3299.  
  3300. 9.2.  WinSock
  3301. =============
  3302.  
  3303. 9.2.1.  I'm having problems with CSocket blocking, what's up?
  3304. -------------------------------------------------------------
  3305.    I've worked around this by creating a dialog box that I pop up after
  3306.    calling Connect()... ie:
  3307.  
  3308.          CMySocket MySocket;
  3309.          MySocket.Create();
  3310.          MySocket.Connect("mysmtphost",25);
  3311.          CDummyDlg DummyDialog;
  3312.          MySocket.m_pDialog=&DummyDialog;
  3313.          DummyDialog.DoModal();
  3314.  
  3315.     This suspends the thread until MySocket sends a WM_CLOSE message to
  3316.     DummyDialog.
  3317.  
  3318.     I'd rather it look like:
  3319.  
  3320.          MySocket.m_hEvent=CreateEvent(...);
  3321.          WaitForSingleObject(MySocket.m_hEvent,INFINITE);
  3322.  
  3323.     But that stops all processing of MySocket.
  3324.  
  3325.     -Cynthia Jennings (idlewild@is.net), programmer.win32, 6/19/95
  3326.  
  3327.     TODO: Find better answer.
  3328.  
  3329. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3330.  
  3331. 10. DLL and Build Questions
  3332. ===========================
  3333.  
  3334.    If you have questions about extension and user DLLs, be sure to read
  3335.    technical notes 11 and 33.  Volume 2 of the documentation has more
  3336.    info too.  Finally, try searching on the sample names dllhusk
  3337.    (extension DLL) and dlltrace (user DLL) in books on-line.
  3338.  
  3339. --------------------------------------------------------------------------
  3340.  
  3341. 10.1. Do I need a CWinApp object in a DLL?
  3342. ------------------------------------------
  3343.    The Microsoft Foundation Class Library supports two types of DLLs:
  3344.    _USRDLL and _AFXDLL. The _USRDLL model requires one CWinApp object
  3345.    to perform the initialization and cleanup of the Microsoft
  3346.    Foundation Class Library Windows classes that the DLL uses. This
  3347.    requirement is described in MFC Tech Note 11; the DLLTRACE sample
  3348.    demonstrates a _USRDLL that contains a CWinApp object.
  3349.    
  3350.    An _AFXDLL does not require a CWinApp object. Because it shares the
  3351.    Microsoft Foundation Class Library classes with the application, it
  3352.    does not require a CWinApp to provide initialization and cleanup.
  3353.    Instead, an _AFXDLL requires a special version of LibMain() and a
  3354.    DLL initialization function. 
  3355.    -MSVC Knowledge Base 6/4/95
  3356.  
  3357. ---------------------------------------------------------------------------
  3358.  
  3359. 10.2. How should I define the WEP in a MFC DLL?
  3360. ------------------------------------------------
  3361.    In a dynamic-link library (DLL) built with Microsoft Foundation
  3362.    Class Library version 2.0, the _USRDLL model uses the WEP()
  3363.    (Windows exit procedure) function provided in the C run-time
  3364.    library. Because the code uses the C library WEP() function,
  3365.    the destructors for static and global objects in the DLL are
  3366.    called and the CWinApp::ExitInstance() function for the DLL
  3367.    application object is called.
  3368.  
  3369.    See MSVC Knowledge Base article Q98374 and Tech notes 11 and 33.
  3370.    -MSVC Knowledge Base 6/7/95
  3371.  
  3372. ---------------------------------------------------------------------------
  3373.  
  3374. 10.3.  How do I build an 'extension DLL'?
  3375. ------------------------------------------------
  3376.  
  3377.    1.  When you're building a 32-bit extension DLL, define _AFXEXT on the
  3378.    compiler command line.  If you look in AFXVER_.H, you'll see that this forces
  3379.    _AFXDLL to also be defined.  So an "AFXEXT" DLL is an AFXDLL.
  3380.  
  3381.    2. When _AFXDLL is defined, AfxGetResourceHandle returns a value stored in
  3382.    MFC's global data, which is shared by the EXE, the extension DLL and the MFC
  3383.    DLL.  The handle returned identifies the module which will be searched first
  3384.    when looking for a resource.
  3385.    (See the source code for AfxFindResourceHandle() if you're curious about the
  3386.    order of the search.)
  3387.  
  3388.    3. Strictly speaking, what we need to load a resource is a module handle
  3389.    rather than an instance handle.  (Instances share modules --- e.g., code and
  3390.    resources --- but have different data.)  A DLL has a module handle which is
  3391.    distinct from the handle of the EXE.
  3392.  
  3393.    4. You can use ::GetModuleHandle to get the handle for your DLL, then pass it
  3394.    to AfxSetResourceHandle so that your DLL is the first place searched for
  3395.    resources.  But note that this removes the EXE module from of modules
  3396.    searched.  You'll probably want to save a copy of the handle returned by
  3397.    AfxGetResourceHandle before calling AfxSetResourceHandle, then restore it
  3398.    once you're done loading the DLL resource.
  3399.    -Charlie Kester, Microsoft Developer Support, MSMFC, 7/19/95
  3400.  
  3401. ---------------------------------------------------------------------------
  3402.  
  3403. 10.4.  How can I manage resources in a resource only DLL and still
  3404.        benefit from ClassWizard? 
  3405. ==================================================================
  3406.  
  3407.    The following text is available as RESDLL.ZIP in the MSMFC library
  3408.    on Compuserve (applies to MSVC20):
  3409.  
  3410.    How to manage an MFC project storing its resources into a resource-only DLL
  3411.    ***************************************************************************
  3412.  
  3413.    Software localization is much easier when your project stores its
  3414.    resources in a resource-only DLL. There area also many situations
  3415.    where storing the project's resources in a DLL can be a good idea.
  3416.  
  3417.    However, if this project is an MFC project, doing so will generate
  3418.    a major drawback: you will not benefit from the Class Wizard
  3419.    capabilities any longer because the resources will be managed in a
  3420.    separate project. 
  3421.  
  3422.    However, there's a trick that you can use to develop your project
  3423.    as if it were a standard project while being able to quickly switch
  3424.    to the resource-only DLL model. Here's how to proceed:
  3425.  
  3426.    METHOD 1
  3427.    ********
  3428.    1. Create your project as usual using AppWizard (we'll name it TEST).
  3429.  
  3430.    2. Close the project and create a new DLL project in the same
  3431.    directory (call it RESDLL). When you click on the Create button,
  3432.    VC++ opens the Add file dialog.  Take this opportunity to add the
  3433.    resource file of the previous project (TEST.RC) to this new project.
  3434.  
  3435.    3. Before being able to compile the resources of the TEST project
  3436.    as a resource-only DLL, you must add the /NOENTRY option to the
  3437.    linker. Unfortunately, the settings dialog box of VC++ doesn't
  3438.    allow to do that in a simple way: 
  3439.  
  3440.      3.1 Select Project|Settings from the man menu.
  3441.      3.2 Click on the Link tab.
  3442.      3.3 Select General from the category combobox.
  3443.      3.4 In the Object/Library Modules field, remove all references to
  3444.          any .LIB file (they are useless) and add /NOENTRY. This
  3445.          option should then appear in the Common Options display area.
  3446.      3.5 Click OK and compile. You now have a DLL containing only the
  3447.          resources for your project.
  3448.  
  3449.    4. Do not open the TEST.MAK project. Instead, copy TEST.MAK to
  3450.       TEST_RES.MAK in your project directory.
  3451.  
  3452.    5. Open TEST_RES.MAK and remove TEST.RC from the project files.
  3453.  
  3454.    6. Select Project|Settings, click on the General tab and add
  3455.       "USE_RESDLL" to the list of Preprocessor Definitions.
  3456.  
  3457.    7. Open TEST.H and modify the class declaration of CTestApp this way:
  3458.  
  3459.      public:
  3460.         CTestApp();
  3461.  
  3462.      #ifdef USE_RESDLL
  3463.      public:
  3464.         virtual int ExitInstance();
  3465.      private:
  3466.         HINSTANCE m_hInstDLL;
  3467.      #endif
  3468.  
  3469.    8. Open TEST.CPP and modify CTestApp::InitInstance as follows.
  3470.       Also, add the newly declared ExitInstance member function:
  3471.  
  3472.     BOOL CTestApp::InitInstance()
  3473.     {
  3474.         // Standard initialization
  3475.         // If you are not using these features and wish to reduce the size
  3476.         //  of your final executable, you should remove from the following
  3477.         //  the specific initialization routines you do not need.
  3478.  
  3479.     #ifdef USE_RESDLL
  3480.         if ((m_hInstDLL = LoadLibrary("resdll.dll")) == NULL)
  3481.         {
  3482.           return FALSE; // failed to load the localized resources
  3483.         }
  3484.         else
  3485.         {
  3486.           AfxSetResourceHandle(m_hInstDLL); // get resources from the DLL
  3487.         }
  3488.     #endif
  3489.     ...
  3490.  
  3491.     #ifdef USE_RESDLL
  3492.     int CTestApp::ExitInstance()
  3493.     {
  3494.         FreeLibrary(m_hInstDLL);
  3495.         return CWinApp::ExitInstance();
  3496.     }
  3497.     #endif
  3498.  
  3499.    9. Compile. TEST_RES.EXE should work very nicely, loading its
  3500.       resources from the DLL.
  3501.  
  3502.    10. Close the project and open TEST.MAK. Compile. TEST.EXE shoudl
  3503.        also work very well but this time, the resources are loaded from the
  3504.        .EXE file because you had not defined USE_RESDLL in this version of
  3505.        the project. 
  3506.  
  3507.     BEWARE: when switching from one model to another, you must either
  3508.     Rebuild All or touch TEST.CPP. Otherwise, you'll have problems.
  3509.  
  3510.     Now, you are able to modify your resources and to use Class Wizard
  3511.     when you work with TEST.MAK. To build the resource-only DLL
  3512.     version of the project, just switch to TEST_RES.MAK after
  3513.     recompiling RESDLL (RESDLL.MAK) if changes  have been made to the
  3514.     resources. 
  3515.  
  3516.     It's that easy!
  3517.  
  3518.     METHOD 2
  3519.     ********
  3520.  
  3521.     1. Proceeed like above for steps 1, 2 and 3
  3522.  
  3523.     2. Instead of creating a new project, copy TEST.RC to RESDLL.RC.
  3524.        Remove TEST.RC from your project and add RESDLL.RC. A different
  3525.        name is somewhat safer.
  3526.  
  3527.     3. Double-click RESDLL.RC to trigger a rebuild of the .CLW file.
  3528.  
  3529.     4. Apply the "Exclude File from Build" command to RESDLL.RC. 
  3530.        (Project|Settings, General Page, "Exclude File From Build")
  3531.  
  3532.     5. Delete TEST.CLW and TEST.RC.
  3533.  
  3534.     Now TEST and RESDLL will work together through the ClassWizard.
  3535.     The resources defined in RESDLL.RC will not be added to TEST.EXE.
  3536.  
  3537.     This method is simpler but doesn't allow you to test your program
  3538.     in both cases (resources in the DLL or resources linked to the .EXE
  3539.     file). I prefer the latter when developing because I do not have
  3540.     to bother about orphaned DLLs when a GPF occurs (although this is less
  3541.     a problem under NT). 
  3542.  
  3543.     Don't forget to recompile the DLL before testing your program each
  3544.     time you modify the resources. A batch file calling NMAKE
  3545.     installed in the Tools menu will certainly be faster than
  3546.     switching from project to project. Using the "New Target" facility
  3547.     won't help in that case. 
  3548.  
  3549.     It would be nice if VC++ had the same capability as Borland C++: a
  3550.     project can contain multiple independant targets. So, the
  3551.     developer is able to manage DLL and EXE creation from within the
  3552.     same project. 
  3553.     -Patick Philippot, CIS Email, 8/3/95
  3554.  
  3555. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  3556.  
  3557. 11. MFC Tips Tricks and Caveats
  3558. ===============================
  3559.  
  3560. 11.1. What's the best way to convert my C Windows App to MFC?
  3561. =============================================================
  3562.    Microsoft and Symantec have jointly developed a tool that helps you
  3563.    make the move from a C Windows application to MFC.  It's called the
  3564.    MFC migration kit.  You can find it on the MSVC 2.x CDROM in the MFCKIT
  3565.    directory.  The kit is also available from the Microsoft Software
  3566.    Library (See section 2.1.4) and from Symantec.
  3567.  
  3568. ---------------------------------------------------------------------------
  3569.  
  3570. 11.2. Why is my MFC application running slow?
  3571. =============================================
  3572.    MFC Apps should be nice and snappy.  Make sure you are not building
  3573.    the debug version and that you have the trace options off
  3574.    (MFCTRACE.EXE).  If your application continues to be slow, try
  3575.    doing some quick profiling to see if you are making any redundant
  3576.    calls.
  3577.    -scot_wingo@msn.com, 5/31/95
  3578.  
  3579. ---------------------------------------------------------------------------
  3580.  
  3581. 11.3. How can I create an application that is initially maximized?
  3582. ===================================================================
  3583.    For new applications, this can be done with AppWizard during Step
  3584.    4. During Step 4, choose Advanced..., and then select the Main
  3585.    Frame tab. Check the Maximized option. 
  3586.  
  3587.    For an MDI application, in the CWinApp::InitInstance() function,
  3588.    set CWinApp::m_nCmdShow to SW_SHOWMAXIMIZED before calling
  3589.    pMainFrame->ShowWindow(m_nCmdShow). In an application generated by
  3590.    AppWizard, the code is as follows:
  3591.    
  3592.           // create main MDI Frame window
  3593.           CMainFrame* pMainFrame = new CMainFrame;
  3594.           if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  3595.               return FALSE;
  3596.           m_nCmdShow = SW_SHOWMAXIMIZED;  // ADD THIS LINE!
  3597.           pMainFrame->ShowWindow(m_nCmdShow);
  3598.           pMainFrame->UpdateWindow();
  3599.  
  3600.           m_pMainWnd = pMainFrame;
  3601.           
  3602.    In an SDI application, in the CWinApp::InitInstance() function, set
  3603.    CWinApp::m_nCmdShow to SW_SHOWMAXIMIZED before calling OnFileNew().
  3604.    For example, in an application generated by AppWizard,  the code is
  3605.    as follows:
  3606.    
  3607.          m_nCmdShow = SW_SHOWMAXIMIZED;
  3608.          // create a new (empty) document
  3609.          OnFileNew();
  3610.    - MSVC Knowledge Base, 6/4/95
  3611.  
  3612. --------------------------------------------------------------------------
  3613.  
  3614. 11.4. How do I enable TRACE macros in my app?
  3615. =============================================
  3616.    If you use Visual C++ 1.0, run the TRACER application from your
  3617.    Microsoft Visual C++ program group (its icon has the title "MFC
  3618.    Trace Options"). Select "Enable Tracing," then choose OK.
  3619.  
  3620.    If you use Microsoft C/C++ 7.0, you must copy the AFX.INI file
  3621.    from the Microsoft Foundation Class Library source directory
  3622.    (by default, C:\C700\MFC\SRC) to your Windows directory (by
  3623.    default, C:\WINDOWS). This file should contain a section such
  3624.    as the following:
  3625.  
  3626.    [Diagnostics]
  3627.    TraceEnabled = 1
  3628.    TraceFlags = 0
  3629.  
  3630.    As long as TraceEnabled is set to 1, tracing is enabled.
  3631.  
  3632.    This AFX.INI file is the same for both C/C++ 7.0 and Visual C++ 1.0.
  3633.    In MSVC 2.x, the TRACE output automatically goes to the 'Debug'
  3634.    window when you run in the debugger.
  3635.    -VC+ Knowledge Base, 6/7/95
  3636.  
  3637. --------------------------------------------------------------------------
  3638.  
  3639. 11.5. How do I perform background processing in my application?
  3640. ===============================================================
  3641.    Many applications perform lengthy processing "in the
  3642.    background" during intervals that the user is not otherwise
  3643.    interacting with the application. In an application developed
  3644.    for the Microsoft Windows operating system, an application can
  3645.    perform background processing by splitting a lengthy process
  3646.    into many small fragments. After processing each fragment, the
  3647.    application yields execution control to Windows using a
  3648.    PeekMessage() loop.
  3649.  
  3650.    An application developed with the Microsoft Foundation Class
  3651.    Library can perform background processing either by using the
  3652.    PeekMessage() loop in the library code's main message loop or
  3653.    by embedding another PeekMessage() loop in the application.
  3654.  
  3655.    See MSVC Knowledge Base Q99999 for more info.
  3656.    -MSVC Knowledge Base 6/7/95.
  3657.  
  3658. --------------------------------------------------------------------------
  3659.  
  3660. 11.6. How do I send a message to another thread?
  3661. ================================================
  3662.    Try using SendNotifyMessage() to send messages to another thread.
  3663.    null@diku.dk, Neils Ull Jacobsen via programmer.misc, 6/18/95
  3664.  
  3665. --------------------------------------------------------------------------
  3666.  
  3667. 11.7.  Does Microsoft use MFC in their products? Which ones?
  3668. ============================================================
  3669.    There are many Microsoft apps written in MFC.  Sometimes its just
  3670.    not obvious... (to name a few: Bookshelf, Bob!, WordArt OLE server,
  3671.    Visual C++ (of course), Win95 paint, Win95 WordPad, some portions of
  3672.    Win95 FAX software, some Win95 games I know of...). 
  3673.  
  3674.    In the future, there are more apps coming out using MFC.  I don't
  3675.    have a way to track all of these uses, so there is certainly more that
  3676.    I'm not aware of or can't remember. 
  3677.  
  3678.    I don't expect Word or Excel to ever use MFC -- they have way too
  3679.    much legacy code and they don't see any customer benefit to rewriting
  3680.    to MFC. 
  3681.  
  3682.    But my point is -- definitely for new code, Microsoft is using MFC.
  3683.    Even some "old" code is taking advantage of MFC in future versions.
  3684.    -Dean McCrory, MSMFC, 6/8/95
  3685.  
  3686. --------------------------------------------------------------------------
  3687.  
  3688. 11.8.  How do I limit my MFC application to one instance?
  3689. =====================================================
  3690.    Look at the Microsoft sample ONETIME.EXE, (MSDN CD or
  3691.    ftp.microsoft.com). In brief:
  3692.  
  3693.    const char* MyMainWndClassName = "MyMainWndXQW"
  3694.  
  3695.    BOOL CMyApp::InitApplication()
  3696.    {
  3697.      //Call base class.  Default version does nothing.
  3698.      CWinApp::InitApplication();  
  3699.  
  3700.      WNDCLASS wndcls;
  3701.      memset(&wndcls, 0, sizeof(WNDCLASS));   // start with NULL defaults
  3702.  
  3703.      // Get class information for default window class.
  3704.      ::GetClassInfo(AfxGetInstanceHandle(),"AfxFrameOrView",&wndcls);
  3705.  
  3706.      // Substitute unique class name for new class
  3707.      wndcls.lpszClassName = MyMainWndClassName;
  3708.   
  3709.      //Register new class and return the result code
  3710.  
  3711.      return ::RegisterClass(&wndcls);
  3712.   }
  3713.  
  3714.   BOOL CMyApp::FirstInstance()
  3715.    {
  3716.      CWnd *PrevCWnd, *ChildCWnd;
  3717.   
  3718.      // Determine if another window with our class name exists...
  3719.      PrevCWnd = CWnd::FindWindow(MyMainWndClassName, NULL);
  3720.      if (PrevCWnd != NULL)
  3721.      {
  3722.        // if so, does it have any popups?
  3723.        ChildCWnd=PrevCWnd->GetLastActivePopup(); 
  3724.        // Bring the main window to the top
  3725.        PrevCWnd->BringWindowToTop();
  3726.     
  3727.        // If iconic, restore the main window
  3728.        if (PrevCWnd->IsIconic()) 
  3729.           PrevCWnd->ShowWindow(SW_RESTORE);
  3730.        // If there are popups, bring them along too!
  3731.        if (PrevCWnd != ChildCWnd) 
  3732.           ChildCWnd->BringWindowToTop();
  3733.        // Return FALSE.  This isn't the first instance
  3734.        // and we are done activating the previous one.
  3735.        return FALSE;
  3736.      }
  3737.      else
  3738.        // First instance. Proceed as normal.
  3739.        return TRUE;
  3740.    }
  3741.  
  3742.    CMyApp::InitInstance()
  3743.    {
  3744.        if (!FirstInstance()) return FALSE;
  3745.        ...
  3746.    }
  3747.    -Niels Ull Jacobsen (null@diku.dk), programmer.tools, 6/19/95
  3748.  
  3749.  
  3750.    See also MS Knowledge base article Q124134 ( "Allowing Only One
  3751.    Application Instance on Win32s") and Advanced Windows NT , chapter 7,
  3752.    "Prohibiting Multiple Instances of an Application from Running: The
  3753.    MultInst Sample Application" (available on the MSDN).
  3754.    -Niels Ull Jacobsen (null@diku.dk), email, 8/8/95
  3755.  
  3756. --------------------------------------------------------------------------
  3757.  
  3758. 11.9.  How do I get my MFC app to use the Registry on Win32 platforms?
  3759. ======================================================================
  3760.    Just make a call to SetRegistryKey("MyCompany") in your CWinApp
  3761.    class and pass it a string (typically your company name). This string
  3762.    will define where in the registry the data goes:
  3763.    HKEY_CURRENT_USER\Software\MyCompany\<application name>\<section
  3764.    name>\<value name> 
  3765.  
  3766.    After making this call just use the normal WriteProfilexxx()
  3767.    routines and the data will go to the registry instead of to an INI
  3768.    file.  It works well and is simple!
  3769.    -Brett Robichaud, brett_robichaud@tallysys.com, 6/23/95, programmer.win32
  3770.  
  3771. --------------------------------------------------------------------------
  3772.  
  3773. 11.10.  How do I programmatically terminate my MFC application?
  3774. ===============================================================
  3775.    MFC does not provide a public function to gracefully exit an application.
  3776.  
  3777.    A method for dealing with this is to create a function in your application like the following:
  3778.  
  3779.  
  3780.    void ExitApp()
  3781.    {
  3782.       // same as double-clicking on main window close box
  3783.       ASSERT(AfxGetApp()->m_pMainWnd != NULL);
  3784.       AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);
  3785.    }
  3786.  
  3787.  
  3788.    As you can see, this is implemented as a global function, which can
  3789.    be called from anywhere in your application. It simply sends a
  3790.    WM_CLOSE message to your application's mainframe window. This
  3791.    initiates an orderly shutdown of the application. 
  3792.  
  3793.    If you are using MFC, version 2.5 or later, you can take advantage
  3794.    of a new global MFC function, "AfxGetMainWnd", to simplify the code: 
  3795.  
  3796.    void ExitMFCApp()
  3797.    {
  3798.       // same as double-clicking on main window close box
  3799.       ASSERT(AfxGetMainWnd() != NULL);
  3800.       AfxGetMainWnd()->SendMessage(WM_CLOSE);
  3801.    }
  3802.  
  3803.  
  3804.    NOTE: Always call CDocument::SetModifiedFlag() after changing your
  3805.    document data. This will ensure that the framework prompts the user to
  3806.    save before shutdown. If you need more extensive control over the
  3807.    shutdown procedure, you can override CDocument::SaveModified(). 
  3808.    -MS FAQ, 6/25/95
  3809.  
  3810. --------------------------------------------------------------------------
  3811.  
  3812. 11.11.  What's the difference between IMPLEMENT_DYNAMIC,
  3813. IMPLEMENT_DYNCREATE and IMPLEMENT_SERIAL?
  3814. ===============================================================
  3815.    IMPLEMENT_DYNAMIC provides run time type information to support
  3816.    macros such as IsKindOf and GetRuntimeClass.
  3817.  
  3818.    IMPLEMENT_DYNCREATE adds the ability to allow MFC to create
  3819.    the type on the fly.  This is required for any concrete data
  3820.    type that will be serialized to a file.
  3821.  
  3822.    IMPLEMENT_SERIAL also provides a version number for the class
  3823.    and adds the ability to use the >> operator to read the
  3824.    type from a file.
  3825.  
  3826.    As an example, if a derived class Dog uses IMPLEMENT_DYNCREATE and a
  3827.    base class Animal uses IMPLEMENT_SERIAL, then a Dog can be written
  3828.    with a pointer to either but can only be read by a pointer to Animal. 
  3829.  
  3830.    MFC 3.x provides a constant called VERSIONABLE_SCHEMA to
  3831.    be used with IMPLEMENT_SERIAL to support multiple versions
  3832.    at the same time.  The implementation in MFC is broken and
  3833.    fails at runtime.
  3834.    -jimb@turningpoint.com, email, 7/11/95
  3835.  
  3836. --------------------------------------------------------------------------
  3837.  
  3838. 11.12.  How can I declare an abstract base class to be
  3839.         IMPLEMENT_SERIAL?
  3840. =======================================================
  3841.    You need a special form of IMPLEMENT_SERIAL that looks like this:
  3842.    Use the regular DECLARE_SERIAL but use IMPLEMENT_SERIAL_ABC shown
  3843.    below instead of IMPLEMENT_SERIAL.
  3844.  
  3845.    #define IMPLEMENT_SERIAL_ABC(class_name, base_class_name, wSchema) \
  3846.            _IMPLEMENT_RUNTIMECLASS(class_name, base_class_name, wSchema, \
  3847.            NULL) \
  3848.            CArchive& AFXAPI operator>>(CArchive& ar, class_name* &pOb) \
  3849.            { pOb = (class_name*) ar.ReadObject(RUNTIME_CLASS(class_name)); \
  3850.            return ar; }
  3851.    -anonymous
  3852.  
  3853.  
  3854. --------------------------------------------------------------------------
  3855.  
  3856. 11.13.  What is afx.inl and afxwin1.inl, etc..?
  3857. =======================================================
  3858.    These files live in the msvcXX\mfc\include directory and include
  3859.    inline functions.  These functions are only 'inline' during non-debug
  3860.    (_DEBUG is not defined) builts of MFC.  They are prefaced with a
  3861.    special _AFX_INLINE derective which gets turned into 'inline' for
  3862.    non-debug builds and '' for debug builds.
  3863.  
  3864.    MFC does this so you can debug into the functions in debug mode, but
  3865.    get the benefits of inlining during release builds.  That's one of the
  3866.    reasons the library shrinks so much in release build mode.
  3867.    -scot_wingo@msn.com, 7/20/95
  3868.  
  3869. --------------------------------------------------------------------------
  3870.  
  3871. 11.14.  Is MFC available on the Macintosh?
  3872. =======================================================
  3873.    Yes!  Microsoft has something called the Visual C++ cross-platform
  3874.    edition.  This product lets you cross-compile for the 68000 based Macs
  3875.    and I think they have a PowerPC version coming out soon.  Contact
  3876.    Microsoft directly for more info.
  3877.    -scot_wingo@msn.com, 7/27/95
  3878.  
  3879.    TODO: Comments on this anyone?
  3880.  
  3881. --------------------------------------------------------------------------
  3882.  
  3883. 11.15.  Is MFC available on OS/2? 
  3884. =======================================================
  3885.    No!
  3886.  
  3887. --------------------------------------------------------------------------
  3888.  
  3889. 11.16.  Is MFC available on UNIX/Motif?
  3890. =======================================================
  3891.    Yes, contact one of the following (or all):
  3892.  
  3893.    Bristol Technology Inc.
  3894.    (203) 438-6969
  3895.    Wind/U - Windows to UNIX toolkit
  3896.    info@bristol.com
  3897.    http://www.bristol.com
  3898.  
  3899.    Software Uno
  3900.    WM_MOTIF - Windows to UNIX (and DOS) toolkit
  3901.    jalvarez@uno.com
  3902.  
  3903. --------------------------------------------------------------------------
  3904.  
  3905. 11.17.  How should I learn/start learning MFC?
  3906. ==============================================
  3907.    I see this posted lots.  To start with, check out section 2.4.2 of
  3908.    this FAQ, books always help.  Another good point is that you can't
  3909.    really get down and dirty in MFC without knowing and understanding the
  3910.    underlying Windows API, so you might want to start with an overview
  3911.    of that. (The 'Petzold' book is the classic here)  At the very
  3912.    least get a feel of what windows does and what it's capable of.
  3913.  
  3914.    Another hint I have is don't rely too much on the Wizards, these
  3915.    are great, but they sometimes shield the newbie too much.  Take a
  3916.    look at what AppWizard/ClassWizard has done from you, run the debugger
  3917.    through a mainfrm.cpp, etc..  You won't understand what the heck is
  3918.    going on until you understand what your magically generated code is
  3919.    doing.
  3920.  
  3921.    I thought the 'writing windows apps with MFC' book was a good merge
  3922.    between Petzold and intro MFC stuff.  'Inside Visual C++' may move
  3923.    too fast for someone that doesn't know Windows already..
  3924.    -scot_wingo@msn.com, 7/27/95
  3925.  
  3926.    * There's no substitute for paying your dues.
  3927.    * Unfortunately MFC is set up so that you're never done paying your dues.
  3928.    (HAHAHAHA!!!)
  3929.    -raymond@btw.com, mfc-l, 7/23/95
  3930.  
  3931.    Start with the VC++ User's Guide and work your way through the
  3932.    Scribble Tutorial.  You get an intro to VC++ and MFC and see how they
  3933.    work together.  Then there are numerous articles on the MSDN CD to
  3934.    help with basic concepts.  Try searching on MFC and Architecture.
  3935.    Don't shy away from reading the MFC Encyclopedia articles (they take
  3936.    more of a 'how-to' approach) and by all means become familiar with the
  3937.    MFC Technical Notes.  Also (hint), stay focused on the 32-bit stuff if
  3938.    you're just starting out.  There are also a number of excellent
  3939.    journals out there to help.
  3940.    -billb@microsoft.com, mfc-l, 7/23/95
  3941.  
  3942.  
  3943.    The important points (of the top of my head) are:
  3944.  
  3945.    If you're a windows programmer don't worry about graphics the CDC
  3946.    member functions are an almost direct encapsulation of the Windows
  3947.    functions. Also CWnd encapsulates much of the window manipulation functions.
  3948.  
  3949.    Learn the Document-View architecture: document templates, the
  3950.    interaction between the application, the documents and views
  3951.    (AfxGetApp, GetDocument, UpdateAllViews etc).
  3952.  
  3953.    Learn serialisation (scribble makes a good intro to it).
  3954.  
  3955.    DDX and DDV for dialog boxes: there is a good tech note on this.
  3956.  
  3957.    WM_COMMAND handlers, COMMAND_UI handlers (which allow you to
  3958.    enable/disable menu items as well as applying check mark and radio
  3959.    button marks on menu items, it also gives you one way to use status bars).
  3960.  
  3961.    During all this you'll also learn how to use ClassWizard and see
  3962.    how it is integrated with the editor and resource editor.
  3963.  
  3964.    Perhaps as part of the MFC FAQ we could create a list of topics
  3965.    (ordered in terms of importance) to learn?
  3966.    {Sure, this is a good start, no? -Scot}
  3967.    -grimes@parallax.co.uk, mfc-l, 7/24/95
  3968.  
  3969. --------------------------------------------------------------------------
  3970.  
  3971. 11.18.  What DLLs should I distribute with my MFC app?
  3972. ======================================================
  3973.    You should review the file REDISTRB.WRI on your Visual C++ CD.
  3974.    This file explains what files are necessary for different kinds of
  3975.    applications; it explains what to do about both Windows files and MFC files.
  3976.    -blaszczak@BIX.com, programmer.tools, 7/9/95
  3977.  
  3978.    dumpbin /imports myapp.exe dll_one.dll dll_two.dll | grep -i dll
  3979.    And recurse through the dll's you find.   Won't find dll's loaded
  3980.    by LoadLibrary() however. 
  3981.    -null@diku.dk, programmer.tools, 7/10/95
  3982.  
  3983. --------------------------------------------------------------------------
  3984.  
  3985. 11.19.  How do I intercept WM_SETTEXT messages
  3986. ======================================================
  3987.    Because MFC didn't provide generic support for overriding WM_SETTEXT, you 
  3988.    can use OnMessage(WM_SETTEXT, OnSetText) in the message map and then 
  3989.    define your own method:
  3990.  
  3991.    LRESULT CMyClass::OnSetText(wParam, lParam);
  3992.    -jfriend@collabra.com, programmer.tools, 8/17/95
  3993.  
  3994. --------------------------------------------------------------------------
  3995.  
  3996. 11.20.  I can't create an instance because of DECLARE_DYNCREATE!
  3997. ================================================================
  3998.   Q> ClassWizard generated a class for me but used DECLARE_DYNCREATE(...) and declared my
  3999.      constructor as protected.  Now, when a try to create an instance of the class I get the 
  4000.      compiler error:
  4001.  
  4002.      error C2248: 'CChkTbl::~CChkTbl' : cannot access protected member
  4003.      declared in class 'CChkTbl' 
  4004.  
  4005.   A> ClassWizard does this because the framework normally handles
  4006.      instantiation for you.  i.e. if this is a CView derived class,
  4007.      normally the CDocumentTemplate instantiates the view during the
  4008.      default OnFileNew(), or when you call
  4009.      CxxxDocTemplate->OpenDocumentFile() or something similar. 
  4010.  
  4011.      The framework does this so that it will give you an error message
  4012.      if you accidentally try to instantiate it yourself.  If you
  4013.      really need to do instantiation outside of the CDocTempate
  4014.      framework, simply change the contructor to be public.
  4015.      -chucks@skypoint.com, programmer.tools, 8/12/95
  4016.  
  4017.   A> The answer is that the DECLARE_DYNCREATE macro lays down a "protected:"
  4018.      directive and leaves it in place.  One needs to make sure that anything
  4019.      following DECLARE_DYNCREATE should be "protected" too; if not, one needs
  4020.      to declare "public:" or "private:, as needed.
  4021.      -duane@anasazi.com, email, 8/15/95
  4022.  
  4023. --------------------------------------------------------------------------
  4024.  
  4025. 11.21.  What the heck is this _T() thing I keep seeing?
  4026. =======================================================
  4027.    _T is a macro to expand the string literal to support unicode.   
  4028.    -Mike Oliver, MSMFC, 8/1/95
  4029.  
  4030. --------------------------------------------------------------------------
  4031.  
  4032. 11.22.  How do I use CMemoryState?
  4033. =================================
  4034.  
  4035.    In MFC 2.0 and above  built in diagnostic facilities are provided.
  4036.    Hence it is not neceesary to include CMemoryState explicitly in your
  4037.    app. The MFC version 2.0 debugging libraries automatically perform
  4038.    memory leak detection. The detection code is in AFXMEM.CPP. This code
  4039.    detects the case in which an application dynamically allocates an
  4040.    object and fails to delete the object before the program terminates. 
  4041.  
  4042.    In fact,CMemoryState may not function properly.
  4043.  
  4044.    You can refer to the following article in KB(Go MDKB in CIS) for more details:
  4045.  
  4046.     ID:Q99022
  4047.     "Foundation Class Debug Library Detects Memory Leaks"
  4048.  
  4049.    <<Where is the best place to define DEBUG_NEW ? Is this done on a
  4050.    per-file basis ? In the header or the cpp file ?>> 
  4051.  
  4052.   #define  new DEBUG_NEW should be defined in  every .CPP source file.
  4053.    Also, insert the following code in InitInstance of the application:
  4054.  
  4055.     #ifdef _DEBUG
  4056.          afxMemDF |= checkAlwaysMemDF;
  4057.     #endif
  4058.  
  4059.    You can refer to the following article in KB for more details:
  4060.  
  4061.    ID: Q117326,  Foundation Classes Common Asserts, Causes and Solutions.
  4062.    -Muniraju, netquest, MSMFC, 8/1/95
  4063.  
  4064. ----------------------------------------------------------------------------
  4065.  
  4066. *11.23.  How do I handle my own registered messages?
  4067. ---------------------------------------------------
  4068.    [Note: In this FAQ, Dean is telling a guy how to handle
  4069.    WM_CHKTBLTOGGLE, which is some message that dude is trying to
  4070.    handle. The guy was doing it a wrong way before, I've left that in for
  4071.    educational reasons.]
  4072.  
  4073.    Use ON_MESSAGE:
  4074.  
  4075.    In your class definition:
  4076.    afx_msg LRESULT OnChkTblToggle(WPARAM wParam, LPARAM lParam);
  4077.  
  4078.    In your message map:
  4079.    ON_MESSAGE(WM_CHKTBLTOGGLE, OnChkTblToggle)
  4080.  
  4081.    In your code:
  4082.    LRESULT CMyView::OnChkTblToggle(WPARAM wParam, LPARAM lParam)
  4083.    {
  4084.          // TODO: write your code here
  4085.    }
  4086.  
  4087.    When you did:
  4088.  
  4089.    | #define ON_WM_CHKTBLTOGGLE() \
  4090.    |               { WM_CHKTBLTOGGLE, 0, AfxSig_vwp, \
  4091.    |               (AFX_PMSG)(AFX_PMSGW)(BOOL (AFX_MSG_CALL CWnd::*)(BYTE,
  4092.    | BYTE))OnChkTblToggle },
  4093.  
  4094.    You told MFC that your fuction is:
  4095.    void CMYView::OnChkTblToggle(UINT, CPoint)
  4096.  
  4097.    That's what the signature AfxSig_vwp means... and definitely not
  4098.    what you want. 
  4099.  
  4100.    ON_MESSAGE and ON_REGISTERED_MESSAGE are intended to allow you to
  4101.    extend the message handlers to your own custom message handlers.
  4102.    Please don't rely on specific AfxSig_* values or on the message map
  4103.    structure -- it may change without notice. 
  4104.  
  4105.    -Dean McCrory, mfc-l, 8/19/95
  4106.  
  4107. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4108.  
  4109. 12. Wizard Questions
  4110. ====================
  4111.  
  4112. 12.1.  How can I change the AppWizard options I selected for my application?
  4113. ----------------------------------------------------------------------------
  4114.    Unfortunately, AppWizard will not modify already created and
  4115.    modified applications.  You need to generate a new skeleton
  4116.    application using AppWizard and either merge your code into that or
  4117.    compare that skeleton with your original to see what's different.
  4118.    The good news is that it's mostly just a minor tweak to add/remove
  4119.    OLE support or MDI or something like that.  It usually is just
  4120.    changing your CWinApp derivate, your frame window, or something
  4121.    like that.
  4122.    - scot_wingo@msn.com, 5/31/95
  4123.  
  4124. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4125.  
  4126. 13. Visual C++ Questions
  4127. ========================
  4128. I'm trying to keep these as generic as possible, but these types of
  4129. questions tend to be very release-specific, so where possible, I've
  4130. included the version that's being questioned.
  4131.  
  4132. 13.1.  Windows 95 questions
  4133. ===========================
  4134.  
  4135. 13.1.1.  I'm running MSVC 2.0 and I can't get Windows 95 look and feel in
  4136.          my dialogs, what's wrong?
  4137. -------------------------------------------------------------------------
  4138.    In MSVC 2.0, go to the Project/Options dialog, select "Linker" and
  4139.    change the linker command line to include:  /subsystem:windows,4.0
  4140.    This is the default in MSVC 2.1.
  4141.    -Chris Marriott, chris@chrism.demon.co.uk, 5/25/95, via programmer.misc
  4142.  
  4143. ...........................................................................
  4144.   
  4145. 13.1.2.  When I compile under Windows 95, it flashes in and out of
  4146.          DOS mode.
  4147. ----------------------------------------------------------------   
  4148.    Remove or rename any dosprmpt.pif files in your win95 and windows
  4149.    directories.  If this doesn't work, do the same with all pif files.
  4150.    -scot_wingo@msn.com, 5/25/95
  4151.  
  4152.    In the Win95\system directory there is a pif for Conagent.  It is
  4153.    this pif file that a person has to change to Window screen mode
  4154.    instead of Full Screen mode.  Worked like a charm on mine after
  4155.    running about a month with the screen blanking...
  4156.    -RockyMoore@aol.com, email, 7/16/95
  4157.   
  4158. ...........................................................................
  4159.  
  4160. 13.1.3.  Can MSVC 1.5 or 2.0 be used for Windows 95?
  4161. ----------------------------------------------------------------   
  4162.    You can run both versions under Windows 95.  Visual C++ 1.5x can
  4163.    ONLY generate 16-bit applications.  You 'can' run these on Windows
  4164.    95, but it's more desirable to have true 32-bit applications,
  4165.    which MSVC 2.0 generates.  These same rules apply to NT.
  4166.    -scot_wingo@msn.com 6/5/95
  4167.  
  4168. ----------------------------------------------------------------------------
  4169.  
  4170. 13.2.  Configuration Questions
  4171. ==============================
  4172.  
  4173. 13.2.1.  What are the memory requirements of MSVC?
  4174. ------------------------------------------------
  4175.    MSVC 1.5.x will work on a 486 class machine with a minimum of 4MB
  4176.    of RAM. 8MB will make your life much better.
  4177.  
  4178.    MSVC 2.x needs at least 16MB.  Microsoft recommends 20MB on the box.
  4179.  
  4180.    Note: VC 1.5 takes a big (3x) performance hit under all operating
  4181.    systems if you have less than 16 Meg.  I published an article about
  4182.    this (and other performance enhancements) in Windows/DOS Developers
  4183.    Journal in May, 95. 
  4184.    -jimb@turningpoint.com, email, 7/11/95
  4185.  
  4186. ...........................................................................
  4187.  
  4188. 13.2.2.  How can I get MSVC 2.1, I can't find it in stores?
  4189. ---------------------------------------------------------
  4190.    The point releases are part of the MSVC subscription (See section
  4191.    2.1.1.).  Only major releases are sold through retail, so you'll
  4192.    need to buy a subscription to get the point releases.
  4193.    Subscriptions are available from Microsoft, Programmer's Paradise
  4194.    and Programmer's shop. (See section 2.1 for info)
  4195.  
  4196. ...........................................................................
  4197.  
  4198. 13.2.3.  Should I run under Win 95 or NT?
  4199. ----------------------------------------
  4200.    Life is a bunch of trade offs.  The trade offs here are if you run
  4201.    under 95, you won't need as much memory, but the OS is not as
  4202.    robust as NT, so you will probably crash more.  On the flip side,
  4203.    if you run under NT (a full 32-bit OS), you won't crash as much,
  4204.    but alas, you will need more memory.  Personally, I prefer the NT
  4205.    route.  NT catches all memory problems and handles them nicely for
  4206.    you without destabilizing the system.
  4207.    -scot_wingo@msn.com, 6/18/95
  4208.  
  4209. ...........................................................................
  4210.  
  4211. 13.2.4.  How do I set the include/lib/exe directories?
  4212. -----------------------------------------------------
  4213.    MSVC versions < 2.0 used environment variables INCLUDE/LIBDIR/EXEDIR.
  4214.    MSVC versions > 2.0 uses settings in the Visual C++ Tools menu.
  4215.  
  4216.    Select "Tools" and then "Options" menu item.
  4217.    A dialog opens, and select "Directories" tab button.
  4218.    There you can set Include directories, Library directories, Executable 
  4219.    directories...
  4220.    -lee@sam1.info.samsung.co.kr (Lee, Jin Woo), via programmer.win32, 6/10/95
  4221.  
  4222. ...........................................................................
  4223.  
  4224. 13.2.5.  I can't compile any programs!  Help!
  4225. ---------------------------------------------
  4226.    Q> I just installed VC1.51 on my system.  Installation proceeded smoothly
  4227.    without any errors. 
  4228.    However, I can't compile any programs!  Even when I try to compile the
  4229.    simplest and shortest programs, I get this error message:
  4230.    
  4231.     Can't open the compilation response file
  4232.  
  4233.    A> A common cause of this type of error is having a TMP or TEMP environment
  4234.       variable which isn't pointing at a valid directory. Eg your AUTOEXEC.BAT
  4235.       file says:
  4236.  
  4237.       set TMP=C:\TMP
  4238.  
  4239.       and you don't have a "C:\TMP" directory.
  4240.       -Chris Marriott, chris@chrism.demon.co.uk, programmer.misc, 6/18/95
  4241.  
  4242. ...........................................................................
  4243.  
  4244. 13.2.6.  Can I setup a project to search different paths for source?
  4245. --------------------------------------------------------------------
  4246.    I would like to have my projects first search for the source in a
  4247.    local directory, and if it can't find it there, search a network
  4248.    drive.
  4249.  
  4250.    TODO: Find answer to this one, seems good.  Asked on tools 6/21 by
  4251.    Joe Kinsella, jkinsella@procd.com
  4252.  
  4253. ...........................................................................
  4254.  
  4255. 13.2.7.  How do I build a browser file for all of MFC?
  4256. ------------------------------------------------------
  4257.    It's nice to be able to browse the MFC classes and source code, the
  4258.    best way to do this is via some Microsoft supplied .BAT files for
  4259.    the Microsoft Software Library:  
  4260.  
  4261.    BLDBSC15.BAT - for VC++ 1.5
  4262.    BLDBSC20.BAT - for VC++ 2.0
  4263.    BLDBSC21.BAT - for VC++ 2.1
  4264.  
  4265.    Basically, you want invoke the compiler on every file with /Zs as
  4266.    the option, which means generate the .sbr file and no .obj.
  4267.    Next, you want to run bscmake.exe on the generated .sbr files to
  4268.    create your .bsc file.  The MFC makefile will complain about the
  4269.    .obj's being missing, but you can ignore that warning.  It will
  4270.    take significantly longer and more time to create both .sbrs and
  4271.    .objs.
  4272.    -scot_wingo@msn.com, 6/25/95
  4273.  
  4274.    It is worth noting that VC 2.1 has a prebuilt browser file that is
  4275.    on the CD-ROM  but is not installed.  It can be loaded at any time
  4276.    into the IDE with the File/Open command.
  4277.    -jimb@turningpoint.com, email, 7/11/95
  4278.  
  4279.    If you are using the 32-bit versions, you can get more information in
  4280.    the README.TXT file in the \msvc20\mfc\src directory.  What is tells
  4281.    you is to move to that directory and from the dos prompt run:
  4282.  
  4283.          nmake DEBUG=1 BROWSEONLY=1
  4284.  
  4285.    -billb@microsoft.com, mfc-l, 7/17/95
  4286.  
  4287. ---------------------------------------------------------------------------
  4288.  
  4289. 13.3.  Language feature questions
  4290. =================================
  4291.  
  4292. 13.3.1.  Does MSVC support templates and exception handling?
  4293. ---------------------------------------------------------
  4294.    The 32-bit Visual C++ 2.0 release introduced templates and
  4295.    exception handling.  There is no support for these C++ features in
  4296.    16-bit versions of the product. 
  4297.  
  4298.    It is worth noting that the 16 bit implementation of THROW and
  4299.    CATCH are brain-damaged.  They do not clean up the stack as it
  4300.    unwinds.  
  4301.    -jimb@turningpoint.com, email, 7/11/95
  4302.  
  4303. ...........................................................................
  4304.  
  4305. 13.3.2.  Does MSVC support the Standard Template Library?
  4306. --------------------------------------------------------
  4307.    You can not compile the HP freeware version of STL with MSVC 2.x.
  4308.    There are some problems with templates that keep this from working.
  4309.    However, several commercial versions of STL are available that work
  4310.    with Visual C++ 2.x.  
  4311.   -scot_wingo@msn.com, 6/7/95
  4312.  
  4313. ...........................................................................
  4314.  
  4315. 13.3.3.  Does MSVC support RTTI?
  4316. ------------------------------
  4317.    Currently none of the MSVC releases support RTTI (C++ Run Time Type
  4318.    Information).  However, all classes derived from CObject support
  4319.    CRuntime which does basically the same thing using some clever macros.
  4320.    -scot_wingo@msn.com, 6/7/95
  4321.  
  4322. ---------------------------------------------------------------------------
  4323.  
  4324. 13.4.  Religious questions
  4325. ==========================
  4326.  
  4327. 13.4.1.  Which is better OWL or MFC, BC++ or MS MSVC?
  4328. ---------------------------------------------------
  4329.    This is constantly getting asked on Usenet.  The answer really
  4330.    depends on what you are doing.  If you demand the latest C++
  4331.    features such as templates, RTTI, etc.. BC++ usually has these
  4332.    first. But be careful, when Borland went from OWL 2 to 3 (or was it
  4333.    1 to 2?) they made everybody completely rewrite their applications.
  4334.    Applications that were written with MFC 1.0 still work with the
  4335.    newer versions of MFC today!
  4336.    The best advice is to get the features from each vendor and see
  4337.    what's best for your situation.
  4338.    -scot_wingo@msn.com 6/8/95, comp.lang.c++ 
  4339.  
  4340. ...........................................................................
  4341.  
  4342. 13.4.2.  Should I use Visual C++ or Visual Basic?
  4343. -------------------------------------------------
  4344.    (Here's a funny analogy I saw posted->)
  4345.    Well, the principle is the same (create interface, add code to respond
  4346.    to events, add code to do something useful).
  4347.    But programming in VB is like riding a kiddy bike, while programming
  4348.    in C++ is like driving a Formula 1 racing car - be prepared for accidents.
  4349.  
  4350.    But seriously, VB is interpreted, MSVC is compiled, therefore MSVC
  4351.    programs should be much faster (if written well).  It's generally
  4352.    believed that VB is the best way to 'prototype' a user-interface,
  4353.    but when it comes to code reuse and solving larger problems, VB
  4354.    breaks down.  Visual C++ on the other hand is not as easy to use as
  4355.    VB, but once you learn it, you can write much more complex programs
  4356.    than with VB.
  4357.  
  4358.    The readers digest version of all this is:  It depends on the application
  4359.    you are writing.
  4360.    -scot_wingo@msn.com, 6/18/95
  4361.  
  4362. ...........................................................................
  4363.  
  4364. 13.4.3.  MFC philosophy (from a microsoftie!)
  4365. ---------------------------------------------
  4366.    Just a note about the classes provided in MFC... keep in mind that
  4367.    these classes are designed as "general-purpose" classes, not
  4368.    "all-purpose" classes. No one implementation can have performance
  4369.    characteristics that are ideal for *all* possible applications. It
  4370.    is up to you, the programmer, to evaluate a provided implementation
  4371.    and decide whether it is appropriate for the task at hand. If it is
  4372.    not, you have several alternatives: modify or subclass the provided
  4373.    implementation; find a more appropriate class from another source;
  4374.    or write one from scratch. 
  4375.    -elsbree@nwrain.com, mfc-l, 7/15/95
  4376.  
  4377. ---------------------------------------------------------------------------
  4378.  
  4379. 13.5. Advanced Visual C++ tips and tricks
  4380. =========================================
  4381.  
  4382. 13.5.1. How do I see the MSVC 'Easter Eggs'?!
  4383. --------------------------------------------
  4384.     FYI: Easter eggs are hidden screens that usually have
  4385.          secret initials, development team names, etc..
  4386.  
  4387.     1.  To see the spinning PLUS with the MSVC team members:
  4388.         In MSVC 2.0 or 2.1->
  4389.         A.  Bring up the about box: help/about
  4390.         B.  Press control-tab and double click in the middle of
  4391.             the box at the same time.
  4392.         NOTE: You must have the MSVC CD loaded for this to work, I think.
  4393.  
  4394.     2. If above does not work, try this->
  4395.        copy the MSVCCRD.DLL from the CD to msvc\bin
  4396.        CTRL+Double-click the picture in the dialog
  4397.        note: release the CTRL key at the same time as the second click.
  4398.        -ohallorj@pwc-tpc.ca, Jeff O'Halloran
  4399.  
  4400. ...........................................................................
  4401.  
  4402. 13.5.2. What are the command line options to MSVC?
  4403. --------------------------------------------------
  4404.    * MSVC /V - Runs the compiler in a dos box (version 1.5 only?)
  4405.      -mark@techop.demon.co.uk
  4406.  
  4407.    * MSVC /NOLOGO - Runs MSVC without the about box, saves second
  4408.      or 2.
  4409.  
  4410.    * MSVC /bppassc:yes - Enables a cool breakpoint counter in the
  4411.      'breakpoints' dialog (under the Debug menu).
  4412.      -jimb@turningpoint.com, email 7/11/95
  4413.  
  4414.    * MSVC -p <pid> - attatches VC++ to a process.
  4415. ...........................................................................
  4416.  
  4417. 13.5.3.  How to change the color of ClassWizard generated code!
  4418. ---------------------------------------------------------------
  4419.    The default color for text modified by the ClassWizard is black
  4420.    print on a white background. Visual C++ is aware of the code that the
  4421.    ClassWizard modifies and can highlight these changes for you using a
  4422.    different color. 
  4423.  
  4424.    Highlighting the text ClassWizard modifies makes the new
  4425.    modifications very obvious and easy to find. To do this, from the
  4426.    Tools menu, choose Options. Then select the Colors tab in the Options
  4427.    dialog box. From the Set Colors For listbox, select Wizard-Modified
  4428.    Code. Then define the colors for text and the background. 
  4429.  
  4430.    NOTE: Only applies to VC++ 2.x, but it's waaaay cool!
  4431.    -MS FAQ, 6/25/95
  4432.  
  4433. ...........................................................................
  4434.  
  4435. 13.5.4.  Ten cool things you can do in the VC++ editor!
  4436. -------------------------------------------------------
  4437.    10. CTRL+ALT+T shows your tab characters
  4438.    9.  SHIFT+ESC closes the active dockable window
  4439.    8.  CTRL+F3 finds the next occurrence of the current word
  4440.    7.  CTRL+M finds the matching bracket
  4441.    6.  CTRL+> and CTRL+< find the next/prev matching #ifdef/#else/#endif
  4442.    5.  CTRL+SHIFT+R starts/stops macro recording
  4443.    4.  CTRL+SHIFT+P plays recorded macro
  4444.    3.  Right-click #includes to open the header file
  4445.    2.  TAB/SHIFT+TAB indent or unindent selected lines
  4446.    1.  Hold ALT key down to select columns
  4447.    -Jeff Henshaw, borrowed of MFC PDC slide, 6/25/95
  4448.  
  4449.   NOTE: Not all of these work in VC++ 1.5x
  4450.  
  4451. ...........................................................................
  4452.  
  4453. 13.5.5.  How do I speed up VC++ compiles?
  4454. -----------------------------------------
  4455.    Use precompiled headers, turn off the browser
  4456.    (Options:Project:Compiler:Listing Files:Browser Information), increase
  4457.    and/or decrease the size of your disk cache, tinker with the INCLUDE
  4458.    and LIB environment variable directory orders. That's about it.
  4459.    -ebarb@iadfw.net, programmer.tools, 8/19/95
  4460.  
  4461. ...........................................................................
  4462.  
  4463. 13.5.6.  Make all MFC keywords a different color!
  4464. -------------------------------------------------
  4465.    Download the file USERTYPE.DAT from the FAQ Archive (See 2.2.6) and
  4466.    follow the directions in there.  Try it, you'll like it!
  4467.    -scot_wingo@msn.com, 8/31/95
  4468.  
  4469. ---------------------------------------------------------------------------
  4470.  
  4471. 13.6.  Miscellaneous Visual C++ questions
  4472. =========================================
  4473.  
  4474. 13.6.1.  What are all these files that MSVC is creating?!
  4475. --------------------------------------------------------
  4476.    Here's a table that explains the common extensions and what MSVC
  4477.    uses them for:
  4478.  
  4479.    Extension           Use                        Notes
  4480.    ------------------------------------------------------------------
  4481.    APS                 App Studio file
  4482.    BSC                 Browser file               SBR's combined into 1 BSC.
  4483.    CLW                 Class Wizard file          
  4484.    ILK                 Incremental linker file
  4485.    PCH                 Pre-compiled header file
  4486.    PDB                 Debugging info             /Z7 affects this
  4487.    RES                 RC 'object' file           Linked into EXE
  4488.    SBR                 Browser info for 1 file    Combined into BSC
  4489.    VCP                 Visual C++ state file
  4490.    
  4491.    TODO: Fill this table in more completely.
  4492.  
  4493. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4494.  
  4495. 14. STUMPERS
  4496. ============================
  4497.  
  4498. This month we have two stumpers:
  4499.  
  4500. ** STUMPER 1: qavec@westminster.ac.uk ()
  4501.  
  4502.    Dear STUMPERS,
  4503.  
  4504.    I have been trying to implement a simple bitmapped button
  4505.    control in a child window of my application. I have not been
  4506.    having much luck and I am becoming frustrated at the
  4507.    apparent simplicity of the task.
  4508.  
  4509.    I have searched though at least ten Visual C++ books and
  4510.    none of them give any helpful information. What I have
  4511.    coded below is an example of what the MFC class reference
  4512.    suggests, however all I can achieve is an empty child window.
  4513.  
  4514.    Normal buttons are no problem, even bitmapped buttons within
  4515.    a dialog box is easy, but in a window ?...?  
  4516.  
  4517.    Below shows an example of what the MFC suggests.
  4518.  
  4519.     int CChild::OnCreate(LPCREATESTRUCT lpCreateStruct)
  4520.     {
  4521.        if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
  4522.                return -1;
  4523.  
  4524.        // TODO: Add your specialized creation code here
  4525.  
  4526.        //initialising data member
  4527.        rect.left =0 ;
  4528.        rect.right = 30;
  4529.        rect.top= 0 ;
  4530.        rect.bottom=30;
  4531.  
  4532.        //declare instance variable
  4533.        CBitmapButton  m_btn;
  4534.  
  4535.        m_btn.Create("bit btn",WS_VISIBLE | BS_OWNERDRAW,
  4536.                                rect,this, IDB_OFFBMP);
  4537.        VERIFY(btn.LoadBitmaps("IDB_OFFBMP"));
  4538.  
  4539.        return 0;
  4540.      }  
  4541.  
  4542. ** STUMPER 2: sylvaind@janus.speedware.com (Sylvain Desjardins)
  4543.  
  4544.    Dear STUMPERS,
  4545.  
  4546.    How can I change the color of the mainframe area ( under the menu )
  4547.    or how can i draw a bitmap.  The one that a document take place
  4548.    when it shows...
  4549.  
  4550.  
  4551. ** Send your stumpers to scot_wingo@msn.com and get results!
  4552.  
  4553. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4554.  
  4555. 15. Third Party MFC Products
  4556. ============================
  4557.    This section lists products that make the MFC developer's life easy.
  4558.    No OCX/VBX type products are listed here, go check some catalog.
  4559.    Where possible, I've put a review by someone!
  4560.  
  4561.    * Stingray Software, Inc.
  4562.      StingSoft@aol.com
  4563.      http://www.unx.com/~stingray
  4564.      CSERVE: GO STINGRAY
  4565.      Company that develops and markets MFC extension class libraries. 
  4566.      Products are in beta right now, will be announcing more info soon.
  4567.  
  4568.  
  4569.  
  4570.    * Premia CodeWright Fusion
  4571.      (800) 547-9902
  4572.      (503) 641-6000
  4573.      Great add-in editor for MSVC, they have both 16 and 32-bit versions.
  4574.      TODO: Get a review, anyone?
  4575.  
  4576.    * Nu-Mega Bounds-Checker
  4577.      (800) 468-6342
  4578.      (603) 889-2386
  4579.      Lets you know if you've clobbered memory, has a special MFC feature
  4580.      so you can see class names and paths through message maps.
  4581.      TODO: Review?
  4582.  
  4583.    * Rogue Wave Tools.h++
  4584.      TODO: Contact info.
  4585.  
  4586.      * There's been a looong thread on the mfc-l about how hard this
  4587.        is to use with MFC, people are trying everything and it doesn't
  4588.        seem to help.  Evidently they use a totally different memory model,
  4589.        internationalization and persistence.
  4590.        -various, mfc-l 7/18/95 - 7/27/95
  4591.  
  4592. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4593.  
  4594. 16. MFC FAQ Revision History
  4595. ============================
  4596.  
  4597. * 1.0 Beta  5/25/95
  4598.   -Did heavy work on TOC, more info, history.  Not many FAQs yet.
  4599.   
  4600. * 1.0 Final Beta  6/2/95
  4601.   -Put in some FAQs I keep seeing. Integrated feedback from mfc-l posting.
  4602.   -Posted one last time to mfc-l for final feedback before FCS...
  4603.  
  4604. * 1.0 FCS! 6/8/95
  4605.   -Put in some FAQs from MSVC KB
  4606.   -Got lots of good feedback from mfc-l
  4607.   -Got some new FAQs from Usenet
  4608.   -Integrated news from MFC Conference, MSVC 4/2.2, etc..
  4609.   -Posted to Usenet and CompuServe for first time.
  4610.  
  4611. * 1.1 6/25/95
  4612.   - Lot's of new stuff from MFC PDC
  4613.   - Lot's of cserve and usenet FAQs too
  4614.   - redid VC++ section
  4615.   - Lots of good book reviews coming out.
  4616.   - Grabbed some stuff from new MS FAQ too.
  4617.  
  4618. * 1.2 7/30/95
  4619.   - Updated from 1.1
  4620.     * Lots of book reviews got emailed and added.
  4621.     * Windows common controls section added.
  4622.     * 11.x - probably needs new hierarchy soon.
  4623.   - Introducing "Instant-FAQ (TM)"
  4624.   - Added article section to complement book section
  4625.   - Updated VC++ 2.2 information.
  4626.  
  4627. * 1.3 8/30/95
  4628.   - Updated from 1.2
  4629.     *
  4630.     *
  4631.     *
  4632.   - Distribution for 1.2:
  4633.     o Instant-FAQ: 241
  4634.     o Web hits for Aug: 2966
  4635.     o ftp: ???
  4636.     o CIS: 684   
  4637.     o Total circ:  3500-4000
  4638.  
  4639.   
  4640. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  4641.  
  4642.                       =-=-=-=-THE END-=-=-=-=-=
  4643.