mfc

Find text autoscroll in MFC CRichEditView

I have an application with a CRichEditView, and I'd like to find text in it. By creating a menu item "Find" with ID_EDIT_FIND, the view opens the find window and text is found by highlighting. BUT... the view is not scrolled, so if a text is found 100 lines below visible, that's where it stays. Ideas on how to make the control autoscroll...

Is is possible to replace the memory allocator in a debug build of an MFC application?

Background: I'd like to make use of Electric Fence in an MFC application. I'd like to track new/delete, and if I can track malloc/free that's an added bonus. Unfortunately, MFC redefines new and delete - but using macros (DEBUG_NEW) - so I can't use the standard C++ method of redefining them. (MFC defines them to have different signatur...

Why is my MFC DLL deadlocking on a single thread near startup?

Using Visual Studio 2005, the debugger tells me that a deadlock has occurred just after startup of the app I'm writing - I'm well in to WinMain() at this point. The callstack shows that we are in a critical section, while calling AFX_MANAGE_STATE2 (for the 666th time, spookily enough) from within an MFC DLL. This has just started happe...

Quickest (Easiest) GUI MFC or C# or QT or ?

I have just finished my first real commercial application written in C++ / MFC. The application consisted of agent installed on users workstations which in turn was controlled from a GUI Application on an administrators workstation. I choose C++ / MFC for these reasons. Because I didn't know C# Because I was not sure how long it w...

Does anybody know any troubles with deploying Visual C++ library using XCopy?

We need to deploy Visual C++ library. We have tried deploy this libraries using Merge Modules, but uninstall became too slow (about 10-20 minutes). So we've decided to deploy this libraries using XCopy method. Does anybody know any troubles with deploying Visual C++ library using XCopy? ...

Why paint messages get lost even after calling UpdateWindow() ?

I have an application with following windows hierarchy: W1 -W2 (Child of W1) - W3 ( Child of W2) --------------------| | W1|------------| | | |W2 |------| | | | | |W3 | | | | | |------| | | | |------------| | |-------------------| When certain event happens in W2, I call UpdateWindow: W2::onCertainEvent()...

Can't get OnContextMenu to work for custom CListCtl class.

I am trying to get a context menu to work for a CListCtrl derived class. I just created a method OnContextMenu, but it isn't being called. What am I missing? I am using Visual Studio 2008, to create a CDialog based MFC application. customlist.h class tcCustomListCtl : public CListCtl { DECLARE_DYNAMIC(tcCustomListCtl) public:...

Win32API: How to determine if EN_CHANGE was because of user action, not software action?

I find this situation comes up from time to time, and I never seem to have a really robust generic solution to it. I have a control - in this example an EDIT control on a dialog. I want to take certain actions in response to the user - and only the user - modifying the contents of the edit control. The edit control can be set programm...

Win32API: How to request embedded windows event notifications out to a parent window

Scenario: I would like a window control which is a sub-window in my dialog (a subwindow of a subwindow) to propagate its notification messages out to the dialog window. e.g. A COMBOBOX contains an EDIT control. I have a circumstance where I would really like to know when the EDIT field gains and loses focus (mainly because the stupid CO...

Manual alternative to message map?

I am trying to create a GUI to display information read from a file. So I will need some number of pushbuttons, text fields, and radio buttons - but I won't know how many I need until run-time. I am using Visual Studio 6.0. My toolset is fairly non-negotiable, so please refrain from suggesting Java, or any C++ toolkit that does not co...

Launching external exe in MFC, how can I bring exe to front if already opened?

I have to open up a external program in my MFC application, which works but if I have already clicked button, I don't want it to open another instance but just bring it to front. The docs say the SW_SHOWNORMAL parameter does this, but it is not working for me. Does the called program have to setup for this also? ShellExecute(NULL, "op...

What is the best way to split up utility functions in a library to maximize reusability?

I have a recurring problem with a statically linked library I've written (or in some cases, code was accumulated from open sources). This library, MFC Toolbox Library by name, has a lot of free functions, classes, and so on which support MFC programming, Win32 API programming, as well as the venerable C-library and newer C++ standard li...

Any language binding for MFC ?

THere are a lot of wrappers for toolkits like Qt, Cocoa or WxWidgets for D, Python, Ruby and other languages. I wonder if anyone has ever written a binding for MFC ? ...

How to avoid using a button in an MFC application?

Hi! This is my first my MFC application, and unfortunately i don't understand, how it works. I found a simple MFC application, which gets the file list of a given path. I modifyed this code for my needs, but now i have one problem. What my application should do is the following. It reads two drive letters from a file. Then gets the file...

Is there any problem calling ::AfxInitRichEdit2 multiple times?

You have to call this before using CRichEditCtrl in a MFC C++ application, and one obvious way is to put it in the application startup code. However I was thinking about including it in a custom control which subclasses CRichEditCtrl, so that an application doesn't have to remember to make this change. Is there any potential reason cal...

Why is VC++ Resource Editor not putting auto-generated code in the right place?

In MyControl.h I have: class CMyControl: public CRichEditCtrl { DECLARE_DYNAMIC( CMyControl) public: CMyControl(); virtual ~CMyControl(); public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMyControl) //}}AFX_VIRTUAL // Generated message map functions protected: //{...

How do I make an MFC control register for its own messages/events?

I am working on a class derived from CRichEditCtrl. I want an instance of my class to know: Update: solved it now. when it has been Created (i.e the HWND is non-null) when it gains/loses focus when the text changes when the selection changes when a right-click has happened (I'm guessing through EN_MSGFILTER) For 1, I found that over...

Something preventing default (explorer-style) CListCtrl jump to line behaviour

I'm maintaining an MFC/COM/ATL 45-odd project solution originally written with VS6. I'm now using VS2008. I'm looking at a list control(vanilla CListCtrl) which doesn't behave as we think it should. Normally in an MFC list control you can press a key, (Q say) & selection will jump down to the 1st line beginning with 'Q' (like windows ex...

Using a CListCtrl, how can I make selection color entire row?

I currently have NM_CUSTOMDRAW message calling a function to color the rows of a listctrl in report mode. I can detect when a row is selected and color it myself, but this method doesn't get called for the cell that is selected, so I can't color that cell. So my question is 1) is there a way to have windows call my custom draw method f...

How does a CRichEditCtrl know a paste operation has been performed?

It has methods like CRichEditCtrl::Copy(), CRichEditCtrl::Paste() which you can call, but I can't spot any messages the control is sent by Windows telling it to perform a paste operation. Does anyone know if such a thing exists? Or does CRichEditCtrl do something lower-level like monitoring WM_CHAR events? If so can I reuse any internal ...