MFC advanced course in layman's language version. Notes Day 5

 

Usually have no access to the MFC code, this is the project dictates, the project involves hands MFC, feeling a bit mean, so looking at the video to learn b station, had not started operating, just fly, a general understanding of this flow of the code, now offer video link station b: MFC advanced course in layman's language version of the
following is the course notes:

[According to the wizard to create a single document, the "user interface features," Cancel "using traditional docked toolbar"]
[rewrite] [database]

A static split window:

 1) Custom two classes CUserTreeView (inherited CTreeView, user information is displayed), CMedicListView (inherited from the CListView, drug information display)
  A) class view, select the top-level folders -> right click -> Add Class - > the MFC -> ......
 2) made in the frame of frame-based processing, using split function class implements CSplitterWnd, .h the class definition object CSplitterWnd
 3) made in the frame-based frame processing, the rewriting OnCreateClient (), in which Internally, the shield default return value, to return human TURE
  A) split the window ((1 row 2): the CSplitterWnd :: CreateStatic
  B) creating a view: the CSplitterWnd CreateView ::
   1) CUserTreeView size: CSize (230,600)
   2 ) CMedicListView size: CSize (720,600)
 4) set the title, the document class OnNewDocument () in: CDocument :: SetTitle


Second, the list view (displaying drug information) initialization

 1) CListView class list control and simplifies the use of the CListCtrl, which itself contains a list of control
 2) CMedicListView .h file defines a CListCtrl class object pointer
 3) CMedicListView right click -> Properties -> rewrite -> OnInitialUpdate (), for initialization () in the OnInitialUpdate
  a) returns the control list associated with the view: the CListView :: GetListCtrl
  B) set list mode: the CWnd :: ModifyStyle (0, LVS_REPORT);
  C) provided a list of style: CListCtrl: : SetExtendedStyle
   pctrl-> SetExtendedStyle (pctrl-> GetExtendedStyle () | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
  D) is inserted into the header: the CListCtrl :: InsertColumn
  E) is inserted into the body content data based on the database
   1) in view, select the top-level folders -> Right-click -> Add class -> MFC -> MFC ODBC users -> data sources -> new -> ...-- -> select the desired name for the new class table ...... CMedicSet
   2 ) CMedicSet defined document class object, easy handling later
   3) acquires a document class object: the GetDocument CView ::
   . 4) without opening the recordset: CRecordset :: IsOpen, open the recordset: CRecordset :: open
   4) After inserting rows query data
    a) Query: the Requery the CRecordset ::
    B) focused on the number of records recorded: the CRecordset :: GetRecordCount
    C) must first insert a new item: the InsertItem the CListCtrl ::
    D) back to set subkey text: the CListCtrl :: SetItemText
      . 1) into a time format the format :: string the CTime
      the CTime pSet = time -> m_produceDate;
      CString STR = time.Format (_T ( "% Y-M-% D%"));
    E ) set record pointer moves backwards: CRecordset :: MoveNext
    

Third, the tree view (display user information) Initialization

1) CTreeView class facilitates the use of control and CTreeCtrl category tree, which itself contains a tree control
2) CuserTreeview .h file defines a pointer to an object of class CTreeCtrl
3) CUserTreeView class right click -> Properties -> rewrite -> OnInitialUpdate (), do the initial work () in OnInitialUpdate
 a) returns the tree controls associated with the view of: CTreeView :: GetTreeCtrl
   need to set style: m_treeCtrl.ModifyStyle (NULL, WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES | TVS_DISABLEDRAGDROP);
 b) create an image list
  1) .h create a chart listing objects CImageList
  2) create a list of images: the create CImageList ::
  3) to load the bitmap: CBitmap :: LoadBitmap
  4) image list additional icons: CImageList: : Add, black color mask the RGB (0,0,0)
 C) tree graphics state control list provided: CTreeCtrl :: SetImageList
 D) initialization data, the data taken from the database
  1) in view, select the top-level folders - -> Right click -> Add class -> MFC -> MFC ODBC user -> data source -> New -> ...... ->Select the desired name for the new class table ...... CUserSet
  2) definition of the object in the document class CUserSet, facilitate the processing of the back
  3) acquires a document class object: the GetDocument CView ::
  . 4) without opening the recordset: CRecordset :: IsOpen, open record set: the Open the CRecordset ::
  . 5) filtering query
   a ) filtration: the CRecordset :: m_strFilter
   B) query: the Requery the CRecordset ::
   C) recording the number of collectively recorded: the CRecordset :: GetRecordCount
   D) set record pointer moves backwards: the MoveNext the CRecordset ::
  . 6) the insertion node: CTreeCtrl :: InsertItem

Guess you like

Origin www.cnblogs.com/yeyeye123/p/11032307.html