mfc

How to make your MFC application bypass UAC in windows7 and Vista

I have an MFC application developed in VS Studio 2008 which reads and writes to a JSON file in its installation folder. It works perfectly in vista(administrator) BUT ONLY when UAC is turned off. When UAC is ON, the application isn't able to write to its JSON file. I figured I had to create a manifest file but I haven't really tried crea...

What's the correct way to create a subclass of a MFC control?

We layout dialogs using the resource editor. So say I have a RichEditCtrl called IDC_RICH. And I want to link it to an instance of a custom class CMyRichEditCtrl : CRichEditCtrl, without losing the ability to set properties on it in resource editor. What's the right way? You can certainly get some functionality by creating a DDX-linked ...

Problem inheriting member functions with similar signatures in C++

I have an MFC C++ program that contains two classes, as follows; struct MyStruct { ' ' }; class Class1 { public: virtual MyStruct *MyFunc(LPCTSTR x); virtual void MyFunc(MyStruct *x); ' ' }; class Class2 : public Class1 { public: virtual void MyFunc(MyStruct *x); ' ' }; main() { ' ' CString Str = _T("WTF"); Class2 a; ...

Setting CTreeCtrl item's checkbox to partial state

First I add TVS_EX_PARTIALCHECKBOXES to the CTreeCtrl's extended styles: TreeView_SetExtendedStyle(tree->GetSafeHwnd(), TVS_EX_PARTIALCHECKBOXES, TVS_EX_PARTIALCHECKBOXES); Now how do I actually set any item to this state? There doesn't appear to be any documentation about that. I guessed that since checking and unchecking works by ch...

Does MFC provide a quick way to throw text on the clipboard?

The add-to-clip-board code we have in our code base is quite low-level - allocating global memory and so on. For the simple case I just want to put some plain text on the clipboard, are there any routines which can wrap all that stuff? An example is that CRichEditCtrl has Copy() & Cut() methods which automatically put the current select...

How to limit number of characters typed in a textbox in MFC?

hello all, I have 2 questions...my 1st question is how do I limit the number of character typed in a textbox in MFC..say if I want the user to type only 4 characters..the text box should take only 4 character.And my 2nd question is when it exceeds the character limit it should jump to the next textbox/tab control.I tried using the...

Simple way to set font type in MFC CListBox

I have always used the default ListBox control with the property of OWNER DRAW set to NO. But now I need to set a fixed sized mono font since my formatted strings are not aligning up even though I have the default right aligned and necessary width padding set beyond the actual size of the digit string. My problem is I don't have a clu...

'MINMAXINFO' : undeclared identifier in MFC application

hi I tried to use MINMAXINFO to resize the window dynamically in MFC application (in VS 2008). i added OnGetMinMaxInfo function through properties window. When i compile the code, i get an error saying that 'ON_WM_GETMINMAXINFO': identifier not found 'MINMAXINFO' : undeclared identifier Please help me to resolve this. Regards, AH ...

Is MFC still used for new development (with any material volume)?

I've never been a big fan of MFC, but that's not really the point. I read that Microsoft is due to release a new version of MFC in 2010 and it really struck me as odd - I thought MFC was dead (no ill intention, I really did). Is is MFC used for new developments? If so, whats the benefit? I couldn't imagine it having any benefit over som...

How do you inherit from CObject and compile successfully?

I am trying to inherit CObject but am failing to do so. My class looks like this: class CCanMessage : public CObject { public: CCanMessage(void); ~CCanMessage(void); unsigned int m_id; //can-id CANMessageTypes m_msgType; //this is an enum unsigned char m_len; char *m_pCmdStr; }; The constructor an...

How to display a non-modal CDialog?

Can someone say me how I could do a No Modal Dialog in MFC's Visual c++ 6.0 for show it? I wrote this, CDialog dialog; if (dialog.init(initialization values...)) dialog.DoModal(); But it blocks my application for show the dialog. I dont know if exists any method or other way to do. Thanks ...

Error loading type library/DLL

When I use the following code I get an compilation error #import <dwmapi.lib> #include <dwmapi.h> I get the following error: fatal error C1083: Cannot open type library file: 'c:\program files\microsoft sdks\windows\v7.0a\lib\dwmapi.lib': Error loading type library/DLL. Intellisense says: 2 IntelliSense: cannot open ...

Converting from MFC dialog units to pixels

Using C#, how would I convert from dialog units (used in resource files to specify height/width) to pixels? ...

After casting pParam, why do I get random characters back?

Hi! This is the first time that i want to use threads, so i don't understand them fully for now. I have two structures: struct ddata //difference content { char *filename; char *size; }; struct ddata *difference = (struct ddata *) malloc( dif * sizeof *difference ); struct test { struct ddata* difference; int diff; ...

Linker fails to link my application (XXXX already defined in XXXX.obj)

When I try to build my application the linker gives loads of errors like this one: modlauch.obj : error LNK2005: "public: virtual __thiscall lolbutton::~lolbutton(void)" (??1lolbutton@@UAE@XZ) already defined in lolbutton.obj I suspect it has something to do with misconfigured compiler but I don't know how to fix it. My cla...

MFC Drawing Lines

Hi, I draw some lines on a SDI application in visual c++, these lines are disappeared whenenver a new line or the size of the windo is changed, any clue how to keep these lines visible all the time? thanks. RZ ...

How to insert colored text int a ListView?

Hi! I have a listview with 3 coloumns. The first two columns has values and the third one is empty yet. I want to know, how can i insert a colored text later into the third column? I don't want to color the full row, only the third column with changing colors. Thanks in advance! kampi ...

How to pass generated image/bitmap/GDI objects to other process?

I have a process A that generates HBITMAP GDI objects to be painted on the screen. I have another process B which wants to display the content of images that process A creates. I plan to do the communications/talking using Point-to-Point message queue or by using other message passing; and use shared memory (along with mutex and or even...

How to Place DialogBar or Dialog box into pane in vc 2008 or vc 2010 Beta

Hi now i am working in 2003 vc++ and i am converting(migrating) my project in to vc 2008 or new vc 2010 Beta,i saw the feature pack of 2008,2010 regards CDockable Pane(Auto Hode,floating),so i require this features ,i want to place a dialogbox or dialog bar into pane(CDockable Pane class), so i done this in my following code Myframe Cod...

How to compile MFC code in visual stdio 2008 with code analyser

I need to run code analyser for my MFC code in VS 2008. I enabled code analysis in following path: project properties -> configuration properties -> Advanced. When I tried to compile, I got the following error unable to find DLL: 'mspft80.dll' How can I resolve this? ...