1. RE: Scrolling a Window
- Posted by Don Phillips <Graebel at hotmail.com> Sep 09, 2002
- 369 views
> I am using win32lib to create a window that has a number of text > controls arranged in rows and columns (tiled as opposed to cascading). I > want to be able to add rows/columns at will, but at some point, I'll > need to be able to scroll the client area of the window in order to see > the new text controls that I've added. > > So what I'm looking for is a simple example of adding scrollbars to a > window, then processing scrollbar messages (or however it's done) to > scroll the contents of the window left/right/up/down. Does anyone know > how to do this? Hellllo Ron... simple example: ========== include Win32Lib.ew without warning constant ScrollWindow = registerw32Procedure( user32, "ScrollWindow", {C_LONG,C_LONG,C_LONG,C_POINTER,C_POINTER} ) constant MainWin = create( Window, "Scroll test", NULL, 0.25, 0.25, 300, 200, WS_VSCROLL ), Edit1 = create( EditText, "Edit1", MainWin, 10, 10, 150, 20, 0 ), Edit2 = create( EditText, "Edit2", MainWin, 10, 110, 150, 20, 0 ), Edit3 = create( EditText, "Edit3", MainWin, 10, 210, 150, 20, 0 ) integer OldVPos OldVPos = 0 procedure ScrollVert( integer Pos ) integer VChange -- Negative value to scroll up or left -- Positive value to scroll down or right VChange = OldVPos - Pos w32Proc( ScrollWindow, {getHandle(MainWin),0,VChange,0,0} ) OldVPos = Pos end procedure onScroll[ MainWin ] = routine_id( "ScrollVert" ) WinMain( MainWin, Normal ) ========== > On a separate topic, I have attached a keyDown handler to this same > window and I'm getting keyCodes for most keys, but not for the Tab key. > I wrote a simple procedure that tells me the raw keyCode value and it > works for a number of other keys I've tried, but when I press the Tab > key, I get nothing. Does anyone know why? Win32Lib uses direct window objects for the windows and controls. As such, in order to emulate a dialog boxes behaviour of tabbing to other controls, Win32Lib itself must intercept the tab key and do some behind the scenes processing. I have found that when Win32Lib processes something, it has the side effect of removing it from the direct callbacks (such as onKeyDown). If you want to capture the tab key, you need to use an onEvent handler instead. ========== procedure CheckKey( atom Msg, atom wParam, atom lParam ) if Msg = WM_KEYDOWN then ?1 end if end procedure onEvent[ Edit1 ] = routine_id( "CheckKey" ) ========== > If I haven't given enough info here, or haven't explained this very > clearly, please let me know and I'll try again. Was clear enough for me =) Hope the examples are self explanitory enough for your use... Don Phillips
2. RE: Scrolling a Window
- Posted by Phil Russell <pg_russell at lineone.net> Sep 10, 2002
- 386 views
Hi Ron, It sounds a bit like you want to create a grid of rows and columns. Have you considered using my EuGrid grid control for this (see Euphoria contributions page)? It allows you to create a grid of editable cells and automatically handles keyboard navigation and scrolling... Please ignore if not relevant! Phil Russell Ron Tarrant wrote: > I am using win32lib to create a window that has a number of text > controls arranged in rows and columns (tiled as opposed to cascading). I > want to be able to add rows/columns at will, but at some point, I'll > need to be able to scroll the client area of the window in order to see > the new text controls that I've added. > > So what I'm looking for is a simple example of adding scrollbars to a > window, then processing scrollbar messages (or however it's done) to > scroll the contents of the window left/right/up/down. Does anyone know > how to do this? > > On a separate topic, I have attached a keyDown handler to this same > window and I'm getting keyCodes for most keys, but not for the Tab key. > I wrote a simple procedure that tells me the raw keyCode value and it > works for a number of other keys I've tried, but when I press the Tab > key, I get nothing. Does anyone know why? > > If I haven't given enough info here, or haven't explained this very > clearly, please let me know and I'll try again. > > -Ron T. > >