Force English language task dialogs to be LTR on RTL systems

151 views Asked by At

We have non-localized debug TaskDialogs in English. These show up RTL on a hebrew system: Screenshot of TaskDialog

How can I force them to be shown LTR? AFAICT this would be the inverse of TDF_RTL_LAYOUT.

1

There are 1 answers

0
AmigoJack On

I couldn't fully test this (as I don't want to switch the entire system to RTL), but it should get you to a solution: if you provide a callback function you can react to the window creation and then simply modify its style. Example:

function CallbackTdi( hWindow: HWND; msg: Cardinal; wp: WPARAM; lp: LPARAM; lpRefData: Pointer ): HRESULT; stdcall;
var
  iStyle: DWord;
begin
  case msg of
    TDN_DIALOG_CONSTRUCTED: begin  // Not yet shown
      iStyle:= GetWindowLong( hWindow, GWL_EXSTYLE );  // Get existing style
      
      // Test for me: trying the opposite by forcing RTL
      //SetWindowLong( hWindow, GWL_EXSTYLE, iStyle or WS_EX_RTLREADING or WS_EX_LAYOUTRTL or WS_EX_RIGHT );

      // Test for you: trying to eliminate everything that can be RTL
      SetWindowLong( hWindow, GWL_EXSTYLE, iStyle and not (WS_EX_RTLREADING or WS_EX_LAYOUTRTL or WS_EX_RIGHT) );
    end;

    TDN_BUTTON_CLICKED: result:= S_OK;  // So the dialog closes
  end;
end;

var
  vTdc: TTaskDialogConfig;
  iButton: Integer;
begin
  ZeroMemory( @vTdc, SizeOf( vTdc ) );
  vTdc.cbSize:= SizeOf( vTdc );
  ...
  vTdc.pfCallback:= @CallbackTdi;  // Point to our callback function
  TaskDialogIndirect( @vTdc, @iButton, nil, nil );
  ...
end;

If it doesn't work right away then analyze which window styles are actually set - in case they look the same on a Hebrew system as for me (WS_EX_CONTROLPARENT or WS_EX_WINDOWEDGE or WS_EX_DLGMODALFRAME = $10101, see Extended Window Styles) we'd have to dig deeper.