mfc

Calling a second dialog from a dialog window fails to make either one active

Sorry for stupid questions, I'm doing everything as described in this tutorial: http://www.functionx.com/visualc/howto/calldlgfromdlg.htm I create the dialog window and try to call another dialog in response to a button press using the following code: CSecondDlg Dlg; Dlg.DoModal(); Modal window appears but isn't active, and main wind...

MFC application to be responsive in the face of an event flood

I have a legacy C++, MFC application, currently compiling in VS2005. It has several socket connections, as well as a user GUI. The sockets are terminated in non-MFC threads, some work is done in those background threads, then a message is posted to the MFC main queue so the main application can take notice and do the appropriate action...

how to restrict copy paste in a Textbox, in MFC?

hello friends,I am developing a small application in MFC... there is a little problem..hope you guys would help me regarding this...Here we go..the problem is...I have 6 little edit control(Text box) in which I will allow the user to enter some numbers..I have limited the number of chars/textbox as 4 but its allowing the user to copy and...

Not able to read the contents in the file in MFC using the function Cfile?

Hello friends,,I am not able to read the contents in the file if I manually write something in the file...If there are contents existing already am able to read the contents...but if I go and manually write something in the file and try to read I am not able to read the contents that I have edited..check the code below that I am using to...

Custom MFC control contains another control - messages not getting through

I have a custom CWnd-derived MFC control, which works like this: the control has its own OnPaint, and a black background clicking anywhere on the control causes an edit control to appear at that location, borderless and with black-background, so it blends in the user types in this box and hits enter, the box disappears and the control'...

UTF-8, CString and CFile? (C++, MFC)

Hello! I'm currently working on a MFC program that specifically has to work with UTF-8. At some point, I have to write UTF-8 data into a file; to do that, I'm using CFiles and CStrings. When I get to write utf-8 (russian characters, to be more precise) data into a file, the output looks like Ðàñïå÷àòàíî: Ñèñòåìà Ïðîèçâîäñòâî and et...

A single MFC/Win32 control seems to be making my whole desktop repaint

I have a custom control, which owns an edit box and moves it around, etc. The edit-box is typically modified with a wodge of code like this: edit.MoveWindow( &rc ); edit.SetWindowText( text ); edit.SetLimitText( N ); edit.ShowWindow(SW_SHOW); edit.SetFocus(); edit.SetSel(0, CB_ERR); RECT rc is in coordinates local to the custom contro...

Dependency difference between Release & Debug

I'm trying to write a rather simple ActiveX using c++ code. Problem is that Release binary has dependency at MFC90.DLL and MSVCR90.DLL which does not apear at the Debug. How to attack this?? ...

Only include certain items in CComboBox type ahead?

I have a dropdown-list style CComboBox on a form. The nice thing about this style is it allows for type ahead--that is, you can type a character and it will jump to the first item in the list matching that character. However, there are certain items which need to be excluded from this behavior. How might this be accomplished? ...

Safely calling strftime with untrusted format string

We have a C++/MFC application which allows users to customize date formatting via configuration files. Not wanting to reinvent the wheel, I pass the format string to CTime::Format("< format string >") to do the actual formatting. Under the covers, Format calls a variant of the standard C function strftime(). Naturally, the user can ac...

Disabling Dialog Controls MFC

Hi, How do I disable all the controls in a dialog window ? I know I could use EnableWindow(FALSE); but this doesnt seem like a good idea because now there is no way for the user to click "Ok" or "Cancel" button or press the "X" icon to exit. The dialog is like frozen. What I am looking for is a way to disable all the controls in a di...

CRichEditCtrl::GetSelText() is not working right

MFC File: winctrl4.cpp (C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc) CString CRichEditCtrl::GetSelText() const { ASSERT(::IsWindow(m_hWnd)); CHARRANGE cr; cr.cpMin = cr.cpMax = 0; ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); CStringA strText; LPSTR lpsz=strText.GetBufferSetLength((cr.cpMa...

With an ActiveX control in an browser window container, how do I detect when user changes tab away from activex control

I have an ActiveX control that gets placed in an IE browser container. The control creates another dialog window that has WS_POPUP and WS_LAYERED properties enabled in order to be able to use SetLayeredWindowAttributes(...) function to accomplish color keyed transparency and alpha blending on top of the control. Because the WS_LAYERE...

Why does my application freeze when I copy a large file?

I have an MFC application. It is basically just copying files from one drive to another. When I'm copying large files (more than 1 Gb) and I click on my window, my application freezes, but the copying proceeds in the background. Someone told me that I have to use a worker thread. I used it, but it still freezes. When I'm copying small fi...

How to use correctly CopyFileEx and CopyProgressRoutine functions?

Hi! I made an application which copies files, usually large files. I want to show the progress of the copying, but i can't it bring to work. Can someone tell me what i am doing wrong? Now it works very interesting. The % goes to 49% than, back to 0, and then to 40, then again back to 0 and then back 35, and this goes on, untill it copi...

MFC Dynamic Text Control?

What MFC control should I use and how should I use it to display constantly changing text (like progress text) on a dialog? For example, should I use the static text control? But can you change it programmatically? ...

Setting Resized bitmap file to an MFC Picture Control

Is there an easier way to do it than this, and if this is the only way, are there any potential memory leaks here? CImage img1; int dimx = 100, dimy = 100; img1.Load(filename); //filename = path on local system to the bitmap CDC *screenDC = GetDC(); CDC *pMDC = new CDC; pMDC->CreateCompatibleDC(scree...

What if I don't call ReleaseBuffer after GetBuffer?

From http://stackoverflow.com/questions/559483/cstring-to-char, ReleaseBuffer() must be used after GetBuffer(). But why? What will happen if I don't use ReleaseBuffer after GetBuffer()? Can somebody show me an example? Thanks. ...

Why is my subclassed window not visible?

I'm following mcdave's advice from http://stackoverflow.com/questions/2191637 and using SubclassWindpow to host a CIPAddressCtrl in a winforms app. My constructor looks like this: IPAddressBox::IPAddressBox(void) { // I have tried it with and without this part INITCOMMONCONTROLSEX icc; icc.dwICC = ICC_INTERNET_CLASSES; ...

Equivalent to MFC CInternetSession in Java?

Hello. I'm in the process of migrating some of our old code into Java and have become stumped on connecting to (what I believe are) MFC ASP ports. In the old code this was done via CInternetSession, but I'm uncertain of what the Java equivalent would be. As an example, the old code had the following: CInternetSession sess; pHttpConn...