Is there a way to change message in MsgMeter?

Is there a way to change message in MsgMeter?

Postby ellano » Wed May 29, 2019 3:27 pm

To everyone:

I want to know if there is a simple way to change the message in a MsgMeter like in the following code:

Code: Select all  Expand view
FUNCTION ReportToExcel(oBrwI, aData)

   MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
             ToExcel ( oMeter, oText, oDlg, @lEnd, oBrwI, aData) },;
             "Sending data to Excel", "Please stand by..." )
RETURN NIL

STATIC FUNCTION ToExcel( oMeter, oText, oDlg, lEnd, oBrwI, aData )

   LOCAL oExcel   := ExcelObj()
   LOCAL oBook    := oExcel:WorkBooks:Add()
   LOCAL oSheet   := oBook:ActiveSheet
   LOCAL oRange, n :=1, nRows :=  Len( aData ), nCols:= Len(aDatos[1]), oCol
...
...
/* 1st phase here ********/
   While n <= nRows .AND. ! lEnd
      oRange:Rows( n+2 ):Value  := aData[ n ]
      oMeter:Set( n++ )
   End
...
/*2nd phase here  *****
* need to change progress bar dialog message to "Getting graphs from data" */

...

   IF lEnd
      MsgAlert( "Report cancel by user", "Excel" )
   Else
      MsgInfo( Len( aData ), "Total animals in these sequence:" )
   EndIf

RETURN Nil


Thank you in advance
Emiliano Llano Dïaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: Is there a way to change message in MsgMeter?

Postby karinha » Wed May 29, 2019 8:20 pm

Hi, look \samples\WIN32?.PRG

Regards.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7339
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Is there a way to change message in MsgMeter?

Postby Silvio.Falconi » Wed May 29, 2019 8:35 pm

erase msgmeter and use this

Code: Select all  Expand view
#include "FiveWin.ch"
#include "constant.ch"

FUNCTION ReportToExcel(oBrwI, aData)
         Local nBottom   := 8
         Local nRight    := 45
         Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
         Local nHeight := nBottom * DLG_CHARPIX_H
         Local oProgress
         local oDlgProgress, oSay01, oSay02, oBmp

DEFINE DIALOG oDlgProgress SIZE nWidth, nHeight;
   TITLE 'Report to Excel' PIXEL  ;
          STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 )

   @ 1,2  BITMAP oBmp  OF oDlgProgress RESOURCE 'INDEX'   SIZE 20,20 NOBORDER
   @ 2,12 SAY oSay01  Prompt "Reporting..."   OF oDlgProgress
          oBmp:lTransparent:=.t.


    @ 2,2 SAY oSay02 PROMPT space(30)    OF oDlgProgress  SIZE 100,10
 
 oProgress := TProgress():New( 2.8, 2, oDlgProgress, , , , .f.,, 150, 15, "your first text", .f., .f. )



   oDlgProgress:bStart := { || SysRefresh(), ToExcel( oProgress , oDlgProgress lEnd, oBrwI, aData ,oSay02), oDlgProgress:End() }

   ACTIVATE DIALOG oDlgProgress center
return nil

Function ToExcel(  oProgress , oDlgProgress lEnd, oBrwI, aData ,oSay02 )

LOCAL oExcel   := ExcelObj()
   LOCAL oBook    := oExcel:WorkBooks:Add()
   LOCAL oSheet   := oBook:ActiveSheet
   LOCAL oRange, , nRows :=  Len( aData ), nCols:= Len(aDatos[1]), oCol
   
local nprogress   := 0

       oProgress:SetRange( 0, RecCount() )

        Ut_ResetMeter( oProgress, nProgress )


/* 1st phase here ********/
   While nprogress  <= nRows .AND. ! lEnd
      oRange:Rows( nprogress +2 ):Value  := aData[ nprogress  ]
     // oMeter:Set( n++ )
              oProgress:SetPos(nProgress++)

   End
...
/*2nd phase here  *****
* need to change progress bar dialog message to "Getting graphs from data" */

