Does RecreateWnd do anything? lazarus / 7-LCL ---------------------------------------------------------------------- Phil · 2006-02-22 23:34 I'm porting some controls that call RecreateWnd, for example when setting the border style (bsNone, bsSingle). Nothing happens when RecreateWnd is called when compiled with Laz, but it works when compiled with Delphi. The control's Style value is the same with both Laz and Delphi (set in CreateParams). Note I changed the call to RecreateWnd(Self). I notice that RecreateWnd isn't called in very many places in the LCL and the few places where it is called it's marked "//TODO: Remove RecreateWnd". Is there something else to use instead of RecreateWnd when control properties change? Or is there something I don't know about how this differs from Delphi's? Thanks. ---------------------------------------------------------------------- mattias · 2006-02-22 23:58 See the note in RecreateWnd. In other words: RecreatWnd destroys and creates a handle, which is a quite expensive action. Most widgetssets do not need that, but can change nearly any property without recreating. That's why the LCL avoids calling RecreateWnd and instead calls the widgetset, which can do that if needed. This is hardly done. BorderStyle is a special property. I guess, this is one of the special properties, that needs a RecreateWnd under gtk and carbon and maybe under win32 too. Keep in mind, that not all BorderStyle FormStyle combinations are available under all platforms. Please give a small example, so we know, from what combination you are switching to what. ---------------------------------------------------------------------- Vincent Snijders · 2006-02-22 23:59 RecreateWnd should be called from the WidgetSet interface implementors (i.e. the sources below lcl\interfaces). Recreating a windows is a costly process, and if setting a property requires recreating its handle may be different depending on the widgetset. I don't think (but I am not sure), that anything is done with CreateParams call. So, if you set the border style of a control, but it is not updated, then that is a bug in the interface. ---------------------------------------------------------------------- Marc · 2006-02-23 10:08 A nice example of why the decision to recreate a window has to be made by the widgetset are the columns of a listview. On win32 you have to add/remove the columns after you have created the listview widget. On gtk you need to specify the amount of columns when creating a widget. So in this case in one situation the widget needs to be recreated and in the other not. The LCL cannot know this, the widgetset does. That is why RecreateWnd is "removed", to trigger "bad" delphi based behaviour. ---------------------------------------------------------------------- Phil · 2006-02-24 22:19 Thanks for the discussion. That got me looking elsewhere for a way to draw a border. The control I'm porting introduces a BorderStyle property and implements it by OR-ing WS_BORDER with the Style parameter in its CreateParams method. CreateParams is apparently called as a result of RecreateWnd, but if the interface code isn't doing anything with Style, then that would explain why no border. I discovered that LCL's TWinControl includes a BorderStyle property, whereas VCL's does not. Calling inherited SetBorderStyle in the control's CreateParams method adds the border. Here's another question: The control's Anchors settings include akRight, but resizing the form horizontally doesn't resize the control. I assume the anchoring behavior is implemented at the TControl level as in Delphi, but something isn't working here. Any ideas? Thanks again. ---------------------------------------------------------------------- mattias · 2006-02-28 10:53 Anchors work. Please provide an example.