VC experience:
1: When the transformation between physical coordinates and logical coordinates (LPTODP AND DPTOLP) See VC insider P55 as long as it does not change the map mode (mm_text mm_loenglish, etc.) does not need this conversion.
2: According to the practice, we should use the C scope resolution (: :) while calling the Win32 function directly.
3: onpreparedc. OnDRAW will automatically call it, but other messaging functions, if you use the device environment of the view, you must manually call it.
4: Add the dialog control at runtime: Turn the constructor first, then call CREATE After calling the CREATE function of the control, call its showWindow function This control can be displayed on the window! ! !
5: Slide strip control and fine tune button control programming VC insider 117 ~ 119 114, pay attention to the STYLE dialog box in the fine-tuning control Select Auto Buddy and Set Buddy Integer
6: About setting mapping mode: You can pass PDC-> setmapmode (***) in the onpreparedc function; **, ***, ***); there is also the same role. By analyzing the EX10B, if you add a CDC member variable, if you set a map mode, the user's self-added CDC member variable also sets the mapping mode, see Void CEX10BVIEW :: OnInitialUpdate Before there is setscrollsize, the user's own m_pdcmemory-> setmapmode (); if the user's MapMode and View's MapMode is different, the user will override View? 7: How to add custom messages and how to use PostMessage. EX07A gives the answer. P129 (below, defining your own message) 130 131 133
8: How to prevent the image from being flicker when image dragging? The EX10B gives an answer. Simple point is to use the memory device environment instead of the VIEW original device environment as a parameter passed from ONPAINT to the onDRAW.
9: Use the BeginWaitcursor and the Endwaitcursor identifies the mouse state. P201
10: How is the progress bar achieved? And see a multi-thread programming, actually only use Timer EX11A P210
11: How does the auxiliary thread and a main thread call? EX11B, generate global thread processing functions and custom message processing functions are used to exit.
12: Use the CEVENT class to synchronize the process. EX11C. Note #include
13: Blocking area
14: How to make a tab type property page. P240 Improved EX12A program.
15: The message transfer mode of the Apply button of the property page, according to EX12A. CPAGE1 only overloads CPROPERTYPAGE: ONApply without having to generate a function of what respond to WM_OnApply messages with ClassWizard (actually there is no message). For the OK button, "Determine" button, there is no need to program itself, and the MFC has done everything. Press OK and Press Apply to cause call onapply (), different is the determination button simultaneously causes the shutdown dialog box! The Apply button is available, depending on whether SETMODIFIED (TRUE), in this case, SetModified (TRUE) is called in ONCOMMAND (TRUE) 16: A more important experience: About the value exchange between controls and variables, for those variables and controls that are linked with ClassWizard, DDX will do everything, don't worry, just call Updatedata (bool), pay attention to the meaning of parameters. True is the control to variable transmission, FALSE is a variable to the control. For the attribute page mentioned in 15, Updatedata is not called, as long as the app is "OK", DDX is automatically called.
17: CWND pointer and the mutual conversion of the control ID. Getdlgitem getdlgctrlid. P109
18: If you want to set the CAPTION of the static text control with setdlgitemtext (), then this static text control ID cannot be
19: Multiple commands map the same command to process the solution P256 on_command_ex default IDC_STATIC.
20: How to handle the status bar, see the EX13B, pay attention to the Indicators array of 267, except for the id_separator, the other three, the character string at the end of the name is the character displayed on the status bar.
21: Save the size and location of the window, use the CPERSIStentFrame class, EX14A
22: How to associate the buttons and menu items on the toolbar? (Ie the menu and menu items have the same function). As long as this button is set to the same, the ID value of the menu item is set to the same.
23: About the Toolbar button and menu item of the menu item: For example, Draw A CIRCLE CIRCLE, "" The previous is the prompt of the menu item, and then the tip of the toolbar button.
24: How to change the CAPTION of the main window, add m_pmainwnd-> setWindowText in the initInstance () in cxxapp;
25: declare_dynamic (class name) IMPLEMENT_DYNAMIC () guarantees that the class name can be obtained during the diagnostic information dump.
26: Sequenified classes must be derived from COBJECT directly or indirectly, and must include Declare_Serial Implement_Serial in class declarations.
27: Any document class generated by AppWizard contains declare_dyncreate implemen ....
28: Chapter 14, call SetRegistryKey in the InitInstance function, use registration data.
29: Use the registry to associate files and programs. P355 top
30: Open a new document by default when the multi-document program starts. AppWizard will automatically join if (! ProcessShellCommand (cmdinfo)) // will call onfilenew return false; if you don't want to open a new document when starting, add IF before this code (cmdinfo.m_nshellcommand == ccommandlineinfo: : FileNew) {cmdInfo.m_nShellCommand = CCommandLineInfo :: FileNothing;} 31: CListCtrl usage http://www.codeproject.com/listctrl/listctrldemo.asp?target=clistctrl attention, LVITEM the iItem and iSubitem. The previous representative line, the column of the latter representation. How to get the currently selected row, use the member function getFirstSelectedItemposition.
32: How to make the window be gray, call this function getDlgitem (idc_button_start_proc) -> EnableWindow (FALSE); parameter is the control ID. In the MFC with CVIEW, the differences in the practice see Excellence EX17A. Void cstudentview :: onupdateCommanddel (ccmdui * pcmdui) {// caled during idle processing and when student menu Drops Down PCMDUI-> Enable (m_position! = Null);}
33: How to pop up the dialog box without AFXMessageBox ("You Info"). With Windows API's MessageBox LPText = Text ("Error: Unable to query the relevant registry information"); lpcaption = text ("port info"); MessageBox (NULL, LPTEXT, LPCAPTION, MB_OK);
34: How to convert an integer into a word character type char buffer [2]; ITOA (Urint, Buffer, 10);
35: CListCtrl, how to make the whole line becomes blue (select state) PMylistCtrl-> setExtendedStyle (PmylistCtrl-> getExtendedStyle () | lvs_ex_fullrowselect);
36: About the attribute page, addpage must be placed in the second constructor. CProSht_DcmConfig :: CProSht_DcmConfig (UINT nIDCaption, CWnd * pParentWnd, UINT iSelectPage): CPropertySheet (nIDCaption, pParentWnd, iSelectPage) {// AddPage (& m_CProPgDimSev); // if this is placed inside the constructor, DoModal when // AddPage (& m_CProPgDrctrs ); // will not react. }
CProSht_DcmConfig :: CProSht_DcmConfig (LPCTSTR pszCaption, CWnd * pParentWnd, UINT iSelectPage): CPropertySheet (pszCaption, pParentWnd, iSelectPage) {AddPage (& m_CProPgDimSev); AddPage (& m_CProPgDrctrs);} but also containing this CProperSheet class constructor initializes at the back This member, (with colon) Like this: cPROSHTDCMCFG ("assumes cPROSHTDCMCFG is a CPROPERSHEET data member) 37:" Apply "on the property page. If there is a different operation for each page, you have a different operation, then you will overload the onapply function of each page, even if setmodified (True) is not set (ie, if the Apply button is available), when the OK button is pressed The onapply () function of each page will still be called one by one. (Note ONAPPLY still want to call the base class onapply, the VC will automatically generate this code, don't delete)
38: How to turn off the warning message below this in stdafx.h
#pragma Warning (Disable: 4507 4244), the rear number is a warning code, which warning promises, add the warning code.
39: Functions related to catalog Makepath, Access, CreateDirectory (ex), MakesuredIRectoryPathexists
40: About the CRecordset class, if my class (inherited from CRecordset), only maps a table, then query, modification, insert, delete, but if multiple tables are mapped, then they can only query.
41: AFXBEGINTHREAD cannot be used with class member functions, http://www.china-askpro.com/msg42/QA64.SHTML
Workaround: Use a static member function as the first parameter of AFXBEGINTHREAD, you can use the THIS pointer as the second parameter, which is the parameter of the static member function, and then use the THIS pointer to use the member variable in the static member function. And functions.
Myclass {static uint threadproc (lpvoid pparam);} // in header file
Myclass :: threadproc (lpvoid pparam) // in the CPP file
{
((Myclass *) pParam) -> .....
}
AfxBeginthread (threadproc, (lpvoid) this); // When using AFXBEGINTHREAD
42: About how to do control, http://www.9cbs.net/develop/read_article.asp?id=18059 It is worth noting that how to make a message to the call object in the control, a fire ****, interesting .
43: Implement VC plugin with ATL
Http://www.yesky.com/softchannel/72342371928702976/20030813/1721237.shtml
44: How to get an object's Runtime Class, any object A that is inherited from COBject, can get the class name of this object via A.GetruntimeClass () -> m_lpszclassname: How to get a variety of objects in the program Pointer: Global Function AFXGetApp You can get a CWINAPP application class pointer AFXGetApp () -> m_pmainwnd is in the frame window pointer in the frame window: cfraMew :: getActiveDocument Get the current activity document pointer in the Frame window: cframeWnd :: getActiveView get the current activity Pinner In the view: CView :: getDocument Get the corresponding document pointer in the document: cdocument :: getFirstViewPosition, cdocument :: getNextView is used to traverse all and document associations. In the document: cdocument :: getDoCtemplate Get the Document Template Pointer in the Multi-Document Interface: cmdiframeWnd :: MDiGetAn Gets the current active MDI sub-window Generally speaking users enter messages (such as menus selection, mouse, keyboard, etc.) If it is not processed, it will be sent to the Framework window. So defining a message mapping is defined in the view, if an application has multiple views while the current activity does not process the message, the message will be sent to the frame window. C experience:
1: A usage of constructor, if you only need to return an object, you can use the constructor myclass (....) directly for this object, it is equivalent to * (new myclass (....)) See p306 void CEX15AVIEW :: OnUpdateEditclerall (ccmdui * pcmdui) {pcmdui-> enable (getDocument () -> m_student! = Cstudent ()); // Directly use the constructor to return an object}
2: Set class, if we want to save the mixed pointer with a collection, use the Coblist class, if we want a collection of security, it only contains a collection of type objects, then we should look at the template pointer of the MFC library. Collection class. CtypedPRTLIST is a good example. P331
3: Get random numbers using the RAND function. The random number returned by the RAND function is between 0-rand_max (32767). If you want to implement a function similar to 0-1, you can follow: Double Randf () {Return (Double) (Double) (Double) RAND_MAX;}
4: Question of the "=" operator If the objects A1 and A2 of the two class A, you can use A1 = A2 to assign a value without overloading. (Is the parent class or subclass of class A can be placed on the right?). If the object is not the object of class A, it is necessary to overload.
5: Initialization of static member variables in the class. If there is a static member variable SA in the MyClass class, you should initialize it like global variables, and its form is int myclass :: sa = 0;
/ **************** Path selection window ****************************** / VOID class name: onbrowse () {// TODO: Add your control notification handler code here // :: SHBrowseForFolder (); LPCITEMIDLIST itemId; BROWSEINFO bi; char folderName [MAX_PATH]; char selectedDir [MAX_PATH]; HWND pHwnd = :: FindWindow (NULL, "CustomCtrl" ); Bi.hwndowner = phwnd; bi.pidlroot = null; bi.pszdisplayName = foldername; bi.lpsztitle = "Please select the root directory"; bi.ulflags = 0; bi.lpfn = null; bi.lparam = 0 Bi.iimage = 0; itemid = :: shbrowseforfolder (itemid) {: shgetpathFromidList (itemid, selectedddir); m_path.format ("% s", selectedddir); // path in Selectddir Updatedata ( False);} / ******************************************************* *********** // *********************************************************************************** ***** / 1.project setting 1. To compile with Release / Debug Can't use CT Debug (Crypto itself) 2.Genernal page MFC settings Your Project and Cryptlib should be consistent, us, for not Using MFC / or other ... 3.c / c page Code Generation two projects to be consistent pre- PRE Compiled Headers is selected, and if you can't do it, try the following compilation: Compile-Batch Build (Alphakk teaches, VC, I am not familiar, there is a problem to find him or old demon, hoto ...) / * *********************************************************** ***************** /