mfc

COM interface disappears from ROT

I have two applications, both of which I have written. AppA was written in C++ using MFC. During startup it registers a CSingleDocTemplate and creates a document. The document provides a COM interface and registers itself in the ROT: LPUNKNOWN punk = GetInterface(&IID_Welder); // doesn't AddRef ::RegisterActiveObject(punk, CLSID_Int...

Hitting Escape versus Enter triggering LVN_ENDLABELEDIT in CListCtrl

how can I differentiate between the two, when the edit field is empty in both cases? when the user hits escape, I assume user doesn't want the new value at all, when enter is hit, I assume the user wants an empty string for the edited item... ...

draw on child canvas

Create an SDI application that incorporates the following object hierarchy. CVeiw<-(Class derived from CWnd) • The CWnd class should response to all size notifications and resize accordingly. It should maximize itself to utilise the entire client area. • The class should be able to support the following interfaces. • ShowRectangle() - A...

Why am I not getting events for a checkbox click in a treeview control?

In my MFC dialog, i have a tree view control with checkboxes. Clicking the checkbox does not raise the NM_CLICK nor the TVN_SELCHANGED events, which I had hoped it would do. How do I correctly determine when a checkbox is checked/unchecked in a tree view control? ...

how to show the device keyboard using C++ MFC for Windows CE device?

Hi, How to show the device keyboard using C++ MFC for Windows CE/Windows Mobile device to type in? thanks ...

Default proxy credentials with native c++

In .NET you have the handy System.Net.CredentialCache.DefaultCredentials to set all your needed proxy data to the default values of the system. How can i do something similar in native C++? I need the proxy address, username and password. Our project uses MFC and cURL ...

Hints to speed up mobile debugging with Visual Studio 2008 C++

I'm debugging a C++ MFC Windows mobile 6 application using Visual Studio 2008 across a USB ActiveSync link. It works ok, but it is very slow. e.g. Adding a new watch for an integer vairable takes ~20 secs. Task manager shows devenv.exe as using 50% CPU at this time, e.g. all cycles on one core, so the problem appears to be CPU bound r...

Help with InternetOpenUrl and InternetReadFile in <WinInet.h> API

I am trying to simply access a page using the WinInet APIs. Once I access it, I'd like to be able to read the contents into a string. I've already initialized the root node. Here's what I got so far: HINTERNET hChildURL = InternetOpenUrl(hInternetRoot, LPCTSTR(CString("http://www.google.com/")), ...

How do I put a checkmark on a menu item that has submenu items. (Visual studio 2008 C++/MFC)

I have a menu that contains submenus. eg: Item1 Item2 Item3 item A Item B Item3 has items under it. At any given time 1, 2, or the items under 3 should be checked. Since I don't have an ID for Item3 I have to use the MF_BYPOSITION indicator when I try to set a check on Item3 to indicate one of its children has a checkmark. Item...

item size not adjusted after font change in CTreeCtrl

Hi, I change the font of tree items in CTreeCtrl with the following code: void CTreeCtrlEx::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVCUSTOMDRAW pNMCD = reinterpret_cast<LPNMTVCUSTOMDRAW>(pNMHDR); *pResult = 0; switch(pNMCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: *pResult = CDRF_NOTIF...

Why does CCmdUI::Enable disable a button after I enable it with CWnd::EnableWindow?

My job requires me to maintain some old MFC programs, and I've been asked to add a CButton to an existing dialog. Even though my code calls CWnd::EnableWindow to enable the button, CCmdUI::Enable disables it. Here is part of the stack trace at the moment CWnd::Enable disables the button. mfc90d.dll!CWnd::EnableWindow() mfc90d.dll!CCmd...

Adding Member variable of check box in MFC Ribbon

hi i added a check box with resourceman in MFC Ribbon (in VS-2010), but i cant create a member variable for it in CMainFrame because "Add Variable..." button is disabled in "Class Wizard" what can i do for adding this variable? and how can i access to the created variable in a document ...

convert CString to CTime

In smart device MFC application: I have successfully converted CTime to CString. Now I want to convert it back, CString to CTime. How can I do that? ...

catch exception in mfc callback function

I'm using vc2008, writing some MFC code, I add a button, double click it, and vc2008 automatically create a callback function for me, and my code is like this: void CDeviceTesterDlg::OnBnClickedButton1() { try { .... } catch (std::exception &e) { .... }; } the problem is, I need place this ugly code in ever...

How to save datetime in EDB database

I want to save datetime into the EDB database. I tried storing the value by converting CTime to CString. But after reading not able to convert CString to Ctime. Ask the same question on stackoverflow, yet no responses. Here are EDB database datatypes. Can I use CEVT_FILETIME? If possible please give me an example. ...

How to Check if a website contains Flash.

I've created a web browser using mfc and i'm using IHhmlReader to read the contents of html when the user enters a url in the browser and page is completely loaded.Now i want to check if the webpage has any flash in it. Any Helps would be highly appreciated. Thank You. ...

Add automation support to MFC DLL

Is there a way to add automation to an existing MFC dll? I know I can create a new project and select Automation during the wizard, but I already have a dll with ATL support which exposes a number of COM objects so I'd rather update that than have to recreated it. ...

problem returning CArray

Hi, I am trying to return CArray from a function and trying to call the function from another class short ListMaker::RetArray(CString szName, CArray<CString, CString&> &szarr_Names) { szarr_Names.Add(szName); return 0; } //////////// main() { .. CArray<CString, CString&> myArray; ListMaker LM; short nCode = LM.Re...

Lock file but allow usage by current process?

I want to be able to lock a file in Win32 so that it can only be used by my current process. The most obvious way to accomplish that seemed to be via CreateFile: HANDLE file = ::CreateFile("c:\\foo.txt", GENERIC_READ | GENERIC_WRITE, 0, NULL, ...

How can I add a watermark or png or bitmap to the background of a CTreeCtrl?

I would like to have a background image for a list control (CTreeCtrl). Is this possible and how can I do it? (This is for a Visual Studio 2008 C++ mfc app) ...