Announcement

Collapse
No announcement yet.

Excel-like Input Screens (use Contools?)

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

  • Excel-like Input Screens (use Contools?)

    I want to create Excel-like input screens to enter a lot of data. I don't need to exactly look like Excel, but want to input rows and columns of data with nice labels, and when you enter one item, it should jump to the next one. I don't want to have dozens of separate input boxes on the screen that each need to be clicked on to enter data.

    A sample of what I'm looking for is at my website - http://www.aircraftdesign.com/desired_input_forms.xls.

    I use PB/CC but also have PB/Win, and have Contools/GFX. What is my best option? Thanks.

  • #2
    One solution is to use a grid control. I recommend EGrid32 (www.egrid32.com). There are others SIGrid (can't get to site), My Little Grid (http://www.psoftsol.com/mlg.html).

    I use EGrid32. I've looked at others available at the time, but selected this grid and have not needed a different grid.

    Another solution is to just use controls, labels, textbox, etc... In the input controls (textbox) events track the keys Tab, Left, Up, Down and Right arrows and SetFocus to the correct control. Since the input form is small, this would be fairly simple. If it were larger I'd a grid control.

    Comment


    • #3
      Thank you!

      Thank you for the reccomendation Brian!

      And just for the record, this task is not problem for
      Egrid32 + the Form Designer (it can also be coded manually).

      Here is a Screenshot:


      And attached, a compiled application with the form embeded,
      as well as the CGF form, in case you want to try it Daniel.

      It was compiled with Jeffrey's snippet: "Excel navigation", to provide
      some excel functionality (Key combinations).

      :wavey:
      Attached Files

      Comment


      • #4
        Oh by the way... i saved the form zoomed in... thats why it looks bigger than original,
        if you want it smaller (normal view), zoom out and save.

        Comment


        • #5
          Elias,

          While lurking...

          ...and when you enter one item, it should jump to the next one. I don't want to have dozens of separate input boxes on the screen that each need to be clicked on to enter data.
          But, your posted example doesn't meet this criteria. Is there an EGrid32 way of making this part work?

          Comment


          • #6
            >> when you enter one item, it should jump to the next one
            > Is there an EGrid32 way of making this part work?

            Yes. However it depends on how you want to define "enter one item". I defined it as "TAB" and "Shift+TAB" advance/retreat one cell...

            Let me see if I can find that EGrid snippet for you... here it is..


            Code:
             LOCAL pEGN AS EgridNotify PTR
            
            
               CASE %WM_NOTIFY      ' Egrid notifications will be sent here.
                  pEGN = lparam
            
                  SELECT CASE AS LONG  @pEGN.HDR.idFrom
            
                      CASE %ID_GRID
                         SELECT CASE AS LONG @pEGN.HDR.Code
                          ' CASE %EGN_MAINCELLLEFTCLIC
                          ' CASE %EGN_MAINCELLRIGHTCLIC
                           'CASE %EGN_HEADERLEFTCLIC
                         CASE %EGN_KEYUP
            
                             SELECT CASE AS LONG @pEGN.KEY     
            
                                 CASE %VK_TAB
                                 ' requires two step because BIT requires VARIABLE name for param #1
            
                                      Shifted = GetKeyState (%VK_SHIFT)
                                      Shifted = ISTRUE BIT(Shifted, 31)
            
                                      ' FIXME: this needs to be adusted if we are on first or last column
            
                                      IF ( (ISTRUE Shifted) AND (@pEGN.CELL.X > %COL_MIN)) _
                                       OR ((ISFALSE Shifted) AND (@pEGN.Cell.X < %COL_MAX)) THEN
            
                                           PostMEssage @pEGN.HDR.hWndFrom, IIF&(Shifted, %EG_MOVECURSORLEFT, %EG_MOVECURSORRIGHT), %NULL, %NULL
                                           'SendMessage @pEGN.HDR.hWndFrom, IIF&(Shifted, %EG_MOVECURSORLEFT, %EG_MOVECURSORRIGHT), %NULL, %NULL
                                       ELSE
                                           MessageBeep %MB_ICONHAND
                                      END IF

            MCM
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              I use EGrid32 in many ways, similar input as yours one.

              The price worth more than the product. frequent update and error corrected in time, a lot of samples program. Highly recommended EGrid32 to anyone.

              :happy:

              Comment


              • #8
                For a very simple syntax and a straightforward method this will do:
                Code:
                Result& = SendMessage(Hgrid, %EG_SETTABMODE, %EG_MOVERIGHT, 0)
                But in this case i would suggest to take Michael's suggestion, as it provides
                more flexibility and adapts better to specific needs.

                Comment


                • #9
                  Egrid - distribution &amp; other questions

                  Egrid looks egood. A few more questions:

                  I need to create grids dynamically - ie., make a new one each time, because the number of rows and columns can be changed by the users. Does the distrubution agreement allow me to distribute the DLL or whatever freely to my customers to permit this?

                  Also, can I hide the ABC row and 123 column? And, does the grid show up within the existing graphic window or in its own window, or is either possible?

                  thanks

                  Comment


                  • #10
                    another Egrid question - data entry

                    I want the active data entry item to automatically advance to the next row when the user presses Enter, and at the end of a column, advance to the first item in the next column. Can this be set up in Egrid?

                    Comment


                    • #11
                      See my code above... just pick off VK_ENTER instead of VK_TAB and that is exactly what it does.

                      Well, no it doesn;'t... if you do "next" (Tab or CR) and you are in the last column it just beeps. So when that happens just do an extra "move down one" command

                      Without looking at my Egrid32 help file, that's probably a separate EGM_MOVECURSORxxx command. I remember one of my 'suggestions' to Elias was that it was silly to have all those discrete "MOVECURSORxxxx" withe wParam and lparam both unused, and that it would have been a lot cleaner to use but ONE message with options, eg.
                      Code:
                        SendMessage hWnd, %EGM_MOVECURSOR, direction, amount
                      Last edited by Michael Mattias; 26 May 2008, 12:11 PM.
                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Daniel Raymer View Post
                        I need to create grids dynamically - ie., make a new one each time, because the number of rows and columns can be changed by the users.
                        No need to recreate the control (if you wanted to do it to create with another size), you can change the size dynamically at run time without losing any contents.

                        Originally posted by Daniel Raymer View Post
                        Does the distrubution agreement allow me to distribute the DLL or whatever freely to my customers to permit this?
                        Yes. Egrid32 can be distributed with your applications freely, following some easy rules. the EULA is in the help file, wich you can download from the Upgrade page in te Egrid32 website.

                        Originally posted by Daniel Raymer View Post
                        Also, can I hide the ABC row and 123 column?
                        Yes.

                        Originally posted by Daniel Raymer View Post
                        And, does the grid show up within the existing graphic window or in its own window, or is either possible?
                        Being a real windows control, Egrid32 requires a host Dialog/Window. Egrid32 also gets it's own control handle.

                        Originally posted by Daniel Raymer View Post
                        I want the active data entry item to automatically advance to the next row when the user presses Enter, and at the end of a column, advance to the first item in the next column. Can this be set up in Egrid?
                        Yes, Michael's code is in the right track, and thats why he added the "FIXME" part, you can add conditional movement there I.E. "IF we are not in the last column THEN move right, ELSE goto first column and move one rown down". I can provide an example for that.

                        Originally posted by Michael Mattias View Post
                        ...I remember one of my 'suggestions' to Elias was that it was silly to have all those discrete "MOVECURSORxxxx" withe wParam and lparam both unused, and that it would have been a lot cleaner to use but ONE message with options, eg.
                        And i remember i agreed with that. Unfortunately many users were already using the comands as they were and i couldnt simply change them. But i just got an idea, i will create 4 new equates, all with negative values, if the EG_MOVECURSOR command gets a positive X value (WPARAM), it will move the grid to specified coordinates, otherwise if will move in the specified direction, the specified number of spaces (LPARAM). This will come in the next update of Egrid32.


                        Here is an Example that will get you started:
                        Code:
                        '======================================================================
                        '        Source code generated with Egrid32 Form designer.
                        '
                        '                        www.Egrid32.com
                        '
                        ' NOTE: To check this code for errors, compile it with PowerBASIC.
                        '======================================================================
                        
                        #DIM ALL
                        #COMPILE EXE "Sample_Application.exe"
                        #INCLUDE "EG32FORMS.INC"
                        
                        %EGRID_WINDOW = %WM_USER + 100
                        
                        GLOBAL HGrid_FORM1_EGRID1 AS DWORD
                        
                        
                        '=========================================================================================================
                        'DIALOG PROCEDURE
                        CALLBACK FUNCTION MAINPROC AS LONG
                        
                        LOCAL  EGN           AS EGRIDNOTIFY PTR
                        
                        SELECT CASE CBMSG
                         
                         CASE %WM_NOTIFY
                          EGN = CBLPARAM
                          
                          SELECT CASE CBWPARAM
                           CASE %EGRID_WINDOW
                            SELECT CASE @EGN.HDR.CODE
                             Case %EGN_KEYDOWN
                              'Code from 'CURSOR MOVEMENT' snippet.
                              IF @EGN.Key <> %VK_RETURN THEN EXIT FUNCTION
                              
                              LOCAL NumRows AS LONG
                              LOCAL NumCols AS LONG
                              
                              ' Retrieve the grid size.
                              NumRows = SendMessage(@EGN.HDR.hwndFrom, %EG_GETMAXROWS, 0, 0)
                              NumCols = SendMessage(@EGN.HDR.hwndFrom, %EG_GETMAXCOLUMNS, 0, 0)
                              
                              ' Check where we are
                              IF @EGN.CELL.X < NumCols then
                              
                               ' Advance one space right
                               SendMessage(@EGN.HDR.hwndFrom, %EG_MOVECURSOR, @EGN.CELL.X+1, @EGN.CELL.Y)
                              
                               ' Scroll to new cell if needed.
                               SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLXTOCELL, @EGN.CELL.X+1, 0)
                               SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLYTOCELL, 0, @EGN.CELL.Y)
                              
                              ELSE
                               IF @EGN.CELL.Y < NumRows then
                              
                                'Advance one space Down and go to first column.
                                SendMessage(@EGN.HDR.hwndFrom, %EG_MOVECURSOR, 1, @EGN.CELL.Y+1)
                              
                                ' Scroll to new cell if needed.
                                SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLXTOCELL, 1, 0)
                                SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLYTOCELL, 0, @EGN.CELL.Y+1)
                              
                               END IF 
                              END IF
                              
                              SendMessage(@EGN.HDR.hwndFrom, %EG_REFRESHALL, 0, 0)
                              
                              FUNCTION = %TRUE
                        
                            END SELECT
                          END SELECT
                        END SELECT
                        EXIT FUNCTION
                        
                        END FUNCTION
                        '=========================================================================================================
                        
                        '=========================================================================================================
                        'MAIN PROGRAM ENTRY
                        FUNCTION PBMAIN AS LONG
                        
                        REGISTEREGPCLASS("EGRID32")
                        
                        LOCAL HMAINDLG AS LONG
                        
                        DIALOG NEW 0, "Egrid32 Generated code",,,500, 300, %WS_CAPTION OR %WS_SYSMENU, 0 TO HMAINDLG
                        
                        CONTROL ADD "EGRID32", HMAINDLG, %EGRID_WINDOW, "", 0,14, 500, 287, %WS_CLIPCHILDREN OR _
                                                                                          %WS_CHILD OR %WS_VISIBLE, _
                                                                                          %WS_EX_CLIENTEDGE
                        
                        CONTROL HANDLE HMAINDLG, %EGRID_WINDOW TO HGrid_FORM1_EGRID1
                        
                        CALL EG32_LOADFORM(HGrid_FORM1_EGRID1, "EGRID32_FORM", %STD_RESOURCE OR %STD_APPLYPROPERTIES)
                        
                        DIALOG SHOW MODAL HMAINDLG CALL MAINPROC
                        
                        END FUNCTION
                        '=========================================================================================================
                        And attached the Executable version. What it does is to move the cell focus to the right when Enter is pressed, if the focus is in the last column, it moves one cell down and goes to the first column. Just press Enter to see it in action. It might require some more tweaks to fit your needs exactly.
                        Attached Files
                        Last edited by Elias Montoya; 26 May 2008, 02:06 PM.

                        Comment


                        • #13
                          The example still seems a bit unnatural.
                          Why should there be two (2) <Enter> key strokes needed in order to move to the next cell?
                          Is this an %EGN_UPKEY notification?

                          Comment


                          • #14
                            Elias, I don't think you are using "EGM_MOVECURSOREX."

                            If you are going to add a new message, using the "EX" suffix would be consistent with what Windows does when it enhances an existing message or function.

                            MCM
                            Michael Mattias
                            Tal Systems Inc. (retired)
                            Racine WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Originally posted by Michael Mattias
                              If you are going to add a new message, using the "EX" suffix would be consistent with what Windows does when it enhances an existing message or function.
                              You confuse me, you first said Egrid32 had already too many commands,
                              and now you suggest one more when this one can be enhanced without
                              breaking compatibility.

                              Let me explain why, when the EG_MOVECURSOR is used, the X and Y
                              parameters are expected to be positive numbers, range 1 to X Column, and
                              1 to Y row. Having 4 equates for Up, Down, Left and Right with negative
                              numbers, would diferentiate the 2 modalities of the calling convention,
                              one doesnt interfere with the other, making unnecesary to create another
                              one, it would just be "upgraded". Old code would still be compatible.

                              I will still think about it though. You are often right and i dont want to miss.

                              Originally posted by John Reinking View Post
                              The example still seems a bit unnatural.
                              Why should there be two (2) <Enter> key strokes needed in order to move to the next cell?
                              Is this an %EGN_UPKEY notification?
                              Its all about tastes John, thats what i said: "It might require some more tweaks to fit your needs exactly."

                              If i wanted to do it in 1 stroke, i would check the EGN.WPARAM of the
                              notification UDT, when it is false, no editions are happening when the key is
                              pressed, when it has a TRUE value (Contains the handle of the edit box
                              being used for the notification), i would use EG_CLOSEEDITION to close the
                              edition before using the movement. This requires only one more line of
                              Code
                              . Example below:

                              Code:
                              '======================================================================
                              '        Source code generated with Egrid32 Form designer.
                              '
                              '                        www.Egrid32.com
                              '
                              ' NOTE: To check this code for errors, compile it with PowerBASIC.
                              '======================================================================
                              
                              #DIM ALL
                              #COMPILE EXE "Sample_Application.exe"
                              #INCLUDE "EG32FORMS.INC"
                              
                              %EGRID_WINDOW = %WM_USER + 100
                              
                              GLOBAL HGrid_FORM1_EGRID1 AS DWORD
                              
                              
                              '=========================================================================================================
                              'DIALOG PROCEDURE
                              CALLBACK FUNCTION MAINPROC AS LONG
                              
                              LOCAL  EGN           AS EGRIDNOTIFY PTR
                              
                              SELECT CASE CBMSG
                               
                               CASE %WM_NOTIFY
                                EGN = CBLPARAM
                                
                                SELECT CASE CBWPARAM
                                 CASE %EGRID_WINDOW
                                  SELECT CASE @EGN.HDR.CODE
                                   Case %EGN_KEYDOWN
                                    'Code from 'CURSOR MOVEMENT' snippet.
                                    IF @EGN.Key <> %VK_RETURN THEN EXIT FUNCTION
                                    
                                    IF @EGN.WPARAM THEN SendMessage(@EGN.HDR.hwndFrom, %EG_CLOSEEDITION, %TRUE, %TRUE)
                                    
                                    LOCAL NumRows AS LONG
                                    LOCAL NumCols AS LONG
                                    
                                    ' Retrieve the grid size.
                                    NumRows = SendMessage(@EGN.HDR.hwndFrom, %EG_GETMAXROWS, 0, 0)
                                    NumCols = SendMessage(@EGN.HDR.hwndFrom, %EG_GETMAXCOLUMNS, 0, 0)
                                    
                                    ' Check where we are
                                    IF @EGN.CELL.X < NumCols then
                                    
                                     ' Advance one space right
                                     SendMessage(@EGN.HDR.hwndFrom, %EG_MOVECURSOR, @EGN.CELL.X+1, @EGN.CELL.Y)
                                    
                                     ' Scroll to new cell if needed.
                                     SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLXTOCELL, @EGN.CELL.X+1, 0)
                                     SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLYTOCELL, 0, @EGN.CELL.Y)
                                    
                                    ELSE
                                     IF @EGN.CELL.Y < NumRows then
                                    
                                      'Advance one space Down and go to first column.
                                      SendMessage(@EGN.HDR.hwndFrom, %EG_MOVECURSOR, 1, @EGN.CELL.Y+1)
                                    
                                      ' Scroll to new cell if needed.
                                      SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLXTOCELL, 1, 0)
                                      SendMessage(@EGN.HDR.hwndFrom, %EG_SCROLLYTOCELL, 0, @EGN.CELL.Y+1)
                                    
                                     END IF 
                                    END IF
                                    
                                    SendMessage(@EGN.HDR.hwndFrom, %EG_REFRESHALL, 0, 0)
                                    
                                    FUNCTION = %TRUE
                              
                                  END SELECT
                                END SELECT
                              END SELECT
                              EXIT FUNCTION
                              
                              END FUNCTION
                              '=========================================================================================================
                              
                              '=========================================================================================================
                              'MAIN PROGRAM ENTRY
                              FUNCTION PBMAIN AS LONG
                              
                              REGISTEREGPCLASS("EGRID32")
                              
                              LOCAL HMAINDLG AS LONG
                              
                              DIALOG NEW 0, "Egrid32 Generated code",,,500, 300, %WS_CAPTION OR %WS_SYSMENU, 0 TO HMAINDLG
                              
                              CONTROL ADD "EGRID32", HMAINDLG, %EGRID_WINDOW, "", 0,14, 500, 287, %WS_CLIPCHILDREN OR _
                                                                                                %WS_CHILD OR %WS_VISIBLE, _
                                                                                                %WS_EX_CLIENTEDGE
                              
                              CONTROL HANDLE HMAINDLG, %EGRID_WINDOW TO HGrid_FORM1_EGRID1
                              
                              CALL EG32_LOADFORM(HGrid_FORM1_EGRID1, "EGRID32_FORM", %STD_RESOURCE OR %STD_APPLYPROPERTIES)
                              
                              DIALOG SHOW MODAL HMAINDLG CALL MAINPROC
                              
                              END FUNCTION
                              '=========================================================================================================
                              And, Here is the snippet, in case someone wants to play with it.

                              :wavey:
                              Attached Files
                              Last edited by Elias Montoya; 27 May 2008, 08:12 PM.

                              Comment


                              • #16
                                The reason I suggest a new message here is because that one new message can REPLACE the other four!

                                SendMessage hGrid, EGM_MOVECURSOREX , direction, amount

                                If the user makes amount "1" he can get rid of all the other EGM_MOVECURSORxxxxx messages!

                                For direction, you could use
                                Code:
                                %EGM_UP        = &h01
                                %EGM_DOWN   = &h02
                                %EGM_LEFT     = &h04
                                %EGM_RIGHT    = &h08
                                %EGM_WRAP     = &h100
                                If you want to go "left with wrap" you do "direction= %EGM_LEFT OR %EGM_WRAP"

                                Combining bit flags like this should be something with which your users are already familar and comfortable.

                                What 'wrap' means with different movement commands you'll have to work out, but it's not like you are out of bits you can use to do different things if you need to.
                                Michael Mattias
                                Tal Systems Inc. (retired)
                                Racine WI USA
                                [email protected]
                                http://www.talsystems.com

                                Comment


                                • #17
                                  Just a clarification for lurkers, I was talking about EG_MOVECURSOR,
                                  and michael was thinking i was talking about EG_MOVECURSORxxx functions.

                                  Comment


                                  • #18
                                    Just as a clarification for lurkers, now you see why I think there are too many different messages?

                                    Elias sent me private message. I reviewed the help file for Egrid and now 'see the light.'

                                    Silly me had assumed because there were four separate messages to move the cursor in each possible direction, there could not possibly be an "EG_MOVECURSOR" without a direction suffix at the end. But there is!
                                    Michael Mattias
                                    Tal Systems Inc. (retired)
                                    Racine WI USA
                                    [email protected]
                                    http://www.talsystems.com

                                    Comment


                                    • #19
                                      Elias,

                                      I'm using a listview for a project. Functionally it does what I want, but we have to owner draw the cells different colors for different states and some cells are updated every 33 ms. When I do both of those, the updated cells flicker. I know EGrid can have colored cells, but how does it look if they are updated as often as I'm doing it?

                                      Thanks,
                                      Russ
                                      "There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers

                                      Comment


                                      • #20
                                        Hello Russ.. No flicker at all. Egrid32 uses double layer DC, so you will never see flicker.

                                        Comment

                                        Working...
                                        X