mfc

IsWindow(activeX.GetSafeHwnd()) always false after upgrade to VS2010

試著忘記壹切 提交于 2020-01-07 00:54:44
问题 I have an MFC application that uses an ancient (circa 1999) third-party ActiveX control. Since upgrading the project from VS2008 to VS2010, I'm having problems... In the OnSize handler of the parent dialog IsWindow always returns false for the handle returned by control.GetSafeHwnd(), even when GetSafeHwnd() returns a non-NULL value. The rest of the control's parent dialog is displayed fine, but it doesn't seem to respond to any input. I've seen this article, but GetSafeHwnd() isn't returning

How Create derived from CWnd POP UP Window?

我的未来我决定 提交于 2020-01-06 23:52:04
问题 I created class CSurfaceWnd from CWnd by Class Wizard. I tried to create window but getting error. That's my code of creating: if(!m_pSurfaceWnd) { CString m_NameClass = AfxRegisterWndClass( CS_VREDRAW | CS_HREDRAW, ::LoadCursor(NULL, IDC_ARROW), (HBRUSH) ::GetStockObject(WHITE_BRUSH), ::LoadIcon(NULL, IDI_APPLICATION)); m_pSurfaceWnd = new CSurfaceWnd; CRect rcTemp; GetWindowRect(rcTemp); VERIFY(m_pSurfaceWnd->CreateEx(WS_EX_CLIENTEDGE, m_NameClass, NULL, WS_POPUP | WS_VISIBLE, rcTemp, mpWnd

Check whether a Cstring contains only Chinese characters

谁都会走 提交于 2020-01-06 20:23:37
问题 I am checking whether a CString variable contains only] Chinese characters. The Unicode range for Chinese characters is 4E00 - 9FFF. I am doing as follows: CString str; char ch; GetDlgItemText( IDC_EDIT1, str ); for(int i=0;i<str.GetLength();i++) { ch=str[i]; if(ch>='\u4E00'&&ch<='\u9FFF') { //even if input chinese character here 'if' evaluates to false SetDlgItemText( IDC_RICHEDIT21, str ); SendDlgItemMessage( IDC_RICHEDIT21, EM_REPLACESEL, TRUE, (LPARAM)(LPCTSTR)str); } else break; But if I

MFC实现图片浏览器

橙三吉。 提交于 2020-01-06 19:24:31
MFC实现图片浏览器(源代码可以加微信:DDDDYKAJ) 一.功能介绍:该程序是基于对话框的图片管理的程序。改程序有以下几个功能: 1,获取加载图片的图片数目 2,按下“下一张”浏览所有图片 3,图片按照序号定位,并显示 4,获取每一张图片的大小信息 点击“下一张”,使得能够浏览图片。点击“获得图片总数”得到程序中所有图片的数量。在“选择图片序号”中可以得到想要的图片。 1,获取加载图片的张数: 2,浏览所有图片 3,获取图片大小 来源: CSDN 作者: weixin_44694878 链接: https://blog.csdn.net/weixin_44694878/article/details/103846277

DLLImport a variable MFC dll

风格不统一 提交于 2020-01-06 15:40:22
问题 So I created the following test project: [DllImportAttribute("TestMFCDLL.dll", CallingConvention = CallingConvention.Cdecl)] internal static extern int test(int number); private void button1_Click(object sender, EventArgs e) { int x = test(5); } Which works fine for my MFC dll that has the function test defined, however what I actually have is many MFC dlls that all share a common entry function and run differently based on my inputs. So basically I have tons of dlls that I cannot know at

Derive a custom class from CMFCVisualManagerOffice2007

别说谁变了你拦得住时间么 提交于 2020-01-06 15:18:50
问题 I was trying to derive a custom class from CMFCVisualManagerOffice2007. Can you suggest me steps to be followed in order to derive a CCustomMFCVisualManagerOffice2007? I am getting following error: error C2248: 'CMFCVisualManagerOffice2007::CMFCVisualManagerOffice2007': cannot access protected member declared in class 'CMFCVisualManagerOffice2007' I am looking for something on the lines of: MFC CMFCVisualManager Override 来源: https://stackoverflow.com/questions/42635165/derive-a-custom-class

Trying to write a for_each algorithm for MFC's CMap

倾然丶 夕夏残阳落幕 提交于 2020-01-06 14:58:33
问题 Yeah, I know that I should make an iterator, but I need this done fast and writing a proper iterator for anything related to VC++ is beyond frustrating. (This also goes for many other standard things and is buggering up my work load. :( ) So I wrote a for_each() algorithm to deal with the nastiness: template <typename K, typename AK, typename V, typename AV> void for_each(CMap<K, AK, V, AV>& container, std::function<void(AK, AV)> body) { POSITION pos = container.GetStartPosition(); while (pos

How can I make a CMenu TrackPopupMenu SubMenu menu-item clickable?

♀尐吖头ヾ 提交于 2020-01-06 14:55:55
问题 Normally when you hover over a sub-menu (with the little arrow) on a CMenu menu item it delays briefly then shows the sub-menu items. Also, if you click the item before the delay timeout, it shows the sub menu items. I want the delay behavior, but I want a different behavior for the click. That is, I want the sub-menu itself (the one with the arrow) to be a clickable entity too, i.e. it has an ID and results in a WM_COMMAND and menu dismissal. The idea is, the main sub-menu menu item is a

How can I make a CMenu TrackPopupMenu SubMenu menu-item clickable?

∥☆過路亽.° 提交于 2020-01-06 14:55:00
问题 Normally when you hover over a sub-menu (with the little arrow) on a CMenu menu item it delays briefly then shows the sub-menu items. Also, if you click the item before the delay timeout, it shows the sub menu items. I want the delay behavior, but I want a different behavior for the click. That is, I want the sub-menu itself (the one with the arrow) to be a clickable entity too, i.e. it has an ID and results in a WM_COMMAND and menu dismissal. The idea is, the main sub-menu menu item is a

Printing In MFC Application

牧云@^-^@ 提交于 2020-01-06 14:19:11
问题 How can I print a document using MFC Dialog Based Application? I have made a print button. After clicking on this button, I want print of some document or some text. 回答1: You can create an invisble CHtmlEditCtrl control and load your text to it with SetDocumentHTML(LPCTSTR) method and then call PrintDocument() method. void WaitForComplete(IHTMLDocument2* document) { BSTR ready; document->get_readyState(&ready); while(wcscmp(ready, L"complete")) { AfxPumpMessage(); document->get_readyState(