Results 1 to 8 of 8

Thread: MFC - scrollbars and colour

  1. #1

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking MFC - scrollbars and colour

    That's right - I am having two problems with a current MFC project I'm working on and want to improve.

    1) How on earth do you use scrollbars? I have added both a horizontal and vertical scrollbar to a dialogue, but can't figure out how to get it so a person can move them! I believe I can set the upper and lower bounds, but whenever I try to scroll, the box doesn't move...There are no messages thrown by the scrollbars, so i can't use them. Any ideas?

    2) Even harder: is it possible to change the colour of a Command Button, or is this aiming too high? In VB you can set the button to 'graphical', then change the colour as you wish, but i can't find this option in C++... I can't use .bmps either, as I would have to make too many of them. Suggestions?

    Thanks for your help


    *BUMP* Surely someone has used a scroll-bar at some stage??
    It's a long weekend now and i'm kinda stuck at this point...
    Last edited by sql_lall; Jun 13th, 2004 at 05:04 AM.
    sql_lall

  2. #2

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    *bump*

    *bump*
    ...it seems like editing doesn't acutally bump.

    Has someone here used a Scrollbar before?
    They're not that uncommon, surely...
    sql_lall

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There's a difference between scrollbar controls and scrollbars. If you give a window the WS_HSCROLL and WS_VSCROLL styles it will have scrollbars. Alternatively you can add scrollbar controls to the window.

    In both cases though you have to manually intercept the WM_SCROLL message and act on it. Or was that WM_VSCROLL and WM_HSCROLL? Can't remember.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking and...

    So....just create my own afx_msg void function, then receive the scroll message?

    However:
    (1) What throws the message. Is it when the user presses either scroll button? (in which case, how do you know which has been pressed)

    (2) Do you have to manually move the .ScrollAt variable (or whatever it is called) or can you read this to find where you are.

    (3) Are scroll bars made to cause confusion? Can't they just automatically move the scroll bit, then thow a WM_CHANGE message or something like that?

    Thanks for you help
    sql_lall

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    1) It's the scroll, no matter how it came to be.

    2) No idea what you mean.

    3) They are made to be flexible. Programs can optimize their scrolling in various ways, some programs even have completely different ideas of what scrolling means.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    hehe

    ok...to clarify:

    (1) How do you know, when you receive the message, whether it has been thrown by the pressing of the buttons at either end of the scroll-bar (moves the actual bar one unit either way), the clicking inside the scroll-bar (usually moves the actual bar more units), or clicking on the bar itself and dragging it?

    Or is it just whenever it changes?

    (2) In the class, there's a function (called SetScrollPos - or something similar), which allows you to set where the bar is (in relation to the start and end). I was wondering if the position updated itself when the user moved the scroll bar, or whether the programmer has to interpret the message and decide how to move the bar.

    (3) It was just that, in the good-old days of simpified VB, the scroll bars were extremely programmer-friendly
    sql_lall

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    1) From MSDN:
    Syntax

    WM_HSCROLL

    WPARAM wParam
    LPARAM lParam;

    Parameters

    wParam
    The low-order word specifies a scroll bar value that indicates the user's scrolling request. This word can be one of the following values.

    The high-order word specifies the current position of the scroll box if the low-order word is SB_THUMBPOSITION or SB_THUMBTRACK; otherwise, this word is not used.

    SB_ENDSCROLL
    Ends scroll.
    SB_LEFT
    Scrolls to the upper left.
    SB_RIGHT
    Scrolls to the lower right.
    SB_LINELEFT
    Scrolls left by one unit.
    SB_LINERIGHT
    Scrolls right by one unit.
    SB_PAGELEFT
    Scrolls left by the width of the window.
    SB_PAGERIGHT
    Scrolls right by the width of the window.
    SB_THUMBPOSITION
    The user has dragged the scroll box (thumb) and released the mouse button. The high-order word indicates the position of the scroll box at the end of the drag operation.
    SB_THUMBTRACK
    The user is dragging the scroll box. This message is sent repeatedly until the user releases the mouse button. The high-order word indicates the position that the scroll box has been dragged to.
    lParam
    If the message is sent by a scroll bar, then this parameter is the handle to the scroll bar control. If the message is not sent by a scroll bar, this parameter is NULL.
    2) I can't remember. Try.

    3) I know of no "good" and "VB" in the same sentence
    VB is easy, but inflexible and inefficient.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Fanatic Member sql_lall's Avatar
    Join Date
    Jul 2002
    Location
    Up Above (i.e. AUS)
    Posts
    571

    Talking THanks

    Thankyou very much for your response...

    And I agree, C++ is much better than VB....but some people can make VB look nice too...
    sql_lall

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width