mfc

HitTest not working as expected

I am wanting to display a context menu when a user right-clicks on an item within a CListCtrl. My code is as follows: void DatastoreDialog::OnContextMenu(CWnd *pWnd, CPoint pos) { // Find the rectangle around the list control CRect rectMainArea; m_itemList.GetWindowRect(&rectMainArea); // Find out if the user right-click...

Is MFC sitll the dominating framework for windows desktop application?

I just wondering about this.It is said that .NET is better than MFC in a lot of aspects.But when I use my PEID to recursive scan my 'program files' directory,it turns out there are still a lot of programs written with 'Visual C++ 6'(esp. for security software),whose GUI should be written with MFC. So my questions are: Is MFC still the...

ComboBoxEx32 (CComboBoxEx) keyboard behaviour

I have a WTL application that uses an extended combobox control (the Win32 class ComboBoxEx32) with the CBS_DROPDOWNLIST style. It works well (I can have images against each item in the box) but the keyboard behaviour is different to a normal combobox - pressing a key will not jump to the first item in the combo that starts with that le...

Draw scaled images using CImageList

If you have images stored in a CImageList, is there an easy way to render them (with proper transparency) scaled to fit a given target rectangle? CImageList::DrawEx takes size information but I don't believe it does scaling, only cropping? ...

MFC: write text using stock font, but bold

This is an easy way to draw some text with a default font. pDC->SelectObject(GetStockObject(DEFAULT_GUI_FONT)); pDC->SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); pDC->DrawText(text, -1, rc, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_END_ELLIPSIS); How can I do exactly the same, but in bold type... same font but bold? Ca...

How to recover from MFC error "Cannot add new member"?

I'm working with an MFC application using Visual C++ 6.0. When I double-click on one of the elements of a dialog box in Resource View, I get the error "Cannot add new member." I understand that the source of this might be corrupted metadata in the source files associated with that resource. Do you know any methods for determining what ...

is there a better way to select correct method overload?

Is this really the only way to get the correct address for an instance function: typedef CBitmap * (CDC::* SelectObjectBitmap)(CBitmap*); SelectObjectBitmap pmf = (SelectObjectBitmap)&CDC::SelectObject; First, one has to create a typedef, and then one has to use that to force the compiler to select the correct overloaded method when t...

How to speed up rotated text output in MFC

I have a MFC application that displays annotated maps, which can include a large amount of text. While the size and font of the text does not tend to change much, the rotation of the text varies considerably, in order to be aligned with the surrounding line work. This basically means that I have to do create and select a new font into ...

Consume events in MFC's CStatic and pass them to the parent

Hello, I am building MFC application where there is CDialog with child control derived from CStatic on it. I want to receive mouse events for CStatic control so I set "Notify" for it to true. Now I am able to receive message events through message map directly in MyStatic: class CMyStatic : public CStatic { afx_msg void OnLButtonDow...

how to add an image along with text in a button in MFC?

hello all,Am having a hard time in adding image along with a text in a Button..I know that it can be done by enabling the owner draw function with bitmapbutton class..But I dont want to that..so is ther anyother way that i can add an image along with text without drawing the text? ...

Windows thumbnail/frame view

What would be the easiest way to make a thumbnail view, where you have a panel with a vertical scroll bar, and a matrix of images describing their associated image? I'd also like it such that if the parent frame resized horizontally, the matrix would shrink to as many columns as necessary to display the thumbnails without a horizontal sc...

Group By and Sort by Column in CMFCListCtrl.

I have a derived CMFCListCtrl which I can used group by and sort by fine via a contect menu. However when group by is being used and I select a column to sort by (by clicking on the coloumn header) the arrow changes but the items are not sorted, I don't get my 'onsortby' message triggered either, any ideas? I'm on XP is that the problem...

Finding a window and setting focus on it...

1.I want to find a window and set focus on it , but window is not taking the focus. 2.If i use HWND_TOP then it does not make the window active and if i use HWND_TOPMOST then it make window always on top. Can anyone help me ?? HWND hwndAppDlg = ::FindWindowEx(hwndDesktop,NULL,lpszClass,lpszWindow); if(hwndAppDlg && IsWindow(hwnd...

IE ActiveX plugin cannot create file

Hi, I wrote an IE plugin using MFC activex. The plugin actually creates a file in CLSID_APPDATA folder and writes some data inside it. But the problem is that file which is created cannot be seen (i mean i cant see any file in CLSID_APPDATA folder on windows vista) whereas I am actually writing data inside it. The plugin is not signed. ...

Manually drawing gradients for buttons, toolbars, tabs etc?

I would like to update some toolbar-like code we have to have a Vista/Win7 gradient roundedness to them. Currently, the buttons have the Windows 2000 look & feel: blocky, single-tone. I've played around with the XP themes, and using DrawThemeBackground, DrawThemeEdge, etc.; but I'm very dissatisfied with the theme drawing mechanics (th...

"Use MFC in a Static Library" links to MFC80U.dll

In my Windows CE DLL project, I am trying to tell Visual C++ to link statically to MFC in a project that originally did not use MFC. However, upon linking successfully, Dependency Walker (depends.exe) says that my DLL is dynamically linked to MFC80U.DLL and MSVCR90.DLL. Has anyone else encountered this bug? If "Use of MFC" is set to "Us...

Load a CBitmap dynamically

I have a Bitmap image that i want to load dynamically. But I am unable to load it. CBitmap bmp; bmp.LoadBitmap("c:\aeimg"); it does not seem to be working. Can someone please help me. Thanks. ...

What's the difference between ON_NOTIFY, ON_CONTROL, ON_CONTROL_REFLECT?

I always struggle to keep all these macros straight in my head. Is there an easy way to remember them, and which to use in a given scenario? Specifically, does one of these allow a dialog to intercept/detect messages to child control windows? e.g Can the dialog register an interest when IDC_MY_CONTROL gets a WM_PAINT message? ...

Intercept pasting to a (rich) edit control

I want to override the default behavior when text is pasted into a rich edit control. Specifically, I want to paste plain-text, not formatted rich-text. I guess that boils down to getting the data as a different clipboard format, but I don't know how to intercept the default behavior first. For reference, I basically have: class MyDial...

Silverlight ActiveX in MFC

Hi, I'm wondering if anyone has any ideas as to how I can host the Silverlight ActiveX control in an MFC application. I have been able to find information on this online, but everything that I have found is related to ATL or C# and so far I have been unable to translate any of this into my MFC application: Silverlight Alternative Hosti...