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...
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...
Is there a built-in way to sort a CArray in C++?
...
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 ?
...
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
...
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.
...
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...
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...
I want to have CListCtrl.EditLabel() for any column of the list. How can I implement such a feature?
...
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 ...
How can I make the command button in my VC++ 6.0 dialog visible or invisible on load?
...
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 -----...
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!
...
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...
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...
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!
...
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
...
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?
...
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 ...
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!
...