FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bitmaps in Xbrowse
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Bitmaps in Xbrowse
Posted: Wed Jun 24, 2009 11:31 AM
Hi,

I'm converting a listbox that used to contain bitmaps to an xBrowse.

Before, i used to create an array of bitmaps

Code (fw): Select all Collapse
    PUBLIC aPics := { ;
    LoadBitmap( GetResources() , "CHECKOFF" ) , ;
    LoadBitmap( GetResources() , "CONFIRMED") , ;
    LoadBitmap( GetResources() , "CHECKON"  ) , ;
    LoadBitmap( GetResources() , "TRAXSENT" ) , ;
    LoadBitmap( GetResources() , "TRAXFAIL" ) , ;
    LoadBitmap( GetResources() , "TICKED"   ) , ;
    LoadBitmap( GetResources() , "NOTTICKED") }


and then just have a field in the listbox that called a function like this:

Code (fw): Select all Collapse
FUNCTION MdiConfirmed(cAlias)
RETURN aPics[IF(&cAlias.->CONFIRMED,8,1)]


I'm now trying to replicate this in an xBrowse, but all i get is a number appearing. The added problem i have, is that i give my customers the ability to define what appears and where it appears in the browse, so i can't hardcode that column 1 will be the bitmap

Thanks in advance

Pete
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bitmaps in Xbrowse
Posted: Wed Jun 24, 2009 12:05 PM

In XBrowse:

oBrw:aCols[ n ]:LoadResource( 'CHECKON' )
oBrw:aCols[ n ]:LoadResource( 'CHECKOFF' )
etc....

then

oBrw:aCols[n]:bBmpData := { || If( (oBrw:cAlias)->CONFIRMED, 1, 2 ) }

Regards



G. N. Rao.

Hyderabad, India
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Bitmaps in Xbrowse
Posted: Wed Jun 24, 2009 01:26 PM

Still getting a number i'm afraid

Pete

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Bitmaps in Xbrowse
Posted: Wed Jun 24, 2009 01:35 PM
Here is a working sample where my bitmaps are resources compiled in the .exe :

Code (fw): Select all Collapse
DEFINE DIALOG oDlg1 RESOURCE "PCASIMPT"  ;
       COLOR "N/W"                       ;
       TITLE cTITLE                      ;

   REDEFINE xBROWSE oLbx1 ;
      ID 111 of oDlg1     ;
      RECORDSET oRsImport ;
      COLUMNS 'load_row',           ;
              'name',               ;
              'pcas_date',          ;
              'clinic',             ;
              'location',           ;
              'program',            ;
              'activity',           ;
              'starttime',          ;
              'endtime',            ;
              'hours',              ;
              'service_type',       ;
              'rectype',            ;
              'unitid',             ;
              'system'              ;
      COLSIZES 30,125,75,90,47,47,47,40,40,40,70,70,70,70 ;
      HEADERS 'Load_row',           ;
              'Name',               ;
              'Service Date',       ;
              'Clinic',             ;
              'Location',           ;
              'Program',            ;
              'Activity',           ;
              'Start',              ;
              'End  ',              ;
              'Hours',              ;
              'Service Type',       ;
              'Record Type',        ;
              'Unit Type',          ;
              'System'              ;
      ON dblclick( _Recalc(oRsImport, oLbx1) ) ;
      AUTOSORT AUTOCOLS FOOTERS LINES CELL

   oLbx1:oCol("Hours"):nTOTAL    := nHOURS
   oLbx1:oCol("Hours"):lTOTAL    := .t.
  
   if .not. Empty( oCol := oLbx1:oCol( "Load_row" ) )
      oCol:SetCheck( { "CHECKON", "CHECKOFF" } )
      oCol:cSortOrder  := nil
      oCol:nEditType := EDIT_GET
      // oCol:lBmpStretch = .T.
   endif

   REDEFINE BUTTON oBTN1 ID 112 of oDLG1     ;
       ACTION ( _Loadum( oRsImport, oDlg1, oBtn3, cMODE ) ) ;
       DEFAULT

   REDEFINE BUTTON oBTN2 ID 118 of oDLG1     ;
       ACTION ( oDlg1:End() )

   ACTIVATE DIALOG oDlg1 ;
     ON INIT( oLbx1:SetFocus(), .F. )
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Bitmaps in Xbrowse
Posted: Wed Jun 24, 2009 02:13 PM
This is the code i'm using to build the columns:

