Re: Scrolling a Window

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ron,

The following "onGotFocus" additions to Don's example seems to make the tab
key function "automatically" (with no need to actually trap the tab key
itself) to move from one edit control to another.  Perhaps with your set of
controls you'd have to do something more?

Dan Moyer

--<Don's code with 2 small onGotFocus additions BEGINS>
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" )


procedure CheckKey( atom Msg, atom wParam, atom lParam )
  if Msg = WM_KEYDOWN then
     puts(1, wParam & "  " & lParam)
 --    ?1
  end if
end procedure
--onEvent[ Edit1 ] = routine_id( "CheckKey" )

procedure onGotFocus_Edit1()
  ScrollVert( 0 )
end procedure
onGotFocus[Edit1] = routine_id("onGotFocus_Edit1")

--procedure onGotFocus_Edit2()

--end procedure
--onGotFocus[Edit2] = routine_id("onGotFocus_Edit2")

procedure onGotFocus_Edit3()
  ScrollVert( 100 )
end procedure
onGotFocus[Edit3] = routine_id("onGotFocus_Edit3")


WinMain( MainWin, Normal )


----- Original Message -----
From: "Ron Tarrant" <rtarrant at sympatico.ca>
To: "EUforum" <EUforum at topica.com>
Sent: Monday, September 09, 2002 9:25 AM
Subject: Scrolling a Window


>
> 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.
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu