Bitmaps in Xbrowse

Bitmaps in Xbrowse

Postby PeterHarmes » 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: Select all  Expand view

    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: Select all  Expand view

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
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Bitmaps in Xbrowse

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bitmaps in Xbrowse

Postby PeterHarmes » Wed Jun 24, 2009 1:26 pm

Still getting a number i'm afraid

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Bitmaps in Xbrowse

Postby Rick Lipkin » Wed Jun 24, 2009 1:35 pm

Here is a working sample where my bitmaps are resources compiled in the .exe :

Code: Select all  Expand view

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. )

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

Re: Bitmaps in Xbrowse

Postby PeterHarmes » Wed Jun 24, 2009 2:13 pm

This is the code i'm using to build the columns:

Code: Select all  Expand view


    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) }

 
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Bitmaps in Xbrowse

Postby PeterHarmes » Mon Jun 29, 2009 8:15 am

Anyone find any problems with the ReBuildSched function above?

Regards,

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England

Re: Bitmaps in Xbrowse

Postby nageswaragunupudi » Mon Jun 29, 2009 1: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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bitmaps in Xbrowse

Postby PeterHarmes » Mon Jun 29, 2009 2:46 pm

Found the problem, it was my mistake :oops:

Pete
PeterHarmes
 
Posts: 363
Joined: Wed Feb 15, 2006 2:06 pm
Location: Oxford, England


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 101 guests