Copying controls

Post Reply
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Copying controls

Post by Natter »

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 ?
User avatar
Antonio Linares
Site Admin
Posts: 42830
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 144 times
Been thanked: 119 times
Contact:

Re: Copying controls

Post by Antonio Linares »

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
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Copying controls

Post by Natter »

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
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Copying controls

Post by Natter »

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()
User avatar
Antonio Linares
Site Admin
Posts: 42830
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 144 times
Been thanked: 119 times
Contact:

Re: Copying controls

Post by Antonio Linares »

Dear Yuri,

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 
regards, saludos

Antonio Linares
www.fivetechsoft.com
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Copying controls

Post by Natter »

This is how it works

Code: Select all | Expand

oCtl:=ocopy(oDlg_1:aControls[1])
oDlg_2:AddControl(oCtl)
User avatar
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

Post by cnavarro »

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
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Copying controls

Post by Natter »

Sorry, I didn't understand you :(
User avatar
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

Post by cnavarro »

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
Natter
Posts: 1279
Joined: Mon May 14, 2007 9:49 am

Re: Copying controls

Post by Natter »

oCtl:=ocopy(oDlg_1:aControls[1])
oCtl:oWnd:=oDlg_2
oDlg_2:AddControl(oCtl)
Post Reply