Announcement

Collapse
No announcement yet.

MLG Questions

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

  • #61
    Hi Mike,

    Good news. Check out MLG_PUTEX with op of -4
    This code will display any SQLitening sql statement in MLG with automatic column names
    Thanks for pointing this out.
    Fredrick Ughimi
    www.meganetsoft.com

    Comment


    • #62
      Probably I did not explain my scenario better. I am filling the grid table from a different form other than the grid form. The grid form just sits there waiting for updates from the its table and reads it updating its content. I don't want to close and re-open the grid form to load the current records. I thought that is what the Refresh or Redraw is all about.
      Fredrick Ughimi
      www.meganetsoft.com

      Comment


      • #63

        MLG_ArrayRedim ghGrid,rows,cols,rows,cols sArray() could be from any file.
        'write to grid and refresh
        MLG_PutEx ghGrid,sArray(),-4,1
        CONTROL SET FOCUS ghDlg,%Grid1 'optional

        Triple check that the hDlg and hGrid are not 0 when the call is made?

        MLG_Put hGrid,row,col,VARPTR(s),refresh,sheet 'The sheet parameter is optional
        https://www.tesla.com/roadster

        Comment


        • #64
          Hello Mike,

          I used the following snippets to achieve what I wanted. Am I looking for trouble doing this? Works alright though.

          Code:
          Case %WM_PAINT 
              FillGrid ' Read the all records to the gird
              Control Redraw ghDlg&, %IDC_MLGGRID   
              hDC = BeginPaint(ghDlg&, pPaint)
                    SendMessage hGrid1,%MLG_REFRESH,0,0
              EndPaint ghDlg&, pPaint
              Function = 1
              Exit Function
          Fredrick Ughimi
          www.meganetsoft.com

          Comment


          • #65
            I do not know if your paint method will cause a problem.
            Filling the grid in the Paint doesn't seem right (could cause endless loop?)

            No form has to be reloaded with MLG_PutEx ghGrid,gsArray(),-4,0 and it refreshes the grid.
            Here is a demo that scrolls the grid as the array gets bigger by 1-row each time the button is clicked and WM_PAINT is not used.
            The docs say refresh may be unreliable so use
            'CASE %WM_PAINT
            ' CONTROL REDRAW CBHNDL,%Grid1

            Please try this code to see if it refreshes.
            If it does then maybe contact the author of your visual designer.
            Tested only using Windows 10.

            Code:
            GLOBAL ghDlg,ghGrid,gCounter AS DWORD
            GLOBAL gsArray() AS STRING
            %Button = 500
            %Grid  =1000
            #INCLUDE ONCE "WIN32API.INC"
            #INCLUDE ONCE "mlg.inc"
            FUNCTION PBMAIN AS LONG
              LOCAL hDlg,hGrid AS DWORD,ROW,COL,rows,cols AS LONG
              DIM gsArray(0,2) AS STRING
              MLG_INIT
              DIALOG NEW PIXELS,0, "Example",600,200,600,600, %WS_OVERLAPPEDWINDOW TO hDlg
              CONTROL ADD BUTTON,hDlg,%Button,"AddRows",10,0,50,20
              CONTROL ADD "MYLITTLEGRID", hDlg, %Grid, "MYLITTLEGRID", 0, 30, 490,490, %MLG_STYLE OR %WS_TABSTOP
              CONTROL HANDLE hDlg, %Grid TO ghGrid
              ghDlg = hDlg
              DIALOG SHOW MODAL hDlg, CALL MyCallBack
            END FUNCTION
            
            CALLBACK FUNCTION MyCallBack() AS LONG
             SELECT CASE AS LONG CB.MSG
              'CASE %WM_PAINT                                'remarked out and still refreshes with MLG_PutEx ghGrid,gsArray(),-4,0
              '  CONTROL REDRAW CBHNDL,%Grid1
              CASE %WM_INITDIALOG
                FillGrid
              CASE %WM_COMMAND
               SELECT CASE AS LONG CB.CTL
                CASE %Button
                 IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                  FillGrid
                 END IF
               END SELECT
             END SELECT
            END FUNCTION
            
            SUB FillGrid  'increase  rows by 1 each time this is called
             LOCAL ROW,COL,rows,cols AS LONG
             cols = 2
             rows = UBOUND(gsArray) + 1
             REDIM gsArray(1 TO rows,cols) AS STRING
            
             FOR ROW = 1 TO rows
              FOR COL = 1 TO cols
               INCR gcounter
               gsArray(ROW,COL) = USING$("#",gCounter)
              NEXT
             NEXT
            MLG_PutEx ghGrid,gsArray(),-4,0
             SendMessage(ghGrid,%MLG_SetTopRow,rows-20,0)  'also works fine if rows less than 20 in testing
            END SUB
            https://www.tesla.com/roadster

            Comment


            • #66
              Hi Mike,

              Yeah it did caused endless loop after further tests.

              Would try your suggestion and get back to you.

              Best regards.
              Fredrick Ughimi
              www.meganetsoft.com

              Comment


              • #67
                Hello Mike,

                I have finally got MLG to refresh. It was easy really but hard to find for me. I only had to call my FillGrid method after my INSERT routine. Woks fine. No endless loop like my last trial. In the FillGrid method I included your suggestions. Thanks a lot.
                Fredrick Ughimi
                www.meganetsoft.com

                Comment

                Working...
                X