Announcement

Collapse
No announcement yet.

MLG - Question Thread

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

  • #41
    There is an UNDO Message you could try

    Code:
    SendMessage hGridhandle, %MLG_UNDO,1,0
    
    
    %MLG_UNDO
    
    Purpose: If cell edit mode is active in a cell (blinking caret) then reload the original string when selection of cell was made.
    
    Parameters:
    
    wParam : 1 will force an exit of the edit mode of the currently selected cell (new ver 2.03)
    
    lParam : not used
    
    Return: None
    
    Comments or Restrictions: None

    Comment


    • #42
      Hello, Graham!
      Yes, but I was wanting to Undo at the cell level - repeated Ctrl-Z to work my way back through changes to cells - all the way back to the start of a session.

      The only real issue is making sure that I can identify all cases where a cell content has changed. I'm not yet acquainted enough with %MLGN_CellDirty to know if it covers all possibilities, such as where my code changes the content of a cell,

      Comment


      • #43
        Hi Gary
        I tend to highlight cells, by changing the background colour, as they change and allowing the user to Revoke those changes back to the current value held in the database using an option on the right click menu.

        There is an Audit trail in my database/s if the users need to look at history.

        Hi James
        MLG_PutEx hGrid,s(),refresh,sheet

        I use this all the time for bulk population of result grids from an array got back from SQL Server stored procedures - so your code is well used .

        Comment


        • #44
          The MLG undo has only one level. The multi-level undo is more of a spreadsheet thing and MLG is more of a database thing with some individual cell formatting abilities.

          Comment


          • #45
            Hi James!
            ... MLG is more of a database thing with some individual cell formatting
            abilities.
            No criticism intended. I'm just test driving my new toy to find out its limits!

            Not that asking questions doesn't give the author ideas for future changes, but I ask questions mostly to make sure I'm using the tool to its fullest extent and that I perhaps haven't missed something in the documentation.

            Comment


            • #46
              The multi-level undo is more of a spreadsheet thing and MLG is more of a database thing with some individual cell formatting abilities.
              ????

              As you know, James, I have been playing around with MLG.

              I would say it's more a "grid thing" than it is either a "spreadsheet thing" or a "database thing."

              It's like a TEXTBOX or LISTBOX or any other control : it supports programming a user interface (both ways) for data entry and display using a format particular to its 'control type.'

              It does what it does, which is exactly what the name suggests!

              MCM

              Comment


              • #47
                Question #13: %MLG_ClearGrid
                Hey James,
                Help says this:
                Comments or Restrictions: This message may have to be run more than once to achieve desired effect
                Is this still true?

                How will I know (in code) when to quit running the message?

                Are you saying that the only way to know for certain is to use another approach, i.e., using one of the other messages to insert "" into each cell?

                Comment


                • #48
                  The clear grid message has a lot options to keep headers or not, various formatting attributes etc. etc. it was easier to set MLG up with the ability to clear attributes of the grid with multiple calls of the same message so the programmer has the option to keep parts of the grid set up.

                  Comment


                  • #49
                    Hey James!
                    Thanks for the response. I had mis-understood what your Help meant. There are a few Windows API where you have to call them twice to ensure the intended result, but that's not the same as what you meant, which was that each new call would be with new settings to get an overall combination of changes.

                    Comment


                    • #50
                      There are a few Windows API where you have to call them twice to ensure the intended result..
                      ????

                      Example requested before belief can take root.

                      Comment


                      • #51
                        Hi MCM,
                        From my notes, I ran across this in a RichEdit snippet ...
                        The code uses GetFirstVisible to get the current topmost visible line and then LineScroll to move to the desired line. LineScroll can scroll up or down. Because the topmost Line can be partially obscured, it's necessary to use the code twice - once to ensure that a full line is visible and a second time to move un-ambiguously to the desired line.
                        My notes don't say where I got the info from, so I guess I'll have to go hunting to find the source.

                        And the snippet lines of interest ...
                        Code:
                              Local iTopLine&, IDesiredLine&
                              iDesiredLine& = 12
                              'first time aligns a line at the top of the control
                              iTopLine& = SendMessage (hRichEdit, %EM_GetFirstVisibleLine, 0,0)
                              SendMessage hRichEdit, %EM_LineScroll, 0, iDesiredLine& - iTopLine&
                              'the second time ensures the proper result
                              iTopLine& = SendMessage (hRichEdit, %EM_GetFirstVisibleLine, 0,0)
                              SendMessage hRichEdit, %EM_LineScroll, 0, iDesiredLine& - iTopLine&

                        Comment


                        • #52
                          Question #14: How to Hide Scrollbars

                          Hi James, I'm trying to create a simple 3x3 grid and would like the scrollbars to be hidden. But I'm not finding the right code to make it happen.

                          I notice (in the example below) that when the grid has focus, the scrollbars appear. When it does not have focus, the scrollbars are gone.

                          I'd like to exercise full control over whether the scrollbars are visible. Can I do that?

                          Code:
                          'Compilable Example:
                          #Include "Win32API.inc"
                          #Include "MLG.INC"
                          %IDC_Grid = 500
                          Global hDlg,hGrid As Dword
                          Function PBMain() As Long
                             MLG_Init
                             Dialog New Pixels, 0, "PowerBASIC",300,300,300,150, %WS_OverlappedWindow To hDlg
                             Control Add "MYLITTLEGRID", hDlg, %IDC_Grid,"r3/c3/w1/z1/j1Desc,Age,Income$/x15,110,40,65", 10, 10, 270, 100, %WS_Visible Or %WS_Border Or %WS_Child
                             Control Handle hDlg, %IDC_Grid To hGrid
                             Dialog Show Modal hDlg
                          End Function

                          Comment


                          • #53
                            Found it! d3 switch does the job just as I wanted!

                            Comment


                            • #54
                              I've been trying out MLG as well and have a question: How does one set the index of a combobox cell, so that the current selection is shown upon the initial population of the grid? I looked at the Help doc but didn't see anything.
                              Mark Newman

                              Comment


                              • #55
                                Hi Mark,

                                Just put the text in the cell that you want to be the current selection.
                                That's all there is to it

                                Comment


                                • #56
                                  Ah, okay, thanks for the info!
                                  Mark Newman

                                  Comment


                                  • #57
                                    Deleted. Wrong thread.
                                    Last edited by Dominic Mitchell; 15 Aug 2015, 04:48 PM.
                                    Dominic Mitchell
                                    Phoenix Visual Designer
                                    http://www.phnxthunder.com

                                    Comment


                                    • #58
                                      OK, so I'm not the first one to this party (LOL! only 4 years late!), but so what!

                                      In the same way that Gary had questions as he got familiar with MLG, I'm reading the Help, the source code samples and the code for the DLL, the INC, etc, and building my own code, to test my understanding of all that I've read... Seems that the "shampoo method" works most of the time -- Read, code, test, repeat...

                                      But I've got questions on a couple of little things that I could use some help with:

                                      1. I cannot find a way to "clear the user selection" -- User selects a range of cells - let's say the grid is 10x10, but the user selects row3, col3 to row5, col7. Great, I can grab the contents of those cells, do whatever I need to... AND THEN I need to clear the selection, but I have NOT found the trick.
                                      Code:
                                      SendMessage hGrid1,%MLG_CLEARBLOCKSEL,3,0 ' 3=Clear Row and Column Highlighting, 0=refresh
                                      isn't working...

                                      2. I can programmatically select a cell and load it with string content, BUT the dark outline does not display. I need some kind of "set focus" that restores the "cursor"...
                                      Code:
                                      SendMessage hGrid1,%MLG_SETSELECTED,3,4
                                      I can tell via several methods that cell 3,4 was selected, text inserted, and read back... But I can't show the user that it's the "current" cell - no border...

                                      Hey, I got the print preview and print stuff working, so I'm not sitting back waiting for the rescue squad...

                                      In my early stages, I must say that MLG is pretty easy to get into and start using, and I'm happy to be learning it.

                                      Thanks in advance for any help with these 2 questions!
                                      -John








                                      Comment


                                      • #59
                                        BTW:
                                        In: Sub MLG_CopyRowBlockToClipBoard() there's a test for the PB include file, but I'm using the JR files, so this mod was needed:
                                        Code:
                                         #If %Def(%WINDOWS_INC)

                                        Also: I needed to copy to the clipboard whatever cells the user has selected, but there's no such function, only a copy of a complete row... So I cloned that procedure, and made only such changes as would respect the columns in the user selection...look for my markers (jhm

                                        Code:
                                        #If 10 ' jhm clone of the above MLG_CopyRowBlockToClipBoard; renamed and re-coded to only copy from the user selected block
                                        Sub MLG_CopyUserSelToClipBoard(ByVal hGrid As Long,Opt ByVal CopyColHeader As Long,Opt ByVal AllowAllRowsCols As Long)
                                          Local startblock,endblock,StartCol,EndCol As Long
                                          Local totrows,totcols As Long
                                          Local flag,I,x,y,rowlimit,skey As Long
                                          Local mystr As String
                                          Local stLen As Long, hData As Long, hGlob As Long, mg As Long
                                        
                                          '#IF %DEF(%WINAPI) 'This sub require WINAPI        'jhm: not sure author's intent for WHY PB include is needed...
                                          #If %Def(%WINDOWS_INC) 'This sub require WINAPI    'jhm: seems to work fine with the JR includes, using: %WINDOWS_INC
                                          rowlimit = 5000   'Adjust to suit.  This prevents accidently trying to copy 2,000,000,000,000 rows
                                        
                                          SendMessage hGrid ,%MLG_GETROWCOLTOTEX,VarPtr(totrows),VarPtr(totcols)
                                          flag = SendMessage (hGrid, %MLG_GETROWCOLALLBLOCKSEL, 0 ,0)
                                          If flag = 1 And AllowAllRowsCols <> 0 Then 'The whole grid has been selected - this could be a problem with selecting many NULL rows
                                           startblock = 1
                                           endblock = totrows
                                          Else   'The whole grid is not selected so check for a USER SELECTION             !jhm: That's this clone!
                                            SendMessage hGrid ,%MLG_GETROWBLOCKSELEX,VarPtr(startblock),VarPtr(endblock)
                                            'jhm: should ALSO check to see if NOT ALL columns are selected, and get which columns ARE in the selection!   *****
                                            SendMessage hGrid ,%MLG_GETCOLBLOCKSELEX,VarPtr(StartCol),VarPtr(EndCol)
                                          End If
                                        
                                          If startblock > 0 And endblock > 0 And (endblock - startblock) < rowlimit Then
                                           'Only copy visible columns
                                           Dim widths(totcols) As Long
                                           mystr=""
                                           For I = 0 To totcols
                                           widths(I)=SendMessage(hGrid,%MLG_GETCOLWIDTH,I,0)
                                           Next I
                                        
                                           If CopyColHeader > 0 Then
                                            For x= 0 To totcols
                                             If widths(x) > 0 Then
                                              If x >= StartCol And x <= EndCol Then     'jhm: only take the headers of columns in the user selection
                                              mystr=mystr & MLG_Get(hGrid,y,x)& $Tab
                                              End If
                                             End If
                                             Next x
                                             mystr=mystr & $CrLf
                                           End If
                                           MousePtr 11 'Hourglass - this needs a progress bar like MS Access
                                           For y = startblock To endblock
                                             skey=GetKeyState(%VK_ESCAPE) And &H8000
                                             If skey<>0 Then Exit Sub
                                             For x= StartCol To EndCol                        'jhm: why we created this clone!
                                             If widths(x) > 0 Then
                                               mystr=mystr & MLG_Get(hGrid,y,x)& $Tab
                                             End If
                                             Next x
                                             mystr=mystr & $CrLf
                                           Next y
                                           MousePtr 1 'Arrow
                                          End If
                                        
                                        
                                          stLen = Len(mystr)
                                          ' Create a global memory object and copy the data into it
                                          hData = GlobalAlloc(%GMEM_MOVEABLE Or %GMEM_DDESHARE, stLen + 1)
                                          hGlob = GlobalLock(hData)
                                          mg = StrPtr(mystr)
                                          MoveMemory ByVal hGlob, ByVal mg, ByVal stLen
                                          GlobalUnlock hData
                                        
                                           ' Open the clipboard
                                          If IsFalse (OpenClipboard(%NULL)) Then
                                            GlobalFree hData
                                            Exit Sub
                                          End If
                                        
                                          ' Paste the data into the clipboard
                                          EmptyClipboard
                                          SetClipboardData %CF_Text, hData
                                          CloseClipboard
                                          #EndIf
                                        
                                        End Sub
                                        
                                        
                                        #EndIf
                                        I hope that can be helpful to folks!

                                        -John

                                        Comment


                                        • #60
                                          Anyone using MyLittleGrid (MLG) able to offer suggestions on the 2 questions I posted in message #58 above?

                                          Appreciate any help you can offer!

                                          Thanks,
                                          -John

                                          Comment

                                          Working...
                                          X