FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Notification boxes colored
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Notification boxes colored
Posted: Thu May 17, 2018 09:46 PM
How create a small message boxes timed and colored for dialogs as these ?



I wish insert it on dialogs with timer and trasparency

desktopalert class is no good
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Thu May 17, 2018 10:04 PM

Explain better, and details your goal

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Fri May 18, 2018 08:45 AM

the message must be inserted inside a colored frame and must be placed at @ x, y of the dialog without shadows must appear and disappear in n seconds as you can see it has a small icon at the beginning and must have at least the possibility to insert two lines text obviously the message if it has two linne has to resize itself. We probably have something already. I do not want messages like desktop alert or similar otherwise I would have opted for the desktopalert class .... you want a simple thing maybe a colored panel and with rounded corners just as you see it in the picture

I need this kind of message because it is very useful in the programs I put in tablets. The operator does not have to press the confirm button as it does in the traditional msginfo () / msgalert () but the message must appear and disappear after n seconds so that the tablet can inform the operator in a simple example:

the operator inserts the wrong dates or the service for those dates is not free. the message notifies the operator of the error in a simple way without the operator having to press esc or press the ok key to go on

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Fri May 18, 2018 10:51 PM

Please try with this sample and tell me what modifications need

https://bitbucket.org/fivetech/fivewin- ... astest.prg

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Sat May 19, 2018 04:45 PM

Sorry I Know it

I have a dialog as this

and for a sample I wish insert a colored message timed into a specific position for a sample

or

or

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Sat May 19, 2018 05:26 PM
Ok, please try with this sample

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//
Function HazAlert204( oWnd, nType )

聽 聽local oTip
聽 聽local cText
聽 聽local cBmp 聽 聽:= "..\bitmaps\16x16\alert.bmp"
聽 聽local lLeft 聽 := .T.
聽 聽local lUp 聽 聽 := .T.
聽 聽DEFAULT nType := 1
聽 聽
聽 聽// oTip := TToast():NewToast( nToast, cText, cBmp, nWidth, nHeight, oWnd, nClrPane, ;
聽 聽// 聽 聽 聽 聽 聽 聽 聽 聽 聽nClrPane2, nClrText, nLev, nTime, lUp, bRet, lLeft )

聽 聽cText 聽 := "Message Success Action"
聽 聽oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
聽 聽 聽 聽 聽 聽 聽 聽CLR_BLUE, , CLR_WHITE, 255, 4000, !lUp, , lLeft )
聽 聽oTip:nWRadio 聽 聽:= 6
聽 聽oTip:nHRadio 聽 聽:= 6
聽 聽oTip:ActivaAlert( oWnd )

   // nTime = -1, no timer active, and user close alert with button X
聽 聽Syswait( 1.0 )
聽 聽cText 聽 := "Message Error Action"
聽 聽oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
聽 聽 聽 聽 聽 聽 聽 聽CLR_RED, , CLR_WHITE, 255, -1, !lUp, , !lLeft )
聽 聽oTip:nWRadio 聽 聽:= 6
聽 聽oTip:nHRadio 聽 聽:= 6
聽 聽oTip:ActivaAlert( oWnd )

聽 聽Syswait( 1.0 )
聽 聽cText 聽 := "Message Attention User"
聽 聽oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
聽 聽 聽 聽 聽 聽 聽 聽CLR_HBLUE, , CLR_WHITE, 255, 4000, lUp, , !lLeft )
聽 聽oTip:nWRadio 聽 聽:= 6
聽 聽oTip:nHRadio 聽 聽:= 6
聽 聽oTip:lBtnClose 聽:= .F.
聽 聽oTip:lBtnSetup 聽:= .F.
聽 聽oTip:ActivaAlert( oWnd )

