change Control Parent

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

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

change Control Parent

Post by AUGE_OHR »

hi,

sometimes i need to change Control Parent.

i have a Progressbar which have a own Window so it will not move when Main Window is moving ... :(
as i don´t want that i "Over-paint" Titlebar with Progressbar so User can´t hit it ;)
but that was just a Workaround.

i found c:\MiniGUI\SAMPLES\BASIC\StatusBar_ProgressBar\demo.prg :idea:
that Demo have a Progressbar in Statusbar ( STATUSITEM / PROGRESSITEM ) but it is not compatible to HMG

---

in e:\hmg.3.4.4\SOURCE\c_windows.c i found

Code: Select all

//        SetParent (hWndChild, hWndNewParent)
HB_FUNC ( SETPARENT )
now i do change Parent of Progressbar ... but "Form" was still on old Position when move so i need both

Code: Select all

#IFDEF ON_STATUSBAR
   nHwnd   := GetProperty( "Pbar_Form", "Handle"  )
   nSbHwnd := GetControlHandle( "STATUSBAR","Win_1" )
   SETPARENT(nHwnd,nSbHwnd)

   nHwnd   := GetControlHandle( "ProgressBar_1","Pbar_Form"  )
   nSbHwnd := GetControlHandle( "STATUSBAR","Win_1" )
   SETPARENT(nHwnd,nSbHwnd)
#ENDIF
now Progressbar and "Form" are "fix" to Statusbar when moving or re-size. :D

this Way you can also "DragDrop" Item from 1st Windows to 2nd Window ... "just" change Parent ( in Background )

---

i know that HMG have a Array for each Control but i did not touch it.
i understand that "Hack" like these can "confuse" hole App so it is NOT recommend when not know exact what doing.

it would be nice if HMG can "integrate" a "safe" Function to change Control Parent.
have fun
Jimmy
Post Reply