Too small confirm dialog when delete from FTP

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

Post Reply
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Too small confirm dialog when delete from FTP

Post by *MVV »

Delete from FTP dialog is too small to keep long filename in different languages.

Image: http://gora.7zsfx.info/test/before.PNG

I think dialog should be resized to keep more lines (at least 4-5) or maybe even auto-resize should be implemented in order to set label/dialog height according to text length. It may be done easilly sinse Delphi already supports auto-resizing for labels:

Manually (we have own code that resizes dialog and moves controls):

Code: Select all

  with CheckMsgBox do begin
    W_InfoText.AutoSize := False;
    W_InfoText.Caption := MessageText;
    W_InfoText.Width := 345;
    W_InfoText.AutoSize := True;
    CheckBox1.Top := W_InfoText.Top + W_InfoText.Height + 21;
    Button1.Top := CheckBox1.Top + 18;
    Button2.Top := CheckBox1.Top + 18;
    Height := CheckBox1.Top + 69;
    ShowModal;
  end;
Using VCL aligning (we just resize dialog and VCL does the rest; checkbox and buttons should be placed into a panel with Align=alBottom and their coordinates should be adjusted due to relative coordinates):

Code: Select all

  with CheckMsgBox do begin
    W_InfoText.AutoSize := False;
    W_InfoText.Caption := MessageText;
    W_InfoText.Width := 345;
    W_InfoText.AutoSize := True;
    Height := W_InfoText.Top + W_InfoText.Height + 90;
    ShowModal;
  end;
So checkbox and buttons will always be below the label and dialog will have correct size. Test project is here.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I will check whether I can make it resizable.
Author of Total Commander
https://www.ghisler.com
User avatar
gora
Junior Member
Junior Member
Posts: 87
Joined: 2010-12-17, 10:37 UTC
Location: Russian

Post by *gora »

In RC3, it looks like this: http://gora.7zsfx.info/test/ftp_del.PNG
Filename: USB_Safely_Remove_x86_x64_v5.1.3.1186_sl2p_120530_11-05_1234567890.7z
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, the height now expanded to the needed number of lines. The width will not be adjusted because it could go over the entire screen width with very long names.

Moving to forum "will not be changed".
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Thanks, dialog with resizeable height looks much better:) and it's a pity that Delphi doesn't wrap very long label lines.
User avatar
MaxX
Power Member
Power Member
Posts: 1175
Joined: 2012-03-23, 18:15 UTC
Location: UA

Post by *MaxX »

2ghisler(Author)
So, may be you can do the size of this window 150% wider (and, if needed, 1-2 lines higher)?
Or, just make this window resizeable?
Ukrainian Total Commander Translator. Feedback and discuss.
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

I think best solution is to learn TC labels to split long filenames to multiple lines in such way:

Code: Select all

"USB_Safely_Remove_x86_x64_v5.1.3.1186_sl2p_120530_11-05_123
4567890.7z"
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Actually it should already split it - I'm using DrawTextW - but strangely it only wraps at spaces in the name. :(

Maybe it's because I have set the WordWrap option?

Anyway, I could limit the dialog box width, to, say, twice the current width, or the screen width, whichever is smaller?
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

As I see, the only wrap feature for DrawText[W] is word wrap so function doesn't allow to auto-wrap long words. I think best way is to use own smart DrawText function that splits long words into multiple ones (e.g. by splitting line onto multiple lines and using DrawText for each of them) but this way may be slow and/or hard. You can try to detect where to break line by calculating draw rectangle w/o actual drawing, this will require multiple DrawText calls so will slow drawing down. Or maybe you can draw entire line into private context with large width and then simply copy its parts into your label's rectangle, one part per line. Part width may be same as label's width (e.g. text needs 1000x20 px, and you draw it onto 5 lines by parts 200x20 px) or nearest that include integral character - first one may split characters but it is fast (in fact, so fast as usual double-buffering). Anyway sometimes it is better than to see only a part of a filename.

Currently that dialog is not resizeable, but if you convert it to resizeable one you can add WM_GETMINMAXINFO message handler to set max allowed width (AFAIK newer Delphi versions support it via VCL directly but it is not so hard to write such handler manually).

If you want to auto-adjust dialog width (w/o making it resizeable) it will be hard because you need to detect when it is necessary, and it will be better to wrap long words in such case.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

For now I will just resize it to the necessary width, limited by the current screen width. Trying to implement my own word wrap would be difficult without a dictionary for all the supported languages, and that would be really overkill.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

How will you determine necessary width? Or you want to display filename on a single line?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50541
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I'm using DrawTextW already, with DT_CALCRECT parameter, it returns new height and width. I only used the height so far.
Author of Total Commander
https://www.ghisler.com
Post Reply