mfc

mfc - MessageBox with rich text

♀尐吖头ヾ 提交于 2020-01-13 21:13:10
问题 I want to be able to display formatted text inside a message box (like bold text, bullet points, italics, etc.). I came across this wonderful article but can't seem to get it to work. I am using the demo application at that same link. Can someone please help me out? I have tried debugging/understanding that code in vain. Constraints: (not my choice) Has to be compatible with Windows XP. I'm using Visual C++ 6. How it is supposed to display: How it actually displays: 回答1: Simply create a

mfc - MessageBox with rich text

一个人想着一个人 提交于 2020-01-13 21:05:34
问题 I want to be able to display formatted text inside a message box (like bold text, bullet points, italics, etc.). I came across this wonderful article but can't seem to get it to work. I am using the demo application at that same link. Can someone please help me out? I have tried debugging/understanding that code in vain. Constraints: (not my choice) Has to be compatible with Windows XP. I'm using Visual C++ 6. How it is supposed to display: How it actually displays: 回答1: Simply create a

How to convert CString to integer and float? [duplicate]

你说的曾经没有我的故事 提交于 2020-01-13 20:18:25
问题 This question already has answers here : Convert MFC CString to integer (11 answers) Closed 4 years ago . I am trying to convert CString to int and float but unable to find any C++ library function to get this done. please help. 回答1: The proper UNICODE -compliant way of doing it in MFC is the following: CString sInt = _T("10"); int n = _ttoi(sInt); CString sFloat = _T("10.1"); float f = _ttof(sFloat); As David Heffernan mentioned: If your project configuration is UNICODE only and you don't

How to convert CString to integer and float? [duplicate]

孤人 提交于 2020-01-13 20:18:08
问题 This question already has answers here : Convert MFC CString to integer (11 answers) Closed 4 years ago . I am trying to convert CString to int and float but unable to find any C++ library function to get this done. please help. 回答1: The proper UNICODE -compliant way of doing it in MFC is the following: CString sInt = _T("10"); int n = _ttoi(sInt); CString sFloat = _T("10.1"); float f = _ttof(sFloat); As David Heffernan mentioned: If your project configuration is UNICODE only and you don't

WebBrowser Control (MFC) created in seperate thread working in Windows 7 and Vista, but Windows XP

久未见 提交于 2020-01-13 19:08:14
问题 I have CWnd in main thread, and a CWnd with a WebBrower control created in a seperate thread. This is necessary, because the WebBrowser navigates to urls which have javascripts running which will block the WebBrowser. So I with the WebBrowser control in a seperate thread I prevent the GUI Thread vom hang. Also I have done this in main thread in my application: CCustomOccManager *pMgr = new CCustomOccManager(); AfxEnableControlContainer(pMgr); That's for extending the WebBrowser control to my

Marshal类的PtrToStructure

爷,独闯天下 提交于 2020-01-13 17:25:05
PtrToStructure,将数据从非托管内存块封送到新分配的指定类型的托管对象 应用:MFC发送消息到WPF界面上 public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if ((MsgType)msg == MsgType.WM_TestChip_R) { ChipTest MsgData; MsgData = (ChipTest)Marshal.PtrToStructure(wParam, typeof(ChipTest)); // 接收封装的消息 currentInfoControlVM.UpdataR(MsgData); handled = true; return IntPtr.Zero; } [StructLayout(LayoutKind.Sequential, Pack = 4)]//设置结构体对齐 public struct tagTestChip { [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 30, ArraySubType = UnmanagedType.R4)] public double[] dRst; } public struct

Byte array marshaling for PostMessage

不打扰是莪最后的温柔 提交于 2020-01-13 11:49:33
问题 I'm trying to port some C++ code to C#, and one of the things that I need to do is use PostMessage to pass a byte array to another process' window. I'm trying to get the source code to the other program so I can see exactly what it's expecting, but in the meantime, here's what the original C++ code looks like: unsigned long result[5] = {0}; //Put some data in the array unsigned int res = result[0]; Text winName = "window name"; HWND hWnd = FindWindow(winName.getConstPtr(), NULL); BOOL result

Setting selection by text in CComboBox (MFC)

半腔热情 提交于 2020-01-13 11:26:31
问题 I have a CComboBox of type DropList (i.e. it's not editable). What's the easiest way to set the current selection by string? I know I can use SetCurSel() to set it by index, but I want the function to search through the list-items by string and set it. 回答1: What about CComboBox::SelectString ? "Searches for a string in the list box of a combo box, and if the string is found, selects the string in the list box and copies it to the edit control." https://msdn.microsoft.com/en-us/library

How to add MFC support to existing Win32 C++ Project?

不羁岁月 提交于 2020-01-13 10:53:13
问题 I am creating a C++ application which uses Qt to create the GUI. However, I need to use a third party library which relies on MFC (for CString's, etc). Is there anyway to add MFC to my application to allow me to use this library or do I need to rewrite it myself? I saw this question, but it doesn't tell me how to add MFC manually to the project. 回答1: If the library app takes/returns/uses CStrings it will need linking with the MFC libs, or will have the MFC libs already statically linked. If

How to drag & drop lots of files without taxing system resources?

爱⌒轻易说出口 提交于 2020-01-13 09:56:05
问题 One of the features that the program that I'm working on is the ability to drag objects from its main window and drop them onto Windows Explorer as files. To do this, we override COleDataSource::OnRenderGlobalData() and, when the format is CF_HDROP , we save each object as a file. This works fine when the number of objects is small. However, as we're now working on supporting enterprise level amounts of objects, we're seeing big delays, sometimes leading to hangs or eventual crashes, when the