Announcement

Collapse
No announcement yet.

Converting LV Codes to MLG

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting LV Codes to MLG

    Hello,

    I am not sure if I can achieve the same with MLG. The code below is of LV, which changes the text colour to red when the guests DepartureDate and DepartureTime has reached or past.

    Code:
    Local iCol, irow As Long, pLVDI As LV_DISPINFO Ptr, lplvcd As NMLVCUSTOMDRAW Ptr, sDepartureDate$  
    
       Case %WM_NOTIFY
             Select Case CB.NMID
                Case %ID_FRMREGISTRATION2_LISTVIEW1
                   Select Case CB.NMCODE
                      Case %NM_CUSTOMDRAW
                         lplvcd = Cb.lParam
                         Select Case @lplvcd.nmcd.dwDrawStage
                            Case %CDDS_PrePaint
                               Function = %CDRF_NOTIFYITEMDRAW : Exit Function
                            Case %CDDS_ItemPrePaint
                               iRow = @lplvcd.nmcd.dwItemSpec + 1
                               iCol = @lplvcd.iSubItem + 1
                               'LISTVIEW Get Text hfrmRegistration2, %ID_FRMREGISTRATION2_LISTVIEW1,iRow,9 To sDepartureDate$
                               LISTVIEW Get Text nCbHndl, %ID_FRMREGISTRATION2_LISTVIEW1,iRow,9 To sDepartureDate$
                               If (SQLiteDate(sDepartureDate$) < SQLiteDate(PBDate(Date$))) Or (SQLiteDate(sDepartureDate$) = SQLiteDate(PBDate(Date$)) And Time$ > "12")Then @lplvcd.clrText = %RED  
                               Function = %CDRF_NEWFONT : Exit Function   'change item/subitem BG colors
                         End Select
                   End Select
             End Select
       End Select
    I have been trying to do the same with MLG without success. Glad if anyone can point me in the right direction.

    Note: Gary Beene helped with the final code of the above.

    Fredrick Ughimi
    www.meganetsoft.com

  • #2
    Howdy, Fredrick!

    In general, you're keeping track of the time, yes? So in the %WM_Timer code put a function that tests the content of cells containing the times you want to monitor, then change the colors appropriately with %MLG_SetTextCellColor and %MLG_SetBkgndCellColor?

    Comment


    • #3
      Hello Gary,

      Thank you for your response.

      I will try that out and see how it goes.

      Best regards.
      Fredrick Ughimi
      www.meganetsoft.com

      Comment


      • #4
        Hello Gary,

        This is what I put together. No luck yet. Is there something I am not doing right?

        Code:
        Function CDate(Pbd As String) As String
          'mm-dd-yyyy to yyyy-mm-dd
        
          Function = Mid$(Pbd,7,4) & "-" & Mid$(Pbd,1,2) & "-" & Mid$(Pbd,4,2)
        
        End Function
        
        Case %WM_TIMER
            [email protected] 'current row
            sDepartureDate = MLG_Get(hRegistrationGrid, myrow,12)
           If (sDepartureDate < CDate(Date$)) Or (sDepartureDate = (CDate(Date$)) And Time$ > "12") Then
              MLG_FormatCellTextColor(hRegistrationGrid,myrow,0,%CELLCOLORRED)
           End If
        Fredrick Ughimi
        www.meganetsoft.com

        Comment


        • #5
          Hi Fredrick.

          To be sure that you are picking up the currently selected row/column I generally use a SendMessage function to pick it up, to ensure that something else hasn't amended Param1.
          I'm assuming your timer event is being triggered by some code in the initialise dialog section?

          Code:
          FUNCTION funGetSelectedRowColumn(hGrid AS DWORD, myRow AS LONG, myCol AS LONG) AS LONG
          ' return the row and column currently selected in the grid
          LOCAL I AS LONG
          '
          I= SendMessage(hGrid, %MLG_GETSELECTED, 0, 0)
          myrow = LO(INTEGER, I)
          mycol = HI(INTEGER,I)
          FUNCTION = I
          END FUNCTION

          Comment


          • #6
            Hello Graham,

            Thank you for your response and the piece of code.

            My intention is not to select the grid, but retrieve the value of the DepartureDate from every row and use it to test my logic. Am I going about it the wrong way?

            Best regards.
            Fredrick Ughimi
            www.meganetsoft.com

            Comment

            Working...
            X