change Icon of TAB ( PAGE )

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

change Icon of TAB ( PAGE )

Post by AUGE_OHR »

hi,

in a TAB every PAGE can have a own ICON.
i want to change these ICON when PAGE is "active" ... how :idea:
have fun
Jimmy
User avatar
danielmaximiliano
Posts: 2625
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: change Icon of TAB ( PAGE )

Post by danielmaximiliano »

hola Jimmy: creo que debes buscar en C:\HMG.3.5\SOURCE\h_tab.prg

Code: Select all

 _HMG_SYSDATA [  9 ]  [k] :=  0   // hImageList 

Code: Select all

If ImageFlag == .T.
		_HMG_SYSDATA [  9 ] [ k ] := AddtabBitMap ( ControlHandle , Images , NoTrans )
	EndIf
https://social.msdn.microsoft.com/Forum ... =vbgeneral
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: change Icon of TAB ( PAGE )

Post by AUGE_OHR »

hi,

thx for Answer.

i have add a "transparent" Dummy Icon at create.
now i want con CHANGE it when TAB PAGE is active

---

i can CHANGE Icon in Statusbar this Way using _SetStatusIcon()

c:\hmg.3.4.4\SOURCE\h_controlmisc.prg

Code: Select all

FUNCTION _SetStatusIcon( ControlName, ParentForm, nItem, cIcon, hIcon )
LOCAL i := GetControlIndex( ControlName, ParentForm )
   SetStatusItemIcon( _HMG_SYSDATA[ 3 ] [ i ], nItem - 1, cIcon, hIcon )
RETURN Nil
c:\hmg.3.4.4\SOURCE\c_status.c

Code: Select all

HB_FUNC ( SETSTATUSITEMICON )
so i search a Solution , like SetStatusItemIcon(), for TAB PAGE :idea:

---

i know ICON of TAB PAGE is Member of TCITEM Structure and need TCIF_IMAGE as "Mask"

this is my Xbase++ Code

Code: Select all

METHOD DXE_TabCtl:SetIcon(nRes,nIndex )

   oIcon := DXE_Icon() :new() :create()
   nIcoHandle := oIcon:load( ::cDLL, nRes )

   nRet := @comctl32:ImageList_ReplaceIcon( ;
	           ::hImgLstSmall, ; // A handle to the image list.
                   - 1, ; // The index of the image to replace. If i is -1, the function appends the image to the end of the list.
                   nIcoHandle ) // The handle to the icon or cursor that contains the bitmap and mask for the new image.

   @ user32:DestroyIcon( nIcoHandle )

   oItem := TCITEM() :NEW()
   oItem:mask := nOr( TCIF_IMAGE )
   oItem:iImage := nRet

   @ USER32:SendMessageA( ::hTabCtl, TCM_SETITEM, nIndex - 1, oItem )
have fun
Jimmy
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: change Icon of TAB ( PAGE )

Post by gfilatov »

AUGE_OHR wrote: Mon Aug 09, 2021 1:14 am hi,

in a TAB every PAGE can have a own ICON.
i want to change these ICON when PAGE is "active" ... how :idea:
Hi Jimmy,

HMG have already the required C-function ADDTABBITMAP() for the above replacement.
But you should use it by himself for such action.

BTW We have in the MiniGUI Ex the above possibility "out of box".

Please take a look for the working example below :arrow:

Hope that helps :idea:
Attachments
Tab_4.zip
(907.88 KiB) Downloaded 69 times
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: change Icon of TAB ( PAGE )

Post by AUGE_OHR »

hi,
gfilatov wrote: Mon Aug 09, 2021 8:50 am Hope that helps :idea:
thx for Answer

i saw

Code: Select all

   oWindow1.Tab1.Image( 1 )   := 'save.ico'
to assign ICO but i want to "change Icon"

so i want do this "later"

Code: Select all

   oWindow1.Tab1.Image( 1 )   := 'MY.ico'
to change 'save.ico' to 'MY.ico'

---

like in HB_FUNC ( SETSTATUSITEMICON ) i need to "DestroyIcon" from Imagelist
it need to assign "new" Icon Position in Imagelist ( most last = -1 )

Code: Select all

   oItem := TCITEM() :NEW()      // Structure TCITEM
   oItem:mask := nOr( TCIF_IMAGE )
   oItem:iImage := nRet // new Position in Imagelist
   SendMessage( ::hTabCtl, TCM_SETITEM, nIndex - 1, oItem )
use "ImageList_ReplaceIcon" work direct in Imagelist of TAB and need no "DestroyIcon"

general i know the Way ...
my Problem are "C" Code for HB_FUNC where i have use Ot4Xb LIB with Xbase++

p.s. i know that Extendet Version can have TCS_OWNERDRAWFIXED but not found Sample which use Ownerdraw
have fun
Jimmy
User avatar
gfilatov
Posts: 1090
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: change Icon of TAB ( PAGE )

Post by gfilatov »

AUGE_OHR wrote: Mon Aug 09, 2021 10:31 am hi,
...
p.s. i know that Extendet Version can have TCS_OWNERDRAWFIXED but not found Sample which use Ownerdraw
Please take a look for the sample at
viewtopic.php?f=24&t=4994&p=47798&hilit ... tab#p47798

for example :idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: change Icon of TAB ( PAGE )

Post by AUGE_OHR »

hi,
gfilatov wrote: Mon Aug 09, 2021 10:40 am Please take a look for the sample at
viewtopic.php?f=24&t=4994&p=47798&hilit ... tab#p47798
for example :idea:
nice Sample of color Tabpage :D

have to look deeper how it work with

Code: Select all

LABEL  WIDTH 0 HEIGHT 0
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: change Icon of TAB ( PAGE )

Post by AUGE_OHR »

hi,

have understand that HB_FUNC ( ADDTABBITMAP ) create "own" Imagelist and "set" ( TCM_SETIMAGELIST ) it as Default

Code: Select all

    DEFINE TAB Tab_1 ;
       ON CHANGE Tab_Change(ThisWindow.Name, This.Name )

Code: Select all

PROCEDURE Tab_Change(ParentForm, ControlName)
LOCAL ControlHandle
LOCAL nTab, Images, NoTrans := .T.

   nTab := GetProperty(ParentForm ,ControlName, "Value")
   DO CASE
      CASE nTab = 1 ; Images := {"GRUENPUNKT","UNCHECK","UNCHECK"}
      CASE nTab = 2 ; Images := {"UNCHECK","GRUENPUNKT","UNCHECK"}
      CASE nTab = 3 ; Images := {"UNCHECK","UNCHECK","GRUENPUNKT"}
   ENDCASE

   ControlHandle := GetControlHandle( ControlName, ParentForm )
   // not sure need to Destroy "old" Imagelist before
   IMAGELIST_DESTROY(ControlHandle)
   // will create own Imagelist and set TCM_SETIMAGELIST
   ADDTABBITMAP( ControlHandle, Images, NoTrans )

RETURN
Question : must i delete "old" ImageList before use TCM_SETIMAGELIST :?:
have fun
Jimmy
Post Reply