Changing xBrowse data source and fields at runtime

Changing xBrowse data source and fields at runtime

Postby Rick Lipkin » Thu Aug 28, 2014 12:56 pm

To All

I am attempting to re-use an xBrowse already defined with an Ado data source and fields assigned to resource ID and browser object. I want to be able to re-use the same xBrowse and assign it a new data source and fields re-using the same resource id and xBrowse object at run-time.

To further clarify .. I want to be able to click on a radio button and show an xBrowse with its data source, fields and resource ID then be able to click on another radio button and re-use the same xBrowse with a new data source and fields utilizing the same resource ID and xBrowse object.

I have not attempted to do this before and have stayed awake most of the night thinking about how I would attempt this Logic.

1) Is there such a method as oLbx:CLose()
2) How would I reconfigure xBrowse at runtime to accept a new data source and fields at run-time using the same resource ID and browser object ?

I would greatly appreciate anyone's thoughts!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Changing xBrowse data source and fields at runtime

Postby FranciscoA » Thu Aug 28, 2014 2:44 pm

Rick:
Maybe this sample code will be of some help. Here, I used ComboBox instead of Radio-buttons.
Code: Select all  Expand view

//---------------------------------//
Function FapSoftScan(oVent)
local oDlg, oBrw, oCbx, oBt2
local aInfo:={}, aTitCols:={}, aWMIscan, bMonitoring
local cVar, nPos:=1, n
local aOptions := {"01  Grupo de Programas      (Win32 Logical Program Group)  ",;
                   "02  Sistema del Ordenador   (Win32 Computer Systen)        " }


bMonitoring := {|| aWMIscan:=FapMonitoring(nPos,oWMI,18) ,;
                   aInfo:=aWMIscan[1], aTitCols:=aWMIscan[2],;
                   oBrw:SetArray(aInfo,.t.,1,.t.),;
                   oBrw:cHeaders := aTitCols, ;
                   oBrw:nHeadStrAligns := AL_CENTER, ;   //    oBrw:nWidths := 160 ,;
                   AEval(oBrw:aCols,{|o,n,oCol|  if(ValType(o:Value) =="N", o:nWidth := Max( 40, oBrw:aCols[n]:HeaderWidth() ), o:nWidth:=160) }),;
                   oBrw:nColSel := 1, oBrw:Refresh(.t.),;
                   oBrw:SetFocus() }


DEFINE DIALOG oDlg SIZE oVent:nWidth, oVent:nHeight TITLE "FapSoftScan" TRANSPARENT

cVar := aOptions[1]

@ oDlg:nTop+10,8 COMBOBOX oCBx VAR cVar OF oDlg PIXEL;
                 ITEMS aOptions ;
                 SIZE 140,16 ;
                 ON CHANGE ( nPos := oCbx:nAt(), Eval(bMonitoring) )

@1,1 XBROWSE oBrw OF oDlg ;
     ARRAY {} CELL LINES FOOTERS AUTOSORT

     oBrw:CreateFromCode()

     Eval(bMonitoring)


 @ oDlg:nTop+245,380 BUTTONBMP oBt2 PROMPT "Salir/Cancelar" OF oDlg ;
                    SIZE 60, 12  PIXEL ;
                    BITMAP "SALIR16x16" TEXTRIGHT ;
                    ACTION oDlg:End()
 
 ACTIVATE DIALOG oDlg CENTERED ;
   ON INIT ( oBrw:nHeight:=oDlg:nHeight-118, oBrw:nWidth:=oDlg:nWidth-34, oBrw:nTop:=oDlg:nTop+50 ,;
             oBrw:SetFocus() )

Return nil


//-------------------------------------------------------------
Function FapMonitoring(nOption,oWMI)
local oPC, oQry
local aInfo:={}, aTitCols, n, nLen

if nOption == 1
   oQry := oWMI:ExecQuery( "Select * FROM Win32_LogicalProgramGroup" )
   aTitCols:= {"Caption","Description","GroupName","Name","UserName","InstallDate","Status"}
   for each oPC in oQry
      aadd(aInfo, {oPC:Caption, oPC:Description, oPC:GroupName, oPC:Name, oPc:UserName, oPc:InstallDate, oPc:Status} )
   next

elseif nOption == 2
   oQry := oWMI:ExecQuery( "Select * FROM Win32_ComputerSystem" )
   aTitCols:= {"Caption","Description","Domain","Model","Name","Processors","Status","System Type","User Name"}
   for each oPC in oQry
      aadd(aInfo, {oPC:Caption, oPC:Description, oPC:Domain, oPC:Model, oPC:Name, oPc:NumberOfProcessors, oPc:Status, oPC:SystemType, oPC:UserName} )
   next  
endif

RETURN {aInfo,aTitCols}
 

Best regards
Last edited by FranciscoA on Thu Aug 28, 2014 3:18 pm, edited 1 time in total.
Francisco J. Alegría P.
Chinandega, Nicaragua.

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

Re: Changing xBrowse data source and fields at runtime

Postby Rick Lipkin » Thu Aug 28, 2014 3:05 pm

Francisco

Great LDAP query !! I understand what you are doing logically .. I don't know if I am going to run into any problems since my xBrowse is tied to a resource ID .. I am thinking I may have difficulty re-initializing the browse since I am using a recordset vs an array :(

I am thinking I am going to create the oRs object and create a recordset, then oRs:Close() and then re-use oRs as my new recordset re-using the same recordset object ?

I am working on the logic now ... Thank you for your suggestion!

Rick
User avatar
Rick Lipkin
 
Posts: 2634
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests