Message from discussion
Access font on edit control
Received: by 10.66.75.7 with SMTP id y7mr1506206pav.12.1343290125844;
Thu, 26 Jul 2012 01:08:45 -0700 (PDT)
Received: by 10.180.105.38 with SMTP id gj6mr1098247wib.0.1343290052451;
Thu, 26 Jul 2012 01:07:32 -0700 (PDT)
Path: c10ni36323pbw.0!nntp.google.com!news2.google.com!7no17173179wig.0!news-out.google.com!q11ni70969026wiw.1!nntp.google.com!goblin1!goblin3!goblin.stu.neva.ru!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From: Christian ASTOR <casto...@club-internet.fr>
Newsgroups: comp.os.ms-windows.programmer.win32
Subject: Re: Access font on edit control
Date: Thu, 26 Jul 2012 10:07:17 +0200
Organization: Aioe.org NNTP Server
Lines: 35
Message-ID: <juqts1$aes$1@speranza.aioe.org>
References: <7cc3a2b3-4daf-4935-a5e1-7fc8d15918e1@w24g2000vby.googlegroups.com> <jul0cp$p6a$1@speranza.aioe.org> <10bc306c-4928-49c7-a05d-c9e7d728ea62@q2g2000vbv.googlegroups.com> <junsjk$aus$1@speranza.aioe.org> <0107afac-c278-41c8-81f5-936d1511285b@k21g2000vbj.googlegroups.com>
NNTP-Posting-Host: 62pblPOAhMj1LXsgcbwtLw.user.speranza.aioe.org
Mime-Version: 1.0
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120715 Firefox/14.0.1 SeaMonkey/2.11
X-Notice: Filtered by postfilter v. 0.8.2
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Paul N a �crit :
> Could you show me how you are getting the DC to use in GetTextMetrics,
> please?
Nothing special, just GetDC(), and I get same results than calling it on
main window =>
In Main window WM_CREATE :
LOGFONT lf = { 0 };
SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &lf,
FALSE);
hFont = CreateFontIndirect(&lf);
SendMessage(hEdit, WM_SETFONT, (WPARAM) hFont, FALSE);
OldEditProc = SetWindowLong(hEdit, GWL_WNDPROC,(LONG)(WNDPROC)NewEditProc);
PostMessage(hEdit, WM_USER, (WPARAM) hFont, FALSE);
in NewEditProc :
case WM_USER:
{
TEXTMETRIC tm;
HDC hdc = GetDC(hWnd);
HFONT hFontOld = (HFONT)SelectObject(hdc, hFont);
GetTextMetrics(hdc, &tm);
int halfwidth = tm.tmMaxCharWidth / 2;
SelectObject(hdc, hFontOld);
ReleaseDC(hWnd, hdc);
}
break;