聽 聽Syswait( 1.0 )
聽 聽cText 聽 := "Message Received"
聽 聽oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
聽 聽 聽 聽 聽 聽 聽 聽CLR_GREEN, , CLR_WHITE, 255, 4000, lUp, , lLeft )
聽 聽oTip:nWRadio 聽 聽:= 6
聽 聽oTip:nHRadio 聽 聽:= 6
聽 聽oTip:lBtnClose 聽:= .F.
聽 聽oTip:lBtnSetup 聽:= .F.
聽 聽oTip:ActivaAlert( oWnd )

Return oTip
//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Sat May 19, 2018 07:52 PM

good it can run
only can you make show and dissapper slowly ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Sun May 20, 2018 06:45 PM
Ok, try with this sample ( last message )
For show slowly, need modify class

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

Function HazAlert204( oWnd, nType )

   local oTip
   local bInit
   local cText
   local cBmp    := "..\bitmaps\16x16\alert.bmp"
   local lLeft   := .T.
   local lUp     := .T.
   DEFAULT nType := 1
   
   // oTip := TToast():NewToast( nToast, cText, cBmp, nWidth, nHeight, oWnd, nClrPane, ;
   //                  nClrPane2, nClrText, nLev, nTime, lUp, bRet, lLeft )

   cText   := "Message Success Action"
   oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
               CLR_BLUE, , CLR_WHITE, 255, 4000, !lUp, , lLeft )
   oTip:nWRadio    := 6
   oTip:nHRadio    := 6
   oTip:ActivaAlert( oWnd )

   Syswait( 1.0 )
   cText   := "Message Error Action"
   oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
               CLR_RED, , CLR_WHITE, 255, 4000, !lUp, , !lLeft )
   oTip:nWRadio    := 6
   oTip:nHRadio    := 6
   oTip:ActivaAlert( oWnd )

   Syswait( 1.0 )
   cText   := "Message Attention User"
   oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
               CLR_HBLUE, , CLR_WHITE, 255, 4000, lUp, , !lLeft )
   oTip:nWRadio    := 6
   oTip:nHRadio    := 6
   oTip:lBtnClose  := .F.
   oTip:lBtnSetup  := .F.
   oTip:ActivaAlert( oWnd )


   Syswait( 1.0 )
   cText   := "Message Received"
   oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oWnd, ;
               CLR_GREEN, , CLR_WHITE, 255, 4000, lUp, , lLeft )
   oTip:nWRadio    := 6
   oTip:nHRadio    := 6
   oTip:lBtnClose  := .F.
   oTip:lBtnSetup  := .F.

   //oTip:bValid     := { || TipTransHide( oTip ), .T. }     // Only Hide slowly
   oTip:bValid     := { || TipTransFlicker( oTip ), .T. }     // Flicker slowly at end

   oTip:ActivaAlert( oWnd )

Return oTip

//----------------------------------------------------------------------------//

//----------------------------------------------------------------------------//

#define LWA_ALPHA 2

//----------------------------------------------------------------------------//

static function TipTransFlicker( oObj )

   TipTransHide( oObj )
   TipTransShow( oObj )
   TipTransHide( oObj )

return NIL

//----------------------------------------------------------------------------//

static function TipTransHide( oObj )

   local x

   for x = oObj:nLevel to 0 step -1
      SetLayeredWindowAttributes( oObj:hWnd, , x, LWA_ALPHA )
      SysWait( 0.0003 )
   next x

return NIL

//----------------------------------------------------------------------------//

static function TipTransShow( oObj )

   local x

   for x = 1 to oObj:nLevel
      SetLayeredWindowAttributes( oObj:hWnd, , x, LWA_ALPHA )
      SysWait( 0.0003 )
   next x

return NIL

//----------------------------------------------------------------------------//
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 06:51 PM
thanks but here not run ok

Please try this test

1. the Message Toast is not on the dialog
2. the animation ( show and dissaperar not run ok)



Code (fw): Select all Collapse
#include "FiveWin.Ch"
#include "constant.ch"


#define LWA_ALPHA 2

