mfc

CAsyncSocket::Close Crashes

Hey, im doing some client/server stuff in a windows service. Pretty much new to this stuff. The problem I'm encountering is that when I try to stop the service through Service Manager, it crashes. I added some MessageBoxes code, to trace where they are crashing and I found that when it closes the listener socket it crashes!!! I tried t...

#define _AFX_NO_DEBUG_CRT causes a stream of compilation errors

I have an MFC C++ project compiler under Visual Studio 2008. I'm adding a _AFX_NO_DEBUG_CRT in my stdafx.h before the #include to avoid all the debug new and deletes that MFC provides (I wish to provide my own for better cross platform compatibility). However when I do this I get a stream of errors such as the following: >c:\progra...

why message box is always hidden behind main dialog and cannot be shown on the top

I am using MFC to write a GUI application. I chose dialog-based application, and put picture control, edit box and buttons on it. When the picture control is mapped to the class derived from CWnd using DDX_Control, all the message boxes (including default system message box pop up when you enter invalid input in the edit box) are hidden...

AfxGetAppName() returns garbage characters

I have the following line of code in my application: CString strAppName = AfxGetAppName(); Sometimes it fills strAppName up with garbage characters, and I can't figure out why. Anyone have any ideas? TIA. ...

How to verify if a window of another program is minimized?

How can I do this? I've tried IsWindowVisible() but that doesn't seem to do the job. ...

Is there a way to verify that the current window of another program is totally visible?

Is there any function, or I'll have to iterate through all windows that are in front of mine and detect if they overlap my window? Thanks ...

DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR When, How and Why?

Hello I found that Windows has some new Windows Data Types DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR, ULONG_PTR can you tell me when, how and why to use them? ...

How to send a notification that's handled by ON_NOTIFY?

I'm trying to post a LVN_ ITEMCHANGED to my custom gridlist's owner. I know how to send a WM_ User message using PostMessage (as shown here) ::PostMessage( AfxGetMainWnd()->GetSafeHwnd(), WM_REFRESH, (WPARAM)pBuffer, (LPARAM)GetOutputIdx() ); When I use this same code to send a LVN_ITEMCHANGED message though, ::PostMessage( AfxGetMa...

CListCtrl WM_TIMER event ids 42 and 43?

I have a CListCtrl derived class that provides subitem editing by creating a CEdit starting at the correct offset of the subitem. Sometimes the subitem is only partially visible so I scroll the CListCtrl to the offset location to gain more space for the CEdit. Now something very weird happens: On Windows Vista and Windows 7 the CListCtr...

How to use CWnd::CreateEx

I was using CreateEx( 0, className, "XXX", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0); in Visual C++ 6.0. when i port the same to VS 2008.., its giving an error message saying that.. error C2664: 'BOOL CWnd::CreateEx(DWORD,LPCTSTR,LPCTSTR,DWORD,const RECT &,CWnd *,UINT,LPVOID)' : cannot ...

MFC versions

what is the version of MFC in VC++ 6.0,vc++ 2003,vc++ 2005 and vc++ 2008 ? i faced this question in interview but i could not reply? so any body tell me the versions of MFC. ...

Why aren't my CTreeCtrl checkboxes checking?

I've got a MFC CTreeCtrl stuck in a dialog with the TVS_CHECKBOXES style turned on. I get checkboxes next to all my tree items fine. In OnInitDialog I set the checked state of some of the items using CTreeCtrl::SetCheck but none of the items in the tree are checked when the tree is displayed. SetCheck is returning TRUE. Checking items wi...

Why is CMFCMenuBar not utilizing the accelerator table?

In a doc/view project using VS2008, a MFCMenuBar seems to load the correct MENU resource (IDR_MAINFRAME) from the project, since adding and removing menu items is reflected in the menu's UI. It even appends the accelerators to the default menu items (e.g. Ctrl+O to the Open... item). However, the accelerator table (IDR_MAINFRAME) doesn...

"Is there a better way?" Error 12029 with wininet on Windows Vista

I kept recieving error 12029 (ERROR INTERNET CANNOT CONNECT, The attempt to connect to the server failed.) when using the the MFC wininet classes on Windows Vista. The cause of the error was due to Windows Defender. Is there a better way to get around this than completely turning off Windows Defender? I tried turning off "real time pr...

How is WinForms programming in Visual C++/C# different from Windows programming in Visual C++(MFC)

How is winforms programming in visual c++/c# different from windows programming in visual c++(MFC). Also I want to know whether C# is strong enough to do Windows programming as in other than forms. ...

Print server - want to catch print command

How should i know at print server whether any client has fire any command. or any way to hook into printer driver at printing driver at server What is print server ??? How print server work in Window??? How muliple client will send request to single print server??? Is any utility is running??? Can anybody clear me on this things??? ...

Transparent window containing opaque text and buttons

I'm creating a non-intrusive popup window to notify the user when processing a time-consuming operation. At the moment I'm setting its transparency by calling SetLayeredWindowAttributes which gives me a reasonable result: However I'd like the text and close button to appear opaque (it doesn't quite look right with white text) while k...

Compiling MFC on Visual Studio 6.0

I'm painfully debugging a legacy VS 6.0 MFC app, and I'd really like to step into MFC code. Now, the code did ship with VS6, and the symbols (mfc42.pdb) too, but the debugger asserts 'Symbols loaded (source information stripped)' upon attaching. By these tips, all copies of mfc42.pdb on my machine are indeed stripped (their size i...

Detecting modal dialogs in MFC

How can I programmatically detect if my MFC application currently is displaying a modal dialog or property sheet? Currently I'm using the following, but I feel that the code also triggers for modeless dialogs. bool HasModalDialog(const CWnd* pWnd) { const CWnd* pChildWnd = pWnd ? pWnd->GetNextWindow(GW_HWNDPREV) : NULL; while (pCh...

CFileDialog :: Browse folders

Hi All, When I try to instantiat a CFileDialog object it shows both the folders and files. How do you create a CFileDialog that browses for folders alone? Thanks... ...