Copying controls
Copying controls
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 ?
How can I do this ?
- Antonio Linares
- Site Admin
- Posts: 42830
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 144 times
- Been thanked: 118 times
- Contact:
Re: Copying controls
Will both dialogs be visible at the same time ?
Maybe you can just change the parent of the control using SetParent()
Maybe you can just change the parent of the control using SetParent()
Re: Copying controls
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
Re: Copying controls
Maybe it's enough to do this ?
Code: Select all | Expand
oNew:=ocopy(oDlg_1:aControls[1])
aadd(oDlg_2:aControls, oNew)
oDlg_2:Refresh()
- Antonio Linares
- Site Admin
- Posts: 42830
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 144 times
- Been thanked: 118 times
- Contact:
Re: Copying controls
Dear Yuri,
Please try it this way:
Please try it this way:
Code: Select all | Expand
#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
Re: Copying controls
This is how it works
Code: Select all | Expand
oCtl:=ocopy(oDlg_1:aControls[1])
oDlg_2:AddControl(oCtl)
- cnavarro
- Posts: 6658
- Joined: Wed Feb 15, 2012 8:25 pm
- Location: España
- Has thanked: 9 times
- Been thanked: 11 times
Re: Copying controls
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
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
- cnavarro
- Posts: 6658
- Joined: Wed Feb 15, 2012 8:25 pm
- Location: España
- Has thanked: 9 times
- Been thanked: 11 times
Re: Copying controls
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
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