Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 RichEdit in a COM server is not being correctly created


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.

    Download FixedRichEdit.pas

    Sample Code

    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.

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use