Microsoft KB Archive/138419

{|
 * width="100%"|

PRB: Edit Control Margins too Large in Windows 95

 * }

Q138419

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), used with:
 * Microsoft Windows 95

-

SYMPTOMS
After you change the font in an edit control in Windows 95, the left and right margins are unusually large.

CAUSE
When the edit control receives the WM_SETFONT message, it calculates the left and right margins based on the average character width of the new font. The control does not do this when it is created. This results in the margins changing drastically when the font is changed.

RESOLUTION
Get the margins of the edit control before sending the WM_SETFONT message, and then set the margins back to their original sizes. The following code fragment demonstrates how to do this:

  { DWORD dwMargins;

dwMargins = SendDlgItemMessage( hWnd,                                    IDC_EDIT,                                    EM_GETMARGINS,                                    0,                                    0);

SendDlgItemMessage( hWnd,                        IDC_EDIT,                        WM_SETFONT,                        (WPARAM),                        0);

SendDlgItemMessage( hWnd,                        IDC_EDIT,                        EM_SETMARGINS,                        EC_LEFTMARGIN | EC_RIGHTMARGIN,                        MAKELPARAM(LOWORD(dwMargins), HIWORD(dwMargins)));

}

STATUS
This problem has been fixed in Windows 95 OSR2 and later versions.

Additional query words:

Keywords : _IK kbCtrl kbEditCtrl kbGrpDSUser kbOSWin95bug kbOSWin95fix

Issue type : kbprb

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch