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: 3815
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 81 times
Been thanked: 130 times

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

Post by Pablo César » Thu Feb 09, 2017 7:55 pm

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: 1538
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 150 times
Been thanked: 23 times
Contact:

Post by serge_girard » Thu Feb 09, 2017 8:50 pm

Thx Pablo !

Serge

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

Post by Pablo César » Thu Feb 09, 2017 9:31 pm

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: 179
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands
Has thanked: 4 times
Been thanked: 10 times

Post by trmpluym » Thu Feb 09, 2017 11:19 pm

Thanks Pablo, again very usefull !

huiyi_ch
Posts: 48
Joined: Sat May 21, 2016 5:27 am
Has thanked: 1 time
Been thanked: 7 times

Post by huiyi_ch » Thu Feb 09, 2017 11:33 pm

Thanks Pablo, again very usefull !

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

Post by Pablo César » Fri Feb 10, 2017 12:19 am

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: 893
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 65 times
Been thanked: 12 times

Post by bpd2000 » Fri Feb 10, 2017 4:42 am

Muchas gracias
BPD
HMG Convert Dream into Reality

User avatar
Rathinagiri
Posts: 5036
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 75 times
Been thanked: 87 times
Contact:

Post by Rathinagiri » Fri Feb 10, 2017 5:44 am

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: 3815
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 81 times
Been thanked: 130 times

Post by Pablo César » Fri Feb 10, 2017 9:06 am

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

Who is online

Users browsing this forum: No registered users and 1 guest