Function ShowInvoice()
Local nBottom   := 47.2
Local nRight    := 147.4
Local nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight   := nBottom * DLG_CHARPIX_H

 DEFINE DIALOG oDlg SIZE nWidth, nHeight   PIXEL  ;
   TITLE "Prenotazione n. "

ACTIVATE DIALOG oDlg CENTERED;
on init Message(oDlg)
//------------------------------------------------//


Function Message(oDlg)

 Local  cText   := "Message Received"
 Local  nType   := 1
 Local  cBmp    := "c:\work\fwh\bitmaps\16x16\check.bmp"
 local lUp     := .T.
 local lLeft   := .T.
 Local oTip
 
   oTip := TToast():NewToast( nType, cText, cBmp, 400, 40, oDlg, ;
               CLR_GREEN, , CLR_WHITE, 255, 4000, lUp, , lLeft )

   oTip:nWRadio    := 6
   oTip:nHRadio    := 6
   oTip:lBtnClose  := .F.
   oTip:lBtnSetup  := .F.
   oTip:bValid     := { || TipTransFlicker( oTip ), .T. }

   oTip:ActivaAlert( oDlg )

return nil 

static function TipTransFlicker( oObj )

   TipTransHide( oObj )
   TipTransShow( oObj )
   TipTransHide( oObj )

return NIL

//----------------------------------------------------------------------------//

static function TipTransHide( oObj )

   local x

   for x = oObj:nLevel to 0 step -1
      SetLayeredWindowAttributes( oObj:hWnd, , x, LWA_ALPHA )
      SysWait( 0.0003 )
   next x

return NIL


static function TipTransShow( oObj )

   local x

   for x = 1 to oObj:nLevel
      SetLayeredWindowAttributes( oObj:hWnd, , x, LWA_ALPHA )
      SysWait( 0.0003 )
   next x

return NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 07:29 PM
Ok, change METHOD NewToast in class TToast

Code (fw): Select all Collapse
.../...
聽 聽nBottom 聽 聽 聽:= nTop 聽+ nHeight
聽 聽nRight 聽 聽 聽 := nLeft + nWidth
聽 聽if ::lAlert
聽 聽 聽 // Add this
聽 聽 聽 if !Empty( ::oWndEvent )
聽 聽 聽 聽 聽aPoint := ClientToScreen( ::oWndEvent:hWnd, { nTop, nLeft } )
聽 聽 聽 聽 聽aPoint := ScreenToClient( ::hWnd, aPoint )
聽 聽 聽 聽 聽nTop 聽 := aPoint[ 1 ]
聽 聽 聽 聽 聽nLeft 聽:= aPoint[ 2 ]
聽 聽 聽 聽 聽nBottom := aPoint[ 1 ] + nHeight
聽 聽 聽 聽 聽nRight 聽:= aPoint[ 2 ] + nWidth
聽 聽 聽 endif
聽 聽 聽 ::Super:New( nTop, nLeft, nBottom, nRight,, nStyle,,,, ::oWndEvent,,, nClrText, nClrPane,,,,,,,.T., nStyleEx,,,)
      //
聽 聽endif
.../...

// and at end of method Add this

聽 聽::bInit 聽 := { || Self:TToolWindow(), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽IF( !HB_IsNIL( ::oWndEvent ), Self:oWndEvent:SetFocus(), ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽Self:nIT := Len( aTToast ), ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽if( Self:lHistory, Self:AddToast(), ) }

return Self

// in method ActivaAlert change this

.../...

聽 聽ACTIVATE WINDOW Self 聽 聽// Remove clause ON INIT
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 07:38 PM

I have allways the message go out of the dialog and not on the dialog

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 07:56 PM

With my last modification ?
Not, run OK

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 08:36 PM

I insert your modification and I see allway the mesage out of the dialog

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Notification boxes colored
Posted: Mon May 21, 2018 08:44 PM

Put all my modifications in METHOD NEWTOAST not Method New
Revise my modifications ( all lines )

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Notification boxes colored
Posted: Tue May 22, 2018 06:44 AM

I made all your modifications
send me your ttoast class

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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