1. 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     » topic index » view message » categorize

2. Re: Scrolling a Window

Ron,
there are some serious problems with scrolling Windows in earlier versions
of the library. I've added better support for the new version (due out on
Tuesday).

Including a reasonable demo programs.


The TAB keys is stolen by win32lib unless you do something about it.

Try adding this to your startup code...

   VOID = setTabCodes(0)

I can see now why this wasn't obvious: I'd forgotten to document this
routine. Sorry.

----------------
cheers,
Derek Parnell
----- Original Message -----
From: "Ron Tarrant" <rtarrant at sympatico.ca>
To: "EUforum" <EUforum at topica.com>
Sent: Tuesday, September 10, 2002 2: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 message » categorize

3. Re: Scrolling a Window

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 message » categorize

4. Re: Scrolling a Window

Ron,

Oops, forgot to mention that the additions of "onGotFocus" to Don's example,
while auto moving the window to each edit control as tab key is pressed,
*doesn't* move the windows scroll bar itself to reflect the movement up/down
the window.  That's at least a visual problem, could maybe create a more
serious problem too?

Dan Moyer

----- Original Message -----
From: "Don Phillips" <Graebel at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Subject: RE: 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?
>
> 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
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Scrolling a Window

Don Phillips wrote:
> 
> Hellllo Ron... simple example:

Thanks, Don. I see how it works now... Ah... Sort of. I tried to get the
horizontal scrollbar working as well, but I don't see how to distinguish
between vertical and horizontal scrolling. My guess is that I'd be
dealing with WM_VSCROLL and WM_HSCROLL messages but they aren't
mentioned in any win32lib docs or examples I have on-hand (which is
likely most that are available). I'm further guessing that I'd have to
watch for an event coming through some message port or other, then see
which of the WM_xSCROLL messages it is. Am I on the right track? 

> ==========
> Win32Lib uses direct window objects for the windows and controls.

Ah, ha! That explains something. Originally I was using child windows
with a TextEdit control in each child window. Then I switched to putting
the TextEdit controls directly into the parent window and got rid of the
child windows. At some point after that I inadvertently passed the
WS_CAPTION flag to create() when building the TextEdit controls and they
all turned into little windows that could be moved. It's not a bug; it's
a feature!

> I have found that when Win32Lib processes
> something, it has the side effect of removing it from the direct
> callbacks (such as onKeyDown).

Okay. I was thinking it had to be something like that.

> If you want to capture the tab key, you need to use an onEvent handler
> instead.

Gotcha. Thanks again, Don.

> ==========
> Was clear enough for me =)
> Hope the examples are self explanitory enough for your use...

Good. Last time I asked a question on this forum I think I'd had too
much coffee... or maybe too little. Either way, I wasn't very
articulate.

Again, thanks.

-Ron T.

"User error. Replace user and try again." - Duane Eddingfield

new topic     » goto parent     » topic index » view message » categorize

6. Re: Scrolling a Window

Derek Parnell wrote:

> there are some serious problems with scrolling Windows in earlier versions
> of the library. I've added better support for the new version (due out on
> Tuesday).

Ah! Excellent! Thanks, Derek! But... does Tuesday come for you before we
get it here in North America or is it the other way around? I've never
understood that International Date Line stuff.

> Including a reasonable demo programs.

That's even better! I'll do my best not to go crazy while I'm waiting.

> The TAB keys is stolen by win32lib unless you do something about it.
> 
> Try adding this to your startup code...
> 
>    VOID = setTabCodes(0)
> 
> I can see now why this wasn't obvious: I'd forgotten to document this
> routine. Sorry.

Okay, I'll try it out. Thanks again, Derek.

-Ron T.

new topic     » goto parent     » topic index » view message » categorize

7. Re: Scrolling a Window

On Mon, 09 Sep 2002 12:25:26 -0400, Ron Tarrant 
<rtarrant at sympatico.ca> wrote: 
 
>window and I'm getting keyCodes for most keys, but not for the Tab key. 
 
Derek partially answered this, but I found I had to use: 
 
--==code begins==-- 
oldcodes=setTabCodes(0)	-- save std/disable tab handling 
procedure onGotFocus_MAIN() 
	void=setTabCodes(0) -- let me handle tab when main has focus 
end procedure 
 
procedure onLostFocus_MAIN() 
	voidsetTabCodes(oldcodes) -- restore std tab handling 
end procedure 
onGotFocus[MAIN]  routine_id("onGotFocus_MAIN") 
onLostFocus[MAIN]  routine_id("onLostFocus_MAIN") 
--==code ends===-- 
 
Depends on how complex your program & tab handling requirements are. 
 
HTH, Pete

new topic     » goto parent     » topic index » view message » categorize

8. Re: Scrolling a Window

Dan Moyer wrote:
> 
> 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.

Very cool, Dan. Thanks!

>  Perhaps with your set of
> controls you'd have to do something more?

Mainly I just want to move from one to the other and Shift-Tab to go
back.

-Ron T.

new topic     » goto parent     » topic index » view message » categorize

9. Re: Scrolling a Window

Dan Moyer wrote:

> Oops, forgot to mention that the additions of "onGotFocus" to Don's example,
> while auto moving the window to each edit control as tab key is pressed,
> *doesn't* move the windows scroll bar itself to reflect the movement up/down
> the window.  That's at least a visual problem, could maybe create a more
> serious problem too?

