CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 07-19-2011, 01:19 PM   #1
ilithian
New Member
portfolio
Tom Gibson
London, United Kingdom
 
Join Date: Apr 2009
Posts: 16
messagebox width?

Hi, sorry to create a whole thread for this, but i wasnt sure where else this should go.
basically is there a way to control the width of a messagebox? I'm currently throwing up some pretty long file paths and they're being lost off the edge.
Any help would be great.
Thanks!
Tom
__________________
Visit my Portfolio :)
 
Old 07-19-2011, 02:09 PM   #2
DaveWortley
<database error>
 
DaveWortley's Avatar
portfolio
David Wortley
Technical Director
London, United Kingdom
 
Join Date: Dec 2004
Posts: 1,918
Send a message via MSN to DaveWortley
You can use escape characters in the strings to make a multi-line error message. So use \n to do a carraige return.

Code:
Messagebox "This is a very very very very very very\nvery\nvery\nvery\nlong message!"


You can easily write a function to put some '\n' in a very long string working out if the string is too long by using thestring.count will give you the number of characters.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/

Last edited by DaveWortley : 07-19-2011 at 02:12 PM.
 
Old 07-19-2011, 02:26 PM   #3
j-man
in 3D!
 
j-man's Avatar
portfolio
Joshua Newman
Director
MESHROOM
London, United Kingdom
 
Join Date: Apr 2005
Posts: 1,345
Send a message via MSN to j-man
Hi,

How about truncating the text? You can test it's width in pixels and then delete some letter in the middle until it fits

Code:
str="This is a very long string that has been written so I can test my string truncation method." width=200 while (GetTextExtent str)[1]>width do str=((substring str 1 ((str.count/2)-3))+"..."+(substring str ((str.count/2)+3) str.count))


(made as small as possible for Denis's benefit, now his turn)

J.
__________________
www.joshuanewman.net
 
Old 07-19-2011, 04:25 PM   #4
ilithian
New Member
portfolio
Tom Gibson
London, United Kingdom
 
Join Date: Apr 2009
Posts: 16
thanks guys, i was doing the forced line break, but i was displaying some long file paths through variables that were causing problems. I might see if i can do something with j-mans suggestion, thanks for that
would be much easier if messageboxes just had a 'width:' attribute, but i guess they really dont..
__________________
Visit my Portfolio :)
 
Old 07-19-2011, 04:33 PM   #5
j-man
in 3D!
 
j-man's Avatar
portfolio
Joshua Newman
Director
MESHROOM
London, United Kingdom
 
Join Date: Apr 2005
Posts: 1,345
Send a message via MSN to j-man
You could also display the complete filename and only truncate the path using:

filenameFromPathand getFilenamePath

to seperate the filename and path before shortening the path.

J.
__________________
www.joshuanewman.net
 
Old 07-19-2011, 04:48 PM   #6
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,871
Send a message via ICQ to denisT
Quote:
Originally Posted by j-man
Hi,

How about truncating the text? You can test it's width in pixels and then delete some letter in the middle until it fits

Code:
str="This is a very long string that has been written so I can test my string truncation method." width=200 while (GetTextExtent str)[1]>width do str=((substring str 1 ((str.count/2)-3))+"..."+(substring str ((str.count/2)+3) str.count))


(made as small as possible for Denis's benefit, now his turn)

J.


the truncating a long text is absolutely right idea. i usually do it to place filenames(paths) in UI.
working with filenames it makes sense to truncate beginning of the path. so my simple version of the string truncation looks:
Code:
str = @"C:\Program Files (x86)\Autodesk\3ds Max 2010 SDK\maxsdk\ProjectSettings\AdditionalCompilerOptio ns.Readme.txt" fn truncateString str width:200 = if (gettextextent str).x > width then ( width -= (gettextextent "...").x local new for k=1 to str.count while (gettextextent (new = substring str k -1)).x > width do () "..." + new ) else str truncateString str
 
Old 07-19-2011, 04:55 PM   #7
j-man
in 3D!
 
j-man's Avatar
portfolio
Joshua Newman
Director
MESHROOM
London, United Kingdom
 
Join Date: Apr 2005
Posts: 1,345
Send a message via MSN to j-man
and there it is <:

J.
__________________
www.joshuanewman.net
 
Old 07-19-2011, 05:11 PM   #8
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,871
Send a message via ICQ to denisT
it's easy do use .net to messages:
Code:
( local str = @"C:\Program Files (x86)\Autodesk\3ds Max 2010 SDK\maxsdk\ProjectSettings\AdditionalCompilerOptio ns.Readme.txt" local mb = dotnetclass "MessageBox" local button = (dotnetclass "MessageBoxButtons").YesNo local icon = (dotnetclass "MessageBoxIcon").Warning local result = mb.show (str + "\n\n" + "Do you want to save the file?") "Quit" button icon format "action: %\n" (result.ToString()) )


the .net messagebox cares about a message length itself.
 
Old 07-19-2011, 05:14 PM   #9
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,871
Send a message via ICQ to denisT
Quote:
Originally Posted by j-man
and there it is <:

J.


actually as you see my function doesn't work correct. it might return a text longer than the limit.
it's why i called it simple version.
 
Old 07-19-2011, 09:36 PM   #10
haavard
PRO
håvard
Norway
 
Join Date: Jul 2006
Posts: 152
I wanted to play with the big boys and went totally overboard and failed:


Looks like I got the wrong handle
__________________
Homepage clicky clickey!
 
Old 07-19-2011, 10:15 PM   #11
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,871
Send a message via ICQ to denisT
he-he... it seems like you want to change message box size. you got the right handle...
 
Old 07-20-2011, 09:49 AM   #12
ilithian
New Member
portfolio
Tom Gibson
London, United Kingdom
 
Join Date: Apr 2009
Posts: 16
haha, wow thanks guys; i came up with a temp fix but i might try out your suggestions when i get more time
__________________
Visit my Portfolio :)
 
Old 07-20-2011, 09:49 AM   #13
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:49 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.