Skip to content

Instantly share code, notes, and snippets.

@VerchenkoAG
Last active August 29, 2017 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VerchenkoAG/be80f18c5e49a062a2d7 to your computer and use it in GitHub Desktop.
Save VerchenkoAG/be80f18c5e49a062a2d7 to your computer and use it in GitHub Desktop.
* Потоки в MiniGui / Streams in MiniGui * Прелодер в MiniGui / Preloader in MiniGui
/*
///////////////////////////////////////////////////////////////////////////////
// У себя в программе можно делать так:
nTime := SECONDS()
// создаём окно ожидания с потоком
WaitThreadCreate( 'Расчёт начислений ...' )
// основной цикл вычислений/расчётов/созданий баз и т.д.
...................
WaitThreadClose() // закрыть окно "ожидания"
cMsg := "Расчет успешно произведён за " + SECTOTIME( SECONDS() - nTime )
MsgInfo(cMsg)
*/
//////////////////////////////////////////////////////////////////////////////
/*
* MINIGUI - Harbour Win32 GUI library Demo
* Потоки в Harbour / Threads in Harbour
* Потоки в MiniGui / Threads in MiniGui
* Прелодер в MiniGui / Preloader in MiniGui
*
* Copyright 2015 Verchenko Andrey <verchenkoag@gmail.com>
* Copyright 2015 Grigory Filatov <gfilatov@inbox.ru>
*/
#include "minigui.ch"
#include "hbthread.ch"
// имя формы - окна "ожидания" / the name of the form - the window "waiting"
STATIC cStatWinWait := ""
// для старта цикла в окне "ожидания"/ for the start of the cycle in the window "waiting"
STATIC lStatWinWait := .T.
// массив картинок для окна "ожидания" / an array of images to window "waiting"
STATIC aStatPictWait := {"FR01","FR02","FR03","FR04","FR05","FR06","FR07","FR08",;
"FR09","FR10","FR11","FR12"}
//////////////////////////////////////////////////////////////////////////////
FUNCTION WaitThreadCreate( cTitle )
LOCAL cFormName := "WaitWin_" + HB_NtoS( _GetId() )
DEFAULT cTitle := "Working..."
// transfer window name "standby" in the public variable
// передать имя окна "ожидания" в public переменную
cStatWinWait := cFormName
// To start an infinite loop in the flow preloding
// для старта бесконечного цикла preloding в потоке
lStatWinWait := .T.
SET INTERACTIVECLOSE OFF
DEFINE WINDOW &cFormName ;
ROW 0 COL 0 ;
WIDTH 420 HEIGHT 230 ;
TITLE '' ;
MINWIDTH 420 MINHEIGHT 230 ;
MAXWIDTH 420 MAXHEIGHT 230 ;
MODAL NOCAPTION ;
BACKCOLOR WHITE ;
ON MOUSECLICK MoveActiveWindow()
@ 10,10 LABEL Label_1 ;
WIDTH 400 HEIGHT 20 ;
VALUE "Прошло времени " + TIME() ;
CENTERALIGN VCENTERALIGN TRANSPARENT
@ 40, (420-128)/2 IMAGE Image_1 PICTURE aStatPictWait[1] ;
WIDTH 128 HEIGHT 128 ;
WHITEBACKGROUND TRANSPARENT
@ 40 + 128 + 10, 10 LABEL Label_2 ;
WIDTH 400 HEIGHT 20 ;
VALUE cTitle ;
CENTERALIGN VCENTERALIGN TRANSPARENT
END WINDOW
Center Window &cFormName
Activate Window &cFormName NoWait
// Start preloding in a separate thread
// Запускаем preloding в отдельном потоке
hb_threadDetach(hb_threadStart(HB_THREAD_INHERIT_MEMVARS, @WaitThreadTimer(), SECONDS() ))
RETURN NIL
//////////////////////////////////////////////////////////////////////
FUNCTION WaitThreadClose()
// завершить функцию в потоке / complete function in the stream
lStatWinWait := .F.
InkeyGui(100)
SET INTERACTIVECLOSE ON
Domethod(cStatWinWait,"Release")
DO MESSAGE LOOP
RETURN NIL
//////////////////////////////////////////////////////////////////////////////
FUNCTION WaitThreadTimer(nTime)
// Variable nTime equal SECONDS () - gives an example of the transmission
// переменная nTime равная SECONDS() - приведена в качестве примера передачи
LOCAL cFormName, nLogo := 1 , lExit := .T., cTime
cFormName := cStatWinWait
DO WHILE lStatWinWait
cTime := "Прошло " + SECTOTIME( SECONDS() - nTime )
nLogo ++ // номер показа картинки
nLogo := IIF( nLogo > LEN( aStatPictWait ), 1, nLogo )
SetProperty( cFormName, "Label_1", "Value", cTime )
SetProperty( cFormName, "Image_1", "Picture", aStatPictWait[ nLogo ] )
InkeyGui(100)
DO EVENTS
ENDDO
RETURN NIL
/////////////////////////////////////////////////
#define HTCAPTION 2
#define WM_NCLBUTTONDOWN 161
PROCEDURE MoveActiveWindow( hWnd )
DEFAULT hWnd := GetActiveWindow()
PostMessage( hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 )
RC_CURSOR( "Grabbed32" )
RETURN
@VerchenkoAG
Copy link
Author

VerchenkoAG commented Jul 29, 2015

  • Потоки в Harbour / Threads in Harbour
  • Потоки в MiniGui / Threads in MiniGui
  • Прелодер в MiniGui / Preloader in MiniGui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment