TOpenDialog: can't change dialog Title property lazarus / 31-LCL ---------------------------------------------------------------------- zoltanleo · 2021-08-11 22:10 Hi folks. I am trying to programmatically change TOpenDialog.Title. This doesn't work  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  with oDlg do  begin    Filter:= 'Item_1|*.q|Item_2|*.w|Item_3|*.e';    Execute;  end; end; procedure TForm1.oDlgTypeChange(Sender: TObject);begin  case oDlg.FilterIndex of    1: oDlg.Title:= 'Item_1';    2: oDlg.Title:= 'Item_2';    3: oDlg.Title:= 'Item_3';  end;end; It's a bug? ---------------------------------------------------------------------- wp · 2021-08-11 22:41 Is this on Windows? Your project shows the same issue. But it seems to be necessary to change the Title before opening the dialog. ---------------------------------------------------------------------- jamie · 2021-08-12 00:30 it can be fixed. The call back procedure for the dialog needs log the Dialog Handle somewhere when the WM_INITDIALOG message is received.  It appears the handle that is there now is not the actual handle to the dialog window. In any case later at some point when the caption needs to be changed it can thus use this handle with the SetWindowTExtW  I suppose the Title property could be a littler smarter in determining what needs to be changed at the time. ---------------------------------------------------------------------- zoltanleo · 2021-08-12 05:26 Quote from: wp on August 12, 2021, 12:41:24 amIs this on Windows? Your project shows the same issue. But it seems to be necessary to change the Title before opening the dialog. This is true for Linux as well (I think it will be true for Darwin as well). If it is not possible to change the title in the OnTypeChange event, then I do not see any other practical use of this event. Quote from: jamie on August 12, 2021, 02:30:31 amit can be fixed. I suppose the Title property could be a littler smarter in determining what needs to be changed at the time. I think so too. Can you create a ticket in the tracker? ---------------------------------------------------------------------- jamie · 2021-08-12 21:01 QuoteThis is true for Linux as well (I think it will be true for Darwin as well).  if I understand you correctly, this request does not work on other targets either ? If that is the case then this is going to turn into a bigger problem to make it work for all targets with a simple patch ---------------------------------------------------------------------- jamie · 2021-08-12 22:12 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.OpenDialog1TypeChange(Sender: TObject);Var  S:WideString;  H:Thandle;begin  H := GetForeGroundWindow; { include the Windows unit}  S := 'The type has been changed to :';  Case OpenDialog1.FilterIndex of   1:S:=S+'Item1 1';   2:S:=S+'Item  2';   3:s:=S+'Item  3';   else S := S+'Default';  End;  SetwindowTextW(H, PWChar(S));end;                            This seems to work for a windows target. ---------------------------------------------------------------------- zoltanleo · 2021-08-15 19:46 Hi jamie Thanks for the answer. This code works perfect, but only for Windows. I need a cross platform solution ---------------------------------------------------------------------- jamie · 2021-08-15 20:20 I don't do cross targets, i do windows only currently.. Looking at the LCLIntf and Lmessages unit, it appears the SetWindowText and LM_SetText do not exist! But it has GetForeGroundWindow, go figure..  Must be some limitation with the widget..