Hi Krzysztof thank you very much for teaching us a little more about Threads, for your contribution and your compliment and from others.
I'm trying another way with Not_HMG window (registered but not with _HMG_SYSDATA structure) but I'm not finished yet.
Code: Select all
/*
Win_Msg - A kind of Notification message so easy and friendly Demo
Version.........: 1.2
Created by......: Pablo César on February 11th, 2017
*/
#include "hmg.ch"
#include "MyWindow.ch"
#define HB_THREAD_INHERIT_PUBLIC 1
Function Main()
Load Window Demo2
Demo2.Center
Demo2.Activate
Return Nil
Function Send_Msgs()
LOCAL pThID
StopWindowEventProcedure("Demo2",.T.)
pThID := hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, @Notifier(), "Printing file xxxxx.xxx sent to EPSON LX-300", , 1)
If hb_ThreadWait( pThID ) = 1
hb_threadQuitRequest( pThID )
hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, @Notifier(), CRLF+"File not found!", 1, 1)
Endif
DoMethod("Demo2","SETFOCUS")
Return 1
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
LOCAL cLastForm := GetFormNameByIndex(GetLastActiveFormIndex())
DEFAULT cMsg := ""
DEFAULT nSeconds := 2
If Empty(cMsg)
Return Nil
Endif
If ValType(ERROR) = "U"
aBcolor := {0,153,0}
Else
aBcolor := {204,0,0}
Endif
// SET WINDOW MAIN OFF // Note need any more for not being HMG window
DEFINE MYWINDOW Win_Msg AT nTop, nLeft WIDTH nWidth HEIGHT nHeight TOPMOST ;
NOMAXIMIZE NOMINIMIZE NOSIZE NOSYSMENU NOCAPTION BACKCOLOR aBcolor
// hWnd := My_DefineWindow ( "Win_Msg",, nLeft, nTop, nWidth, nHeight, .F., .F., .F., .F., .T.,.F., "",, ,, , ,, aBcolor, , .F. , .T. , .F. , , .T. , ,, , , ,, , , , , , , , , , .F. , , , , .F. , , , , , , , , , , .F. )
/*
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.)
EnableWindow( hWnd, .T. )
AnimateWindow(hWnd, (nSeconds*300), AW_VER_NEGATIVE)
hb_IdleSleep(nSeconds)
AnimateWindow(hWnd, (nSeconds*1500), (AW_BLEND + AW_HIDE))
// UnRegisterWindow("Win_Msg")
SendMessage( hWnd, WM_SYSCOMMAND, SC_CLOSE, 0 )
StopWindowEventProcedure(cLastForm,.F.)
// SET WINDOW MAIN ON
Return Nil
Function My_DefineWindow( FormName, ; /* 01 "Form_1",*/
Caption, ; /* 02 ,*/
x, ; /* 03 nLeft,*/
y, ; /* 04 nTop,*/
w, ; /* 05 nWidth,*/
h, ; /* 06 nHeight,*/
nominimize, ; /* 07 .F.,*/
nomaximize, ; /* 08 .F.,*/
nosize, ; /* 09 .F.,*/
nosysmenu, ; /* 10 .F.,*/
nocaption, ; /* 11 .T.,*/
StatusBar, ; /* 12 .F.,*/
StatusText, ; /* 13 "",*/
initprocedure, ; /* 14 ,*/
ReleaseProcedure, ; /* 15 ,*/
MouseDragProcedure, ; /* 16 ,*/
SizeProcedure, ; /* 17 ,*/
ClickProcedure, ; /* 18 ,*/
MouseMoveProcedure, ; /* 19 ,*/
aRGB, ; /* 20 aBcolor,*/
PaintProcedure, ; /* 21 ,*/
noshow, ; /* 22 .F.,*/
topmost, ; /* 23 .T.,*/
main, ; /* 24 .F.,*/
icon, ; /* 25 ,*/
child, ; /* 26 .T.,*/
fontname, ; /* 27 ,*/
fontsize, ; /* 28 ,*/
NotifyIconName, ; /* 29 ,*/
NotifyIconTooltip, ; /* 30 ,*/
NotifyIconLeftClick, ; /* 31 ,*/
GotFocus, ; /* 32 ,*/
LostFocus, ; /* 33 ,*/
virtualheight, ; /* 34 ,*/
VirtualWidth, ; /* 35 ,*/
scrollleft, ; /* 36 ,*/
scrollright, ; /* 37 ,*/
scrollup, ; /* 38 ,*/
scrolldown, ; /* 39 ,*/
hscrollbox, ; /* 40 ,*/
vscrollbox, ; /* 41 ,*/
helpbutton, ; /* 42 .F.,*/
maximizeprocedure, ; /* 43 ,*/
minimizeprocedure, ; /* 44 ,*/
cursor, ; /* 45 ,*/
NoAutoRelease, ; /* 46 .F.,*/
InteractiveCloseProcedure, ; /* 47 ,*/
visible, ; /* 48 ,*/
autorelease, ; /* 49 ,*/
minbutton, ; /* 50 ,*/
maxbutton, ; /* 51 ,*/
sizable, ; /* 52 ,*/
sysmenu, ; /* 53 ,*/
titlebar, ; /* 54 ,*/
cPanelParent, ; /* 55 ,*/
panel ; /* 56 .F. */
)
LOCAL vscroll , hscroll , BrushHandle , FormHandle, ParentHandle
/* Unused Parameters */
StatusBar := Nil
StatusText := Nil
DEFAULT x := GetDesktopRealLeft()
DEFAULT y := GetDesktopRealTop()
DEFAULT w := GetDeskTopRealWidth()
DEFAULT h := GetDeskTopRealHeight()
DEFAULT nosize := .Not. sizable
DEFAULT nosysmenu := .Not. sysmenu
DEFAULT nocaption := .Not. titlebar
DEFAULT nominimize := .Not. minbutton
DEFAULT nomaximize := .Not. maxbutton
DEFAULT NoAutoRelease := .Not. AutoRelease
DEFAULT NoShow := .Not. Visible
FormName := AllTrim(FormName)
DEFAULT Caption := ""
DEFAULT scrollup := ""
DEFAULT scrolldown := ""
DEFAULT scrollleft := ""
DEFAULT scrollright := ""
DEFAULT hscrollbox := ""
DEFAULT vscrollbox := ""
DEFAULT InitProcedure := ""
DEFAULT ReleaseProcedure := ""
DEFAULT MouseDragProcedure := ""
DEFAULT SizeProcedure := ""
DEFAULT ClickProcedure := ""
DEFAULT MouseMoveProcedure := ""
DEFAULT PaintProcedure := ""
DEFAULT GotFocus := ""
DEFAULT LostFocus := ""
DEFAULT VirtualHeight := 0
DEFAULT VirtualWidth := 0
DEFAULT aRGB := { -1, -1, -1 }
If VirtualHeight = 0
vscroll := .f.
Else
vscroll := .t.
Endif
If VirtualWidth = 0
hscroll := .f.
Else
hscroll := .t.
Endif
UnRegisterWindow(FormName)
If ValType( icon ) == 'U' .and. ValType( _HMG_DefaultIconName ) != 'U'
icon := _HMG_DefaultIconName
Endif
BrushHandle := RegisterWindow( icon, FormName, aRGB )
Formhandle = InitWindow( Caption , x, y, w, h, nominimize, nomaximize, nosize, nosysmenu, nocaption, topmost, FormName, ParentHandle, vscroll, hscroll, helpbutton, panel )
If Valtype ( cursor ) != "U"
SetWindowCursor( Formhandle , cursor )
EndIf
If valtype(NotifyIconName) == "U"
NotifyIconName := ""
Else
ShowNotifyIcon( FormHandle , .T., LoadTrayIcon(GETINSTANCE(), NotifyIconName ), NotifyIconTooltip )
Endif
InitDummy(FormHandle)
If VirtualHeight > 0
SetScrollRange ( Formhandle, SB_VERT, 0, VirtualHeight - h, .T. )
EndIf
If VirtualWidth > 0
SetScrollRange ( Formhandle, SB_HORZ, 0, VirtualWidth - w, .T. )
EndIf
_HMG_SYSDATA [ 264 ] := .F.
Return (FormHandle)