2

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.

Uli Gerhardt
  • 13,748
  • 1
  • 45
  • 83
  • What have you tried yourself so far? Is `TaskDialog` mandatory or may `TaskDialogIndirect` also be okay? Would you also accept `MessageBox`? Would `SetWindowsHookEx( WH_CBT ... )` be okay? – AmigoJack Sep 23 '20 at 20:35
  • I've just used plain TaskDialogIndirect (in a wrapper) up to now, because I've no clue how to proceed. I'd rather stay with task dialogs. The issue is not important enough for hooking and other advanced "tricks". – Uli Gerhardt Sep 24 '20 at 09:10

1 Answers1

0

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.

AmigoJack
  • 5,234
  • 1
  • 15
  • 31