Jump to content
Sign in to follow this  
Docfxit

Creating a copyable MsgBox

Recommended Posts

Docfxit

I'd like to find a way to create a MsgBox that a person could copy some text out of.

I don't know if there is an easier way to create a copyable MsgBox. I don't know if I'm creating something that is way more complicated than it needs to be.

I'm open to suggestions.

The code I created below has two problems.

1. The box it creates doesn't have the correct width and height. I'd like it to be dynamic depending on the text of the message.

2. The first box doesn't close when the X in the top right corner is clicked.

#include <GUIconstants.au3>

$DebugMsg = "This doesn't create the correct size box" 
        DisplayMsg($DebugMsg)
        
;  Do some stuff

$DebugMsg = "The first box doesn't close" 
        DisplayMsg($DebugMsg)

; Do more stuff

Func DisplayMsg($DebugMsg)
$BoxWidth = StringLen($DebugMsg)
GuiCreate("Information Message", $BoxWidth*2.5 +25, 160,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$inputText = GuiCtrlCreateEdit($DebugMsg, 10, 10, $BoxWidth*2.5 + 5, 140)
GUICtrlSetStyle($inputText, $ES_READONLY)
GUICtrlSetBkColor($inputText, 0xC0F0F0)
    GuiSetState()
    While 1
        $msg = GuiGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd

EndFunc

Thank you,

Docfxit

Edited by docfxit

Share this post


Link to post
Share on other sites
Valuater

maybe...

#include <GUIconstants.au3>

$DebugMsg = "This doesn't create the correct size box"
        DisplayMsg($DebugMsg)
       
;  Do some stuff

$DebugMsg = "The first box doesn't close"
        DisplayMsg($DebugMsg)

; Do more stuff

$DebugMsg = "This doesn't create the correct size box or maybe it does if i really read all of this information... thanks Valuater"
        DisplayMsg($DebugMsg)
       

Func DisplayMsg($DebugMsg)
$BoxWidth = StringLen($DebugMsg) * 4.5 + 20
$Boxer = GuiCreate("Information Message", $BoxWidth +20, 160,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$inputText = GuiCtrlCreateEdit($DebugMsg, 10, 10, $BoxWidth, 140)
GUICtrlSetStyle($inputText, $ES_READONLY)
GUICtrlSetBkColor($inputText, 0xC0F0F0)
    GuiSetState()
    While 1
        $msg = GuiGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    WEnd
    GUIDelete($Boxer)
EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Docfxit

That's really great Valuater. That solved both problems.

Thank you very much.

Docfxit

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.