Jump to content

Custom made msgbox function message line cut off for multiline


Morthawt
 Share

Recommended Posts

I am experimenting making a function which will generate a GUI and give me the ability to put message, title, button 1 text, button 2 text etc. The problem I am running into is if I try and add @CRLF to my message or make it too long so it wraps to a new line, the area for it to be able to be seen is cut off and you see only the tips of the writing on the new line.

What should I do to be able to dynamically make the height match the content so it can all be read even if I make a long message?

Thanks

Link to comment
Share on other sites

  • Moderators

Morthawt,

Use the StringSize UDF in my sig - it tells you the size required for any text. :graduated:

Or use the ExtMsgBox UDF you find there to create the GUI directly! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thanks I saw that. I am just trying to do it without having to download code. I hate having to get external things and keep track of them and make sure I have differnt includes. I prefer to have all internal things. Are there any normal methods to do this?

Link to comment
Share on other sites

  • Moderators

Morthawt,

Are there any normal methods to do this?

What is abnormal about my UDFs (unless you are trancexx)? :)

Seriously, why the aversion to dowmloading UDFs? It is one of the strengths of AutoIt that we can use the functions within these prewritten code sections as easily as the built-in ones by using a single #include directive. And there is no need to keep track of UDF release dates - if you have one which works you can just keep using it even if a new version is released. And it is very easy to keep any downloaded or personal UDFs in separate folder - see here to find out how to do it (and a couple of posts further down I explain how to set CallTips and AutoComplete for the functions within them). ;)

Anyway, if you do not want to download my beautifully packaged ready-to-use UDFs, please feel free to extract any or all of the code in them to use internally with your scripts. Or rewrite it as you please to meet your specific requirements. They are pretty well commented, but I am always happy to explain further if required. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

lol, see I like to have guarentees where possible. If something is in autoit its self then I can be assured it will be reworked to work with any updated autoit product. User defined things on the forum are up to the creator to update and what ever and since there are no guarantees I prefer to stick with what I know is always there.

Plus I am funny about using copy paste code that I do not know how to do. I have looked into the whole com thing but its complicated and I have nothing in the help file that tells me how to access everything, so that means I do not touch com interactions with the system. One of the main reasons I got into AutoIt at all was how helpful the offline helpfile is. I can install autoit from my hard drive and the helpfile gives me all the info on the commands and how to use them and even supplies examples. I love that! That is not the same with some of the system interactions that require COM because its a microsoft thing and I gave up trying to find an equally helpful text on all the com info.

Link to comment
Share on other sites

I checked the code on your string size and your using dll calls and all kinds of things, thats way over my head. I need to find simple means to do simple things. I was trying to look at the coding for MsgBox but I guess it does not exist in the includes.

Link to comment
Share on other sites

  • Moderators

Morthawt,

If you only want use the built-in AutoIt functions then you are are severely limiting your abilty to code in AutoIt - but that is your decision. :graduated:

As to sizing text, the only accurate way to do it is via a call to the GetTextExtentPoint32W function in gdi32.dll. Look inside the StringSize UDF to see how to use the built-in DllCall function do it. ;)

M23

Edit:

I was trying to look at the coding for MsgBox but I guess it does not exist in the includes

The built-in functions like MsgBox use direct calls to the Windows API from within AutoIt - the standard includes are just code donated by more experienced users - not a lot different from the downloadable ones really. :) Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I would love it if AutoIt would incorporate some of the better UDF's from this forum into AutoIt (with the creators permission of course) and then support and update its continued function at the same feature level but with no bugs. They can always update it when the user has updated their UDF with a better version, but at least in the mean time we can guarantee to have the functionality and that it will continue to work even when a new revision of Autoit comes out. I would gladly use UDF's under those circumstances. I have no problem using an include for something that comes optionally with autoit ( I do it all the time )

Link to comment
Share on other sites

Here is what I made in an attempt to make a custom msgbox. This is a test, not an actual production script lol..

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
; Below the line is making use of a function I created, supplying it with the data required.
$choice = Msg2button('Oh no!', 'A man walks into a heavy metal bar... What do you do next?', 'Give him a towel', 'Get him to turn the music up')
If $choice = 1 Then
MsgBox(0, 'What?', 'A towel? thats it?')
ElseIf $choice = 2 Then
MsgBox(0, 'What?', 'You don''t want it TOO loud...')
EndIf
 
; 95% of the code for this sectoion below was generated automatically from me visually designing the dialogue using the Koda feature...
Func Msg2button($msgtitle, $msgmessage, $msgbutton1, $msgbutton2)
$msg2btn = GUICreate($msgtitle, 364, 110, -1, -1)
$Label1 = GUICtrlCreateLabel($msgmessage, 64, 24, 256, 34)
$Icon1 = GUICtrlCreateIcon("C:\Windows\System32\shell32.dll", -173, 16, 16, 32, 32)
$GUIButton1 = GUICtrlCreateButton($msgbutton1, 16, 64, 139, 25)
$GUIButton2 = GUICtrlCreateButton($msgbutton2, 176, 64, 171, 25)
GUISetState(@SW_SHOW)
While 1
  $nMsg = GUIGetMsg()
  Switch $nMsg
   Case $GUI_EVENT_CLOSE
    Exit
   Case $GUIButton1
    GUIDelete($msg2btn)
    Return 1
 
   Case $GUIButton2
    GUIDelete($msg2btn)
    Return 2
 
  EndSwitch
WEnd
 
EndFunc   ;==>Msg2button

I made this for a friend who is learning AutoIt

Edited by Morthawt
Link to comment
Share on other sites

  • Moderators

Morthawt,

I would love it if AutoIt would incorporate some of the better UDF's from this forum into AutoIt

How do you think the current standard includes got there? ;)

But I think it is unlikely to that you will see very many more added, for the very reason to which you allude. It is a major undertaking to keep all the standard UDFs up-to-date with changes to AutoIt - just look at the current problems with Structs under x86/x64.

Personally I use quite a few UDFs from the more experienced members who do provide regular updates and a good bug-fix service (in which category I hope I can place myself :)) but also several which I have had to update myself as the original author is no longer active on the forum. I found that the exercise made me a better coder as I had to understand what was going on in the original - and even on occasion resulted in a better UDF. :graduated:

So I again suggest that you are unnecessarily restricting your coding ability by refusing to use downloaded UDFs for the reasons you state. But it is your decision...

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I understand. I am trying to desmonstrate things to my friend as he is emailing me "how do you.." "what is..." and he wants to know if you can make nice looking things like have an image and then layer things on top. Now I have been able to do it but I cant click the buttons even after reordering things.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 486, 325, -1, -1)
$Pic1 = GUICtrlCreatePic("C:\Users\techwg\Desktop\so_70s_background.jpg", 0, 0, 484, 324)
$Label1 = GUICtrlCreateLabel("Welcome to layering", 136, 120, 183, 27)
GUICtrlSetFont(-1, 15, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x008000)
$Button1 = GUICtrlCreateButton("Button1", 72, 216, 115, 25)
$Button2 = GUICtrlCreateButton("Button2", 272, 216, 115, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

Do you have any ideas why I cannot click the buttons?

Link to comment
Share on other sites

  • Moderators

Morthawt,

If I had £1 for every time I have answered this, I would be a rich man. ;)

From the help file for GUICtrlCreatePic:

"If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control and create it after the others controls: GuiCtrlSetState(-1,$GUI_DISABLE)"

Basically if you have overlapped controls, AutoIt cannot decide which you wanted to click and so actions neither. :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...