Article View: borland.public.cppbuilder.nativeapi
Article #3993Re: Length of text in MessageBox function
From: Richard Casten
Date: Thu, 30 Mar 2006 16:03
Date: Thu, 30 Mar 2006 16:03
40 lines
2393 bytes
2393 bytes
I realized I was using the position of the window within the parent window to
specify my drawing. I have now corrected it to this:
LRESULT CALLBACK new_window_proc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM
lParam)
{
char *second_line = "Second line of error";
RECT rect;
HDC hdc;
HFONT fnt,old_fnt;
int diff;
if(uMsg == WM_PAINT)
{
CallWindowProc(old_window_proc,hwnd,uMsg,wParam,lParam);
hdc = GetDC(hwnd);
GetWindowRect(hwnd,&rect);
diff = rect.bottom - rect.top;
rect.top = diff/2;
rect.bottom = diff + 1;
rect.left = 0;
rect.right = rect.right - rect.left + 1;
SetBkMode(hdc, TRANSPARENT);
fnt = GetStockObject(SYSTEM_FONT);
old_fnt = SelectObject(hdc,fnt);
DrawText(hdc,second_line,strlen(second_line),&rect,
DT_SINGLELINE | DT_BOTTOM | DT_INTERNAL);
SelectObject(hdc,old_fnt);
ReleaseDC(hwnd,hdc);
SetWindowLong(hwnd,GWL_WNDPROC,(LONG)old_window_proc);
return(0);
}
return(CallWindowProc(old_window_proc,hwnd,uMsg,wParam,lParam));
}
The second line is displayed but with a much larger font. How do I use the same
size font as the MessageBox font?
Technical Details
Message-ID:
<442C0153.352A598@aero.org>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4422D533.32E31292@aero.org> <4422ea15$1@newsgroups.borland.com> <4422FA56.83B7F39@aero.org> <442319ab@newsgroups.borland.com> <442ADEA7.B11F561C@aero.org> <442af3e1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b8d4aea1a094904b X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <442C0153.352A598@aero.org> Date: Thu, 30 Mar 2006 08:03:31 -0800 From: Richard Casten <richard.casten@aero.org> X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Length of text in MessageBox function References: <4422D533.32E31292@aero.org> <4422ea15$1@newsgroups.borland.com> <4422FA56.83B7F39@aero.org> <442319ab@newsgroups.borland.com> <442ADEA7.B11F561C@aero.org> <442af3e1$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 130.221.27.185 X-Trace: newsgroups.borland.com 1143734507 130.221.27.185 (30 Mar 2006 08:01:47 -0700) Lines: 41 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail