Announcement

Collapse
No announcement yet.

MLG Questions

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

  • #41
    Good catch, second parameter defaults to binary.
    Added "T" for the bind and it now works in SQLite Expert.
    slBuildBindDat(FromGrid(r,c),"T")
    https://www.tesla.com/roadster

    Comment


    • #42
      Hello Mike,

      Works good.

      Thanks.
      Fredrick Ughimi
      www.meganetsoft.com

      Comment


      • #43
        Hello,

        How do you get the total number of records in MLG (not rows). I thought there would be a straight function for that. Nothing pointed to that direction when I checked the help file.

        Kind regards.
        Fredrick Ughimi
        www.meganetsoft.com

        Comment


        • #44
          There is no built in function for counting records since MLG is a free form grid and not dedicated to any one purpose If you are storing the Sqlite record number in the row header you could poll those from row 1 to TotRows and count the non-zero record numbers.

          Good Luck
          Jim

          Comment


          • #45
            Hello James,

            Thank you James for your response and hint.

            Best regards.
            Fredrick Ughimi
            www.meganetsoft.com

            Comment


            • #46
              Bought the "real" version a while ago and will begin using the MLG in a new project.

              My question is:
              * Can not find the code for MLGprint.dll, it is available somewhere?
              * Is there anyone who has used MLG against Accsess or Microsoft SQL similar to the examples of SQLitening?

              MLG is awesome, works for many purposes and is quick and easy to learn.

              Thanks

              Comment


              • #47
                This isn't a reply to any previous question but is a new question ( with a little background on why ).

                Currently I'm having eye problems which prevent me from reading a screen with birght colors. So I'm trying to build in some changes that will allow my programs to be viewable in something
                close to white on black. My eye problem prevents me from finding any answers in the help file ( I haven't been able to get MS help program to alter its basic bright white background ).
                I'm trying to add a line like

                SendMessage ghGrid1, %MLG_SETWINDOWBKCOLORRGB, %rgb_PowderBlue, 1

                to change the background and foreground color of the whole grid without having to redo the color of each cell or part.

                Is this possible?

                Thanks for any help.

                Comment


                • #48
                  Try the helper function

                  MLG_FormatGridex(hGrid,%RGB_POWDERBLUE,0,0,0,0,0,0,0,0)

                  That should be what you want. By the way, Gary Beene now owns MLG. I don't plan to visit much anymore. Jim

                  Comment


                  • #49
                    - "By the way, Gary Beene now owns MLG."
                    Then I understand.
                    Then we direct the question to Garry, Previously the source code was included for the MLG, is the source code to MLGPrint.dll available somewhere?

                    Grateful for answers in any direction.

                    PS! Like the new look

                    Comment


                    • #50
                      Whoto mirror switch h(x)

                      How do I delete the row and column header of the middle sheet in MLG workbook, when I have for example three sheets?
                      I can’t finds message correspondence to switch h(x)

                      In the example with graphics, it works with :
                      Probably advisable to hide the headers
                      SendMessage hGrid1 ,%MLG_SETCOLWIDTH ,0,0
                      SendMessage hGrid1 ,%MLG_SETROWHEIGHT ,0,0

                      Have tried different variations, can remove the row header but in the column header will be left a few pixels on top.

                      Any suggestions?

                      Comment


                      • #51
                        Hello,

                        I am just trying for the first time to use MLG in real project.

                        A while ago my development system crashed and I was able to recover most of the
                        project file. But I lost almost the codes I wrote on using MLG with SQLitening.
                        I can't seems to remember how I figured out how (with the help Mike Doty) to dynamically
                        read the cell contents of MLG into individual Textboxes.

                        Any pointers or sample codes would be much appreciated.

                        Best regards.

                        Fredrick Ughimi
                        www.meganetsoft.com

                        Comment


                        • #52
                          Howdy, Fred!

                          To get the text in a cell ... from the "Function Reference" section of MLG Help ...

                          Code:
                          Buffer$ = MLG_Get(hGrid, Row, Col)
                          Control Set Text hDlg, %IDC_TextBox, Buffer$

                          Comment


                          • #53
                            Hello Gary,

                            Thank you for responding. I understand that. Doing that would be very
                            tedious for what I want to achieve. I want to be able to select through rows and
                            have its contexts displayed on textboxes dynamically. Maybe this is not a Grid thing?

                            I do that all the time with Listview. I do that mostly for the purpose of editing
                            and saving back changes to the database through the textboxes. I guess
                            I don't have to do that anymore with the Grid control. Users can edit the cells of a
                            row directly on the grid and then save back to the database.

                            Saving a row to the database is now something I need to find out.

                            Best regards.


                            Fredrick Ughimi
                            www.meganetsoft.com

                            Comment


                            • #54
                              Hello, Fred!

                              Yes, with the grid, users would edit the row/cell content in place. Then, there is a Save function that saves all rows and columns at one time (a sheet at a time).

                              See the "Save and Load" section of Help for details.

                              Comment


                              • #55
                                Thank you, Gary.
                                Fredrick Ughimi
                                www.meganetsoft.com

                                Comment


                                • #56
                                  Thank you for responding. I understand that. Doing that would be very
                                  tedious for what I want to achieve. I want to be able to select through rows and
                                  have its contexts displayed on textboxes dynamically. Maybe this is not a Grid thing?

                                  I do that all the time with Listview. I do that mostly for the purpose of editing
                                  and saving back changes to the database through the textboxes. I guess
                                  I don't have to do that anymore with the Grid control. Users can edit the cells of a
                                  row directly on the grid and then save back to the database.

                                  Saving a row to the database is now something I need to find out.
                                  Sounds like you were doing it right

                                  Listview, listbox are great for viewing, sorting, grouping and selecting.
                                  By trying to do everything in a listview or grid doesn't eliminate the need for all
                                  validation checks and formatting input still needs to be checked.

                                  Maybe look at a second control with the list or grid control:
                                  PickList, Property grid, combobox or text boxes like you were doing.
                                  The edit control could popup, stay on screen or be text boxes..

                                  Two controls is much easier to program and control than trying to work on a single grid line.





                                  https://www.tesla.com/roadster

                                  Comment


                                  • #57
                                    Hello Mike,

                                    Thank you for your response.

                                    I have found a way to save MLG row to SQLitening table. Infact you provided provided the solution here in one of your posts.

                                    Now I have found out that the MLG don't refresh its contents when records are entered into its corresponding SQLitening table. I have tried PB's Control Redraw... and MLG's SendMessage hGrid Refresh.... Nothing seems to work.

                                    Best regards.
                                    Fredrick Ughimi
                                    www.meganetsoft.com

                                    Comment


                                    • #58
                                      Need to see some code.
                                      Last edited by Mike Doty; 12 Oct 2018, 07:33 AM.
                                      https://www.tesla.com/roadster

                                      Comment


                                      • #59
                                        Hi Mike,

                                        Here is a snippet.

                                        Code:
                                        GLOBAL hBillingPatientsGrid AS DWORD
                                        
                                        METHOD BrowseBillingPatientsRecords(BYVAL nCbHndl AS LONG) AS LONG
                                        
                                                    DIM sArray() AS STRING
                                                    LOCAL cols,rows,op,refresh,x,ROW,COL AS LONG
                                                    LOCAL COUNT AS LONG
                                                    LOCAL myrow  AS LONG
                                                    LOCAL mycol  AS LONG
                                        
                                                    op = 2
                                                    refresh = 1
                                        
                                                    MLG_Init
                                                    CONTROL HANDLE nCbHndl, %ID_FRMBROWSEBILLINGPATIENTSWAITING_USERCONTROL1 TO hBillingPatientsGrid
                                                    MLG_FormatColTitles hBillingPatientsGrid,"RecNo,SNo,HNo,Surname,Othernames,Category,TimeSent,Doctor,SentBy,Clinic/Section,Locked,Default"
                                        
                                                     'Set column width
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 1, 1
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 2, 100
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 3, 120
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 4, 200
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 5, 200
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 6, 150
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 7, 200
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 8, 200
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 9, 200
                                                     SendMessage hBillingPatientsGrid, %MLG_SETCOLWIDTH, 10, 200
                                        
                                                     'sort
                                                     SendMessage hBillingPatientsGrid, %MLG_SORT, %MLG_ASCEND , 4
                                        
                                                     'Set grid color
                                                     GI.CellBkColorRGB=RGB(255,255,200)
                                                     GI.WindowBkColorRGB=RGB(255,200,150)
                                                     SendMessage hBillingPatientsGrid, %MLG_SETGRIDEXSTYLE, VARPTR(GI), 0
                                                     FOR COUNT=2 TO 24 STEP 2
                                                         MLG_FormatRowHighLight hBillingPatientsGrid,COUNT,%MLG_HILITE
                                                     NEXT COUNT
                                        
                                                   'Load Records
                                                   slSelAry "SELECT RowID as RecordNo, * from tblBillingAwaiting ORDER BY TimeSent",sArray()
                                                   cols = UBOUND(sArray(1))
                                                   rows = UBOUND(sArray(2))
                                                   IF cols < 0 THEN BEEP:EXIT METHOD
                                                      DIM sArray2(rows,cols) AS STRING     'move data to another array
                                                      FOR ROW = 0 TO rows
                                                        FOR COL = 1 TO cols
                                                         sArray2(ROW,COL) = sArray(COL,ROW)
                                                        NEXT
                                                      NEXT
                                        
                                                      MLG_ArrayRedim hBillingPatientsGrid,rows,cols,rows,cols
                                                      MLG_PutEx hBillingPatientsGrid,sArray2(),op,refresh
                                                      SendMessage hBillingPatientsGrid,%MLG_REFRESH,0,0
                                        
                                              END METHOD
                                        
                                           'Notifications
                                           SELECT CASE nCbMsg
                                            CASE %WM_INITDIALOG
                                                  PatientsAwaiting.BrowseBillingPatientsRecords(nCbHndl)
                                        
                                                  CASE %WM_PAINT
                                                    CONTROL REDRAW nCbHndl, %ID_FRMBROWSEBILLINGPATIENTSWAITING_USERCONTROL1
                                        
                                        '            hDC = BeginPaint(nCbHndl, pPaint)
                                        '                 SendMessage hNursesPatientsGrid,%MLG_REFRESH,0,0
                                        '            EndPaint nCbHndl, pPaint
                                        '            Function = 1
                                        '            Exit Function
                                        
                                               CASE %WM_NOTIFY
                                                   MLGN=nCbLparam
                                                    IF @MLGN.NMHeader.idFrom = %ID_FRMBROWSEBILLINGPATIENTSWAITING_USERCONTROL1 THEN
                                                     SELECT CASE @MLGN.NMHeader.Code
                                                         CASE %MLGN_ROWSELCHANGE  'sent after buttonup if whole row/rows selected
                                                           myrow=@MLGN.Param1 'current row
                                                           sRecordNo = MLG_Get(hBillingPatientsGrid, myrow,1)
                                                              slSEL "SELECT RowID as RecordNo, * FROM tblBillingAwaiting WHERE RecordNo  = '" + sRecordNo + "'"
                                                           IF ISTRUE slGetRow THEN
                                                              VD_Text(nCbHndl, %ID_FRMBROWSEBILLINGPATIENTSWAITING_TXTRECORDNO, slFN("RecordNo"))
                                                           END IF
                                                           slCloseSet
                                        
                                                       END SELECT
                                        
                                                    END IF
                                        
                                        END SELECT
                                        Last edited by Fredrick Ughimi; 12 Oct 2018, 06:51 PM.
                                        Fredrick Ughimi
                                        www.meganetsoft.com

                                        Comment


                                        • #60
                                          Good news. Check out MLG_PUTEX with op of -4

                                          This code will display any SQLitening sql statement in MLG with automatic column names
                                          Clicking Test button will ask for a SQL statement

                                          Didn't add resizing code which would make this great
                                          Add grid to a portion of a form or create another form with the grid and pop-up.

                                          The grid on the screen is from the database "sample.db3" that comes with SQLitening containing 10,000 rows.


                                          Click image for larger version  Name:	fred1.png Views:	1 Size:	13.6 KB ID:	775540
                                          Code:
                                          #PBFORMS CREATED V2.01
                                          #COMPILE EXE
                                          #DIM ALL
                                          GLOBAL ghDlg,ghGrid AS DWORD,gSQL AS STRING
                                          %Grid1 = 1000
                                          #PBFORMS BEGIN INCLUDES
                                          %USEMACROS = 1
                                          #INCLUDE ONCE "WIN32API.INC"
                                          #PBFORMS END INCLUDES
                                          #INCLUDE ONCE "mlg.inc"
                                          #INCLUDE ONCE "sqlitening.inc"
                                          #PBFORMS BEGIN CONSTANTS
                                          %Grid1       = 1000
                                          %BTN_BUTTON1 = 1001
                                          #PBFORMS END CONSTANTS
                                          #PBFORMS DECLARATIONS
                                          FUNCTION PBMAIN()
                                            gSql = "select rowid,* from parts" 'default sql statement
                                            slOpen "sample.db3"
                                            MLG_INIT
                                            ShowDialog1 0
                                          END FUNCTION
                                          '------------------------------------------------------------------------------
                                          CALLBACK FUNCTION ShowDIALOG1Proc()
                                          
                                            SELECT CASE AS LONG CB.MSG
                                                CASE %WM_NCACTIVATE
                                                STATIC hWndSaveFocus AS DWORD
                                                IF ISFALSE CB.WPARAM THEN
                                                  ' Save control focus
                                                  hWndSaveFocus = GetFocus()
                                                ELSEIF hWndSaveFocus THEN
                                                  ' Restore control focus
                                                  SetFocus(hWndSaveFocus)
                                                  hWndSaveFocus = 0
                                                END IF
                                          
                                              CASE %WM_INITDIALOG
                                                FillGrid
                                              CASE %WM_COMMAND
                                                ' Process control notifications
                                                SELECT CASE AS LONG CB.CTL
                                                  CASE %BTN_BUTTON1
                                                    IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                                      STATIC sql AS STRING
                                                      gSql = INPUTBOX$("prompt","Title",gSql)
                                                      FillGrid
                                                    END IF
                                          
                                                  CASE %Grid1
                                          
                                                END SELECT
                                            END SELECT
                                          END FUNCTION
                                          '------------------------------------------------------------------------------
                                          FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
                                            LOCAL lRslt AS LONG
                                          
                                          #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
                                            LOCAL hDlg  AS DWORD
                                          
                                            DIALOG NEW hParent, "MLG/SQLitening", ,, 730, 350, %WS_POPUP OR %WS_BORDER _
                                              OR %WS_DLGFRAME OR %WS_THICKFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
                                              %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR _
                                              %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR _
                                              %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg
                                          
                                            CONTROL ADD "MYLITTLEGRID", hDlg, %Grid1, "MYLITTLEGRID", 20, 0, 700, 300, %MLG_STYLE
                                            CONTROL ADD BUTTON, hDlg, %BTN_BUTTON1, "Test", 15, 320, 50, 13
                                          #PBFORMS END DIALOG
                                            ghDlg = hDlg
                                            CONTROL HANDLE ghDlg, %Grid1 TO ghGrid
                                            DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
                                          
                                          #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
                                          #PBFORMS END CLEANUP
                                          
                                            FUNCTION = lRslt
                                          END FUNCTION
                                          
                                          FUNCTION FillGrid AS LONG
                                           DIM sArray() AS STRING
                                           LOCAL s AS STRING
                                           LOCAL cols,rows,ROW,COL AS LONG
                                          
                                           'Select records from SQLitening
                                           IF LEN(gSQL) = 0 THEN EXIT FUNCTION
                                           slSelAry gSql,sArray(),"E0"
                                           IF slGetErrorNumber THEN ? slGetError,,FUNCNAME$:EXIT FUNCTION
                                          
                                           cols = UBOUND(sArray,1)
                                           rows = UBOUND(sArray,2)
                                           IF rows < 1 THEN ? "No data",,FUNCNAME$:EXIT FUNCTION
                                           DIALOG SET TEXT ghDlg,gSql
                                          
                                           'size grid and set column names
                                           MLG_ArrayRedim ghGrid,rows,cols,rows,cols 'so column names fit first time
                                           s="" 'column names in row 0
                                           FOR COL = 1 TO cols
                                            s+= USING$("&_,",sArray(COL,0))
                                           NEXT
                                           s = LEFT$(s,-1)
                                           MLG_FormatColTitles ghgrid,s
                                          
                                           'Create second array in row,col order for MLG
                                           DIM sArray2(rows,cols) AS STRING
                                           FOR ROW = 1 TO rows
                                            FOR COL = 1 TO cols
                                             sArray2(ROW,COL) = sArray(COL,ROW)
                                            NEXT
                                           NEXT
                                           'write to grid
                                           MLG_PutEx ghGrid,sArray2(),-4,0
                                           CONTROL SET FOCUS ghDlg,%Grid1
                                          END FUNCTION
                                          Last edited by Mike Doty; 12 Oct 2018, 08:45 PM.
                                          https://www.tesla.com/roadster

                                          Comment

                                          Working...
                                          X