Win_Msg - A kind of Notification message so easy and friendly Demo

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Win_Msg - A kind of Notification message so easy and friendly Demo

Post by Pablo César »

Hi all,

Here's below a simple demo. A different way to display a message:

Code: Select all

/*  
  Win_Msg - A kind of Notification message so easy and friendly Demo
  
  Version.........: 1.1
  Created by......: Pablo César on February 9th, 2017
 */

#include <hmg.ch>

Function Main()
SET WINDOW MAIN OFF
Notifier("Printing file xxxxx.xxx sent to EPSON LX-300",,3)
Notifier(CRLF+"File not found!",1)
SET WINDOW MAIN ON
Return Nil

Function Notifier(cMsg,ERROR,nSeconds)
LOCAL nHeight := 82, nWidth := 204
LOCAL nLeft := (GetDesktopWidth() - 5) - nWidth
LOCAL nTop := (GetDesktopHeight() - 50) - nHeight
LOCAL hWnd, aBcolor, nWinRow := nTop, nWinCol := nLeft

DEFAULT nSeconds := 2
If ValType(ERROR) = "U"
   aBcolor := {0,153,0}
Else
   aBcolor := {204,0,0}
Endif

DEFINE WINDOW Win_Msg AT nTop, nLeft WIDTH nWidth HEIGHT nHeight TOPMOST ;
    NOMAXIMIZE NOMINIMIZE NOSIZE NOSYSMENU NOCAPTION BACKCOLOR aBcolor
	
    DEFINE LABEL Label_1
        ROW         10
        COL         10
        WIDTH       nWidth - 20
        HEIGHT      nHeight - 20
        VALUE       cMsg
        FONTNAME    "MS Shell Dlg"
        FONTSIZE    10
        FONTBOLD    .F.
        BACKCOLOR   aBcolor
        FONTCOLOR   WHITE
        CENTERALIGN .T. 
    END LABEL

END WINDOW
hWnd := GetFormHandle("Win_Msg")
HMG_ChangeWindowStyle(hWnd, WS_EX_CLIENTEDGE, NIL, .T.)

AnimateWindow(hWnd, (nSeconds*300), AW_VER_NEGATIVE)
hb_IdleSleep(nSeconds)
AnimateWindow(hWnd, (nSeconds*1500), (AW_BLEND + AW_HIDE))
SendMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 )
Return Nil
I hope you all enjoy! :)
Last edited by Pablo César on Thu Feb 09, 2017 9:30 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
serge_girard
Posts: 3165
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Win_Msg - A kind of Notification message so easy and friendly Demo

Post by serge_girard »

Thx Pablo !

Serge
There's nothing you can do that can't be done...
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Win_Msg - A kind of Notification message so easy and friendly Demo

Post by Pablo César »

You are welcome Marek and Serge. Nice to know you have enjoyed. :)

P.S.: Source code re-edited. Time delay was added (in seconds).
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Win_Msg - A kind of Notification message so easy and friendly Demo

Post by trmpluym »

Thanks Pablo, again very usefull !
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: Win_Msg - A kind of Notification message so easy and friendly Demo

Post by huiyi_ch »

Thanks Pablo, again very usefull !
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Win_Msg - A kind of Notification message so easy and friendly Demo

Post by Pablo César »

Good to know it will be useful. :D

Thanks guys to give me feedback.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Win_Msg - A kind of Notification message so easy and friendly Demo

Post by bpd2000 »

Muchas gracias
BPD
Convert Dream into Reality through HMG
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Win_Msg - A kind of Notification message so easy and friendly Demo

Post by Rathinagiri »

Looks very nice and decent! My small addition to center window and transparency.

Now, until the notifier is removed, does the application stop processing? If yes, can this process be moved to a multi-threading enabled thread?

Code: Select all

/*  
  Win_Msg - A kind of Notification message so easy and friendly Demo
  
  Version.........: 1.1
  Created by......: Pablo César on February 9th, 2017
 */

#include <hmg.ch>

Function Main()
SET WINDOW MAIN OFF
Notifier("Printing file xxxxx.xxx sent to EPSON LX-300",,3)
Notifier(CRLF+"File not found!",1)
Notifier("Printing file xxxxx.xxx sent to EPSON LX-300",,3, .t., 128 )
Notifier(CRLF+"File not found!",1,, .t., 100 )
SET WINDOW MAIN ON
Return Nil

Function Notifier(cMsg,ERROR,nSeconds, lCenter, nTransparency)
LOCAL nHeight := 82, nWidth := 204
LOCAL nLeft := (GetDesktopWidth() - 5) - nWidth
LOCAL nTop := (GetDesktopHeight() - 50) - nHeight
LOCAL hWnd, aBcolor, nWinRow := nTop, nWinCol := nLeft
DEFAULT lCenter := .f.
DEFAULT nTransparency := 255


DEFAULT nSeconds := 2
If ValType(ERROR) = "U"
   aBcolor := {0,153,0}
Else
   aBcolor := {204,0,0}
Endif

DEFINE WINDOW Win_Msg AT nTop, nLeft WIDTH nWidth HEIGHT nHeight TOPMOST ;
    NOMAXIMIZE NOMINIMIZE NOSIZE NOSYSMENU NOCAPTION BACKCOLOR aBcolor
	
    DEFINE LABEL Label_1
        ROW         10
        COL         10
        WIDTH       nWidth - 20
        HEIGHT      nHeight - 20
        VALUE       cMsg
        FONTNAME    "MS Shell Dlg"
        FONTSIZE    10
        FONTBOLD    .F.
        BACKCOLOR   aBcolor
        FONTCOLOR   WHITE
        CENTERALIGN .T. 
    END LABEL

END WINDOW
if lCenter
   center window win_msg
endif
SET WINDOW win_msg TRANSPARENT TO nTransparency
hWnd := GetFormHandle("Win_Msg")
HMG_ChangeWindowStyle(hWnd, WS_EX_CLIENTEDGE, NIL, .T.)

AnimateWindow(hWnd, (nSeconds*300), AW_VER_NEGATIVE)
hb_IdleSleep(nSeconds)
AnimateWindow(hWnd, (nSeconds*1500), (AW_BLEND + AW_HIDE))
SendMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 )
Return Nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Win_Msg - A kind of Notification message so easy and friendly Demo

Post by Pablo César »

Rathinagiri wrote:Now, until the notifier is removed, does the application stop processing? If yes, can this process be moved to a multi-threading enabled thread?
Yes. I thought the same thing last night when I adapted it to my application.
Thank you Rathi for the suggestion and the changes. It looks great.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply