HMG 3.1.5

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
dhaine_adp
Posts: 457
Joined: Wed Aug 06, 2008 12:22 pm
Location: Manila, Philippines

Re: HMG 3.1.5 (Test)

Post by dhaine_adp »

Hi Rathi and Dr. Claudio,

Thanks you very much for this HMG Forum Anniversary Release.

More power!

Danny
Regards,

Danny
Manila, Philippines
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.1.5 (Test)

Post by srvet_claudio »

Pablo César wrote:
srvet_claudio wrote:
Pablo César wrote: Is it possible an example of these ?

- ANIMATE WINDOW cFormName MODE nFlags INTERVAL nMilliseconds
- ANIMATE WINDOW cFormName MODE nFlags (See Docs for various modes)
- New Read Keyboard Functions (like as HMG_GetLastVirtualKeyDown, HMG_GetLastVirtualKeyName, HMG_VirtualKeyIsPressed, GetKeyState, HMG_SendCharacter...)
- New Convert Unicode Value (like as HMG_GetUnicodeValue and MG_GetUnicodeCharacter)
You asked for it, now have fun :D
Thank you gentleman ! :D

I found nothing about "ANIMATE WINDOW" command throughout your code. :cry:

I was fascinated with your code and I would like to contribute with some changes that I believe will provide a better interface:

- I changed the position and size of each window, because depending on the screen resolution, it is difficult to interact.
- I put the the "Modal Window" in separate function, just for be called via a button.
- HMG_InstallEventMonitor was add a label with options.
- I changed the string from Tamil to Arabic because it is visible in some cases where Windows XP does not have support for Asian linguaguem (Case CueBanner).
- There is a problem when is focused on Button_1 and Button_2, MsgInfo is incorrect according Mouse Pointer be focused (see screen captured below):
Screen.PNG
Probably this mistake needs a different approaching for to be solved. :?
Thanks Friend for your interest!!!

The code I posted is not an example of the new capabilities of HMG, is only for testing purposes, the idea is that over time the main code (HMG_EventMonitor.PRG) becomes a debugger for events.

HMG_EventMonitor has already begun to do their work, in all previous versions of HMG when called ActivateWindow creates a new message loop when it should be only one message loop per application (This bug I discovered with HMG_EventMonitor and I fixed in HMG.3.1.5).

PS: In your previous picture the mouse pointer is over the button 2, but the keyboard input focus has the button 1 (see as button 1 is highlighted).
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.1.5 (Test)

Post by Pablo César »

srvet_claudio wrote:In your previous picture the mouse pointer is over the button 2, but the keyboard input focus has the button 1 (see as button 1 is highlighted).
Yes, I had seen, but as you said "to put the focus", I suppose it's just appoint with the mouse on to button to the event OnGotFocus would serve to identify the object.
Only works if we click the button then it is positioned on the correct button that was appointed with the mouse, but then triggers the "action" button.
Pablo César wrote:I found nothing about "ANIMATE WINDOW" command throughout your code. :cry:
And what about ANIMATE WINDOW command ? Any example ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.1.5 (Test)

Post by srvet_claudio »

Pablo César wrote:And what about ANIMATE WINDOW command ? Any example ?

Code: Select all

#include "hmg.ch"

Function Main
DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 400 ;
   HEIGHT 200 ;
   MAIN 

END WINDOW
CENTER WINDOW Form_1

#define AW_HOR_POSITIVE 0x00000001
#define AW_HOR_NEGATIVE 0x00000002
#define AW_VER_POSITIVE 0x00000004
#define AW_VER_NEGATIVE 0x00000008
#define AW_CENTER       0x00000010
#define AW_SLIDE        0x00040000
#define AW_BLEND        0x00080000

nFlag1 := AW_HOR_POSITIVE + AW_VER_POSITIVE
nFlag2 := AW_HOR_POSITIVE + AW_VER_NEGATIVE
nFlag3 := AW_CENTER
nFlag4 := AW_BLEND
nMiliseconds := 5000

AnimateWindow (Form_1.HANDLE, nMiliseconds, nFlag4)

ACTIVATE WINDOW Form_1
Return Nil
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.1.5 (Test)

Post by srvet_claudio »

Pablo César wrote:
srvet_claudio wrote:In your previous picture the mouse pointer is over the button 2, but the keyboard input focus has the button 1 (see as button 1 is highlighted).
Yes, I had seen, but as you said "to put the focus", I suppose it's just appoint with the mouse on to button to the event OnGotFocus would serve to identify the object.
Only works if we click the button then it is positioned on the correct button that was appointed with the mouse, but then triggers the "action" button.
The focus of an object only changes when you click on it with the mouse, use the TAB key or employ SetFocus (hWnd).
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.1.5 (Test)

Post by Pablo César »

I Understand. In this case, in this case would be best as an example, the control key pressed in a TextBox or EditBox.

I made another adjustment to better exemplify this event control in modal window (EditBox):

Code: Select all

#include "hmg.ch"

#include "HMG_EventMonitor.prg"

FUNCTION MAIN()

DEFINE WINDOW Form1 AT 0, 0 WIDTH 316 HEIGHT 405 TITLE "Form1" MAIN ;
   VIRTUAL WIDTH 800 VIRTUAL HEIGHT 800 ON INIT HMG_InstallEventMonitor ()

    DEFINE MAIN MENU
	    POPUP '&File'
			ITEM '&Open'         ACTION MsgInfo ('File:Open') IMAGE 'Check.Bmp' 
            ITEM 'Save'          ACTION MsgInfo ('File:Save') IMAGE 'Free.Bmp'  
            ITEM 'Print'         ACTION MsgInfo ('File:Print') IMAGE 'Info.Bmp'  
            ITEM 'Save As...'    ACTION MsgInfo ('File:Save As')
            ITEM 'HMG Version'   ACTION MsgInfo (HMGVersion())
            SEPARATOR
            ITEM 'Exit'          ACTION MsgInfo ('File:Exit') IMAGE 'Exit.Bmp'
        END POPUP

        POPUP '&Test' 
            ITEM 'Item 1'     ACTION MsgInfo ('Item 1')  name xxx
            ITEM 'Item 2'     ACTION MsgInfo ('Item 2')

            POPUP 'Item 3' name test
               ITEM 'Item 3.1'      ACTION MsgInfo ('Item 3.1') 
               ITEM 'Item 3.2'      ACTION MsgInfo ('Item 3.2')

               POPUP 'Item 3.3'
                  ITEM 'Item 3.3.1'       ACTION MsgInfo ('Item 3.3.1')
                  ITEM 'Item 3.3.2'       ACTION MsgInfo ('Item 3.3.2')
                  POPUP 'Item 3.3.3'
                     ITEM 'Item 3.3.3.1'     ACTION MsgInfo ('Item 3.3.3.1')
                     ITEM 'Item 3.3.3.2'     ACTION MsgInfo ('Item 3.3.3.2')
                     ITEM 'Item 3.3.3.3'     ACTION MsgInfo ('Item 3.3.3.3')
                     ITEM 'Item 3.3.3.4'     ACTION MsgInfo ('Item 3.3.3.4')
                     ITEM 'Item 3.3.3.5'     ACTION MsgInfo ('Item 3.3.3.5')
                     ITEM 'Item 3.3.3.6'     ACTION MsgInfo ('Item 3.3.3.6')

                  END POPUP
                  ITEM 'Item 3.3.4'    ACTION MsgInfo ('Item 3.3.4')
               END POPUP

           END POPUP
            ITEM 'Item 4'     ACTION MsgInfo ('Item 4')
         END POPUP

         POPUP '&Help'
		    ITEM 'About'      ACTION MsgInfo ('Help:ABout')
         END POPUP
    END MENU

    @ 50,  10 LABEL Label_1 VALUE "Press F9       : Show/Hide _HMG_FormMonitor" AUTOSIZE BOLD
    @ 80,  10 LABEL Label_2 VALUE "Press ALT + F9 : Close the application" AUTOSIZE BOLD
    @ 120, 10 LABEL Label_3 VALUE "Put the focus on Button_1 or Button_2 and type: á or Á" AUTOSIZE BOLD FONTCOLOR BLUE

    DEFINE BUTTON Button_1
       ROW    170
       COL    10
       WIDTH  150
       HEIGHT 50
       CAPTION "Button_1"+CRLF+"Run Test !"
       ACTION  OpenTest()
       FONTNAME "Arial"
       FONTSIZE 9
	   MULTILINE .T.
    END BUTTON

    DEFINE BUTTON Button_2
       ROW      230
       COL      10
       WIDTH    150
       CAPTION  "Button_2"
       ACTION   InputBox('What your name?','')
       TOOLTIP  "type: á or Á"
    END BUTTON
	
    DEFINE BUTTON Button_3
       ROW      270
       COL      10
       WIDTH    150
       CAPTION  "Form_Modal"
       ACTION   Win_Modal()
       TOOLTIP  ""
    END BUTTON

    CREATE EVENT PROCNAME Proc_OnKey1() HWND Form1.Button_1.HANDLE  //GetControlHandle ("Button_1","Form1")
    CREATE EVENT PROCNAME Proc_OnKey2()

END WINDOW
// CENTER WINDOW Form1
// ACTIVATE WINDOW Form1, Form_Modal
ACTIVATE WINDOW Form1
RETURN NIL

Function Proc_OnKey1()
LOCAL ch
   
ch := HMG_GetLastCharacter()
IF (ch == "á" .OR. ch = "Á")
   MsgInfo ("Character typed: " + HMG_GetLastCharacter() +HB_OSNEWLINE() +"In control: "+ GetControlInfoByHandle( EventHWND() ), "Button_1" )
   HMG_CleanLastCharacter()   //   avoid re-entry
ENDIF
Return NIL

Function Proc_OnKey2()
LOCAL ch, hWnd

ch := HMG_GetLastCharacter(@hWnd)
IF (ch == "á" .OR. ch = "Á") .AND. hWnd == Form1.Button_2.HANDLE   // GetControlHandle ("Button_2","Form1")
   MsgInfo ("Character typed: " + HMG_GetLastCharacter(),"Button_2")
   HMG_CleanLastCharacter()   //   avoid re-entry
ENDIF
Return NIL

Function Win_Modal()
LOCAL aCode := HMG_GetUnicodeValue ("موجة العالم")   // Return string Arabic to an array --> {1605, 1608, 1580, 1577, 0032, 1575, 1604, 1593, 1593, 1575, 1604, 1604 }
// LOCAL aCode := {1605, 1608, 1580, 1577, 0032, 1575, 1604, 1593, 1593, 1575, 1604, 1604 } // "Hellow World"
LOCAL cTamil := HMG_GetUnicodeCharacter (aCode)

DEFINE WINDOW Form_Modal;
    AT 406,0 ;
    WIDTH 200 HEIGHT 280 ;
    TITLE 'Form_Modal' ;
    MODAL
    @ 10 , 10 EDITBOX Edit_Modal WIDTH  150  HEIGHT 150 VALUE ""
    @ 170, 10 BUTTON  Button_Modal CAPTION "HMG_SendCharacter" ACTION HMG_SendCharacter ( Form_Modal.Edit_Modal.HANDLE, cTamil ) WIDTH 150
	@ 220, 10 LABEL Label_1 WIDTH 180 HEIGHT 24 VALUE "Type:    á        (to test it)" BOLD
	
	CREATE EVENT PROCNAME Proc_OnKey3()
END WINDOW
// CENTER WINDOW Form_Modal
ACTIVATE WINDOW Form_Modal
Return Nil

Function Proc_OnKey3()
LOCAL ch, hWnd

ch := HMG_GetLastCharacter(@hWnd)
IF (ch == "á" .OR. ch = "Á") .AND. hWnd == Form_Modal.Edit_Modal.HANDLE   // GetControlHandle ("Button_2","Form1")
   MsgInfo ("Character typed: " + HMG_GetLastCharacter(),"Edit_Modal")
   HMG_CleanLastCharacter()   //   avoid re-entry
ENDIF
Return NIL
I added this last function Proc_OnKey3. It is so great !


And thank you for your example of ANIMATE WINDOW. :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.1.5 (Test)

Post by Pablo César »

I just tested it and I found very nice ! :)

I made these adjustments just to show all animate effects:

Code: Select all

#include "hmg.ch"

Function Main
Local nMiliseconds := 2000 , I
Local aFlag:={0x00000001, 0x00000002, 0x00000004,;
             0x00000008, 0x00000010, 0x00040000,;
             0x00080000}

Local aMode:={"AW_HOR_POSITIVE", "AW_HOR_NEGATIVE",;
             "AW_VER_POSITIVE", "AW_VER_NEGATIVE",;
             "AW_CENTER", "AW_SLIDE", "AW_BLEND"}

DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 400 ;
   HEIGHT 200 ;
   MAIN 

END WINDOW
CENTER WINDOW Form_1
For I=1 to 7
    Form_1.Title:=aMode[I]
    AnimateWindow (Form_1.HANDLE, If(I>5,nMiliseconds+600,nMiliseconds), aFlag[I])
	Form_1.Hide
Next
ACTIVATE WINDOW Form_1
Return Nil
But the AW_SLIDE effect is not executed. Is there any differentiation in the parameterization of this specific mode or something I doing wrong ?
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.1.5 (Test)

Post by srvet_claudio »

srvet_claudio wrote:I added this last function Proc_OnKey3. It is so great !
Yes, is very easy.

Code: Select all

#include "hmg.ch"

Function Main

      DEFINE WINDOW Form_1 ;
         AT 0,0 ;
         WIDTH 640 HEIGHT 480 ;
         MAIN 

         @ 30,10 EDITBOX Edit_1 ;
            WIDTH 500 ;
            HEIGHT 140 ;
            VALUE 'EditBox_1'

         @ 230,10 EDITBOX Edit_2 ;
            WIDTH 500 ;
            HEIGHT 140 ;
            VALUE 'EditBox_2'

      END WINDOW

      CREATE EVENT PROCNAME OnkeyEditBox1() HWND Form_1.Edit_1.HANDLE MSG WM_CHAR 

      Form_1.Center()
      Form_1.Activate()
Return Nil


Function OnkeyEditBox1()
LOCAL cUTF8_UpperCase := "Á"
LOCAL cUTF8_LowerCase := "á"

   IF  HMG_GetLastCharacter() == cUTF8_UpperCase .OR.  HMG_GetLastCharacter() == cUTF8_LowerCase
      MsgInfo ("Hello")
   ENDIF

Return NIL

Pablo César wrote:But the AW_SLIDE effect is not executed. Is there any differentiation in the parameterization of this specific mode or something I doing wrong ?
See flags description in: http://msdn.microsoft.com/en-us/library ... s.85).aspx
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
luisvasquezcl
Posts: 1258
Joined: Thu Jul 31, 2008 3:23 am
Location: Chile
Contact:

Re: HMG 3.1.5 (Test)

Post by luisvasquezcl »

Estimados amigos,
muchas felicidades por estos 6 años y también mi agradecimiento a Roberto López por el gran aporte que ha hecho a la comunidad xbase.
Saludos cordiales,
Luis Vasquez.

Dear Friends,
congratulations for these six years and also to thank Roberto Lopez for the great contribution he has made to the community xbase.
Best regards,
Luis Vasquez.
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

HMG 3.1.5 (Test)

Post by Pablo César »

srvet_claudio wrote:
Pablo César wrote:But the AW_SLIDE effect is not executed. Is there any differentiation in the parameterization of this specific mode or something I doing wrong ?
See flags description in: http://msdn.microsoft.com/en-us/library ... s.85).aspx
ahhh yes, now I see why ... it is for this reason...
Uses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.
This is because AW_SLIDE is used combined with other mode except with AW_CENTER.

I made other adaptations to exemplify all modes (including mixed mode):

Code: Select all

/* 
   Note that this function does not work correctly on windows 
   vista/7 with the aero theme enabled.
*/

#include "hmg.ch"

Function Main
Local nMiliseconds := 1000 , I
Local aFlag:={0x00000001, 0x00000002, 0x00000004,;
             0x00000008, 0x00000010, 0x00080000,;
			 0x00000004+0x00000001+0x00040000,;
			 0x00000004+0x00000002+0x00040000,;
			 0x00000008+0x00000001+0x00040000,;
			 0x00000008+0x00000002+0x00040000}

Local aMode:={"Left to Right"+CRLF+"(0x00000001)",;
             "Right to Left"+CRLF+"(0x00000002)",;
			 "Top to Bottom"+CRLF+"(0x00000004)",;
			 "Bottom to Top"+CRLF+"(0x00000008)",;
			 "From Center"+CRLF+"(0x00000010)",;
			 "Fade"+CRLF+"(0x00080000)",;
			 "Top Left Down"+CRLF+ "(0x00000004+0x00000001+0x00040000)",;
			 "Top Right Down"+CRLF+"(0x00000004+0x00000002+0x00040000)",;
			 "Down Left Top"+CRLF+ "(0x00000008+0x00000001+0x00040000)",;
			 "Down Right Top"+CRLF+"(0x00000008+0x00000002+0x00040000)"}

DEFINE WINDOW Form_1 ;
   AT 0,0 ;
   WIDTH 400 ;
   HEIGHT 200 ;
   MAIN TOPMOST
   
   DEFINE BUTTON Button_1
        ROW    60
        COL    70
        WIDTH  100
        HEIGHT 28
        ACTION MyMsgWait("Set Flash Window","Atenção",5)
        CAPTION "Button_1"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

END WINDOW
CENTER WINDOW Form_1

For I=1 to 10
	Form_1.Title:=SubStr(aMode[I],1,At(CRLF,aMode[I])-1)
	If I=6
	   HB_IDLESLEEP( 1 )
	Endif
	AnimateWindow(Form_1.HANDLE, If(I=6,nMiliseconds+1600,nMiliseconds), aFlag[I])
	Msginfo(aMode[I],If(I>6,"Mixed mode","Simple mode"))
	Form_1.Hide
Next

Form_1.Show
Form_1.Title:="Set Window Transparent"
SET WINDOW Form_1 TRANSPARENT TO 150
MsgInfo("Set Window Transparent")

Form_1.Title:="Set Window to Opaque"
SET WINDOW Form_1 TO Opaque
MsgInfo("Set Window Opaque (Normal)")

Form_1.Title:="Flash Window"
FLASH WINDOW Form_1 CAPTION COUNT 20 INTERVAL 50
// MyMsgWait("Set Flash Window",,5)
// Inkey(2)

/* Need to implement a new MsgWait("Set Flash Window",,3) 
   thru a C function MessageBox, otherwise it will not
   work before Main Window activated.*/

Form_1.Minimize
Form_1.Title:="Flash Window TaskBar"
FLASH WINDOW Form_1 TASKBAR COUNT 20 INTERVAL 100
MsgInfo("Set Flash TaskBar")

Form_1.Restore
Form_1.Title:="Set Window Normal (Demo Finish)"
ACTIVATE WINDOW Form_1
Return Nil

Function MyMsgWait(cMessage, cTitle, nTime)
Local I:=0, nHeight:=0, nLastLine:=0

Private lLoop := .T.

cMessage:=If(cMessage=Nil," ",cMessage)
cTitle:=If(cTitle=Nil,"Atenção",cTitle)
nTime:=If(nTime=Nil, 10 , nTime)

If IsWindowDefined(Upper("Form'"))
   ThisWindow.Release()
Endif

nHeight:=((If((HMG_Len(cMessage)/68)-Int(HMG_Len(cMessage)/68)=0,Int(HMG_Len(cMessage)/68),Int(HMG_Len(cMessage)/68)+1))*40)+30
If nHeight <= 70
   nHeight := 90
Endif

DEFINE WINDOW FormMsgWait AT 0,0 WIDTH 300 HEIGHT nHeight+35 ;
    TITLE cTitle ICON 'info.bmp' MODAL NOSIZE               ;
	ON RELEASE If(lLoop,lLoop:=.F.,) ON INIT Counting(nTime)

    ON KEY ESCAPE of FormMsgWait ACTION FormMsgWait.Release
	
    For I:=1 TO MLCount(cMessage,68,8,.f.)
        cTexLabel := 'Text'+Str(I,1)
		nLastLine := nLastLine+20
        @ nLastLine,06 LABEL &cTexLabel WIDTH 278 HEIGHT 16 ;
		    VALUE HMG_PADC(Alltrim(MemoLine(cMessage,68,I,8,.t.)),68) ;
		    FONT 'ARIAL' SIZE 10 CENTERALIGN
    Next I
    
    @ nLastLine+30,115 BUTTON Button_1 CAPTION '&Ok' ;
	    WIDTH 80 HEIGHT 30 ACTION (FormMsgWait.Release)

END WINDOW
CENTER WINDOW FormMsgWait
ACTIVATE WINDOW FormMsgWait
Return Nil
	
Function Counting(nSecs)
Local nSeconds := 0, nCount := nSecs

Do While nCount > -1 .and. lLoop
   If Abs( Seconds() - nSeconds ) >= 1
      FormMsgWait.Button_1.Caption:=LTrim(Str(nCount))+" Second"+If(nCount > 1, "s", "")
      nSeconds := Seconds()
	  nCount--
   Endif
   Do Events
Enddo
If lLoop
   lLoop := .F.
   FormMsgWait.Release()
Endif
Return Nil
This source code, was updated with all new Visual Effects on Windows (Contributed by Dr. Claudio Soto).

This video shows almost everything in Windows XP, do not know why Fades effects and Main window (at the end of the video) are not shown..
[youtube]ymRWs-2eFig[/youtube]
This app/example at Windows 7, the effects are not same behavior... :(

Fades are only effects that works properly in Win7.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply