I have a RichEdit control in my COM Server application that uses the tmFree threading model for COM objects, and the RichEdit control is not being created. How can I get around this?
This is related to a bug in the VCL for Delphi 5 and you can click here to read more about it. (It is also mentioned in the readme file for Delphi 5).
One possible workaround given was to override CreateParams for a TRichEdit and add the ES_EX_NOCALLOLEINIT style to it. However, this may not always work. Another possible solution is to capture the WM_NCCREATE message and set the proper params at that point. Below is a component that will do that for you.
unit FixedRichEdit; interface uses Windows, Messages, Classes, Controls, RichEdit, ComCtrls; type TFixedRichEdit = class(TRichEdit) protected procedure WMNCCreate(var message: TWMNCCreate); message WM_NCCREATE; end; procedure Register; implementation procedure TFixedRichEdit.WMNCCreate(var message: TWMNCCreate); var gwlEx : Longint; begin gwlEx := GetWindowLong(WindowHandle, GWL_EXSTYLE); gwlEx := gwlEx or ES_EX_NOCALLOLEINIT; message.CreateStruct^.dwExStyle := gwlEx; inherited; end; procedure Register; begin RegisterComponents('Samples', [TFixedRichEdit]); end; end.
Last Modified: 05-APR-00