Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Dec : EM_SETRECT Win 9x strange behavior

www.cryer.info
Managed Newsgroup Archive

EM_SETRECT Win 9x strange behavior

Subject:EM_SETRECT Win 9x strange behavior
Posted by:"Michael Purcell" (mpurce..@alltel.net)
Date:Sat, 23 Dec 2006 13:30:38

Originally developed this program in D2, released in 2001. Now
preparing an updated version in D2005.

The main window uses a richedit to display some text. It uses the
following procedure to set the margins of the edit window.

procedure TMainForm.SetEditRect;
var
  R: TRect;
begin
  R := MainRichEdit.ClientRect;
  InflateRect(R, -20, -18);
  SendMessage(MainRichEdit.Handle, EM_SETRECT, 0, Longint(@R));
end;

This procedure is called from the LoadDocument procedure that loads
the text into the edit window, from the FormResize event, and a few
other places.

When the program starts, SetEditRect gets called from the LoadDocument
procedure, and a registry RestoreFormPosition procedure also triggers
the FormResize event, which calls it a second time.

The original program works as expected on all platforms. The new
version of the program works as expected on XP, but on Win 9x when the
program first starts, the text displays in the edit window without
margins. The margins subsequently get set correctly when a new
document is loaded or the window is resized. The lack of margin only
happens on startup on win 9x

I'm guessing that something is the D2005 vcl has changed and now
blocks the SendMessage() call somehow on win 9x. I have access to
machines with 98se and one with 95 which I can use for testing, but I
can't load D2005 on them to debug this, if D2005 would even run. So
I'm at a loss to figure out how to fix it.

Thanks,
Michael

Replies:

www.cryer.info
Managed Newsgroup Archive