Code (fw): Select all Collapse
    oBrw := TXBrowse():New( oWndBrw )
    ReBuildSched(.F., oBrw, oWndBrw, Self)
    oBrw:bPopup := { || SchedPopup(oBrw, ::cScedAlias, Self)}
    IF Alltrim(Upper(GetIwsSysIni("System Info", "Browse 2007 Style"))) <> "NO"
        oBrw:l2007 := .T.   //2007 Style
    ELSE
        oBrw:l2007 := .F.
    ENDIF

    oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROWMS  //Ticking Style
    
    IF !Empty(GetIwsSysIni("System Info", "Browse Column Dividers"))
        nColStyle := Val(GetIwsSysIni("System Info", "Browse Column Dividers"))
    ENDIF
    IF nColStyle > 0
        oBrw:lColDividerComplete := .T.
    ENDIF
    oBrw:nColDividerStyle    := nColStyle
    IF !Empty(GetIwsSysIni("System Info", "Browse Row Dividers"))
        nRowStyle := Val( GetIwsSysIni("System Info", "Browse Row Dividers") )
    ENDIF
    oBrw:nRowDividerStyle := nRowStyle
    
    // Select a Drag cursor  
    oBrw:oDragCursor := oCursor          
    // Start the dragging operations from the listbox             
    oBrw:bDragBegin := { | nRow, nCol, nKeyFlags | ;
         (SetDropInfo( STR(&ScedAlias.->SITE_ID,2,0)+STR(&ScedAlias.->OR_TICKNBR,8,0) ))}

    // Set a DropOver action for the ListBox
    oBrw:bDropOver := { | uDropInfo, nRow, nCol, nKeyFlags | ;
                  ::MoveTicket(uDropInfo)}

    IF !Empty(::cMessage)
        oBrw:bChange := { || MdiMessage( ::cMessage )}
    ENDIF

    ::oBrw := oBrw
    
    oBrw:CreateFromCode() 
    oWndBrw:oClient := oBrw

STATIC FUNCTION ReBuildSched(lDelete, oBrw, oWnd, oSchedule)    
    LOCAL nLines := 1
    IF lDelete
        DeletexBrowse(oBrw)
    ENDIF
    
    //Go top to bottom of database to read in what columns should appear
    SCHEDETS->(DBGOTOP())
    DO WHILE !SCHEDETS->(EOF())
        IF SCHEDETS->SCHED_SEQ <> "ZZ"  
            nLines := Max(nLines, numat("CHR(13)", UPPER(SCHEDETS->SCHED_COL)) + 1)                         
            cCol := Alltrim(SCHEDETS->SCHED_COL) 
            //This swaps database names to the aliases used
            cCol := UpdateSced(cCol, {"CUSTOMER", "ORDERS", "CONTCAT", "SCHEDULE", "OrdConfirmed()", "Printed()", "OBCStatus()","SITEADDR"}, {oSchedule:cCustAlias, oSchedule:cOrdAlias, oSchedule:cContAlias, oSchedule:cOrdAlias, "MdiConfirmed('" + oSchedule:cOrdAlias + "')", "ScedPrinted()", "ScedOBCStatus()", oSchedule:cSiteAlias})
            oCol := oBrw:AddCol()
            
            //This is the function that i used to use to display the bitmap
            IF Left(cCol, 13) == "MdiConfirmed("                
                oCol:AddResource( "CONFIRMED" )
                oCol:AddResource( "NOTTICKED" )
                oCol:bBmpData := { || If( &OrdAlias.->CONFIRMED, 1, 2 ) }
            ELSE 
                oCol:bStrData := GenbStrData( cCol )
            ENDIF
            oCol:cHeader := SCHEDETS->SCHED_HEAD
            
            oCol:nWidth   := SCHEDETS->SCHED_SIZE
        ENDIF
        SCHEDETS->(DBSKIP())
    ENDDO
    oBrw:nDataLines := nLines
    oBrw:nRowHeight := (18 + ((nLines - 1) * 13))
    IF lDelete
        oBrw:Refresh()
    ENDIF
RETURN NIL

FUNCTION GenbStrData( cCol )
RETURN { || &(cCol) }
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Bitmaps in Xbrowse
Posted: Mon Jun 29, 2009 08:15 AM

Anyone find any problems with the ReBuildSched function above?

Regards,

Pete

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Bitmaps in Xbrowse
Posted: Mon Jun 29, 2009 01:07 PM

If you can provide a small self contained sample, which we can compile and run at our end, we could come up with some solution for you

Regards



G. N. Rao.

Hyderabad, India
Posts: 363
Joined: Wed Feb 15, 2006 02:06 PM
Re: Bitmaps in Xbrowse
Posted: Mon Jun 29, 2009 02:46 PM

Found the problem, it was my mistake :oops:

Pete

Continue the discussion