PDA

View Full Version : How do you make Msgboxw text selectable ?



DirectuX
22-04-2020, 11:34
Hi,


all in the title :

How do you make Msgboxw text selectable -> Ctrl+C copy ?

primo
23-04-2020, 08:47
Hi
for the first time i know that while the msgBox is on if we press ctrl-C the msgbox text is copied to the clipboard. but selectable text seems not possible, look different approaches here: https://stackoverflow.com/questions/12188769/selectable-text-in-vba-message-box
someone have an approach of using a TextBox

ErosOlmi
23-04-2020, 14:00
You can create your own message box.

Something like the following:



USES "UI"


begin ControlID
%txt_Message
%btn_OK
end ControlID


function MyMsgBox(byval hParent as long, byval sText as string, byval sCaption as string) as long
DIALOG New Pixels , Name frmMsgBox,
hParent,
sCaption,
-1, -1, 320, 240,
%WS_SYSMENU

CONTROL ADD Textbox , Name txtMessage , frmMsgBox.Handle, %txt_Message , "",
5, 5, frmMsgBox.CW - 10, frmMsgBox.CH - 100,
%ES_WANTRETURN | %ES_MULTILINE | %ES_READONLY, %WS_EX_TRANSPARENT

CONTROL ADD BUTTON , Name btnOK , frmMsgBox.Handle, %btn_OK , "OK",
frmMsgBox.CW/2-50, frmMsgBox.CH - 50, 100, 25, %BS_DEFAULT | %WS_TABSTOP


txtMessage.Text = sText

DIALOG SHOW MODAL frmMsgBox.Handle


end Function


'------------------------------------------------
CallBack Function frmMsgBox.OnLoad() As Long
'------------------------------------------------
txtMessage.BackColor = Win_GetSysColor(%COLOR_BTNFACE)

End Function
'------------------------------------------------
' Function fired when button Run me is clicked
'------------------------------------------------
CallBack Function btnOK.OnClick() As Long
'------------------------------------------------
frmMsgBox.Close
End Function




MyMsgBox(0, "Hi there" + $crlf + "from thinBAsic", "My Message Box")

DirectuX
23-04-2020, 14:32
Thanks both!

@Primo, as stated in the link you provide Ctrl+C on the Msgbox is not user friendly as it catches the title and the 'OK' button texts.
@Eros, I understand the 'own' message box.

First, I thought that the stackO link gave me a third approach, quick & clean: the inputbox (InputBox$ in TB) but unfortunately it's not InputBoxW$. Thus, Eros, you did provide the answer I needed.

Thanks both!