Questions tagged [mfc]

1

votes
2

answer
122

Views

How to eliminate flickering with erase background in mfc

I am working with SDI app to redraw graph and update data by using timer in View file. Even though I use ON_WM_ERASEBKGND to eliminate flickering, but it still happen. And below are my code that I tried to implement. Anyone has any ideas to eliminate flickering? Here are my MSG_MAP ON_WM_PAINT() ON_...
Lê Duy Cường
1

votes
3

answer
4k

Views

How do I dynamically change the text of a CMFCRibbonLabel

My CMDIFrameWndEx derived main frame window uses a CMFCRibbonStatusBar to which I add a CMFCRibbonLabel. I'd like to change the text of this label at runtime: m_pLabel->SetText(description); m_pLabel->Redraw(); It only updates the text but not the rectangle in which to draw it. So if the original te...
foraidt
1

votes
3

answer
2k

Views

Passing objects as WPARAM in window messages using smart pointers

I am looking for a way to pass an object (vector in my case) as a WPARAM in C++11 style. The tutorials I found used a C-style cast or a reinterpret_cast to pass a pointer to the object. This requires that the recipient of the message properly disposes the object after receiving it. Is there a way to...
lowglider
1

votes
0

answer
104

Views

emplace_back different definitions

I'm using emplace_back function in a cpp project in visual studio and it works correctly. Visual studio shows following definition for it: void std::vector::emplace_back(CHAR(&_Val)[1]) Then, I'm going to move my cpp project files to a MFC project and use them in a dialog based app. When I moved c...
Mahdi
1

votes
0

answer
147

Views

CListBox SetScrollPos doesn't work

I have a dialog with a CListBox member with a vertical scroll bar which gets destroyed and recreated occasionally. On those occasions, I want the scroll bar to stay in the same position it was before destruction. In the function that causes re-creation, I have this line: int scrollPos = m_checkListC...
dkb
1

votes
0

answer
43

Views

How to efficiently copy contents between two list controls

I want to copy rows from one List Control to another List Control. I am only able to copy them by sub item. I think this is not very efficient. There must be a method to copy the content by rows. The following is my code that copies content one sub item at a time. CString CurItem, tem, copystr; int...
Lee
1

votes
1

answer
180

Views

Can a MFC dialog resource be attached to a CChildView?

I have a single document MFC app, which consists of the MainFrame (derived from CFrameWnd) and within contained CChildView (derived form CWnd). These are generated by the VS MFC Wizard. In resource editor I have designed a simple UI and tagged it as IDD_CUSTOMCONTROL with few buttons and text field...
Rafal
1

votes
1

answer
184

Views

Qt DLL in MFC app - How to make QDialog *really* modal?

At the moment I am developing a Windows DLL with Qt 5.9.2 (MSVC 2015 compiler), which should be loaded by an existing, commercial MFC application. Upon request of this application a modal instance of QDialog should be displayed. Since QApplication::exec() would block the entire application, I 'simul...
FlKo
1

votes
1

answer
416

Views

Boost Filesystem exists Access violation

I have a Problem with boost::filesystem::exists(pathName). When the folder did not exists the method returns false as expected. If the Folder exists it throws an exception in the make_permissions(const path& p, DWORD attr) Method of the Boost File operations.cpp. This is the code from that file if...
Kevin
1

votes
0

answer
202

Views

how to handle warning C4191: 'type cast' : unsafe conversion from 'int (__cdecl CWnd::* )(LPCREATESTRUCT)' to 'AFX_PMSGW'

My solution is written in MFC (C++) and is migrate from maybe VC6. I also need to support 64-bit machines. Now there is a warning in my MainForm, which is located in MainForm.cpp: BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_WM_CREATE() //C4191 warning END_MESSAGE_MAP() C4191: 'type cast' : unsafe...
Penny
1

votes
1

answer
473

Views

MSVC++ Exception 0x80000003 In Different Language

I have some software that I've helped modify. We took the application from 32 to MFC to 64 bit MFC. It's been a pretty big project, but we are having this one really strange issue. My installer works on all of our computers here, the application works and doesn't have issues; however, when our cu...
thephysicsguy
1

votes
1

answer
144

Views

Visual Studio 2017 MFC SDI Debug Assertion OnCreate

I want to create a MFC Single Document Application with Visual Studio 2017. I had made the following Configuration when I create the new Project: If i now Build and Run the newly created Project without any changes on the code it immediately crashes with an Debug Assertion Error. This is the Message...
Kevin
1

votes
0

answer
88

Views

MFC program in a shared dll compiled by Visual Studio 2012 running Windows XP

I have the Visual Studio 2012 with Update 5 on windows 10. I have been writing some programs which can also be run on Windows XP. I have searched some articles on how to compile a program which use MFC in a static library, and it can indeed work, but since I have been writing multi programs in a sof...
Bob
1

votes
1

answer
201

Views

CFileDialog file name change?

I've successfully subclassed a CFileDialog and added an area with a few controls that control load/save file format using SetTemplate(). My control message handlers are being called correctly. Depending on the file name typed, my controls may need to update. I'm getting OnFileNameChange() when the...
Swiss Frank
1

votes
0

answer
55

Views

MSChart CreateControl launches Windows installer

I have this code below trying to initialize CMSChart in a DLL I have created. When it gets to myChart->CreateControl, for some reason it is launching a Windows Installer dialog, and says 'Preparing to install...' indefinitely. I am no longer able to use this DLL as this install dialog pops up and ne...
Matthew Mallimo
1

votes
0

answer
60

Views

How to set PowerPoint version in PowerPoint C++ automation?

I am using MFC,PowerPoint2003&2010 C++ automation,in Windows 10. There are PowerPoint2003 and PowerPoint2010 in my computer. My code is: // Firstly,I load PowerPoint2003 and PowerPoint2010 c++ automation library // Start the powerpoint in Powerpoint2003 automation CApplication app2003; if(!app2003.C...
zet
1

votes
1

answer
84

Views

In MFC CTreeCtrl how to disable/skip hot tracking style for some items?

In my MFC CTreeCtrl I am using TVS_TRACKSELECT style. I want to skip or disable this style for some items in my Tree control. How to achieve it?
User890
1

votes
0

answer
60

Views

Why CDC::IsPrinting() return FALSE when is from CPrintDialog::GetPrinterDC()?

I'm using CPrintDialog to setup printer parameters and I get the DC with the GetPrinterDC() method. CPrintDialog pd ( TRUE , PD_RETURNDC ); if ( pd.DoModal () == IDOK ) { HDC hDC = pd.GetPrinterDC(); CDC printDC; printDC.Attach ( hDC ); /*...*/ } In my generic drawing function I want to know is the...
prompt
1

votes
0

answer
51

Views

Setting back and font colour for CComboBoxEx items

I have read up on a few articles about CComboBox and changing font properties by using owner draw. But I am using a CComboBoxEx. At the moment I can set the images etc.: COMBOBOXEXITEM cmbItem; cmbItem.mask = CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_TEXT | CBEIF_LPARAM; if (psReference != nullptr)...
Andrew Truckle
1

votes
1

answer
65

Views

SmartCardCredentialsProvider.dll UI doesn't accept user input

My company is programming for the SmartCard security setup in Windows. However, we hit a snag when we updated to Fall Creators, which a developer was able to mitigate by not passing a parent window to the CredUIPromptForWindowsCredentialsW() function (desktop/root/NULL). If we pass a parent window...
Adrian
1

votes
1

answer
81

Views

MFC: hidden margin around CMainFrame

Main frame in my app is common: class CMainFrame : public CFrameWndEx. In my code I am looking for a MainFrame position on the screen and if it is out, (for example when any monitor is swiched off or disconnected) I move the window on a valid area. int VIRTSCR_Left = GetSystemMetrics(SM_XVIRTUALSCRE...
Lubomir
1

votes
1

answer
89

Views

Retrieve radio input value in a CDHtmlDialog based application

I'm working on a MFC application based on html dialogs. I've encountered lot of struggle for exchanging datas between the html and the c++ code, but I finally managed to make it working. I'm retrieving without any problems values from text inputs (DDX_DHtml_ElementText()), selects (DDX_DHtml_SelectV...
Lozah
1

votes
0

answer
45

Views

Resizing another threads window with MFC above screen size

I use the handle of a window from another process to resize and reposition it from an MFC based app. The handle comes from a window search for Title. Repositioning works fine, resizing too - if not larger then the screen resolution. But that's the problem - I want it to be bigger then the actual sc...
Idenwen
1

votes
1

answer
152

Views

convert ID3D11Resource* to Bitmap or CDC for MFC code

In a MFC project, I need to save a D3D11Resource* to a CDC, CBitmap, or BITMAP, not as a file. First I'm validating that I can save off the Texture as bitmap object or memory-mapped file, before using the bitmap. Not going for speed here; just need the bitmap. Using DirectXTex, I've gotten as far as...
user1953804
1

votes
2

answer
69

Views

How to put checkbox in each CMFCTabCtrl's tab header

I have a MFC application. I am using CMFCTabCtrl in a dialog. My requirement is I have to add a checkbox in each tab page of CMFCTabCtrl as below. Is it possible to add checkbox in each tab page of CMFCTabCtrl ?
User890
1

votes
0

answer
176

Views

Custom drawn MDI child frame client rectangle and message issues

I am trying to create a class derived from CMDIChildWndEx which draws the child frame in Windows 10 style (theme colored caption bar, single pixel borders with an transparent region outside those allowing sizing, no 3D frame) rather than the old-style pale blue default. I am making progress on drawi...
Paul Harrison
1

votes
0

answer
254

Views

CreateService and quotes for lpBinaryPathName parameter

I'm trying to install a kernel driver from an MFC application using CreateService function and I'm not sure that I fully understand how lpBinaryPathName parameter is supposed to be set up. Quoting MSDN: The fully qualified path to the service binary file. If the path contains a space, it must be quo...
MikeF
1

votes
0

answer
66

Views

Using WS_EX_CONTEXTHELP with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles

I see here that it says: WS_EX_CONTEXTHELP WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. Is this still the case? I would like to have this icon too. The reason I ask is because when using Windows Blinds I get these: So it has: Collapse to just the title bar (don'...
Andrew Truckle
1

votes
0

answer
78

Views

Adding statusbar to CDialog and setting control positions correctly

So, I have a CDialog resource that I have had for a long time and I decided to add a statusbar to it. Here is the resource: All controls fit nicely in the dialog. Now, at runtime this is what it looks like: The tutorial I followed was here and for the most part it works. Here is my setup code: /////...
Andrew Truckle
1

votes
0

answer
50

Views

Function “hiding” and OnSize

I really don't get this. Take the OnSize function: afx_msg void OnSize( UINT nType, int cx, int cy); So, it is not virtual. So we make our own method using ClassWizard in our derived class. Eg: void CCreateReportDlg::OnSize(UINT nType, int cx, int cy) { CResizingDialog::OnSize(nType, cx, cy); if...
Andrew Truckle
1

votes
0

answer
51

Views

MFC frame application not repainting when covered or shaken

I am creating a MFC frame based application for instrument monitoring/plotting/interaction, with several child windows hosted in a main frame. These child windows are all created by the main frame using: MakeCommandsWindow('Child Window', WS_VISIBLE | WS_CHILD , CommandsRect, this, NULL); which c...
V J
1

votes
1

answer
43

Views

CMFCTabCtrl's Active tab close button

In CMFCTabCtrl there is a function EnableActiveTabCloseButton() to have or not close button on any active tab. I don't want to have close button only in my first tab. Th e other tab will have close button. How to achieve it? Thanks.
User890
1

votes
1

answer
450

Views

Visual Studio setting to deal with missing MSVCP140D.dll

My build computer is different than my target (although both are Windows 10). I am using VS2017 with the latest updates. The target machine has MFC: 14.12.25810 How do I set my project settings so that I can target that version of MFC. I keep getting an error of: missing MSVCP140D.dll And when I try...
Dr.YSG
1

votes
1

answer
106

Views

SetFocus and KillFocus

I have a CMFCTabCtrl in my dialog and my CMFCTabCTrl has two tabs. The first tab has a CComboBox and the second tab also has a CComboBox. Whatever item newly added in ComboBox in first tab will reflect in ComboBox in second tab. Similarly, whatever item newly added in ComboBox in second tab will ref...
User890
1

votes
0

answer
49

Views

Selected item in dropdown does not get highlighted the next time I click on the dropdown

I have tried searching for a solution but could not come to one. The item selected from the combo box is not getting highlighted the second time I click on the drop down. Example: suppose I have selected an item named dog from the combo box, now when I click the drop down, the control should be in o...
Roselina Moven
1

votes
2

answer
89

Views

Call Dervied Class function Using Base Class object

I’m trying to draw CMFCRibbonTab a with slightly small difference in which the text is a positionned a little bit higher. To achieve that I’ve created a derived class called DCRibbonTab that extends CMFCRibbonTab and rewritten virtual void OnDraw(CDC * pDC) function as the following : #pragma on...
Annabi Gihed
1

votes
1

answer
178

Views

Rectangle not showing on OnPaint MFC

I have a dialog based application written in c++ and MFC. The dialog has a CStatic picture control. I am drawing a BITMAP in the OnPaint() function of the PictureCtrl. The relevant code is as follows: void PictureCtrl::OnPaint() { CDC* pDC = this->GetDC(); pDC->SelectStockObject(PS_SOLID); pDC->Rect...
ubaabd
1

votes
1

answer
64

Views

How can I to detect if keyboard is attached?

I have a MFC Application that sometime work on touch screen I want to open my virtual keyboard when focused edit box if keyboard isn't attached
1

votes
1

answer
58

Views

Why can't I quit the MFC program when I used MsgWaitForMultipleObjects?

HANDLE g_event = CreateEvent(NULL, TRUE, FALSE, L'tasdfasdfsadfasdfasdfas'); BOOL bIsok = TRUE; while(bIsok) { DWORD dwTime = MsgWaitForMultipleObjects(1, &g_event, FALSE, 5000, QS_ALLINPUT); MSG msg; switch(dwTime) { case WAIT_OBJECT_0: break; case WAIT_OBJECT_0 + 1: { if(PeekMessage(&msg, NULL, 0,...
tobin
1

votes
0

answer
57

Views

MFC CComboBoxEx select text only

I am using the CComboBoxEx control in MFC to select color for future drawing. Items in my ComboBox have small pictures – examples of color, and color names. Everything is Ok, except one annoying thing – when I select some item, not only text in selected item has different background, but the pic...
Andrey

View additional questions