FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Copying controls
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Copying controls
Posted: Mon Apr 14, 2025 07:35 AM
On the dialog "A" there is a control - xBrowser. In the process of work I need to copy it to the dialog "B" (ocopy())/.
How can I do this ?
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Copying controls
Posted: Mon Apr 14, 2025 07:55 AM

Will both dialogs be visible at the same time ?

Maybe you can just change the parent of the control using SetParent()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Copying controls
Posted: Mon Apr 14, 2025 08:05 AM

Yes, both dialogs are visible at the same time. And each will have its own (similar in structure) xBrowse. In this case SetParent is not suitable

Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Copying controls
Posted: Mon Apr 14, 2025 08:23 AM
Maybe it's enough to do this ?
oNew:=ocopy(oDlg_1:aControls[1])
aadd(oDlg_2:aControls, oNew)
oDlg_2:Refresh()
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Copying controls
Posted: Mon Apr 14, 2025 12:29 PM
Dear Yuri,

Please try it this way:
#include "FiveWin.ch"

function Main()

    USE customer

    XBROWSER SETUP BrwSetup( oBrw ) 

return nil    

function BrwSetup( oBrw )

   local oDlg, oBrw2, hWnd

   DEFINE DIALOG oDlg SIZE 800, 600 

   @ 1, 1 XBROWSE oBrw2 OF oDlg SIZE 600, 500 

   oBrw2:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
      ON INIT ( hWnd := oBrw2:hWnd, oBrw2 := OClone( oBrw ), oBrw2:hWnd := hWnd, oBrw2:oWnd := oDlg, .T. ) 

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Copying controls
Posted: Wed Apr 16, 2025 01:16 PM
This is how it works
oCtl:=ocopy(oDlg_1:aControls[1])
oDlg_2:AddControl(oCtl)
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Copying controls
Posted: Wed Apr 16, 2025 01:30 PM

Ok, but it strikes me that you don't have to change the xbrowse oWnd ( parent ) to the new destination oDlg

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Copying controls
Posted: Wed Apr 16, 2025 01:48 PM
Sorry, I didn't understand you :(
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Copying controls
Posted: Wed Apr 16, 2025 02:00 PM

When you add the xbrowse object to the list of controls of the new dialog, that may be correct, but the oWnd data of the xbrowse object still holds the previous oDlg object.

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Copying controls
Posted: Wed Apr 16, 2025 03:40 PM

oCtl:=ocopy(oDlg_1:aControls[1])

oCtl:oWnd:=oDlg_2

oDlg_2:AddControl(oCtl)

Continue the discussion