Curiosidad XBROWSE

Curiosidad XBROWSE

Postby FranciscoA » Tue Aug 06, 2013 10:37 pm

Hola.
Podría alguien explicarme por qué funciona bien el siguiente código?

El caso es que el XBrowse no existe en recursos, mucho menos el ID 180.
aArray es un array de un solo elemento con varias filas {1,2,3,4,5,6}, oVent es un boton desde otro dialogo.
Code: Select all  Expand view
//---------------------------------//
Function Prueba(aArray,oVent)
local oBrw, oDlg, n
local aRect := GetWndRect( oVent:hWnd )

   DEFINE DIALOG oDlg SIZE 100,100 PIXEL STYLE nor( WS_POPUP, WS_VISIBLE, WS_BORDER)

   REDEFINE XBROWSE oBrw ID 180 OF oDlg ;
         ARRAY aArray

    ACTIVATE DIALOG oDlg ;
         ON INIT ( oDlg:nWidth := oVent:nWidth, oDlg:nHeight:=oBrw:nRowHeight*oBrw:nLen ,;
                   oBrw:SetSize( oDlg:nWidth,oDlg:nHeight ) ,;
                   oDlg:Move(aRect[1] + oVent:nHeight-1, aRect[2]) )
Return nil
 

Saludos.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2129
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Re: Curiosidad XBROWSE

Postby nageswaragunupudi » Sun Aug 11, 2013 2:26 pm

Only part of the code that must be confusing is why "REDEFINE ...." is working. It should not be difficult to understand why rest of the code is working as is working.

There is no big difference between REDEFINE XBROWE command and @ r,c XBROWSE command, except that in the case of REDEFINE an ID is specified.

If the dialog is created from resource, then the ID should match. Otherwise an error occurs.

Because the dialog is from source code, XBrowse got registered with the ID given instead of registering with a new ID, because there was no conflict.

While we can understand the internal working and why it worked, it is not desirable to use REDEFINE with a non-resource dialog.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10317
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Curiosidad XBROWSE

Postby FranciscoA » Sun Aug 11, 2013 3:44 pm

Only part of the code that must be confusing is why "REDEFINE ...." is working.

Yes, that's.

There is no big difference between REDEFINE XBROWE command and @ r,c XBROWSE command, except that in the case of REDEFINE an ID is specified.
Yes, I know that.

If the dialog is created from resource, then the ID should match. Otherwise an error occurs.

Yes, I know that.

Because the dialog is from source code, XBrowse got registered with the ID given instead of registering with a new ID, because there was no conflict.

This is new for me.

it is not desirable to use REDEFINE with a non-resource dialog.

Yes I know.

It all started when a user asked me to modify the code, and I found out that I had left this part, unconsciously. So I thought found a curious case, and I posted it here.

Regards.
Francisco J. Alegría P.
Chinandega, Nicaragua.

Fwxh-MySql-TMySql
User avatar
FranciscoA
 
Posts: 2129
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 133 guests