2014年8月18日 星期一
Drag and Drop (OLE)
1. There is the MSDN document introduce it -- http://msdn.microsoft.com/en-us/library/96826a87.aspx
2. There is a document talk about how to implement it. -- http://www.codeproject.com/Articles/840/How-to-Implement-Drag-and-Drop-Between-Your-Progra
3. There is a document talk about CRicheditView with Drag & Drop -- http://computer-programming-forum.com/82-mfc/cad93aec74dd76a3.htm
CRichEditView supports OLE drag and drop. It has the interfaces that
determines the data it can accept. Therefore, WM_DROPFILES won't be
received unless it fails to perform the OLE drag & drop. You can override
CRichEditView::QueryAcceptData, which is the actual implementation of
IRichEditOleCallback::QueryAcceptData. In QueryAcceptData, return S_FALSE
directly. However, this disables the OLE drop/paste operation. You can also
handle CRichEditView::QueryAcceptData more elaborately so that specific
data can be handled in WM_DROPFILES. You may want to check
CRichEditView::QueryAcceptData in viewrich.cpp for more information.
2013年11月18日 星期一
CoInitializeSecurity call fails with error code RPC_E_TOO_LATE
In the VC++ MFC MDI, the CoInitializeSecurity call fails with error code RPC_E_TOO_LATE
1. We can check (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) for WMI troubleshooting.
2. There is the example code in the http://support.microsoft.com/kb/948829
3. The code here (http://www.codeproject.com/Articles/216077/Making-Your-Cplusplus-Code-Robust) can help us solve the WMI execquery problem.
4. Please check http://msdn.microsoft.com/en-us/library/windows/desktop/aa393609(v=vs.85).aspx. The key point is CoSetProxyBlanket function.
1. We can check (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) for WMI troubleshooting.
2. There is the example code in the http://support.microsoft.com/kb/948829
3. The code here (http://www.codeproject.com/Articles/216077/Making-Your-Cplusplus-Code-Robust) can help us solve the WMI execquery problem.
4. Please check http://msdn.microsoft.com/en-us/library/windows/desktop/aa393609(v=vs.85).aspx. The key point is CoSetProxyBlanket function.
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);
2013年11月13日 星期三
SetFont for CButton
About the SetFont of the CButton, there is a example in the http://support.microsoft.com/kb/85518/en-us.
It will be failed, if you put the CFont m_font in the OnInitDialog()
class CMyAboutBox : public CDialog { CFont m_font; public: // Constructor -- This code assumes a dialog box // template named "ABOUTDLG" in the application's .RC file. CMyAboutBox(CWnd* pParentWnd = NULL) : CModalDialog("ABOUTDLG", pParentWnd) {}; BOOL OnInitDialog(); };
It will be failed, if you put the CFont m_font in the OnInitDialog()
2013年7月31日 星期三
About the GRID control for the VS MFC
I don't understand why MS don't try to provide a MFC GRID control. We can try to make CListCtrl to be the Grid control style. You can refer the MSDN document here (http://msdn.microsoft.com/en-us/library/ms364048(v=vs.80).aspx), but it's not easy. Anyway, we can use the code (http://www.codeproject.com/Articles/8/MFC-Grid-control-2-27) in the codeproject to be the base and modify it.
2012年12月28日 星期五
How to create CMFCPropertySheet
1. First, "Project" -> "Class Wizard.."->"Add Class" --> Select "CPropertyPage". If you select "CMFCPropertyPage", it will get error, when you run it.
2.After class was created, we replace all "CPropertyPage" by "CMFCPropertyPage".
3. Add CMFCPropertySheet class. And add the code.
CMySheet.h
public:
CMySheet();
virtual ~CMySheet();
CMyPage m_page1;
CMySheet.cpp
CMySheet::CMySheet()
{
AddPage(&m_page1);
}
4.
//Cf9Dlg dlg;
CMySheet dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
-----------------------
1. The first step, we can check http://msdn.microsoft.com/en-us/library/bb981937.aspx about the MSDN CMFCCpropertySheet Class information (Remarks).
2. We can try to find the information in the http://support.microsoft.com/kb/325613/en-us to know how to add the CPropertySheet and CPropertyPage.
3. There is the http://blog.163.com/xu_chao2000/blog/static/277706102010430338431/ for the CMFCPropertySheet and CMFCPropertyPage. You will need to create new DIALOG resource to add "CPropertyPage" base class, because the Visual studio has the problem to use "CMFCPropertyPage" as the base class. After add OK, then change it to "CMFCPropertyPage".
4. More information about CMFCPropertySheet -- http://blog.csdn.net/tory75034/article/details/5404061
2012年11月7日 星期三
New a Dialog with CEdit and initial string problem
I want to DoModal() a new dialog with a CEdit, and there is one initial string inside the CEdit. It's not easy to put the string in the CEdit and show it when DoModal(). Anyway, the web link (http://stackoverflow.com/questions/11715888/domodal-does-not-show-dialog-but-does-its-work ) show us how to do it.
2012年11月3日 星期六
Putting Controls On Toolbars
You can learn how to add combo box into toolbar by http://msdn.microsoft.com/en-us/library/bb983718.aspx in the MFC project.
There is also the information in the http://msdn.microsoft.com/en-us/library/bb982770.aspx (
CMFCToolBarComboBoxButton Class). It also show some code in the Visual Studio Demo sample of the MFC sample codes. You can build the code and play it.
To add a combo box button to a toolbar, follow these steps:
There is also the information in the http://msdn.microsoft.com/en-us/library/bb982770.aspx (
CMFCToolBarComboBoxButton Class). It also show some code in the Visual Studio Demo sample of the MFC sample codes. You can build the code and play it.
To add a combo box button to a toolbar, follow these steps:
1. Reserve a dummy resource ID for the button in the parent toolbar resource.
2. Construct a CMFCToolBarComboBoxButton object.
3. In the message handler that processes the AFX_WM_RESETTOOLBAR message, replace the dummy button with the new combo box button by usingCMFCToolBar::ReplaceButton.
But anyway, it can't work. It take me several days to check this problem. After all, I find we can add m_wndToolBar.ResetAll (); in the SHOWMESSAGE or SIZE message to solve this problem.
2012年5月31日 星期四
CRichEditCtrl to show the hyperlink text
The key point is
CRichEditCtrl::SetAutoURLDetect
Sets the rich edit control to automatically detect a URL.
SetEventMask to ENM_LINK
http://blogs.msdn.com/b/murrays/archive/2009/08/31/automatic-richedit-hyperlinks.aspx
SetEventMask to ENM_LINK
pmyRichEditCtrl->SetEventMask(pmyRichEditCtrl->GetEventMask() |
ENM_CHANGE);
http://blogs.msdn.com/b/murrays/archive/2009/08/31/automatic-richedit-hyperlinks.aspx
2012年5月11日 星期五
Explorer like utility sample code
I try to search the Windows explorer.exe sample code in the google and codeproject, but I don't find it. Finally, I find it in the MFC sample code (\C++\MFC\Visual C++ 2008 Feature Pack\Explorer).
There is one useful MFC class CMFCShellListCtrl (http://msdn.microsoft.com/zh-tw/library/bb983966.aspx) in the Explorer sample code. The CMFCShellListCtrl class provides Windows list control functionality and expands it by including the ability to display a list of shell items.
You can find more in the MFC Explorer sample code.
There is one useful MFC class CMFCShellListCtrl (http://msdn.microsoft.com/zh-tw/library/bb983966.aspx) in the Explorer sample code. The CMFCShellListCtrl class provides Windows list control functionality and expands it by including the ability to display a list of shell items.
You can find more in the MFC Explorer sample code.
2012年2月25日 星期六
CMFCMenuButton
The MFC examples are in the MFC\Visual C++ 2008 Feature Pack\NewControls. The menu button work fine. But it will meet the problem when I try it. It can find more information in the http://stackoverflow.com/questions/3151790/why-isnt-the-dropdown-arrow-drawn-for-an-cmfcmenubutton
Can't load bitmap: 42b8.GetLastError() = 716
> CMenuImages. Can't load menu images 3f01
2012年2月24日 星期五
Rich Edit Control initialization
If you are using a rich edit control in a dialog box (regardless of whether your application is SDI, MDI, or dialog-based), you must callAfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program's InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time. You do not have to call AfxInitRichEdit if you are working with CRichEditView.
AfxInitRichEdit2 for RichEditCtrl2.0
Call this function to load the RICHED20.DLL and initialize version 2.0 of the rich edit control. If you call the Create method of CRichEditCtrl,CRichEditView, or CRichEditDoc, you typically don't need to call this function, but in some cases it might be necessary.
2012年1月12日 星期四
MFC ListBox DeleteString
For the code below, it will not be able to clear all ListBox string.
int c= m_list.GetCount ();
for(int k=0;k<c;k++)
m_list.DeleteString (i);
The problem is that the index will become 0 ~ n-1 (not 1 ~ n) after you delete index 0. You need to modify the code below to make the task success.
int c= m_list.GetCount ();
for(int k=0;k<c;k++)
m_list.DeleteString (0);
訂閱:
文章 (Atom)
