mfc

Is setting parent for a window from different process correct?

I have two applications having two different top level windows: App1 -- Window1 App2 -- Window2 Now, I am creating a Dialog Dlg1 in App1 and I want to set window2(App2) as a parent window. ( That is because I want my Dlg1 to come on top of Window2 ). I created the dialog by setting Window2 as parent. It worked. But is it the correct ...

Convert a modeless dialog to modal at runtime

I have a dialog (CDialog derived class) that can be used in two different ways (edition mode and programming mode). When the dialog is open to be used in programming mode it is a modeless dialog that it is used for modifying the main view (kind of a toolbar). When it is open in edition mode the user can change the configuration of the d...

Error in CFont?

Hi All, I have a property grid on the right side of my app. By clicking on a tree item on the left side, properties of the clicked item are shown on the right side. However, whenever I change the value on the property grid control, the items turn in BOLD format and I get an error pointing to line 154 of MFC's afxpropertygridtooltipctrl....

Drawing transparent/alpha images using CxImage

I am trying to draw a transparent (alpha) PNG image using CxImage, but it seems I'm missing some obvious step... The code so far is: CxImage image(m_pImage, m_lSize, CXIMAGE_FORMAT_UNKNOWN); CRect rcOut = rc; rcOut.left = (rc.Width()/2) - (image.GetWidth()/2); rcOut.right = rcOut.left + image.GetWidth(); rcOut.top = (rc.Height()/2) - (...

MFC CEdit Ctrl Question

I have a CEdit control that I want to be able to take time input from. Now I want this input to come in the form hh:mm:ss. Currently I am using a separate CEdit control for hour, mins, & secs. I know I could require the user enter in colons to separate hours, mins, secs, but this I believe will get confusing for my users. I actually...

How to take output from .NET executable and convey to MFC application ?

I have a dialog based MFC application through which I have to call a .NET executable. My question are: How will the MFC application know that the .NET executable is closed? if suppose a .Net executable process some information and want to convey the output to the MFC application, how can this be achieved. Please help!! ...

MFC Tabbed Documents - how to enable middle-mouse button to close document?

If you create a new MFC application (with MFC Feature Pack), and using all the defaults, click Finish. It creates an MDI application with the new "Tabbed Documents" style. I think these are great except it really annoys me that I can't close a Tabbed Document window by middle-clicking on the tab. This is possible in Firefox, IE, Chro...

How can I get an HDC object from a CDC object?

I have an object, dc, of type CDC and I'd like to get an HDC object. I read the MSDN documentation here, but don't really understand it. Can someone provide me with a brief example/explanation on how to do this? ...

Why does the original CString get overwritten when passing a copy to the DrawText function with the DT_MODIFYSTRING option?

I've already found a workaround to this problem, but was just wondering if anyone knew what was actually happening to cause the problem I was seeing. My guess is that it has something to do with mutability of strings, but I thought the CString object accounted for that in the copy constructor. The following code causes mFileName to be ...

Where is the memory leak in this C++?

I have been told be a couple of tools that the following code is leaking memory, but we can't for the life of us see where: HRESULT CDatabaseValues::GetCStringField(ADODB::_RecordsetPtr& aRecordset, CString& strFieldValue, const char* strFieldName, const bool& bNullAllowed) { HRESULT hr = E_FAIL; try { CO...

CDialog not main frame descendant

Is there a way to make a dialog (CDialog) not descendant of the main frame? If I don't specify a parent window at creation time the parent window is the main application window. I have tried to use SetOwner and SetParent with a NULL parameter but didn't work. So is there any way to make a dialog not child of the main window or any othe...

How to show available windows in the Window menu

I have a MFC MDI application that I've recently ported from VS2003 to VS2008, and at the same time moved from Stingray Objective Studio 2006 v2 to v10.1. On the previous versions of my application, if I had more than one view open, the Window menu would be populated by an enumerated list of available views, e.g. 1 MyViewA, 2 MyViewB etc...

How to know a certain disk's format(is FAT32 or NTFS)

I am programing under windows, c++, mfc How can I know disk's format by path such as "c:\". Does windows provide such APIs? ...

Using CreateCompatibleDC with mapping modes other than MM_TEXT

I have a visual C++ application that uses a CView derived class to render its display, which is primarily 3d vector data and true type text. The mapping mode used is either MM_ANISOTROPIC or MM_LOMETRIC. I can't use MM_TEXT as I use the same code for printing and plotting of the data and also have to overcome non-square screen pixel is...

Scrolling Dialog in MFC on Win CE / Windows Mobile

Hi, I'm building a dialog based Windows Mobile application. My main container dialog has a tab control which alternates between different child dialogs (as separate tab sheets). As I have limited display real-estate I need my dialogs to scroll vertically. Following some online example, I added a vertical scroll bar, and the appropriate...

Wait Until Event Occurs

Hey, I'm doing sockets programming. Pretty much new to it. The application is a Windows Service, in its ServiceMain() function I call CAsyncSocket's Listen() method, to listen for client connections. But after it starts listening for connections, it'll return and the ServiceMain() function will return and the service is stopped. What I...

How can I provide access to this buffer with CSingleLock?

I have these two methods for thread-exclusive access to a CMyBuffer object: Header: class CSomeClass { //... public: CMyBuffer & LockBuffer(); void ReleaseBuffer(); private: CMyBuffer m_buffer; CCriticalSection m_bufferLock; //... } Implementation: CMyBuffer & CSomeClass::LockBuffer() { m_bufferLock.Lock(); ...

Catching a WM_NOTIFY message from a custom ListCtrl

My application is c++, and is a combination of MFC and ATL. The part I'm working with here is MFC. I have a custom list control class in one of my dialogs which inherits from CListCtrl. I'm trying to add a handler for the LVN_ITEMCHANGED message so I can update the rest of the dialog form, which is dependant on the contents of the list...

C++ unit testing with Microsoft MFC

Hey all, I'm trying to convince my organization to start running unit tests on our C++ code. This is a two-part question: Any tips on convincing my employer that unit testing saves money in the long run? (They have a hard time justifying the immediate expenses.) I'm not familiar with any C++ testing frameworks that integrate well with...

Intercepting mouse clicks when the mouse is hovering above a control

I'm working on a MFC C++ dialog where I need to respond to right mouse click events for a dialog even if the mouse is hovering over a control. I could write event handler code for each control to delegate the work to the parent dialog, but I'm hoping there is a more elegant solution? I'm hoping there is some way to intercept the window...