1

Does anyone know why my dynamically created CEdit is not animated like a CEdit control created in the dialog editor?

When hovering with the cursor over the control, the color of the frame does not change (In normal case the gray color changes slightly) - When Selected, the color of the frame does not change either (should be blue).

CRect staticEditRect = CRect();
m_ctrlEditStatic.GetWindowRect(&staticEditRect);
ScreenToClient(&staticEditRect);

// offset position
CONST INT defaultPosVertSpace = 7;
staticEditRect.OffsetRect(0, staticEditRect.Height() + defaultPosVertSpace);

// create dynamic Edit 
CEdit* ctrlEditDynamic = new CEdit;
ctrlEditDynamic->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, staticEditRect, this, IDC_EDIT_NEW_DYNAMIC);
ctrlEditDynamic->SetFont(m_ctrlEditStatic.GetFont());

Here is an example of what it usually looks like: Blue border while focused

And here is a screenshot of what my CEdit Control looks like: My CEdit control (Nothing happend)

My goal was to add, depending on the case, dynamic CEdit controls that look exactly like the original (say size, appearance, behavior...). I have already tried a few things, but can't find the damn reason.

Can someone help me with this?

ALex3Fuu
  • 11
  • 1
  • 1
    Have you [enabled Visual Styles](https://learn.microsoft.com/en-us/windows/win32/controls/cookbook-overview)? – IInspectable Sep 09 '21 at 08:48
  • maybe this helps: https://stackoverflow.com/questions/59995885/mfc-how-to-set-the-focus-of-cedit-boxes – dorKKnight Sep 09 '21 at 09:08
  • @IInspectable Do I need this? The other control is also without "in style". Besides, I only want the default style and it is not a custom control. Is there a simple function with which I can set/activate the default "visual style"? Thanks – ALex3Fuu Sep 09 '21 at 10:18
  • I just provided you with a link that explains how to enable the default visual style, that was introduced in Windows Vista. – IInspectable Sep 09 '21 at 10:56

0 Answers0