mfc

MFC/OLE Drag & Drop - freeing Globally allocated memory

If using COleDataSource & COleDataObject, you allocate some global memory for each clipboard data format you wish to store data in the drag'n'drop operation. In the drop code, you query if the object has data in the format(s) you want and can then access & free that memory. But as a drop-target you can't know all the formats that might ...

MFC: Displaying a tabulated display of text items

This should be simple it seems but I can't quite get it to work. I want a control (I guess CListBox or CListCtrl) which displays text strings in a nice tabulated way. As items are added, they should be added along a row until that row is full, and then start a new row. Like typing in your wordprocessor - when the line is full, items sta...

How to code a responsive progress bar that uses callback functions?

I have this progress bar that uses callback functions from a third party driver, to display a traditional progress bar in a window called CFProgress. CFProgress *cFM=new CFProgress(); theApp.m_cFM = cFM; cFM->Create(CFProgress::IDD); cFM->ShowWindow(SW_SHOW); thirdpartydriver->set_OnProgress(ProgressFuncC, (void *) cFM); thirdpartydrive...

Help please: No BN_CLICKED for custom radio button (MFC, VC++6)

Hi, I have derived a CButton class and created my own radion button control. Its all working nicely with the exception that I can't get the parent dialog to detect when the radio button it clicked. The parent dialog will detect the radio button click if I call CButton::OnLButtonUp() but the problem in doing that is that the framework al...

How do you handle with field/property level security?

When you bind properties to a view how do you handle the properties visibility and edibility for users and object state? I have seen several examples of using an authorized attribute on the poco's property. But this does not seem flexible. The best that I could come up with was to store this display information in a dictionary the vi...

Bold labels in MFC

I want to create labels in MFC (Static text) that have both bold and non-bold text. Something like this: "I would like my label to look like this, for example" Any thoughts of how to do this? I know that I can change the font of the entire label and have it either bold or not, but is there any way of merging more than one style, o...

How can save Application Settings in the Registry via MFC?

Hi, I have a MFC application created by the MFC Project Wizard. I wanted to save/read application settings in the registry and so asked this question to find a C++ Registry wrapper as the Windows API is very messy. However, I have now heard that the MFC provides a way to do this. Is this true? If so, how can I read/write values, see whe...

Controlling width/layout in CListCtrl (Icon view)

Apart from the fact I still can't see why this class fills columns and scrolls horizontally, rather than filling rows and scrolling vertically, I'm confused how the width of items is controlled. I'm seeing quite a lot of padding (50-80 pixels) between the longest item in a column and the next column which means wasted space. Is it contr...

How to debug/track when a dialog is invalidated?

Hi, My MFC application has a CView and a couple of floating non-modal dialogs. I am currently trying to figure why an invalidation/repaint of my view also causes the dialogs to be redrawn. This even happens if the dialogs are not overlapping with the view. Does anybody know how to debug/track who request a specific dialog redraw? Inter...

Listbox width size dependent of text length

My application has a window with a ListBox inside which is filled with text that changes over time, therefore Listbox entries can have several length. I'd like to make the window and the listbox width to change dynamically dependent on the listbox entries length (in number of characters). As an example, if my listbox has several entri...

how to hook control closing in an MFC custom control class

I am interested in allocating pointers, storing those in the LPARAM data of a comboboxex control, and making that control responsible for deleting those pointers when it is destroyed. Since I am working in MFC, I can subclass a CComboBoxEx, and add either a message handler or a virtual member function. The question is: Is this pattern ...

How to dock CPaneDialog to MainFrm and.. ?

Hello, I have problem with CPaneDialog. I tested with SetPaneSize MFC feature pack sample projects. What is weird is that CPaneDialog can't be docked to MainFrm while CDockablePane can be. The CPaneDialog is also a child class of the CDockablePane, but it can't be. Only DockToWindow( &other_CPaneDialog_instance... ) is possible. If I ca...

Deserialize Bitmap from Archive

Hello, everyone! I've got a problem with my MFC app. When I'm trying to deserialize CBitmap from the archive and create new CBitmap, it doesn't properly load CBitmap's bits. Here's the code: BITMAP bm; ar >> bm.bmType; ar >> bm.bmWidth; ar >> bm.bmHeight; ar >> bm.bmWidthBytes; ar >> bm.bmPlanes; ar >> bm.bmBitsPixel; int nSize = bm.b...

Unicode / Non-Unicode / UTF-8 Problems

An application I am working on stores data in an INI file. The application creates the INI file which in turn will be read by another application we also created. The INI file may also be hand edited. It is likely sooner or later that the INI file will contain different languages so we were careful to ensure that all data used in thi...

How to make CFileDialog synchronize the displayed filename with the selected extension?

We have a class that derives from CFileDialog that overrides the OnTypeChange() method to allow it to change the filename to keep it in synch with the selected extension whenever the user selects a new extension from the filter combobox. (Our filters are set to contain only one extension per filter entry.) Unfortunately, the way we are d...

How to get List of free port number in VC++?

How to get List of free port number in VC++? Aslo i want to check wether user define port number is free or not ? ...

Confused about CWnd::OnLButtonDown() and CTreeCtrl::OnLButtonDown()

MFC Library Reference CWnd::OnLButtonDown void CMyCla::OnLButtonDown(UINT nFlags, CPoint point) { CWnd::OnLButtonDown(nFlags, point); } void CMyTreeCla::OnLButtonDown(UINT nFlags, CPoint point) { CTreeCtrl::OnLButtonDown(nFlags, point); } I know the inheritance. class CTreeCtrl : public CWnd { ...... } Is there any clea...

What is going on at the top of this function

I'm currently looking at a function example that I can't seem to figure out using MFC in Visual C++. The function is as follows CMFC_OSG_MDIView::CMFC_OSG_MDIView() :mOSG(0L) { } I understand everything here except the mOSG(0L) snippet. mOSG was declared in the MFC_OSG _MDIView class as follows: cOSG* mOSG; Any help is greatly appr...

MFC's GetClientRect and MoveWindow don't preserve size?

I'm using MFC for Visual Studio 2003. I have an Edit Control with ID IDC_COMMENT_EDIT. In the following code, after my first call to GetClientRect, I don't expect the value of rc to change. CWnd* pWnd = GetDlgItem(IDC_COMMENT_EDIT); if (pWnd != NULL) { RECT rc; pWnd->GetClientRect(&rc); pWnd->MoveWindow(&rc, TRUE); pWnd->GetClie...

Windows.h error

I am getting error : WINDOWS.H already included. MFC apps must not #include <windows.h> Help needed. ...