The MASM Forum

General => The Campus => Topic started by: jj2007 on November 24, 2014, 10:15:05 AM

Title: Displaying a chess board: WM_SETFONT & WM_ERASEBKGND problems
Post by: jj2007 on November 24, 2014, 10:15:05 AM
While playing with a proggie to display a chess board, I stumbled over two things:

1. In the main WndProc, a big font is created and selected via WM_SETFONT. It displays fine in the edit control. However, the DC obtained in the subclass for WM_ERASEBKGND seems to use another font; only when using ...
  CASE WM_ERASEBKGND
   invoke SelectObject, wParam, hFont
... results become meaningful.

2. In the edit subclass, WM_ERASEBKGND doesn't get triggered when the user edits text. Is there a default/recommended way to redraw the background?

(source attached in *asc = RTF format. Line 125 defines the Board$)
Title: Re: Displaying a chess board: WM_SETFONT & WM_ERASEBKGND problems
Post by: jj2007 on November 25, 2014, 04:40:36 AM
No replies?

Re the font issue: that seems badly documented, but apparently the OS uses the "good" DC with the font selected by the WM_SETFONT message during WM_PAINT, but during WM_ERASEBKGND the SYSTEM_FIXED_FONT is selected. Most probably, it's a feature :greensml:
Title: Re: Displaying a chess board: WM_SETFONT & WM_ERASEBKGND problems
Post by: Gunther on November 25, 2014, 04:53:08 AM
Jochen,

displays the chess board without the black basic row.

Gunther
Title: Re: Displaying a chess board: WM_SETFONT & WM_ERASEBKGND problems
Post by: jj2007 on November 25, 2014, 06:08:40 AM
Quote from: Gunther on November 25, 2014, 04:53:08 AMdisplays the chess board without the black basic row.

Gunther,
Enlarging it a few pixels downwards should display the last row, too. I've not yet worked on the details, at present I only wanted to understand this DC issue.
Title: Re: Displaying a chess board: WM_SETFONT & WM_ERASEBKGND problems
Post by: Gunther on November 25, 2014, 06:30:39 AM
Quote from: jj2007 on November 25, 2014, 06:08:40 AM
Enlarging it a few pixels downwards should display the last row, too. I've not yet worked on the details, at present I only wanted to understand this DC issue.

yes, that works and brings by the way another false positive by Avira.

Gunther