The height of the edit file name in more than 7.56a

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

Fine, oversized edits are history with beta 8. But maybe they are a little too tight now. Combo height minus its edit height is always 6px here, but your rename edit is text height + 4px. Are you substracting those 2px intentionally?

And about vertical position of rename edit, the text is still moved down by 1px compared to original text in list. I know it's been like this before, but since now the rename edit height is result of precise calculation, it should also be possible to set the right position to prevent "jumping" text. It would be exactly the list text position minus half of border sum, so currently 2px (4/2) or 3px (6/2) if you used my suggestion.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Fine, oversized edits are history with beta 8. But maybe they are a little too tight now. Combo height minus its edit height is always 6px here, but your rename edit is text height + 4px. Are you substracting those 2px intentionally?
Strange, I just checked my code, and I'm actually substracting 4 pixels! Why do you get 2?

Here is what I'm using right now:

Code: Select all

  oldfont:=selectobject(dc,ListsFont);
  gettextmetrics(dc,@tm);
  newheight:=tm.tmheight;
  selectobject(dc,oldfont);

   getwindowrect(CmdLine.handle,r2);
   getwindowrect(GetComboEdit(CmdLine.handle),r3);
   newheight:=newheight+(r2.bottom-r2.top)-(r3.bottom-r3.top);
    if is_nt95 then dec(newheight,4);  // <- was remaining from older version
The problem: when I leave out the dec(newheight,4); completely, then the edit control is actually two pixels too high! With 4 or 2 substracted it's just right. I have no idea what could be wrong. Do I need to substract the font external leading value?
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

It should work without any corrections (substracting anything):

http://web.hisoftware.cz/sob/img/tc-rename-edit-height.png

RenameEdit is mine (height is computed using the actual command line combo from TC's window), the second edit with "TC 8.0b8" text is captured in-place rename edit from TC and it's always lower by 2px.

The strange thing is, I don't see any differences compared to your code. To check where the numbers differ, font settings for screenshots are Microsoft Sans Serif 8 bold for WinXP and Segoe UI 9 regular for Win7 (for both window and list fonts).

Code: Select all

function GetEditTextHeight(Edit: TEdit): Integer;
var
  Metrics: TTextMetric;
  hObject: THandle;
  DC: HDC;
begin
  DC:=GetDC(Edit.Handle);
  hObject:=SelectObject(DC, Edit.Font.Handle);
  GetTextMetrics(DC, Metrics);
  SelectObject(DC, hOBject);
  ReleaseDC(0, DC);
  Result:=Metrics.tmHeight;
end;

procedure TForm1.Test(ch: THandle); // ch = Combo handle
var
  eh: THandle;
  cr, er: TRect;
  t: Integer;
begin
  eh:=GetWindow(ch, GW_CHILD);
  GetWindowRect(ch, cr);
  GetWindowRect(eh, er);
  t:=GetEditTextHeight(RenameEdit);
  Memo1.Lines.Add('Combo height = '+IntToStr(cr.Bottom-cr.Top));
  Memo1.Lines.Add('Combo edit height = '+IntToStr(er.Bottom-er.Top));
  Memo1.Lines.Add('Borders = '+IntToStr((cr.Bottom-cr.Top)-(er.Bottom-er.Top)));
  Memo1.Lines.Add('RenameEdit text height = '+IntToStr(t));
  Memo1.Lines.Add('New RenameEdit height = '+IntToStr(t+(cr.Bottom-cr.Top)-(er.Bottom-er.Top)));
  RenameEdit.Height:=t+(cr.Bottom-cr.Top)-(er.Bottom-er.Top);
  RenameEdit.SelectAll;
end;
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry, no idea - I'm using Micorosoft Sans Serif, Bold too.

tmheight is 13, and (r2.bottom-r2.top)-(r3.bottom-r3.top) is 6.

Which values do you get?
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

As seen in image in previous post (bottom part where Microsoft Sans Serif is used), we have exactly the same values, 13 for text height and 6 for borders.

And then comes the difference. I take 13 + 6 = 19, use if for rename edit height and get edit 19px high. You have 13 + 6 - 4 = 15 and the actual height of edit shown by TC comes to 17px. It looks like it's hitting some minimum height limit, because 17px is the smallest edit height for the text to be completely visible.

You wrote that when you leave out dec(newheight,4), the edit is too high. Is it really higher than "RenameEdit" in my image? It would be possible to see even without precise measuring, the text would no longer be centered vertically, but instead more to the top.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

You wrote that when you leave out dec(newheight,4), the edit is too high. Is it really higher than "RenameEdit" in my image?
Yes it is!

How do you set the height? I'm using the Delphi/Lazarus properties (Top and Height).
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

Yes, nothing special, just setting Height. I'm not doing anything with Top, but it influences only position not height. And the number I set Height to is the exact height in pixels I get. I just checked it again in Lazarus and Delphi 5, same results in both. Only other thing I must change is AutoSize property to False (and only in Lazarus, Delphi doesn't seem to care much), because when it's True, edit's height is font height + 8. But you can't have AutoSize:=True either, because it would not allow font height + 4 high edit that I see in TC.

That might be an interesting question for anyone who watches this thread and cares at least a little. Do you see what I see? Check the screenshot four posts back. Edits with text "TC 8.0b8" are screen captures of TC's in-place rename edits and they have:

- 1px border and 1px padding (same color as background of inner part) with themes enabled
- 2px border (consisting of two colors) and no padding (selected text touches the border) with themes disabled (Classic style)

Edits with text "RenameEdit" are IMHO better sized:

- 1px border and 2px padding with themes enabled
- 2px border and 1px padding with themes disabled
User avatar
gora
Junior Member
Junior Member
Posts: 87
Joined: 2010-12-17, 10:37 UTC
Location: Russian

Post by *gora »

The bug has appeared again. :(

TC8b9 x64, Win7 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I haven't changed it, I have no idea what is wrong (see discussion above). :(
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 »

2ghisler(Author)
In version 8 all was normal for me. Return as was in version 8, please.
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

ghisler(Author)
But something must have been changed, because 8.0β8 showed the correct rename box height, and in β9 x64 it's increased again; the same wincmd.ini is used. 32-bit versions of 8.0β8 and 8.0β9 look identical.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

8.0β8 showed the correct rename box height
???

SOB writes in the post above:
But maybe they are a little too tight now.
I had this code in beta 8 remaining from a previous version:

Code: Select all

if is_nt95 then dec(newheight,4);
I removed that completely in beta 9 64-bit. I beta 9 32-bit, I changed it to

Code: Select all

if is_nt95 then dec(newheight,2);
So in TC beta 9 64-bit, height is set exactly to font height + 6, while in TC 32-bit, it's set to font height +4, and in beta 8 32+64bit, it's set to font height + 2.

Now it's up to you to decide which is the best solution...
Author of Total Commander
https://www.ghisler.com
User avatar
Flint
Power Member
Power Member
Posts: 3487
Joined: 2003-10-27, 09:25 UTC
Location: Antalya, Turkey
Contact:

Post by *Flint »

ghisler(Author)
The discussion was a little tricky to follow because of different fonts and other conditions, but from my point of view the progress looked like this:
0) I'm using the default font (Micsoroft Sans Serif), Win7 x64, Aero theme.
1) In 8.0β5 and below in x64 the rename box was higher than in x32; I posted a number of screenshots here: http://ghisler.ch/board/viewtopic.php?p=231342#231342
2) In 8.0β6 this problem was fixed: x64 version decreased the height of the box, so that the height became identical in versions x64 and x32.
3) Other users claimed a different problem, reproducable both in 32- and 64-bit versions (and even in 7.56a) that the rename box height was inconsistent (but identical!).
4) Now, in 8.0β9 the difference between x32 and x64 behaviour returned back, and again, like in old β5, the rename box in 64-bit is higher than in 32-bit.

So, to me the change in β9 looks just a regression, a rollback of all the good fixes back to β5 times…
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 10.52 / Win10 x64
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

See my message aboce yours - I have made two different changes for 32-bit and 64-bit because I don't know which is better - it's up to you to decide.
Author of Total Commander
https://www.ghisler.com
Sob
Power Member
Power Member
Posts: 941
Joined: 2005-01-19, 17:33 UTC

Post by *Sob »

I'm really sorry if I made Mr. Ghisler break it for other people, but honestly, I don't get it, it doesn't make any sense. If my observation was based only on one system, I'd say I have it broken. But I have consistent results with several different systems, some of them even clean installs with no settings changed. Strange.
ghisler(Author) wrote:So in TC beta 9 64-bit, height is set exactly to font height + 6, while in TC 32-bit, it's set to font height +4, and in beta 8 32+64bit, it's set to font height + 2.
I get FH+8 (too high) in beta 9 64-bit, FH+6 (perfect) in beta 9 32-bit and FH+4 (too low) in beta 8 both versions. And btw, if you think about it, FH+2 in beta 8 would mean edit only 2px higher than included text, so only single pixel for each border...

I'll prepare some test for anyone interested to try.
Post Reply