mfc

Why OnVScroll() method enters only once?

I design a class which derives from CScrollBar in a dialog-based MFC application. In the dialog class (MyScrollbarDlg), I set the ON_WM_VSCROLL message and declare the OnVSCroll method in the .h file. I also Implement the OnVScroll() method in the corresponding .cpp file. But to my surprise, when I click the arrow at the buttom of of the...

CTimeSpan.GetDays() and daylight savings time

I found in a bug in an old C++ MFC program we have that calculates an offset (in days) for a given date from a fixed base date. We were seeing results that were off by one for some reason, and I tracked it down to where the original programmer had used the CTimeSpan.GetDays() method. According to the documentation: Note that Daylig...

How do I sort a CArray of a user defined type?

Is there a built-in way to sort a CArray in C++? ...

MFC Panel and window handle

Is there something like a panel that I can use in a MFC application. This is to overlay the default window in MFC (a dialog application). Then to paint the panel black and paint some random stuff on top of it. Something like a view port. is there a better option than this to achieve the same effect ? ...

Direct3D MDI Project: MFC or .NET?

I'm looking at a new project where both Native and Managed approaches sound like a good idea. This is a Windows desktop application which should support an MDI interface. The client area will make extensive use of Direct3D. The developers on the project are equally skilled on C#, C++/CLI and MFC. MFC Advantages: Doc/View Architecture ...

The DrawItem() method is performed repeatedly

I used the owner-drawn strategy on CMyListBox class which derives from CListBox. I only want the DrawItem() method to perform when I insert an item in the listbox. But the method is invoked many times. How can I change to invoke it whenever I need. ...

Is there an auto-update framework for C++/Win32/MFC (like Sparkle)?

I've decided to add auto-update functionality to one of my applications and was looking for any existing solutions that compare the current running version with the latest version that is then downloaded from the web. I know Sparkle on Mac OSX which is very nice and powerful, but was wondering whether there is something similar for Win3...

CListBox's Item size changed when changing the size of the list box even if I specify the size in MeasureItem() method?

I used a class which derives from CListBox, and create it with following style:WS_CHILD|WS_VISIBLE |LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL I expect the ListBox's item to be have a fixed size, not affected by the size of the list box. So I override the MeasureItem() method, in which I specify the item's size like below: void CMyLi...

How to edit columns in-place with CListCtrl?

I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature? ...

How to programmatically activate the menu in Windows mobile

In most versions of windows, you can get to the menu by pressing the F10 key, thus avoiding having to use the mouse. This behaviour does not appear to be present in Windows Mobile 5.0, but is desirable as the device I am using will be more keyboard than touch screen driven. Is there a way of programmatically activating and using the ...

Setting command button visibility in VC++ 6.0?

How can I make the command button in my VC++ 6.0 dialog visible or invisible on load? ...

How to Convert CString and ::std::string ::std::wstring to each other?

CString is quit handy, while std::string is more compatible with stl container. I am using hash_map, however, hash_map does not support CString as key, so I wish I could convert CString into std::string, is it possible? Write a CString hash function seems take lots of time. CString ------> std::string ? how can I do? std::string -----...

[MFC] How to get On Focus CWindow handle?

Is there any way to get the handle to the control that has focus? I am looking for a way to get the ID of control on focus in my app. After that it would be easy to get the id with GetDlgCtrlID. CWnd *pwnd = GetWindowOnFocus(); int wID = pwnd->GetDlgCtrlID(); It's the GetWindowOnFocus part that I am missing! ...

MFC Event Handlers

Just wondering what the difference between MFC control messages prefixed with the following is: LVN (e.g. LVN_ITEMCHANGED) HDN (e.g. HDN_TRACK) NM (e.g. NM_HOVER) Also, I am using a ListControl and trapping when the user clicks on an item using the NM_CLICK message. I also want to trap when a user selects a new item view a key e.g. up...

How to make the group-box text background transparent

I want to make a transparent dialog. I capture the OnCtlColor message in a CDialog derived class...this is the code: HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); if(bSetBkTransparent_) { pDC->SetBkMode(TRANSPARENT); hbr = (HBRUSH)GetSto...

Can I serialize map of STL in MFC using CArchive?

I need to write the content of a map (key is ID of int, value is of self-defined struct) into a file, and load it from the file later on. Can I do it in MFC with CArchive? Thank you! ...

Higher color depth for MFC toolbar icons?

Hi all, I was wondering how to make a toolbar in MFC that used 24bit or 256 colour bitmaps rather than the horrible 16 colour ones. Can anyone point me in the direction of some simple code? Thanks ...

MFC: Capturing Resizes

Just wondering where is best to put functionality in an MFC application that is triggered when the whole window is resized. I was thinking mainfrm but I couldn't seem to capture any OnSize messages... Can someone tell me what I am doing wrong? ...

How do I decide if a selection of text in CRichEditCtrl has multiple font sizes?

Problem: How can I tell if a selection of text in the CRichEditCtrl has multiple font sizes in it? Goal: I am sort of making my own RichEdit toolbar (bold, italic, font type, font size, etc). I want to emulate what MS Word does when a selection of text has more than a single font size spanning the selection. Ex - You have a line of ...

Can CArchive read and write from a specified location of a file?

I want to serialize and deserialize a list of objects into a file. But I found that if I use CArchive, the new content will overwrite the original content in the file, which is not my expectation. Is there any method to allow me to read and write from a specified location in the file? Thank you! ...