Derek says he's got a new version of win32lib coming out tomorrow that
deals with scrolling problems. Maybe this has been addressed as well.

-Ron T.

new topic     » goto parent     » topic index » view message » categorize

10. Re: Scrolling a Window

petelomax at blueyonder.co.uk wrote:
> 
> Derek partially answered this, but I found I had to use:
> 
> --====code begins====--
> oldcodes=setTabCodes(0) -- save std/disable tab handling
> procedure onGotFocus_MAIN()
>         void=setTabCodes(0) -- let me handle tab when main has focus
> end procedure
> 
> procedure onLostFocus_MAIN()
>         void=setTabCodes(oldcodes) -- restore std tab handling
> end procedure
> onGotFocus[MAIN] = routine_id("onGotFocus_MAIN")
> onLostFocus[MAIN] = routine_id("onLostFocus_MAIN")
> --====code ends====--
> 
> Depends on how complex your program & tab handling requirements are.

Hmmm... This reminds me of some things we used to do to the Commodore
64. smile

And the Amiga...

Hmmm...

-Ron T.

new topic     » goto parent     » topic index » view message » categorize

11. Re: Scrolling a Window

Ron,
win32lib noraml handles tabbing from one control to the next automatically. Is
there some reason why
its default behaviour is not meeting the needs of your application?

For example, I'd like to add a routine to the library so that an application can
alter the tabbing
order.
>
>Mainly I just want to move from one to the other and Shift-Tab to go
>back.
>
>-Ron T.

new topic     » goto parent     » topic index » view message » categorize

12. Re: Scrolling a Window

Derek Parnell wrote:

> win32lib noraml handles tabbing from one control to the next automatically. Is
> there some reason why its default behaviour is not meeting the needs of your
> application?

The default would be fine, but with doing onKeyDown events for other
things, I just want the default behaviour reinstated.

Of course, if I could exchange default Tab behaviour for default
Control-Tab behaviour that would be great, too. Then I can allow
inserting tabs within a multi-line EditText control using just the Tab
key and move from one control to the next using Control-Tab, the exact
opposite of what MS Word does in tables. It just seems more intuitive to
me to use a key qualifier for the 'bigger' behaviour.

Actually, now that I think about it, it might be better to handle
changing focus with Shift-Arrow keys. That would give me two dimensions
of movement with a single paradym.

Hmmm... Guess I should go do some more work on my design spec.

> For example, I'd like to add a routine to the library so that an application
> can
> alter the tabbing order.

Anything that increases the flexibility of the library is a good idea.
In my original plan for this app, this would have come in handy, so I'm
sure there are other cases where it still would. In fact, this app is
going to have several different windows and it might still come in handy
for one of the others. I haven't nailed down the design spec as yet, so
I don't know for sure.

I don't suppose this tab reordering feature will be in Tuesday's
release, will it? smile

-Ron T.

PS: BTW, I've just become a published author! I know that mentioning it
here is tantamount to spamming, but I'm so excited about this. Check it
out at:

www.actiontales.com/titles.html

new topic     » goto parent     » topic index » view message » categorize

13. Re: Scrolling a Window

Phil Russell wrote:

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

Actually, this sounds like pretty much exactly what I'm trying to do.
I'll look it up on the RDS site and take a browse through your docs.

Thanks, Phil!

-Ron T.

new topic     » goto parent     » topic index » view message » categorize

14. Re: Scrolling a Window

Derek wrote:

>
> Ron,
<snip>
>
> For example, I'd like to add a routine to the library so that an
application can alter the tabbing
> order.
> >

That sounds like an *excellent* idea!  Way better than hand modifying the
order of creation of the controls (usually backwards) to attempt to get the
tab to work as you might like it to.

Dan Moyer

new topic     » goto parent     » topic index » view message » categorize

15. Re: Scrolling a Window

If anyone else is interested in window scrollbars, I finally stopped
panicking and figured out how to scroll in _both_ directions. This is
built on the code Don Phillips so kindly supplied. My changes are marked
with --** at the ends of the lines. I left out the enhancements Dan
Moyer added (sorry Dan) so that it would be an example of only the
scrolling stuff.

I haven't tried this with win32lib v55, but it works with v57.9:

--------------------------------------------------------------

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_HSCROLL, WS_VSCROLL, WS_SYSMENU}), --**
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,
OldHPos --**

OldVPos = 0
OldHPos = 0 --**

procedure ScrollVert(integer Pos)
    integer VChange, HChange --**

    integer hPos, vPos --**
    hPos = getHScrollPos(MainWin) --**
    vPos = getVScrollPos(MainWin) --**

    -- Negative value to scroll up or left
        -- Positive value to scroll down or right
    if vPos = OldVPos then --**
	HChange = OldHPos - Pos --**
	w32Proc(ScrollWindow, {getHandle(MainWin), HChange, 0, 0, 0}) --**
	OldHPos = Pos --**
    else --**
    	VChange = OldVPos - Pos
    	w32Proc(ScrollWindow, {getHandle(MainWin), 0, VChange, 0, 0})
    	OldVPos = Pos
   end if --**

end procedure

onScroll[MainWin] = routine_id("ScrollVert")

WinMain(MainWin, Normal)

-----------------------------------------------------------------------

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu