Scroll bars

This is a discussion on Scroll bars within the C++ Programming forums, part of the General Programming Boards category; I'm controlling a 3rd party program through some software that I wrote. I am able to click buttons and move ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    22

    Scroll bars

    I'm controlling a 3rd party program through some software that I wrote.
    I am able to click buttons and move various controls but when it comes to the scroll bars I've hit a brick wall.

    Just to help you visualize here's a pic of the program I'm talking about.
    http://img.photobucket.com/albums/v4...3/untitled.bmp

    Code:
    apptr1->SendDlgItemMessage(0x42B, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(100, 8000));
    apptr1->SendDlgItemMessage(0x42B, TBM_SETPOS, (WPARAM) TRUE, (LPARAM)/*SetPos Here*/100);
    I am using setrange and setpos to control where I want the slider to go. And this works well... to a point. The static text next to the slider is supposed to change as you slide it but it doesn't do anything. You have to click the new position with your mouse for it to register any change.

    My program is controlled by a remote device and I cannot have any interaction with the mouse to be successful. Is there a command I can send to the scroll bar to make it register the changes? Or is there a better way to do this.

    BTW I'm using MFC.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    It seems that you will have to send the notification message manually. This is what MSDN has to say about trackbar notification messages:
    Quote Originally Posted by MSDN Trackbar Notification Messages
    A trackbar notifies its parent window of user actions by sending the parent a WM_HSCROLL or WM_VSCROLL message. A trackbar with the TBS_HORZ style sends WM_HSCROLL messages. A trackbar with the TBS_VERT style sends WM_VSCROLL messages. The low-order word of the wParam parameter of WM_HSCROLL or WM_VSCROLL contains the notification code. For the TB_THUMBPOSITION and TB_THUMBTRACK notifications, the high-order word of the wParam parameter specifies the position of the slider. For all other notifications, the high-order word is zero; send the TBM_GETPOS message to determine the slider position. The lParam parameter is the handle to the trackbar.
    Reading this "from the other side" we should be able to manually construct and send the three notification messages that the target application is most likely to be responding to:
    Code:
    apptr1->SendMessage(WM_HSCROLL, (WPARAM) MAKELONG(TB_THUMBTRACK, 100),    (LPARAM) (HWND) apptr1->GetDlgItem(0x42B));
    apptr1->SendMessage(WM_HSCROLL, (WPARAM) MAKELONG(TB_THUMBPOSITION, 100), (LPARAM) (HWND) apptr1->GetDlgItem(0x42B));
    apptr1->SendMessage(WM_HSCROLL, (WPARAM) MAKELONG(TB_ENDTRACK, 0),        (LPARAM) (HWND) apptr1->GetDlgItem(0x42B));
    It should be noted that notification messages are sent to the parent window. As a style issue, you should consider defining constants for control ids rather than using magic numbers.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    22
    You seem to know what you're talking about but when I put the code into my program it doesnt do anything... my scroll bar doesnt move...

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I thought you already had the trackbar moving? The code I posted doesn't replace your movement code, it goes after the movement code to notify the application of the change. If it doesn't work, it may be expecting a different notification message.

  5. #5
    Registered User
    Join Date
    Feb 2005
    Posts
    22
    Ok, well I moved the bar than did the code still to no avail...

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    >> Ok, well I moved the bar than did the code still to no avail... <<

    You can try sending TB_PAGEDOWN as well, other than that I'm out of ideas...
    Code:
    apptr1->SendMessage(WM_HSCROLL, (WPARAM) MAKELONG(TB_PAGEDOWN, 0),        (LPARAM) (HWND) apptr1->GetDlgItem(0x42B));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scroll Bars Are Scrolling Me Crazy
    By Iyouboushi in forum C# Programming
    Replies: 6
    Last Post: 03-03-2006, 12:43 PM
  2. Scroll bars.......
    By incognito in forum Windows Programming
    Replies: 5
    Last Post: 01-11-2004, 06:57 AM
  3. Scroll Bars and Focus
    By Thantos in forum Windows Programming
    Replies: 1
    Last Post: 08-21-2003, 11:57 AM
  4. Horizontal Scroll Bars with CListBox
    By Malek in forum Windows Programming
    Replies: 1
    Last Post: 04-10-2003, 09:58 PM
  5. Scroll Bars
    By bc17 in forum Windows Programming
    Replies: 2
    Last Post: 02-21-2003, 02:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21