mfc

WinAPI and UTF-8 support

Quick question regarding UTF-8 support and various Win32 API's. In a typical C++ MFC project, is it possible for MessageBox() to display a UTF-8 encoded string? Thanks, Andrew ...

VS2005 C++ compiler problem including <comdef.h> in MFC application

I am having some trouble converting an old project from VS6 to VS2005. At one place in the code it uses the type variant_t so it includes comdef.h for this purpose. comdef.h then includes comutil.h which generates these errors for me: c:\program files\microsoft visual studio 8\vc\include\comutil.h(978) : error C2535: '_variant_t::_varia...

Simple object-oriented 2D graphics framework for use in Visual C++?

We're building a method of connecting components visually via a GUI in a Visual C++ application (MFC). Simple things like clicking on boxes and drawing lines between those that are connected, and storing information on them. The problem is that we're making all this by ourselves from the ground up in GDI and it quickly becomes a heck of ...

How to convert a float to a string regardless of regional settings?

My product is targeted to a Portuguese audience where the comma is the decimal symbol. I usually use CString::Format to input numbers into strings, and it takes into account the computer's regional settings. While in general this is a good approach, I'm having problems in formatting SQL queries, for instance: CString szInsert; szInsert....

Detecting a single mouse click in MFC

In MFC a double-mouse click event triggers the following sequence of messages WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBCLK WM_LBUTTONUP So responding to the WM_LBUTTONDBCLK message allows you to detect a double-click. But if I just want to detect a single-click how to I distinguish it? But just looking at the WM_LBUTTONUP message isn...

CRecordset - get auto-generated ID after Update()

Having just called Update() on an MFC CRecordset (ODBC/Dynaset) what can I do to pull the auto-generated ID without hitting the database again? Ideally whatever it is would work in both SQL Server and MS Access (so querying for the last identity might not work...) ...

How to determine if the current window is the active window?

How can I tell if my window is the current active window? My current guess is to do GetForegroundWindow and compare the HWND with that of my window. Is there a better method than that? I'm using Win32 API / MFC. ...

How to know when a controls is going to be hidden

Hi all, I have a control derived from a CWnd object that has its custom implemented tooltip system . The tooltip is implemented using a CDialog and works fine but I have a problem to know when I have to hide it. The tooltip shows up when the mouse hover over the control (WM_MOUSEHOVER) and it's hidden when the mouse leaves the control ...

Using IStream to open a file

Hi I am getting the contents of a file in an IStream object. I want to be able to open the IStream contents in a Windows program based on the extension of the file (I know the extension and the mime types) from a dll where I am getting this object. Can someone please tell me how to go about with this. Thanks. ...

Are "#define new DEBUG_NEW" and "#undef THIS_FILE" etc. actually necessary?

When you create a new MFC application, the wizard creates the following block of code in almost every CPP file: #ifdef _DEBUG #define new DEBUG_NEW #endif and sometimes it also adds this: #undef THIS_FILE static char THIS_FILE[] = __FILE__; I would like to remove this code from my CPP files if it is redundant. I am using an MFC app...

The curious problem of the missing WM_NCLBUTTONUP message when a window isn't maximised

I've got a window that I handle WM_NCLBUTTONUP messages, in order to handle clicks on custom buttons in the caption bar. This works great when the window is maximised, but when it's not, the WM_NCLBUTTONUP message never arrives! I do get a WM_NCLBUTTONDOWN message though. Strangely WM_NCLBUTTONUP does arrive if I click on the right of th...

Detecting when a CControlBar's docking state has changed

I'm using a CControlBar-derived class and I would like to detect when the docking state of the CControlBar has changed (i.e., docking from vertical to horizontal or when it goes into floating mode). Of course, I could handle WM_SIZE but it seems to be a waste of ressources doing the task every time a WM_SIZE message is fired instead of ...

How should I deploy an MFC application?

I created an application in VS 2008 Express as an MFC app just to take advantage of the easy GUI creation. I might re-do this app in pure win32 since no other MFC classes are used (just a button and a text box, the button fires off the main program, all win32). My only question that determines whether I stay in MFC or port it over to pur...

CMFCRebar on a dialog box.......

Can we create a CMFCRebar on a dialog box? If yes, then how? I need to have a CMFCReBar drawn on a dialog box with a toolbar and and menubar. ...

why does the BTNS_DROPDOWN style cause the whole toolbar to move down a couple pixels?

I have a CToolbar and within it I have a button with style BTNS_BUTTON|BTNS_DROPDOWN. I would like to make it a split button, so the left side of the button is a button, and the right side has a drop down menu. To complete this, I create the button then I call ::SendMessage like so: ::SendMessage( hwndForButton, TB_SETEXTENDEDSTYLE, 0...

Converting specical characters in XML stream

I have an XML stream which contains special characters such ' stored in a CString object. Is there any method other than replacing individual characters in the stream to convert these special characters ? ...

Handling Return key in CEdit control

How to handle return key (VK_RETURN) in a CEdit control? CEdit is lying in a CDialog. ...

MFC - How can I disable a list item?

I have a CListCtrl with checkboxes. I want to be able to disable one of the items so that the user cannot click the checkbox. Is this possible? If so, how? Edit: Found the specifics on how to hide a checkbox in another question http://stackoverflow.com/questions/190667 ...

How to change font/color on MFC dialog for Windows Mobile?

Hi, Does anyone know how to set font and color on a static text and other controls of MFC dialog for Windows Mobile? Where can I get the list of supported fonts? Thanks! ...

How to add data Filtering using CListCtrl and CHeaderCtrl

Background: Applications that manipulate a collection of data typically present using a grid containing a header. These same applications typically incorporate a filter to allow the user to narrow the data set (Excel is a wonderful example. There are many others). In my MFC application, I'm attempting to do the same using the CListCtr...