...
       oSay:SetText(i18n("Getting graphs from data")
               oProgress:SetRange( 0, RecCount() )
                    Ut_ResetMeter( oProgress, nProgress )



   IF lEnd
      MsgAlert( "Report cancel by user", "Excel" )
   Else
      MsgInfo( Len( aData ), "Total animals in these sequence:" )
   EndIf

RETURN Nil


   



I use the same system for index, create dbf and convert into xls,cvs,xlm
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6848
Joined: Thu Oct 18, 2012 7:17 pm

Re: Is there a way to change message in MsgMeter?

Postby ellano » Thu May 30, 2019 9:39 am

Thanks for your kind responses.

Sorry, but I meant without using a dialog, only the advantages of MsgMeter (if there is a simple way). There is also a oText and oDlg object there, so maybe...

You cannot beat one line of code with at least 20 lines of creating and administrating yourself a dialog :(

Sincerely
Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: Is there a way to change message in MsgMeter?

Postby ellano » Thu May 30, 2019 9:54 am

Ahhhhaaaaaaaa! I answer myself: :mrgreen:

Code: Select all  Expand view
  FUNCTION ReportToExcel(oBrwI, aData)

       MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
                 ToExcel ( oMeter, oText, oDlg, @lEnd, oBrwI, aData) },;
                 "Sending data to Excel", "Please stand by..." )
    RETURN NIL

    STATIC FUNCTION ToExcel( oMeter, oText, oDlg, lEnd, oBrwI, aData )

       LOCAL oExcel   := ExcelObj()
       LOCAL oBook    := oExcel:WorkBooks:Add()
       LOCAL oSheet   := oBook:ActiveSheet
       LOCAL oRange, n :=1, nRows :=  Len( aData ), nCols:= Len(aDatos[1]), oCol
    ...
    ...
    /* 1st phase here ********/
       While n <= nRows .AND. ! lEnd
          oRange:Rows( n+2 ):Value  := aData[ n ]
          oMeter:Set( n++ )
       End
    ...
    /*2nd phase here  *****
    * need to change progress bar dialog message to "Getting graphs from data" */

    ...
 
   oDlg:cTitle:= "My New oDlg Title goes here!"
   oText:SetText ("The progress bar message is placed here!")

       IF lEnd
          MsgAlert( "Report cancel by user", "Excel" )
       Else
          MsgInfo( Len( aData ), "Total animals in these sequence:" )
       EndIf

    RETURN Nil


The one liner is completely respected and you do not need to administrate a whole dialog.

Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am

Re: Is there a way to change message in MsgMeter?

Postby Silvio.Falconi » Thu May 30, 2019 11:23 am

Emiliano,I wouldn't use msgmeter
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6848
Joined: Thu Oct 18, 2012 7:17 pm

Re: Is there a way to change message in MsgMeter?

Postby ellano » Thu May 30, 2019 4:15 pm

Silvio:

Without being rude, I use both of them and I only see advantages in the 2nd one (unless you clarify the point):

1st method: (at least 5 lines)
Code: Select all  Expand view
 LOCAL oDlgP, oProg1
  DEFINE DIALOG oDlgP FROM 1, 1 TO 5, 44 ;
      TITLE "Initial configuration"
@ 1, 2 PROGRESS oProg1 SIZE 135, 12
  ACTIVATE DIALOG oDlgP CENTERED NOWAIT ;
        ON INIT (HB_SYMBOL_UNUSED(self), oProg1:SetRange( 0, 100 ))
  oProg1:SetPos( INT(i*100/num_reg ) )  //add to progress bar
  oDlgP:End()                                        //do not forget to close at the end
 


2nd method: (3 lines; very simple to maintain)

Code: Select all  Expand view
  MsgMeter( { | oMeter, oText, oDlg, lEnd | ;
             AExcel ( oMeter, oText, oDlg, @lEnd, oBrwI, aData, cImages) },;
             "Progress bar message (can change later)...", "Dialog message (can also change later on..." )
  oMeter:nTotal = nRows  // get it from what you want to control
  oMeter:Set( n++ )         // progress bar on a loop


In the same line of thought, we can also implement MsgStop, MsgWait, etc. using the comdlg32.dll loosing all advantages of a simple interface :shock:

Sincerely
Emiliano Llano Díaz
ellano
 
Posts: 107
Joined: Tue Sep 15, 2009 7:52 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests