CLASS Code with HMG Controls

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

CLASS Code with HMG Controls

Post by AUGE_OHR »

hi,

it is easy to include a CLASS under HMG but how to "use it" :?:

i use CLASS Code for DLT Sample but that CLASS do not use Controls

Code: Select all

   ::oControl := DEFINE CONTROL blabla
this Syntax does not work. :roll:

how do i create a "Main" as CLASS :idea:

---

now i use it this Way

Code: Select all

   DEFINE WINDOW MainForm ;
      MAIN ;
      ON INIT DLTstart( lFlagCircle, lFlagSmooth, lFlagEdge, lRibQuick, nPointsCount ) ;

Code: Select all

STATIC PROCEDURE DLTstart( lFlagCircle, lFlagSmooth, lFlagEdge, lRibQuick, nPointsCount )

   oDemoForm := DemoForm() :New()
   oDemoForm:InitFromDBF()
   // overrride
   IF lFlagCircle = .T. 
      oDemoForm:lFlagCircle := .T. 
   ENDIF
   IF lFlagSmooth = .T. 
      oDemoForm:lFlagSmooth := .T. 
   ENDIF
   IF lFlagEdge = .T. 
      oDemoForm:lFlagEdge := .T. 
   ENDIF
   IF lRibQuick = .T. 
      oDemoForm:lRibQuick := .T. 
   ENDIF
   IF nPointsCount > 0
      oDemoForm:SetMaxPoints( nPointsCount )
   ENDIF

   oDemoForm:OnInit()
   oDemoForm:GenPoints( .T. )

RETURN
have fun
Jimmy

User avatar
jairpinho
Posts: 365
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Has thanked: 3 times
Been thanked: 11 times
Contact:

Post by jairpinho »

have you studied what the class structure would look like in harbor ?, do you already have a basic example?
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br

User avatar
danielmaximiliano
Posts: 2289
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 348 times
Been thanked: 63 times
Contact:

Post by danielmaximiliano »

Jimmy :
See 3.3 Classes and objects
http://www.kresin.ru/en/hrbfaq_3.html
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

hi,
jairpinho wrote:
Sun Jun 28, 2020 11:36 pm
have you studied what the class structure would look like in harbor ?, do you already have a basic example?
i have found
c:\hmg.3.4.4\SAMPLES\Advanced\USER_COMPONENTS\mybutton.prg

i see HMG_SYSDATA Array but only 6 of 40 Elements are filled so how to use it :idea:
i understand that Control is create in "C" Part but i like to inherit from existing Control and enhance it

---

i try to run demo but fail :(

i have read c:\hmg.3.4.4\SAMPLES\Advanced\USER_COMPONENTS\readme.txt
i have fill c:\hmg.3.4.4\INCLUDE\i_UsrInit.ch (not UsrInit.ch) and i_UsrSOOP.ch as told
i use this Syntax

Code: Select all

      @ 10 , 10 MYBUTTON test1 ;
            OF Win1 ;
            CAPTION 'Custom Button' ;
            ACTION MsgInfo("hello") 
Harbour 3.2.0dev (r1703241902)
Copyright (c) 1999-2016, http://harbour-project.org/
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x20): multiple definition of `HB_FUN__DEFINEMYBUTTON'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x40): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x40): multiple definition of `HB_FUN_MYBUTTONEVENTHANDLER'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x60): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x60): multiple definition of `HB_FUN_MYBUTTONSETFOCUS'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x80): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x80): multiple definition of `HB_FUN_MYBUTTONENABLE'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0xa0): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0xa0): multiple definition of `HB_FUN_MYBUTTONDISABLE'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0xc0): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0xc0): multiple definition of `HB_FUN_SETMYBUTTONHANDLE'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0xe0): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0xe0): multiple definition of `HB_FUN_GETMYBUTTONHANDLE'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x100): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x100): multiple definition of `HB_FUN_SETMYBUTTONCAPTION'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x120): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x120): multiple definition of `HB_FUN_GETMYBUTTONCAPTION'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x140): first defined here
R:/Temp/hbmk_fwcdkf.dir/mybutton.o:mybutton.c:(.text+0x140): multiple definition of `HB_FUN_INITMYBUTTON'
R:/Temp/hbmk_fwcdkf.dir/demo.o:demo.c:(.text+0x160): first defined here
collect2.exe: error: ld returned 1 exit status
hbmk2[demo]: Error: Running linker. 1
i don´t understand why get Error o Dupe :?:
have fun
Jimmy

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

hi,
AUGE_OHR wrote:
Mon Jun 29, 2020 3:26 am
i don´t understand why get Error o Dupe :?:
hahaha :lol:

Code: Select all

#include "hmg.ch"
// this line make dupe ...
*  Set Procedure To MyButton.Prg

Function Main
have play with CLASS "MYBUTTON" and modify HMG_SYSDATA Array
this Demo include "C" Code which create Control ( CreateWindow() )

what i ask is : can i build a CLASS inherit from HMG Control :idea:

now i have to build "MYcontrol" and build all "existing" Method and VAR in new Code

----

how can i add this to Progressbar

Code: Select all

// iTasklist Interface
//
METHOD DXE_ProgressBar:StartProgressMode()
LOCAL p := 0
LOCAL nRet := 0
LOCAL r,pu,pwb

   IF ::UseiTasklist = .T.
      ::iTask := @user32:RegisterWindowMessageW(L("TaskbarButtonCreated"))
   ELSE
      ::iTask := 0
   ENDIF

   IF ::iTask = 0
      ::pTaskBarlist := 0
   ELSE
      @ole32:CoCreateInstance( UuidFromString(CLSID_TaskbarList),;
                                                               0,;
                                                      CLSCTX_ALL,;
                               UuidFromString(IID_ITaskbarList3),;
                                                              @p )
      IF p <> S_OK
         ::pTaskBarlist := p
         ::nHrInit      := ::TBL1_HrInit()

         IF ::nHrInit <> S_OK
*           Msgbox( FormatErrorMessage( ::nHrInit ), "Error iTasklist" )
            ::pTaskBarlist := 0
         ENDIF

         // "Turning on" progress mode and setting the initial progress value to 0.
         // m_pTaskBarList3->SetProgressState(m_hWnd, TBPF_NORMAL);
         // m_pTaskBarList3->SetProgressValue(m_hWnd, 0, 100);
         IF ::pTaskBarlist <> 0
            nRet := ::TBL3_SetProgressState( ::MainHandle, TBPF_NORMAL )
            nRet := ::TBL3_SetProgressValue( ::MainHandle, ::nValue, ::nMaximum )
         ENDIF

      ENDIF
   ENDIF
RETURN
ot4xb Syntax :
@user32 -> User32.DLL
@ole32 -> OLE32.DLL
L() -> Unicode String
iTasklist3.jpg
iTasklist3.jpg (19.87 KiB) Viewed 301 times
it is to enable Icon in Taskbar to show running Progressbar
have fun
Jimmy

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

hi,

have made "my Progressbar" using Original Source
have rename all "Progressbar" to "PBar" and include it in i_UsrInit.ch and i_UsrSOOP.ch

now when use

Code: Select all

  Form_1.Progress_1.Value := nValue
nothing happend ... :o ... hm

i just have "copy/paste" this from Sample MYButton

Code: Select all

#define SOOP_PBAR ;;
#xtranslate <Window> . \<Control\> . Disable  => Domethod ( <"Window">, \<"Control"\> , "Disable" )  ;;
#xtranslate <Window> . \<Control\> . Enable  => Domethod ( <"Window">, \<"Control"\> , "Enable" )  ;;
#xtranslate <Window> . \<Control\> . Handle  => GetProperty ( <"Window">, \<"Control"\> , "Handle" )  ;;
#xtranslate <Window> . \<Control\> . Handle  := \<v\> => SetProperty ( <"Window">, \<"Control"\> , "Handle" , \<v\> )  ;;
#undef SOOP_PBAR ;;
i guess i need Entry for Value ... :(

---

to set Value of Progressbar this is need

Code: Select all

   SetPosPBarItem( Form_1.Progress_4.handle , nValue )

HB_FUNC( SETPOSPBARITEM )     // SetPosPBarItem( HwndProgressBar, nPos )
{
   HWND hwndProgressBar = ( HWND ) HMG_parnl( 1 );

   ShowWindow(  hwndProgressBar, hb_parni( 2 ) ? SW_SHOW : SW_HIDE );
   SendMessage( hwndProgressBar, PBM_SETPOS, ( WPARAM ) hb_parni( 2 ), 0 );
}

Code: Select all

   nPos := GetPosPbarItem( Form_1.Progress_4.handle)

FUNCTION GetPosPbarItem(ControlHandle)
LOCAL retval := SendMessage ( ControlHandle, PBM_GETPOS, 0, 0 )
RETURN retval
so how to use #xtranslate ... VALUE => Function() :idea:
have fun
Jimmy

User avatar
gfilatov
Posts: 741
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 27 times
Been thanked: 349 times
Contact:

Post by gfilatov »

Hi Jimmy,

Please take a look for the following working example:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 * Copyright 2016 Grigory Filatov <gfilatov@inbox.ru>
*/

#include "minigui.ch"

FUNCTION Main()

   LOCAL nSlider := 40, nVar

   IF !IsWinNT() .OR. !ISVISTAORLATER()
	MsgStop( 'This Program Runs In Windows 7 Or Later!', 'Stop' )
	Return Nil
   ENDIF

   DEFINE WINDOW Win_1 ;
	AT 0,0 ;
	WIDTH 400 ;
	HEIGHT 500 ;
	TITLE "TaskBarList Demo" ;
	MAIN

        This.Sizable   := .F.
        This.MinButton := .F.
        This.MaxButton := .F.

	Define Button Button_1
		Row	10
		Col	10
		Height  32
		Caption	'RESET'
		Action  ( TBL_RESET(ThisWindow.Handle), FlashWindowEx(ThisWindow.Handle, 2, 1, 100) )
	End Button

	Define Button Button_2
		Row	50
		Col	10
		Height  32
		Caption	'PROCESSING'
		Action  TBL_PROCESSING(ThisWindow.Handle)
	End Button

	Define Button Button_3
		Row	90
		Col	10
		Height  32
		Caption	'PROGRESS'
		Action  ( TBL_SETPROGRESS(ThisWindow.Handle), TBL_SETVALUE(ThisWindow.Handle, nSlider, 100) )
	End Button

	Define Button Button_4
		Row	130
		Col	10
		Height  32
		Caption	'ERROR'
		Action  TBL_SETERROR(ThisWindow.Handle)
	End Button

	Define Button Button_5
		Row	170
		Col	10
		Height  32
		Caption	'PAUSE'
		Action  TBL_SETPAUSE(ThisWindow.Handle)
	End Button

	@ 210,10 SLIDER Slider_1 ;
		RANGE 0,100 ;
		WIDTH 365 ;
		HEIGHT 36 ;
		BOTH NOTICKS ;
		VALUE nSlider ;
		ON SCROLL {|| nVar := This.Value, TBL_SETVALUE(ThisWindow.Handle, nVar, 100) } ;
		ON CHANGE {|| nVar := This.Value, TBL_SETVALUE(ThisWindow.Handle, nVar, 100) }

   END WINDOW

   Win_1.Center

   ACTIVATE WINDOW Win_1
   
RETURN Nil


#pragma BEGINDUMP

#include <windows.h>
#include <ShObjIdl.h>

#include <hbapi.h>

ITaskbarList3* TBL_SetProgressState(HWND hWnd, TBPFLAG state)
{
   ITaskbarList3* m_pTaskBarlist;
   HRESULT hr;

#if defined(__cplusplus)
   if((hr = CoCreateInstance( CLSID_TaskbarList, 0, CLSCTX_ALL, IID_ITaskbarList3, ( void ** ) &m_pTaskBarlist ) )==S_OK)
#else
   if((hr = CoCreateInstance( &CLSID_TaskbarList, 0, CLSCTX_ALL, &IID_ITaskbarList3, ( void ** ) &m_pTaskBarlist ) )==S_OK)
#endif
   {
      if( (signed) state != -1 )
#if defined(__cplusplus) && !defined(CINTERFACE)
         m_pTaskBarlist->SetProgressState( hWnd, state );
#else
         m_pTaskBarlist->lpVtbl->SetProgressState( m_pTaskBarlist, hWnd, state );
#endif
      return m_pTaskBarlist;
   }

   return NULL;
}

#ifndef _WIN64
   #define GETHWND ( HWND ) hb_parnl( 1 )
#else
   #define GETHWND ( HWND ) hb_parnll( 1 )
#endif

HB_FUNC( TBL_RESET )
{
   TBL_SetProgressState(GETHWND,TBPF_NOPROGRESS);
}

HB_FUNC( TBL_PROCESSING )
{
   TBL_SetProgressState(GETHWND,TBPF_INDETERMINATE);
}

HB_FUNC( TBL_SETPROGRESS )
{
   TBL_SetProgressState(GETHWND,TBPF_NORMAL);
}

HB_FUNC( TBL_SETVALUE )
{
   HWND hWnd = GETHWND;
   ULONGLONG n = hb_parnll( 2 );
   ULONGLONG m = hb_parnll( 3 );
   ITaskbarList3* m_pTaskBarlist = TBL_SetProgressState( GETHWND, (TBPFLAG) -1 );

   if( m_pTaskBarlist )
   {
#if defined(__cplusplus) && !defined(CINTERFACE)
      m_pTaskBarlist->SetProgressValue( hWnd, n, m );
#else
      m_pTaskBarlist->lpVtbl->SetProgressValue( m_pTaskBarlist, hWnd, n, m );
#endif
   }
}

HB_FUNC( TBL_SETERROR )
{
   TBL_SetProgressState( GETHWND, TBPF_ERROR );
}

HB_FUNC( TBL_SETPAUSE )
{
   TBL_SetProgressState( GETHWND, TBPF_PAUSED );
}

#pragma ENDDUMP
Hope that useful :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

hi,
gfilatov wrote:
Tue Jun 30, 2020 7:52 am
Please take a look for the following working example:
Hope that useful :idea:
PERFECT :!:
have fun
Jimmy

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

your "C" Code work PERFECT but it seem me it work when start App.

is it possible to have a "HB_FUNC( TBL_START )" to CoCreateInstance() :idea:

how do i "release" it :?:

Code: Select all

METHOD DXE_ProgressBar:EndProgressMode()
LOCAL nRet

   IF !EMPTY(::pTaskBarlist)
      // m_pTaskBarList3->SetProgressState(m_hWnd, TBPF_NOPROGRESS);
      // m_pTaskBarList3->Release();
      // m_pTaskBarList3 = NULL;

      nRet := ::TBL3_SetProgressState( ::MainHandle, TBPF_NOPROGRESS )
      nRet := ::TBL3_Release()

      IF NIL <> ::nHrInit
         nRet := ::TBL1_Release()
         ::nHrInit := NIL
      ENDIF

      ::pTaskBarlist := 0

      @ole32:CoUninitialize()
   ENDIF

RETURN

Code: Select all

METHOD DXE_ProgressBar:TBL3_Release()
LOCAL bError
LOCAL oError

   IF !Empty(::pTaskBarlist)
      bError := ErrorBlock( {|oErr| Break( oErr ) } )
      BEGIN SEQUENCE
         ::nLastError := ITaskbarList3_Release(::pTaskBarlist)
      RECOVER USING oError
      ENDSEQUENCE
      ErrorBlock( bError )
   ENDIF

RETURN ::nLastError
have fun
Jimmy

User avatar
AUGE_OHR
Posts: 874
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 132 times
Been thanked: 218 times

Post by AUGE_OHR »

hi,

we got the PERFECT Sample from Grigory for Progressbar :!:

when using "MyControl" i have to add Method and Property into i_UsrSOOP.ch which can "re-direct" it to Function
i try to use this

Code: Select all

#define SOOP_PBAR ;;
#xtranslate <Window> . \<Control\> . Disable  => Domethod ( <"Window">, \<"Control"\> , "Disable" )  ;;
#xtranslate <Window> . \<Control\> . Enable  => Domethod ( <"Window">, \<"Control"\> , "Enable" )  ;;
#xtranslate <Window> . \<Control\> . Handle  => GetProperty ( <"Window">, \<"Control"\> , "Handle" )  ;;
#xtranslate <Window> . \<Control\> . Handle  := \<v\> => SetProperty ( <"Window">, \<"Control"\> , "Handle" , \<v\> )  ;;
#xtranslate <Window> . \<Control\> . VALUE  := \<v\> => SetPBValue( <"Window">, \<"Control"\> , \<v\> )  ;;
#undef SOOP_PBAR ;;

Code: Select all

   Form_1.Progress_1.Value := nValue

FUNCTION SetPBValue(cForm,cProgress,xValue)
LOCAL hWnd := GetControlHandle( cProgress, cForm )
   SetProperty(cForm,cProgress,"Value",xValue)
   SetPosPBarItem( hWnd , xValue )
RETURN NIL
---

now Sample "MyProgressbar" work ... but when compile i got new Error
.hbmk/win/mingw/ASKFORM.o:ASKFORM.c:(.data+0x298): undefined reference to `HB_FUN_SETPBVALUE'
.hbmk/win/mingw/Browser.o:Browser.c:(.data+0x9a8): undefined reference to `HB_FUN_SETPBVALUE'
.hbmk/win/mingw/EXPORT.o:EXPORT.c:(.data+0x208): undefined reference to `HB_FUN_SETPBVALUE'
.hbmk/win/mingw/FMGRID.o:FMGRID.c:(.data+0x998): undefined reference to `HB_FUN_SETPBVALUE'
.hbmk/win/mingw/FMSETUP.o:FMSETUP.c:(.data+0x678): undefined reference to `HB_FUN_SETPBVALUE'
.hbmk/win/mingw/HBEJECT.o:HBEJECT.c:(.data+0x3b8): more undefined references to `HB_FUN_SETPBVALUE' follow
collect2.exe: error: ld returned 1 exit status
so it is wrong Way :?
have fun
Jimmy

Post Reply