Raised This Month: $51 Target: $400
 12% 

Alignment by columns


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2018 , 14:57   Alignment by columns
Reply With Quote #1

Hi.

Like, if I want to have 2 columns in menu with correct alignment:
Code:
AddItem("Weapon1      - 10" ...
AddItem("Weapon1345   - 20" ...
Does anybody wrote such code before, to measure the width of each font character to know how many white spaces we need to add to get correct position of 2-nd column for each separate line?

\t - tab is not working there. It has the same width as white space.

Of course, it's good to have opportunity to switch into monospace font,
but we have no such choise, AFAIK.

P.S. I don't know the name of menu items in advance, that's why I need to align that lines dynamically.
PPS. Personally, it's not hard for me to write such code, but how to measure precisely the width of each character?

Thanks, Alex.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 04-24-2018 at 15:03.
Dragokas is offline
pride95
Senior Member
Join Date: Aug 2015
Old 04-24-2018 , 15:15   Re: Alignment by columns
Reply With Quote #2

You can align if your first column has numbers:

PHP Code:

char Buffer
[];
Format(Buffersizeof(Buffer), "%09d   %s"intchar); 
you have an int with size 9. before numbers you have zeros.
000232324
000000001
000000233

etc.
pride95 is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-24-2018 , 15:22   Re: Alignment by columns
Reply With Quote #3

It's not the case. Each digit has approximately the same width. I have no numbers. It's just an example.

Like, if you write 10 little L and 10 w, width will vary significantly:

llllllllll
wwwwwwwwww
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 04-25-2018 , 18:10   Re: Alignment by columns
Reply With Quote #4

Have you tried \t ?
__________________

Last edited by Neuro Toxin; 04-25-2018 at 18:10.
Neuro Toxin is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 04-25-2018 , 18:20   Re: Alignment by columns
Reply With Quote #5

Yea, even several \t\t\t. It is displayed as usual white space. Always the same width.

Anyway, I followed in some way the idea of pride95 by reorganizing positions of my columns.
And rest column is absorbed by additional submenus.

I could write code to measure every char. width, but I prefer save my time.
Also, such code is superfluous load on CPU.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:27.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode