GIF animation demo

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: GIF animation demo

Post by gfilatov »

Roberto Lopez wrote:
gfilatov wrote: The command DRAW PANEL exists in the HMG Extended Edition.
The new TGif class will be available at the next buid of HMG EE :arrow:
:mrgreen:

Could be you so kind to post the DRAW PANEL command source code adapted for HMG?

So, I could add in the 'PROPOSED.FEATURES' folder of the next HMG release... or better... you could add the code to HFCL.
Roberto,

No problem. Kindly take a look for the sample below:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 * Copyright 2002-2009 Roberto Lopez <harbourminigui@gmail.com>
 * http://harbourminigui.googlepages.com/
 *
*/

#include "minigui.ch"

#xcommand DRAW PANEL IN WINDOW <parent> ;
		AT <frow>,<fcol> ;
		TO <trow>,<tcol> ;
          =>;
		DrawWindowBoxRaised( <"parent">, <frow>, <fcol>, <trow>, <tcol> )

#xcommand DRAW BOX IN WINDOW <parent> ;
		AT <frow>,<fcol> ;
		TO <trow>,<tcol> ;
          =>;
		DrawWindowBoxIn( <"parent">, <frow>, <fcol>, <trow>, <tcol> )

function main

	define window x ;
		at 0,0 ;
		width 640 ;
		height 480 ;
		title "Draw Box And Panel Sample By Grigory Filatov" ;
		main nomaximize nosize ;
		on init x.Button_1.Setfocus

		DRAW BOX			;
		IN WINDOW x			;
		AT 20,20			;
		TO 200,300

		@ 110, 140 LABEL Label_1 VALUE "Box In" AUTOSIZE

		DRAW PANEL			;
		IN WINDOW x			;
		AT 20,320			;
		TO 200,610

		@ 110, 440 LABEL Label_2 VALUE "Panel" AUTOSIZE

		@ 220,20 FRAME Frame_1 ;
			CAPTION "Frame Title" ;
			WIDTH 280 ;
			HEIGHT 180 ;
			OPAQUE

		@ 220,320 FRAME Frame_2 ;
			WIDTH 290 ;
			HEIGHT 180 ;
			OPAQUE

		@ 310, 410 LABEL Label_3 VALUE "Frame without title" AUTOSIZE

		@ 414, 530 BUTTON Button_1 ;
			CAPTION "&Close" ;
			ACTION ThisWindow.Release ;
			WIDTH 78 HEIGHT 26

	end window

	x.center

	Activate Window x

Return


function DrawWindowBoxIn(window,row,col,rowr,colr)
   Local i := GetFormIndex ( Window )
   Local FormHandle := GetFormHandle ( Window )
   Local hDC := GetDC( FormHandle )

   WndBoxIn( hDC, row, col, rowr, colr )
   aadd ( _HMG_SYSDATA [ 102 ] [i] , { || WndBoxIn( hDC := GetDC( FormHandle ), row, col, rowr, colr ), ReleaseDC( FormHandle, hDC ) } )
   ReleaseDC( FormHandle, hDC )

return nil

function DrawWindowBoxRaised(window,row,col,rowr,colr)
   Local i := GetFormIndex ( Window )
   Local FormHandle := GetFormHandle ( Window )
   Local hDC := GetDC( FormHandle )

   WndBoxIn( hDC, row, col, rowr, colr )
   aadd ( _HMG_SYSDATA [ 102 ] [i] , { || WndBoxRaised( hDC := GetDC( FormHandle ), row, col, rowr, colr ), ReleaseDC( FormHandle, hDC ) } )
   ReleaseDC( FormHandle, hDC )

return nil


#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"

void WndDrawBox( HDC hDC, RECT * rct, HPEN hPUpLeft, HPEN hPBotRit )
{
   HPEN hOldPen = ( HPEN ) SelectObject( hDC, hPUpLeft );
   POINT pt;

   MoveToEx( hDC, rct->left, rct->bottom, &pt );

   LineTo( hDC, rct->left, rct->top );
   LineTo( hDC, rct->right, rct->top );
   SelectObject( hDC, hPBotRit );

   MoveToEx( hDC, rct->left, rct->bottom, &pt );

   LineTo( hDC, rct->right, rct->bottom );
   LineTo( hDC, rct->right, rct->top - 1 );
   SelectObject( hDC, hOldPen );
}

void WindowBoxIn( HDC hDC, RECT * pRect )
{
   HPEN hWhite = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );
   HPEN hGray = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );

   WndDrawBox( hDC, pRect, hGray, hWhite );

   DeleteObject( hGray );
   DeleteObject( hWhite );
}

void WindowRaised( HDC hDC, RECT * pRect )
{
   HPEN hGray  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
   HPEN hWhite = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );

   WndDrawBox( hDC, pRect, hWhite, hGray );

   DeleteObject( hGray );
   DeleteObject( hWhite );
}

HB_FUNC ( GETDC )
{
   hb_retnl( (ULONG) GetDC( (HWND) hb_parnl(1) ) ) ;
}

HB_FUNC ( RELEASEDC )
{
   hb_retl( ReleaseDC( (HWND) hb_parnl(1), (HDC) hb_parnl(2) ) ) ;
}

HB_FUNC( WNDBOXIN )
{
   RECT rct;

   rct.top    = hb_parni( 2 );
   rct.left   = hb_parni( 3 );
   rct.bottom = hb_parni( 4 );
   rct.right  = hb_parni( 5 );

   WindowBoxIn( ( HDC ) hb_parnl( 1 ), &rct );
}

HB_FUNC( WNDBOXRAISED )
{
   RECT rct;

   rct.top    = hb_parni( 2 );
   rct.left   = hb_parni( 3 );
   rct.bottom = hb_parni( 4 );
   rct.right  = hb_parni( 5 );

   WindowRaised( ( HDC ) hb_parnl( 1 ), &rct );
}

#pragma ENDDUMP
BTW The C-code is available in the file c_graph.c at the folder hmg\source\graph ;)
Attachments
Demo screenshot
Demo screenshot
demo.JPG (21.85 KiB) Viewed 4865 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: GIF animation demo

Post by Roberto Lopez »

gfilatov wrote:
No problem. Kindly take a look for the sample below:
<...>
Thanks!

I've already added to 'PROPOSED.FEATURES' folder in HMG distribution.

The idea to put it there is that it be widely tested and discussed prior to adding as an standard component of HMG.

Thanks again.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: GIF animation demo

Post by gfilatov »

Roberto Lopez wrote:...
I've already added to 'PROPOSED.FEATURES' folder in HMG distribution.

The idea to put it there is that it be widely tested and discussed prior to adding as an standard component of HMG.
Roberto,

Thanks a lot!

One more suggestion. :o
This sample needs the following addition in the procedure _RefreshDataControls for proper showing a panel at the application's startup:

Code: Select all

*------------------------------------------------------------------------------*
Procedure _RefreshDataControls (i)
*------------------------------------------------------------------------------*
Local SplitIndex
Local x
Local w

   If Len ( _HMG_SYSDATA [ 102 ] [i] ) > 0
      SendMessage( _HMG_SYSDATA [ 67 ] [i] , WM_PAINT , 0 , 0 )
   EndIf
...
I hope that helps :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: GIF animation demo

Post by Roberto Lopez »

gfilatov wrote: One more suggestion. :o
This sample needs the following addition in the procedure
Ok.

Thanks again!
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: GIF animation demo

Post by mustafa »

Hola Grigory
Ante todo felicidades por esta aportación
Una cuestión he compilado tu ejemplo para HMG con la versión 2.9.5
con el compile.bat y cuando arranca la aplicación no salen los
recuadros undido , ni el realzado , entonces si hago minimizar la aplicacion
y otra vez regreso a la misma ya aparecen los cuadros.
Un Cordial Saludo
*---------------------*
Hello Grigory
First of all congratulations for this contribution
One question I have compiled your example for HMG to version 2.9.5
with compile.bat and when you boot the application does not leave the
sunken boxes nor enhanced, then if I minimize the application
and again return to it and the boxes appear.
Regards
Mustafa
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: GIF animation demo

Post by mustafa »

Error :?:
Attachments
Error.jpg
Error.jpg (53.32 KiB) Viewed 4849 times
User avatar
gfilatov
Posts: 1060
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: GIF animation demo

Post by gfilatov »

mustafa wrote:Error :?:
Hello Mustafa,

It is a known behaviour (take a look for my aboved suggestion to Roberto for fixing this problem).

I hope that helps :!:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: GIF animation demo

Post by mustafa »

Grigory Thanks for the reply
Mustafa :oops:
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: GIF animation demo

Post by srvet_claudio »

mustafa wrote: ... cuando arranca la aplicación no salen los
recuadros undido , ni el realzado , entonces si hago minimizar la aplicacion
y otra vez regreso a la misma ya aparecen los cuadros.
....
*---------------------*
... when you boot the application does not leave the
sunken boxes nor enhanced, then if I minimize the application
and again return to it and the boxes appear.
...
Codigo Original:

Code: Select all

function main

   define window x ;
      at 0,0 ;
      width 640 ;
      height 480 ;
      title "Draw Box And Panel Sample By Grigory Filatov" ;
      main nomaximize nosize; 
      on init  x.Button_1.Setfocus
 
      ..........................

Cambiar el ON INIT original de la ventana por:

Code: Select all

on init {||SendMessage (GetFormHandle (ThisWindow.Name),15,0,0), x.Button_1.Setfocus}
Esto envía un mensaje WM_PAINT a la ventana cuando arranca y hace que los cuadros se vean como deberían verse, sin
necesidad de minimizar la ventana.

Saludos,
Claudio Soto
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mustafa
Posts: 1158
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: GIF animation demo

Post by mustafa »

Otro Truquillo para los adornos

Another trick for the ornaments
Attachments
Box.zip
(851 Bytes) Downloaded 304 times
Post Reply