MessageBox with TimeOut

Creative ideas/suggestions for HMG

Moderator: Rathinagiri

Post Reply
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

MessageBox with TimeOut

Post by Pablo César » Fri Aug 02, 2013 4:02 pm

Hellow every one !

I am looking for a simple solution for automatically closing a message box, function similar like this:

MsgStop(<Message>,<Title>,<Seconds>)
Screen.PNG
Screen.PNG (6.99 KiB) Viewed 3097 times
Would it be wonderfull to have it with changing seconds (SetTimer) at Caption of Button "Ok".
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sat Aug 03, 2013 12:48 pm

Sometimes we think: the guy wants everything for free ... but please this is not the case.
I made my way to the one and tried to run this function MyMsgWait and am available to you:

Code: Select all

Function MyMsgWait(cMessage, cTitle, nTime)
Local I:=0, nHeight:=0, nLastLine:=0

Private lLoop := .T.

cMessage:=If(cMessage=Nil," ",cMessage)
cTitle:=If(cTitle=Nil,"Atenção",cTitle)
nTime:=If(nTime=Nil, 10 , nTime)

If IsWindowDefined(Upper("Form'"))
   ThisWindow.Release()
Endif

nHeight:=((If((HMG_Len(cMessage)/68)-Int(HMG_Len(cMessage)/68)=0,Int(HMG_Len(cMessage)/68),Int(HMG_Len(cMessage)/68)+1))*40)+30
If nHeight <= 70
   nHeight := 90
Endif

DEFINE WINDOW FormMsgWait AT 0,0 WIDTH 300 HEIGHT nHeight+35 ;
    TITLE cTitle ICON 'info.bmp' MODAL NOSIZE               ;
	ON RELEASE If(lLoop,lLoop:=.F.,) ON INIT Counting(nTime)

    ON KEY ESCAPE of FormMsgWait ACTION FormMsgWait.Release
	
    For I:=1 TO MLCount(cMessage,68,8,.f.)
        cTexLabel := 'Text'+Str(I,1)
		nLastLine := nLastLine+20
        @ nLastLine,06 LABEL &cTexLabel WIDTH 278 HEIGHT 16 ;
		    VALUE HMG_PADC(Alltrim(MemoLine(cMessage,68,I,8,.t.)),68) ;
		    FONT 'ARIAL' SIZE 10 CENTERALIGN
    Next I
    
    @ nLastLine+30,115 BUTTON Button_1 CAPTION '&Ok' ;
	    WIDTH 80 HEIGHT 30 ACTION (FormMsgWait.Release)

END WINDOW
CENTER WINDOW FormMsgWait
ACTIVATE WINDOW FormMsgWait
Return Nil
	
Function Counting(nSecs)
Local nSeconds := 0, nCount := nSecs

Do While nCount > -1 .and. lLoop
   If Abs( Seconds() - nSeconds ) >= 1
      FormMsgWait.Button_1.Caption:=LTrim(Str(nCount))+" Second"+If(nCount > 1, "s", "")
      nSeconds := Seconds()
	  nCount--
   Endif
   Do Events
Enddo
If lLoop
   lLoop := .F.
   FormMsgWait.Release()
Endif
Return Nil
But it did not work where I wanted it to work (before activation of the Main window).
Screen.PNG
Screen.PNG (12.45 KiB) Viewed 3037 times
This happend because this:
Screen2.PNG
Screen2.PNG (17.67 KiB) Viewed 3037 times
As we know, the MessageBox function C does not depend on it, and for this reason I come to ask (perhaps the person who always contributed his expertise in C) the creation of a new function that allows do the autorelease through some timer. But it must be done in C. :|

This function I'm wanting is to be used in this example and also will be usefull for other cases as well.

I do not know if I'm the only one in need of it ... :(
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
bpd2000
Posts: 1077
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 197 times
Been thanked: 96 times

Post by bpd2000 » Sat Aug 03, 2013 4:04 pm

BPD
Convert Dream into Reality through HMG

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sat Aug 03, 2013 4:46 pm

Thank you Dave for your interest to help. I also found this http://www.codeproject.com/Articles/197 ... essage-box but I think the best way is to make a new function at C:\hmg.3.1.5\SOURCE\c_msgbox.c with MessageBox...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Fri Aug 09, 2013 12:49 am

Googling for a solution using the MessageBoxIndirect and I found in CodeProject (one of my favorite site) this example:

http://www.codeproject.com/Articles/957 ... geBox-v1-0

The example is very old (2005) but very well prepared, because it has several options with various combinations of MessageBox examples.

Image

Worth checking out ... :D
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
danielmaximiliano
Posts: 2141
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 155 times
Been thanked: 23 times
Contact:

Post by danielmaximiliano » Fri Aug 09, 2013 1:28 am

muchas cosas buenas hay en Codeproject. yo hace muchisimos años miro el sitio
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
Jairo Maia
Posts: 53
Joined: Sun Jul 17, 2011 1:47 pm
Location: Campinas - SP - Brazil

Post by Jairo Maia » Fri Aug 09, 2013 9:45 am

Hello Pablo,

Thanks for sharing this information. I didn´t know this site. It´s very cool.

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Tue Dec 30, 2014 1:01 pm

Our MsgDebug() uses MessageBoxTimeout. It's very good one, I use too much.

HMG MessageBoxTimeout

Thank you Claudio, you're a genius !

But I'm looking for a MessageBox with ListView (grid). Many and many times I use to debug for display and sometimes are too large, so many items to make preview of it values. I've to count with a pen on the screen to see it each position and believe me this takes a lote of time.
So I got an idea, to put it into a grid in MessageBox (MessageBox, because is not necessary to declare any form/window) then could display each parameter in one line, displaying line number column + values, this would display with scrollbars.

I saw something at:

http://www.codeproject.com/Questions/61 ... to-message

I also found a Scrollable MessageBox at:

Image

http://www.c-sharpcorner.com/UploadFile ... geBox.aspx

Or adding ListBox at MessageBox:

https://social.msdn.microsoft.com/Forum ... rplanguage

The important is to display all listed data, complete and if is posible numerated by line numbers.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Tue Dec 30, 2014 7:46 pm

I made this adaptation:
Screen2.png
Screen2.png (71.96 KiB) Viewed 2466 times

Code: Select all

#include <hmg.ch>

Function Main()
MsgDebug2(hb_ATokens( "Pablo       César  Arrascaeta", .T. ))
MsgDebug2(_HMG_SYSDATA[11],_HMG_SYSDATA[12],_HMG_SYSDATA[13],_HMG_SYSDATA[14],_HMG_SYSDATA[15],_HMG_SYSDATA[16],_HMG_SYSDATA[17],_HMG_SYSDATA[18],_HMG_SYSDATA[19],_HMG_SYSDATA[110],;
		  _HMG_SYSDATA[121],_HMG_SYSDATA[122],_HMG_SYSDATA[123],_HMG_SYSDATA[124],_HMG_SYSDATA[125],_HMG_SYSDATA[126],_HMG_SYSDATA[127],_HMG_SYSDATA[128],_HMG_SYSDATA[129],_HMG_SYSDATA[130],;
		  _HMG_SYSDATA[131],_HMG_SYSDATA[132],_HMG_SYSDATA[133],_HMG_SYSDATA[134],_HMG_SYSDATA[135],_HMG_SYSDATA[136],_HMG_SYSDATA[137],_HMG_SYSDATA[138],_HMG_SYSDATA[139],_HMG_SYSDATA[140],;
		  _HMG_SYSDATA[141],_HMG_SYSDATA[142],_HMG_SYSDATA[143],_HMG_SYSDATA[144],_HMG_SYSDATA[145],_HMG_SYSDATA[146],_HMG_SYSDATA[147],_HMG_SYSDATA[148],_HMG_SYSDATA[149],_HMG_SYSDATA[150],;
		  _HMG_SYSDATA[151],_HMG_SYSDATA[152],_HMG_SYSDATA[153],_HMG_SYSDATA[154],_HMG_SYSDATA[155],_HMG_SYSDATA[156],_HMG_SYSDATA[157],_HMG_SYSDATA[158],_HMG_SYSDATA[159],_HMG_SYSDATA[160])
Return Nil


Function MsgDebug2
Local i, cMsg, cTitle

cMsg := "Called from: " + PROCNAME(1) + "(" + LTRIM(STR(PROCLINE(1))) + ") --> " + PROCFILE (1) + CRLF + CRLF
For i = 1 To PCount()
    cMsg := cMsg + AllTrim(Str(i))+". " + HB_VALTOEXP (PVALUE (i)) + IIF (i < PCOUNT(), CRLF, "")
Next
cTitle := _MsgDebugTitle
HMG_MessageBoxTimeout ( cMsg, MsgDebugTitle(), MsgDebugType(), MsgDebugTimeOut() )
cMsg := cTitle + CRLF + cMsg
Return cMsg
But when is more than 60 items, there is not scrollbars to help for rolling down the screen. :(

Please note line of each parameter, help to identify each item.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 182 times

Post by Pablo César » Sun Jan 04, 2015 6:39 pm

I read this: MsgList shows an array on a modal dialog box.

An also this in Java: https://code.google.com/p/gv4me/wiki/MsgList

Probably useful.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Post Reply