Q: Is CFILE use buffer?
Tell me if CFILE uses a buffer to handle files?
A: CFILE does not use the I / O buffer routine of the run library. In this sense, CFILE does not use buffers.
However, it is possible that the operating system uses a buffer when processing a file. If you don't need a buffer, you can
The unique way to set up file_flag_no_buffering.cfile in this mode is CFILE :: attach ().
Q: DAO's password?
I created an MFC application using the database. Use the class template to generate CDaorecordSet to open
Database (not through ODBC), but how do I open a database with password protection?
A: Try the following code:
DaoDBEngine * pdbengine = AFXDAOGETENGETENGETENGESE ();
Assert (pdbengine! = Null);
Colevariant Varusername (strusername, vt_bst);
Colevariant Varpassword (strpassword, vt_bst);
DAO_CHECK (PDBENGINE-> PUT_DEFAULTUSER (V_BSTR (& VaruserName);
DAO_CHECK (PDBENGINE-> PUT_DEFAULTPASSWORD (V_BSTR (& Varpassword));
A2: You can use the cdaodatabase Open method to open:
MyDaodatabase-> Open ("c: /mydatabasefile.mdb", false, false, "; pwd = mypassword");
BTW: Don't forget the PWD = front;
Q: How do I know when clistbox scroll?
A: Every time you draw a list box, you have to reload an item, get DC color from the parent window by message WM_CTLCOLOR. Because
This time you can scroll by WM_CTLCOLOR to verify whether you scroll.
Hbrush cparentdlg :: onCTLCOLOR (CDC * PDC, CWND * PWND, UINT NCTLCOLOR)
// is the control _the_ list box we're intended in?
IF (nctlcolor == ctlcolor_listbox && pwnd-> getdlgctrlid () == IDC_LIST)
{
// if the top index change, The List Box Has Been Scrolled
INT ITOP = ((ClistBox *) PWND) -> gettopIndex ();
IF (ITOP! = m_itopold)
{
// Keeps Tracking of the top index change
m_itopold = ITOP;
// Process Scroling
...
}
}
Hbrush Hbr = CDIALOG :: ONCTLCOLOR (PDC, PWND, NCTLCOLOR);
Return Hbr;
Using this method can do not have to generate a inheritance class in order to achieve this function.
Q: How to deal with the inactivity of the viewport?
Is there any way to make ClistView a style similar to a WM_DIASBLED or a background color.
A: What you have to do is to process the WM_SETFOCUS message of ClistView, then call in TreeView
SetFOCUS, so ListView will never get focus.
AFX_MSG Void CmylistView :: OnsetFocus (CWND * PoldWnd);
{
// assuming m_pwndtreeView Points to the Valid TreeView // on The Left Side
m_pwndtreeview-> setfocus ();
}
A2: Overloads PretranslateMessage, then returns true when the message is WM_LBUTTONDOWN or WM_RBUTTONDOWN.