Pastable MsgBox popup

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
HGAutomator
Posts: 202
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Pastable MsgBox popup

Post by HGAutomator »

Hi,

Is there an existing popup info dialog like MsgBox, that allows you to select part of the message, in order to copy and paste it elsewhere?
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Pastable MsgBox popup

Post by Claudio Ricardo »

Hi HG.
I think you'll have to do it with a small window with a read-only EditBox or RichEdit control...
I will do something like this to highlight in bold or color part of the text.
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
HGAutomator
Posts: 202
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: Pastable MsgBox popup

Post by HGAutomator »

Yep, that's what I thought. Ok, thanks C.R.
Claudio Ricardo wrote: Mon Dec 13, 2021 6:07 pm Hi HG.
I think you'll have to do it with a small window with a read-only EditBox or RichEdit control...
I will do something like this to highlight in bold or color part of the text.
User avatar
Claudio Ricardo
Posts: 367
Joined: Tue Oct 27, 2020 3:38 am
DBs Used: DBF, MySQL, MariaDB
Location: Bs. As. - Argentina

Re: Pastable MsgBox popup

Post by Claudio Ricardo »

Hello, This allows you to copy and what I needed: to highlight part of the text, in addition to changing font and size.
It could be done much better and more neat (even put color) but I have little time for a lot of work.

Code: Select all

cText := "+CRLF  Está seguro/a de querer eliminar {TODOS} los datos ? +CRLF  Esta acción {NO} puede deshacerse !"
	If MsgSiNo ( cText, "Atención !", 150, 320 )
Screenshot_20211215_163105.png
Screenshot_20211215_163105.png (10.56 KiB) Viewed 825 times

Code: Select all

	If MsgSiNo ( cText, "Atención !", 160, 400, "Times-Roman", 12 )
Screenshot_20211215_162434.png
Screenshot_20211215_162434.png (12.07 KiB) Viewed 825 times

Code: Select all

#include <hmg.ch>

Function MsgSiNo ( cString, cTitle, nHeight, nWidth, cFontName, nFontSize )

LOCAL cText := ""
PRIVATE lRetu := .F.

Default cTitle := ""
Default nHeight := 160
Default nWidth := 400
Default cFontName := "Arial"
Default nFontSize := 9

cString := StrTran ( cString, "+CRLF", "\par" )
cString := HMG_Unicode_To_Ansi ( cString )
cText := '{\rtf1\ansi\pard '
cText += StrTran ( cString, "{", "{\b " )
cText += '}'

Hb_MemoWrit ("Text.rtf", cText)
cText := Hb_MemoRead ("Text.rtf")

	DEFINE WINDOW Win_1 AT 0,0 WIDTH nWidth HEIGHT nHeight TITLE cTitle MODAL BACKCOLOR {255,255,255} NOSYSMENU

		DEFINE RICHEDITBOX Edit_1
			ROW 0
			COL 0
			WIDTH nWidth - 16
			HEIGHT nHeight - 80
			VALUE ""
			READONLY .T.
			FONTNAME cFontName
			FONTSIZE nFontSize
			TABSTOP .F.
			HSCROLL .F.
			VSCROLL .F.
		END RICHEDITBOX

		DEFINE BUTTON Button_1
			ROW nHeight - 75
			COL nWidth - 240
			WIDTH  100
			HEIGHT 28
			ACTION ExitMsg (.T.)
			CAPTION "Ok"
		END BUTTON

		DEFINE BUTTON Button_2
			ROW nHeight - 75
			COL nWidth - 125
			WIDTH  100
			HEIGHT 28
			ACTION ExitMsg (.F.)
			CAPTION "Cancel"
		END BUTTON

	END WINDOW

	CENTER WINDOW Win_1
		Win_1.Edit_1.RTFLoadFile ("Text.rtf", .F., 4)
	ACTIVATE WINDOW Win_1

Return lRetu
//--------------------------------------------------------------------------------------------------//

STATIC Procedure ExitMsg (lParam)

Default lParam := .F.

	If lParam
		lRetu := .T.
	EndIf
	
	Ferase ( "Text.rtf" )
	DoMethod ("Win_1" , "Release")
	
Return Nil
Corrige al sabio y lo harás más sabio, Corrige al necio y lo harás tu enemigo.
WhatsApp / Telegram: +54 911-63016162
HGAutomator
Posts: 202
Joined: Thu Jul 16, 2020 5:42 pm
DBs Used: DBF

Re: Pastable MsgBox popup

Post by HGAutomator »

Looks more than adequate, thanks Claudio.

Claudio Ricardo wrote: Wed Dec 15, 2021 7:49 pm Hello, This allows you to copy and what I needed: to highlight part of the text, in addition to changing font and size.
It could be done much better and more neat (even put color) but I have little time for a lot of work.

Code: Select all

cText := "+CRLF  Está seguro/a de querer eliminar {TODOS} los datos ? +CRLF  Esta acción {NO} puede deshacerse !"
	If MsgSiNo ( cText, "Atención !", 150, 320 )
Screenshot_20211215_163105.png

Code: Select all

	If MsgSiNo ( cText, "Atención !", 160, 400, "Times-Roman", 12 )
Screenshot_20211215_162434.png

Code: Select all

#include <hmg.ch>

Function MsgSiNo ( cString, cTitle, nHeight, nWidth, cFontName, nFontSize )

LOCAL cText := ""
PRIVATE lRetu := .F.

Default cTitle := ""
Default nHeight := 160
Default nWidth := 400
Default cFontName := "Arial"
Default nFontSize := 9

cString := StrTran ( cString, "+CRLF", "\par" )
cString := HMG_Unicode_To_Ansi ( cString )
cText := '{\rtf1\ansi\pard '
cText += StrTran ( cString, "{", "{\b " )
cText += '}'

Hb_MemoWrit ("Text.rtf", cText)
cText := Hb_MemoRead ("Text.rtf")

	DEFINE WINDOW Win_1 AT 0,0 WIDTH nWidth HEIGHT nHeight TITLE cTitle MODAL BACKCOLOR {255,255,255} NOSYSMENU

		DEFINE RICHEDITBOX Edit_1
			ROW 0
			COL 0
			WIDTH nWidth - 16
			HEIGHT nHeight - 80
			VALUE ""
			READONLY .T.
			FONTNAME cFontName
			FONTSIZE nFontSize
			TABSTOP .F.
			HSCROLL .F.
			VSCROLL .F.
		END RICHEDITBOX

		DEFINE BUTTON Button_1
			ROW nHeight - 75
			COL nWidth - 240
			WIDTH  100
			HEIGHT 28
			ACTION ExitMsg (.T.)
			CAPTION "Ok"
		END BUTTON

		DEFINE BUTTON Button_2
			ROW nHeight - 75
			COL nWidth - 125
			WIDTH  100
			HEIGHT 28
			ACTION ExitMsg (.F.)
			CAPTION "Cancel"
		END BUTTON

	END WINDOW

	CENTER WINDOW Win_1
		Win_1.Edit_1.RTFLoadFile ("Text.rtf", .F., 4)
	ACTIVATE WINDOW Win_1

Return lRetu
//--------------------------------------------------------------------------------------------------//

STATIC Procedure ExitMsg (lParam)

Default lParam := .F.

	If lParam
		lRetu := .T.
	EndIf
	
	Ferase ( "Text.rtf" )
	DoMethod ("Win_1" , "Release")
	
Return Nil
Post Reply