mfc

How to add submenu to a CMenu in MFC?

会有一股神秘感。 提交于 2021-02-07 10:30:41
问题 I have an MFC app that uses CMenu for the main menu bar. I haven't been able to create submenus successfully. I can have the first level of File, Edit, View, etc and their sub menus, but I can't create a submenu off of one of those menus. For example, I would like to be able to go File->Recent Items-> list of items in submenu I can do this easily enough with the resource editor in VS, but this needs to be done dynamically. Am I using the right class in CMenu? Any suggestions on what to try? I

Different behaviour between CString operators “+=” and “+”

眉间皱痕 提交于 2021-02-07 06:51:22
问题 While migrating an application from VisualStudio 2005 to VisualStudio 2015 we found a different behaviour in some code that concatenates CString instances when that code is built with VS2015. So, I've created a simple Win32 console application to demonstrate the problem. The console application (using MFC as shared dll and Unicode charachter set) executes this simple function: void f() { CString x( '\0' ); CString r( 'a' ); r += x; CString rr( 'a' ); rr = rr + x; int rSize = r.GetLength();

CMFCButton with Vista Style

六月ゝ 毕业季﹏ 提交于 2021-02-04 15:29:41
问题 I can't seem to get a CMFCButton to be displayed in Vista style in a dialog box application. I'm using VS2008 with MFC Feature Pack. Here are some steps to reproduce my problem: Create a new MFC Project; Specify a Dialog based project. Add two buttons to the main dialog. Add a variable for each button. Make one of the variables a CButton, the other one a CMFCButton. Compile and run. test app picture http://img7.imageshack.us/img7/3/testapp.png As you can see, the CButton has the correct style

How to edit cell in listcontrol mfc?

爱⌒轻易说出口 提交于 2021-01-29 22:11:29
问题 I need edit my text in second column and I don't want use MFC grid control. how I can edit cell by kicking on it. please give me simple example. There what I have: void CTab1::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST1, m_LISTC); } BEGIN_MESSAGE_MAP(CTab1, CDialogEx) ON_NOTIFY(LVN_ENDLABELEDIT, IDC_LIST1, OnEndEdit) END_MESSAGE_MAP() // CTab1 message handlers BOOL CTab1::OnInitDialog() { CDialogEx::OnInitDialog(); m_LISTC.InsertColumn(0, L

How to add database to MFC project in Visual Studio 2017?

主宰稳场 提交于 2021-01-29 08:00:09
问题 I need to create an MFC project with database. As I can see in screens of VS 2015, there was a special option for it. But in VS 2017 I don't see it. Here's the list of components I have: But I still can't find anything that can help me find database support for mfc. I will be grateful for any help. Thanks in advance! 回答1: This will be similar to my answer I am missing the Add new item Add "MFC Class From Typelib" in VS-2019 or this issue The big ATL wizard misery. You will need to create it

AfxMessageBox going on background

故事扮演 提交于 2021-01-29 04:23:17
问题 In a connection check i am showing a modal dialog to ensure the connection. But to give people escape from the modal dialog i want to a message box to keep try connection or exit the application. Source Code : void CRoboVibMainFrame::OpenSystemSettingsDialog(int activeTabIndex /*= 0*/) { while (activeTabIndex >= 0) { m_settingsDialog = std::make_unique<SettingsDialog>(this,activeTabIndex); m_settingsDialog->DoModal(); activeTabIndex = GetNotConnectedPSVControl(); if (AfxMessageBox(Polytec:

How to use EM_SETHANDLE on edit control?

人走茶凉 提交于 2021-01-29 02:10:52
问题 I am unable to figure out how to properly use the EM_SETHANDLE mechanism to set the text for an edit control. Get and Set window text will be too slow for my application. From the documentation I understand that the allocated buffer will be sued by the control and it works partially for me. When the text is entered in the control, it is seen in the buffer but when the buffer is updated using memcpy etc (no bug in the code), the updated text won't show properly. I even tried EM_SETHANDLE

mfc bitmap reads a completely black bitmap

雨燕双飞 提交于 2021-01-28 18:40:13
问题 I want to use a bitmap to read the current view window, make some changes to it and output the bitmap back to the view. The program is supposed to read a white window and draw a square against this background. However, the image that I see in the final window is a square in a black background. void CScribbleView::OnLButtonDown(UINT, CPoint point) { //CClientDC dc(this); //OnPrepareDC(&dc); HBITMAP initialMap; RECT t; BITMAP bmpScreen; GetClientRect(&t); initialMap = CreateCompatibleBitmap

SendMessage/PostMessage to a derived CView class not working for MFC application

谁说我不能喝 提交于 2021-01-28 14:53:31
问题 I am building a test application(testApp) for a legacy MFC based application (MFC-app). I am trying to simulate mouse clicks on the MFC-app using message-passing between them. I was able to do this successfully for bring up dialog boxes from the MFC-app menu. However when I am trying to simulate a mouse click on the View of the MFC -app it doesn't seem to work. The main question I have is whether there are any known limitations in trying to use SendMessage,PostMessage functions to communicate

isupper and islower for wstring

老子叫甜甜 提交于 2021-01-28 07:07:53
问题 I have a std::wstring and I want to find which character are upper case and which ones are lowercase. the std::isupper and islower seems to work on ASCII characters only but I want to be able to find out all kinds of uppercase and lowercase characters e.g. á is an "Latin small letter a with acute" and Á is an "Latin capital letter A with acute" similarly ä and Ä are lower and upper case german letters. Is there any function (mfc, boost or in any other library) which I can use to find out if a