Announcement

Collapse
No announcement yet.

Scrollbar difficulties

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

  • Scrollbar difficulties

    I'm having 2 problems with a scrollbar.

    1. When I use something like the code below, the scrollbar does not align with the top. I've tried various alignment style& values. None seem to work. Is there an obvious thing I've missed?

    Control Add ScrollBar, hdlg, 505, "status",10,10,20,60, %sbs_rightalign Or %sbs_vert

    Using the Dialog New statement, I can get a scrollbar aligned with the side, just not with the Control Add Scrollbar statement.


    2. Control Add Scrollbar Help says to %wm_hscroll and %wm_vscroll are available. Scrollbar Get TrackPOS says %sb_thumbtrack and %sbthumbposition are available. When I create a callback statement, the two %wm notifications don't appear, but the two %sb do (but only on the scroll box). None of the 4 occur when clicking on the scrollbar arrows or body.

    I can't tell for sure, but I'm guessing that the Help reference to GetScrollInfo API is old, and that's it not been updated to the new tools in v9.

    I looked under the Samples folder and all the examples use the Dialog New approach.

    Anyone have clarifications?

  • #2
    without more code, like most of the dialog add/dialog new statements, it's difficult to comment other than with the placement paramaters, it looks like you either have a tiny (width) dialog. Also, if you want the scrollbar at the top of the dialog (below the title bar if it exists) then I would assume a value of 0 for the first parameter and not 10. Again without more code my comments are a shot in the dark.
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      Thanks Fred. I shy away from putting too much code, perhaps too little in this case.

      But the key code was the %sbs_rightalign Or %sbs_vert style values. I read Help to mean that those style values would force an edge alignment, regardless of any xy, xx,yy values I used.
      Last edited by Gary Beene; 18 Jan 2009, 05:29 PM. Reason: grammar

      Comment


      • #4
        Code:
        Control Add ScrollBar, hdlg, 505, "status",10,10,20,60, %sbs_rightalign Or %sbs_vert
        Not correct. Do this
        Code:
        DIALOG GET CLIENT hDlg TO cxClient, cyClient
        CONTROL ADD SCROLLBAR, hdlg, 505, "status", 0, 0, cxClient,cyClient, %SBS_RIGHTALIGN OR %SBS_VERT
        The vertical control is aligned on the left or right side of the rectangle specified.

        Using the Dialog New statement, I can get a scrollbar aligned with the side,
        just not with the Control Add Scrollbar statement.
        Two different animals.
        CONTROL ADD SCROLLBAR creates a scrollbar control. A scrollbar control is a window and has a handle.
        DIALOG NEW(WS_HSCROLL or WS_VSCROLL or both) creates a window with a scrollbar painted in then non-client
        area of the window. This scrollbar is not a window and does not have a handle. Its(the image) location is
        set by the OS and cannot be moved easily.
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          Thanks Dominic! That works.

          But how the heck would I have know that? Was there a discussion somewhere in Help that would have shown the approach you took?

          I hate the part where I have to ask questions if there was a place I should have read it myself.

          I also hate the part where Help doesn't tell me something already known, or gives me only half the recipe. Then I have to rely on the kindness of strangers (not that you're strange, of course!).

          Thanks again,
          Gary

          Comment


          • #6
            Adding to Dominic's comments about "different animals", once created the scrollbar control does not automatically change size with a change in Dialog size. The application has to handle the resizing. With the Dialog New approach, the scrollbar changes size automatically as the dialog changes size.

            Comment


            • #7
              But how the heck would I have know that?
              Good point.
              Was there a discussion somewhere in Help that would have shown the approach you took?
              Don't know.

              MSDN and the docs that are derived from it can be cryptic, downright confusing, wrong or missing that
              important tidbit that might allow a programmer to keep his or her hair. This is one example where
              what the documentation is trying to convery may not be immediately apparent unless you have fiddled around
              with controls for a while.
              Dominic Mitchell
              Phoenix Visual Designer
              http://www.phnxthunder.com

              Comment


              • #8
                I missed the second part of your question.
                A filter for vertical scrollbar controls will look like the following:
                Code:
                  ' Filter message 
                  SELECT CASE CB.MSG
                    CASE %WM_VSCROLL  
                
                      ' Filter control by ID
                      SELECT CASE GetDlgCtrlID(CB.LPARAM)
                        CASE %IDC_FORM1_VSCROLL1
                           
                          ' Filter scroll code 
                          SELECT CASE LO(WORD, CB.WPARAM)
                            CASE %SB_BOTTOM        
                            CASE %SB_ENDSCROLL     
                            CASE %SB_LINEDOWN      
                            CASE %SB_LINEUP        
                            CASE %SB_PAGEDOWN      
                            CASE %SB_PAGEUP        
                            CASE %SB_THUMBPOSITION 
                            CASE %SB_THUMBTRACK    
                            CASE %SB_TOP           
                          END SELECT    
                
                      END SELECT  
                      
                  END SELECT
                Dominic Mitchell
                Phoenix Visual Designer
                http://www.phnxthunder.com

                Comment


                • #9
                  Dominic, thanks! That's just what I was looking for.

                  As a new PB programmer I'm trying to document that same information for all 22 of the controls PB supports.

                  Would you tell me where you pulled the list from, or was it one that you've put together over time?

                  Do you have an already compiled list of events for all the controls that you could share?

                  Whatever you have available would be appreciated.

                  I'll be the first to admit that working it out for myself has some learning value. There's always something else that I learn when trying to find information.

                  Here's the event list, by control, I've pulled together so far. You can see that I have some info, but am particularly missing events for the listview, progressbar, statusbar, tab, toolbar, and treeview controls.

                  I'm also worried that the events I've gleamed from the PB Help file are incomplete. Sometimes there were lists, and sometimes I had to pull it out of discussions. So I won't be surprised to find that my lists are incomplete. For example, your list has more entries than what I could pull out of the PB Help.

                  Here's the information I have pulled so far (including the info from you).

                  Button
                  %BN_CLICKED - mouse click
                  %BN_DBLCLK - double click
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  Check3State
                  %BN_CLICKED - mouse click
                  %BN_DBLCLK - double slick
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  CheckBox
                  %BN_CLICKED - mouse click
                  %BN_DBLCLK - double slick
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  ComboBox
                  %cbn_closeup - list box closed
                  %cbn_dblclk - double-clicks list box
                  %cbn_dropdown - before list is shown
                  %cbn_editchange - change made in edit box
                  %cbn_editupdate - before change made in edit box
                  %cbn_errspace - memory allocation problem
                  %cbn_killfocus - keyboard focus lost
                  %cbn_selchange - selection about to change (mouse click or arrow keys)
                  %cbn_selcancel - item selection canceled
                  %cbn_selendok - item selection accepted
                  %cbn_setfocus - keyboard focus received.

                  Image
                  %STN_CLICKED - mouse click
                  %STN_DBLCLK - double slick
                  %STN_DISABLE - when control has been disabled
                  %STN_ENABLE - when control has been enabled

                  ImageX
                  %STN_CLICKED - mouse click
                  %STN_DBLCLK - double slick
                  %STN_DISABLE - when control has been disabled
                  %STN_ENABLE - when control has been enabled

                  ImgButton
                  %BN_CLICKED - mouse click
                  %BN_DBLCLK - double slick
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  ImgButtonX
                  %BN_CLICKED - mouse click
                  %BN_DBLCLK - double slick
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  Label
                  %STN_CLICKED - mouse click
                  %STN_DBLCLK - double slick
                  %STN_DISABLE - when control has been disabled
                  %STN_ENABLE - when control has been enabled

                  Line
                  %STN_CLICKED - mouse click
                  %STN_DBLCLK - double slick
                  %STN_DISABLE - when control has been disabled
                  %STN_ENABLE - when control has been enabled


                  ListBox
                  %lbn_dblclk - doubleclick
                  %lbn_errspace - not enough memory
                  %lbn_killfocus - keyboard focus lost
                  %lbn_selcancel - ignore initial user selection
                  %lbn_selchange - selection about to be changed (arrow or mouse)
                  %lbn_setfocus - keyboard focus received

                  ListView
                  ... in work (not in PB Help)

                  Option
                  %BN_CLICKED - mouse click
                  %BN_KILLFOCUS - focus is lost
                  %BN_SETFOCUS - focus is received

                  ProgressBar
                  ... in work (not in PB Help)

                  ScrollBar
                  %SB_BOTTOM
                  %SB_ENDSCROLL
                  %SB_LINEDOWN
                  %SB_LINEUP
                  %SB_PAGEDOWN
                  %SB_PAGEUP
                  %SB_THUMBPOSITION
                  %SB_THUMBTRACK
                  %SB_TOP

                  StatusBar
                  ... in work (not in PB Help)

                  Tab
                  ... in work (not in PB Help)

                  TextBox
                  %EN_CHANGE - text has changed (after screen updated)
                  %EN_ERRSPACE - insufficient space
                  %EN_HSCROLL - horizontal scroll bar clicked (before screen update)
                  %EN_KILLFOCUS - textbox loses keyboard focus
                  %EN_MAXTEXT - maximum character length exceeded. truncates text.
                  %EN_SETFOCUS - textbox receives keyboard focus
                  %EN_UPDATE - text change (after formatting, before screen update)
                  %EN_VSCROLL - vertical scrollbar clicked (before screen updated)

                  Toolbar
                  ... in work (not in PB Help)

                  Treeview
                  ... in work (not in PB Help)

                  Again, thanks for your help - and for any other information on events that you can share.

                  Comment


                  • #10
                    Navigate to the MSDN Control Library and you will find all the information about all the controls: http://msdn.microsoft.com/en-us/libr...69(VS.85).aspx

                    For example, this if the complete list for Button's notification messages:

                    Notifications

                    BCN_DROPDOWN
                    Sent when the user clicks a drop down arrow on a button. The parent window of the control receives this notification message in the form of a WM_NOTIFY message.

                    BCN_HOTITEMCHANGE
                    Notifies the button control owner that the mouse is entering or leaving the client area of the button control. The button control sends this notification in the form of a WM_NOTIFY message.

                    BN_CLICKED

                    Sent when the user clicks a button.
                    The parent window of the button receives the BN_CLICKED notification code through the WM_COMMAND message.

                    BN_DBLCLK
                    Sent when the user double-clicks a button. This notification is sent automatically for BS_USERBUTTON, BS_RADIOBUTTON, and BS_OWNERDRAW buttons. Other button types send BN_DBLCLK only if they have the BS_NOTIFY style.
                    The parent window of the button receives the BN_DBLCLK notification code through the WM_COMMAND message.

                    BN_DISABLE
                    Sent when a button is disabled.
                    Note This notification message is provided only for compatibility with 16-bit versions of Microsoft Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_DISABLE notification code through the WM_COMMAND message.

                    BN_DOUBLECLICKED
                    Sent when the user double-clicks a button. This notification is sent automatically for BS_USERBUTTON, BS_RADIOBUTTON, and BS_OWNERDRAW buttons. Other button types send BN_DOUBLECLICKED only if they have the BS_NOTIFY style.
                    The parent window of the button receives the BN_DOUBLECLICKED notification code through the WM_COMMAND message.

                    BN_HILITE
                    Sent when the user selects a button.
                    Note This notification message is provided only for compatibility with 16-bit versions of Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_HILITE notification code through the WM_COMMAND message.

                    BN_KILLFOCUS
                    Sent when a button loses the keyboard focus. The button must have the BS_NOTIFY style to send this notification message.
                    The parent window of the button receives the BN_KILLFOCUS notification code through the WM_COMMAND message.

                    BN_PAINT
                    Sent when a button should be painted.
                    Note This notification message is provided only for compatibility with 16-bit versions of Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_PAINT notification code through the WM_COMMAND message.

                    BN_PUSHED
                    Sent when the push state of a button is set to pushed.
                    Note This notification message is provided only for compatibility with 16-bit versions of Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_PUSHED notification code through the WM_COMMAND message.

                    BN_SETFOCUS
                    Sent when a button receives the keyboard focus. The button must have the BS_NOTIFY style to send this notification message.
                    The parent window of the button receives the BN_SETFOCUS notification code through the WM_COMMAND message.

                    BN_UNHILITE
                    Sent when the highlight should be removed from a button.
                    Note This notification message is provided only for compatibility with 16-bit versions of Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_UNHILITE notification code through the WM_COMMAND message.

                    BN_UNPUSHED
                    Sent when the push state of a button is set to unpushed.
                    Note This notification message is provided only for compatibility with 16-bit versions of Windows earlier than version 3.0. Applications should use the BS_OWNERDRAW button style and the DRAWITEMSTRUCT structure for this task.
                    The parent window of the button receives the BN_UNPUSHED notification code through the WM_COMMAND message.

                    NM_CUSTOMDRAW (button)
                    Notifies the parent window of a button control about custom draw operations on the button.
                    The button control sends this notification in the form of a WM_NOTIFY message.

                    WM_CTLCOLORBTN
                    The WM_CTLCOLORBTN message is sent to the parent window of a button before drawing the button. The parent window can change the button's text and background colors. However, only owner-drawn buttons respond to the parent window processing this message.
                    Forum: http://www.jose.it-berater.org/smfforum/index.php

                    Comment


                    • #11
                      As you've probably deduced by now, an indispensible tool is a Microsoft SDK reference.

                      If you don't have one on CD/hard disk (fairly inexpensive), you can always use the online version (links above) for the cost of the connection.
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Yes, I'm learning that lesson. I'm lazy enough that I'd hoped to find more or less all that I need in the Help file. But now that I understand the real world, I'll adjust!

                        Support at PowerBASIC alerted me to an SDK installation file on the PB installation CD.

                        "set up windows api help.exe"

                        I'll install and use it.

                        Thanks to everyone who responded with help - Fred, Michael, Jose, Dominic, and Jeff!
                        Last edited by Gary Beene; 19 Jan 2009, 11:47 AM. Reason: error

                        Comment


                        • #13
                          I'm lazy enough that I'd hoped to find more or less all that I need in the Help file
                          You will find less, not more, than what you need if you restrict yourself to the compiler's help file.

                          The compiler's help files explain how the compiler works. However, you need more than compiler knowledge to create applications.

                          First and foremost, the compiler help file assumes you understand the fundamentals of programming in the BASIC language.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment

                          Working...
                          X