is handle a scrollbar?

This is a discussion on is handle a scrollbar? within the Windows Programming forums, part of the Platform Specific Boards category; hi to everyone, i need your help, i am checking if the handle i retrieved is a scrollbar such as ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    13

    is handle a scrollbar?

    hi to everyone,

    i need your help, i am checking if the handle i retrieved is a scrollbar such as VerticalScrollbar or HorizontalScrollbar, i did the enumeration of the childwindow:

    BOOL EnumChildWindows(HWND hWndParent,
    WNDENUMPROC lpEnumFunc,
    LPARAM lParam);

    and in callback function it is:

    BOOL CALLBACK EnumChildProc(HWND hwnd,
    LPARAM lParam);

    in every enumeration for this childwindow this first param HWND hWnd receives new hWnd this hWnd now i need to know is scrollbar itself? what is the function i need to use to check each hWnd if it is Hscrollbar of Vscrollbar?

    thank you!

  2. #2
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    If you pass GetClassName the hwnd and a string buffer, you can then test to see if it is "SCROLLBAR".

    I think you'd have to use GetWindowLongPtr and retrieve the window style to determine if it is horizontal or not.

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    13
    Quote Originally Posted by SMurf View Post
    If you pass GetClassName the hwnd and a string buffer, you can then test to see if it is "SCROLLBAR".

    I think you'd have to use GetWindowLongPtr and retrieve the window style to determine if it is horizontal or not.
    ================================================== ===
    hi THANK YOU VERY MUCH FOR THE HELP REALLY APPRECIATED,

    Types of Window Classes
    There are three types of window classes:

    1. System Classes
    2. Application Global Classes
    3. Application Local Classes
    -------------------------------------
    you are correct SCROLLBAR is a class under System Classes, so here when i tried your first suggestion GetClassName(...):

    wchar_t ClassName[255];
    int getClassName = GetClassName(hWnd, ClassName, wcslen(ClassName));

    i debug the output param ClassName:
    ClassName: 0031F37C (i know this is a hexa value right)

    i was expecting since the datatype is wchar_t i will retrived the word "SCROLLBAR" as its classname. so how can i relate this output to the word SCROLLBAR?(maybe later on if it is HSCROLL or VSCROLL)

  4. #4
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    That would appear to be telling you the address of your buffer, not its content. How are you doing this?
    Try:-
    Code:
    MessageBox(NULL, ClassName, NULL, MB_ICONINFORMATION);

  5. #5
    Registered User
    Join Date
    Jul 2010
    Posts
    13
    Hi when i try to add this function:
    Code:
    MessageBox(hWnd, ClassName, NULL, MB_ICONINFORMATION);
    - using this function it gives the class names:
    MsoCommandBarDock
    MsoCommandBarDock
    MsoCommandBarDock
    MsoCommandBar
    MsoCommandBar
    MsoCommandBarDock
    VsChannel
    VsChannel
    VsChannel
    VsChannel
    VsStatusBar
    msctls_statusbar32
    msctls_progress32
    Generic Pane
    VsResultsListBaseToolWndClass
    SysListView32

    But what i am expecting is the scrollbar now here is the list of tables for CLASSES STYLES:

    Code:
    Class 		Description 
    --------------------------------------------------------------------
    Button 		The class for a button. 
    ComboBox 	The class for a combo box. 
    Edit 		The class for an edit control. 
    ListBox 	                The class for a list box. 
    MDIClient 	The class for an MDI client window. 
    ScrollBar 	                The class for a scroll bar. 
    Static 		The class for a static control.
    Thank you very much

  6. #6
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    The thing about scrollbars is that they aren't usually implemented as independent controls, their functionality is derived by most other classes.

    Including WS_HSCROLL or WS_VSCROLL styles into a window causes scrollbars to be drawn based on private data inside the base window class.

    So the best way to detect them would be to use GetWindowLongPtr(GWL_STYLE) like so:-
    Code:
    if (GetWindowLongPtr(GWL_STYLE) & (WS_HSCROLL | WS_VSCROLL))
        MessageBox(NULL, "Scrollbars in here", NULL, MB_ICONINFORMATION);
    else
        MessageBox(NULL, "No scrollbars in here", NULL, MB_ICONERROR);

  7. #7
    Registered User
    Join Date
    Jul 2010
    Posts
    13
    Quote Originally Posted by SMurf View Post
    The thing about scrollbars is that they aren't usually implemented as independent controls, their functionality is derived by most other classes.

    Including WS_HSCROLL or WS_VSCROLL styles into a window causes scrollbars to be drawn based on private data inside the base window class.

    So the best way to detect them would be to use GetWindowLongPtr(GWL_STYLE) like so:-
    Code:
    if (GetWindowLongPtr(GWL_STYLE) & (WS_HSCROLL | WS_VSCROLL))
        MessageBox(NULL, "Scrollbars in here", NULL, MB_ICONINFORMATION);
    else
        MessageBox(NULL, "No scrollbars in here", NULL, MB_ICONERROR);
    hi there, sorry you are misunderstanding my question "IS handle A scrollabar?"
    means IS handle A scrollbar, means the handle is the SCROLLBAR itself, that is my question NOT if handle HAS scrollbar, cause your code here:

    Code:
    if (GetWindowLongPtr(GWL_STYLE) & (WS_HSCROLL | WS_VSCROLL))
        MessageBox(NULL, "Scrollbars in here", NULL, MB_ICONINFORMATION);
    else
        MessageBox(NULL, "No scrollbars in here", NULL, MB_ICONERROR);
    i am done with this, this code you have shown means the window HAS scrollbar, what i need is if this handle IS scrollbar ITSELF.

    thank you
    Last edited by anne03; 07-29-2010 at 09:15 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 05:02 PM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 04:36 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Retrieving handle to child scrollbar
    By rottinglich in forum Windows Programming
    Replies: 5
    Last Post: 11-03-2004, 11:22 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 10:37 AM

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