none
Getting a Framed Parent window to Scroll RRS feed

  • Question

  • I need more controls on a window interior than the height of the interior.

    How do you get the Main window to scroll a STATIC thats longer then the main window.

    Here a bit of code, but its in FreeBasic,  But i'm sure the concept works also in C or C++ , As FreeBasic just includes the normal API , so the calls would be the same.

    #define WIN_INCLUDEALL
    #Include "windows.bi"
    
    
    Dim As MSG msg
    Dim shared As HWND hWnd, statics , edits1 , edits2
    
    ' Create window
    hWnd = CreateWindowEx( 0, "#32770", "BigCalc version 8.0 by Albert Redditt 8,2009-1,2010", WS_OVERLAPPEDWINDOW Or WS_VISIBLE or WS_VSCROLL , 100, 100, 640, 480, 0, 0, 0, 0 )
    
    'create a static control bigger then the main window
    statics = CreateWindowEx( 0 , "STATIC" , "" , ws_border or WS_VISIBLE Or WS_CHILD                                                                                 ,  0,  0, 640,1024, hWnd   , 0, 0, 0 )
    edits1  = CreateWindowEx( 0 , "EDIT"   , "" , ws_border Or WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL Or ES_MULTILINE , 10, 10, 610,  70, statics, 0, 0, 0 )
    edits2  = CreateWindowEx( 0 , "EDIT"   , "" , ws_border Or WS_VISIBLE Or WS_CHILD Or WS_HSCROLL Or WS_VSCROLL Or ES_AUTOHSCROLL Or ES_AUTOVSCROLL Or ES_MULTILINE , 10,700, 610,  70, statics, 0, 0, 0 )
    
    
    While GetMessage( @msg, 0, 0, 0 )
      TranslateMessage( @msg )
      DispatchMessage( @msg )
      
      Select Case msg.hwnd
        Case hWnd
          Select Case msg.message
            Case 273
              PostQuitMessage(0)
              'End
          End Select
    
      End Select
    
    Wend
    
    PostQuitMessage(0)
    
    END
    
    I need the STATIC to scroll inside the main window...
     
    Friday, September 7, 2012 2:08 AM

Answers

  • Hi alber_redditt,

    You can follow the window scroll example in the link below.

    http://www.pismotek.com/brainout/content/windows_scroll_example.php

    Best Regards.

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by albert_redditt Wednesday, September 12, 2012 6:25 PM
    Wednesday, September 12, 2012 9:08 AM
    Moderator

All replies

  • Hi albert_redditt,

    To make a scrollable Window, you can set it's Window Styles. WS_HSCROLL means the window has a horizontal scroll bar. WS_VSCROLL means the window has a vertical scroll bar, see http://www.codeproject.com/Articles/2283/Scrollbars-using-the-WS_HSCROLL-and-WS_VSCROLL-sty

    You can also use Form::AutoScroll Property to enable autoscrolling.

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 10, 2012 9:01 AM
    Moderator
  • I put  "OR WS_VSCROLL" into the main window  CreateWindowEX( 0 #32770 ,

    hWnd = CreateWindowEx( 0, "#32770", "Window Title", WS_OVERLAPPEDWINDOW Or WS_VISIBLE or WS_VSCROLL , 100, 100, 640, 480, 0, 0, 0, 0 )

    It puts a scrollbar on the parent window alright , but the scrollbar is non-functional in scrolling the STATIC, that my controls are on.

    If I skip the STATIC and just put the controls on the interior it also doesn't scroll.

    Maybe i need other code in there to cause the static to actually scroll ?? Thats what i'm asking about.

    I need like 18 multiline edit boxes on the interior, and want each to be at least several lines tall with sufficient space in between each, for a label.

    Tuesday, September 11, 2012 10:07 PM
  • Hi alber_redditt,

    You can follow the window scroll example in the link below.

    http://www.pismotek.com/brainout/content/windows_scroll_example.php

    Best Regards.

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by albert_redditt Wednesday, September 12, 2012 6:25 PM
    Wednesday, September 12, 2012 9:08 AM
    Moderator
  • Thanks, I Think??

    The code link you posted , looks pretty good , I'll see if i can convert it to FreeBasic.

    You would think that; just adding a scrollbar to the main window, would automatically scroll the interior, if the interior is larger than the main window.

    Thers lots of idio-snycracies with the Windows API..  The most prolific one,

    A Window gets redrawn 3 times for every button click , that one; has been in there since Windows 3.1 or earlier. you can spot it by single stepping through a windowed app, or overloading windows with lots of apps.

    Wednesday, September 12, 2012 6:24 PM