1. Win32Lib input box
- Posted by Erik-Jan van Kampen <e.vankampen at student.tudelft.nl> Feb 22, 2006
- 392 views
Hello EUForum, I was trying to make an input box for numbers with Win32Lib that takes exactly 9 rows of 9 numbers in such a way that when you type in the numbers you will automatically go to the next line when you have entered 9 numbers. It must also not be possible to enter more than 9 rows. I got this to work correctly on my system (Windows XP) by setting a specific font for the input box and adjust the size of the box manually such that it holds exactly 9 numbers per row and 9 rows:
InputBox = create( MleText,"",InputWindow,180,20,85,155,ES_NUMBER) setFont(InputBox, "System", 16, {Bold,0,0,0,ANSI_CHARSET,0,0,0,0} )
The problem is that on other systems (Windows ME) this input box can only take 8 numbers per row. I know I can just make the input box bigger and press enter after every 9 numbers, but I would like it if the cursor would jump to the next row by itself. Any solutions for this problem??? Thanks, Erik-Jan
2. Re: Win32Lib input box
- Posted by don cole <doncole at pacbell.net> Feb 22, 2006
- 396 views
Erik-Jan van Kampen wrote: > > Hello EUForum, > > I was trying to make an input box for numbers with Win32Lib that takes exactly > 9 rows of 9 numbers in such a way that when you type in the numbers you will > automatically go to the next line when you have entered 9 numbers. It must > also > not be possible to enter more than 9 rows. > > I got this to work correctly on my system (Windows XP) by setting a specific > font for the input box and adjust the size of the box manually such that it > holds exactly 9 numbers per row and 9 rows: > > }}} <eucode> > InputBox = create( MleText,"",InputWindow,180,20,85,155,ES_NUMBER) > setFont(InputBox, "System", 16, {Bold,0,0,0,ANSI_CHARSET,0,0,0,0} ) > </eucode> {{{ > > The problem is that on other systems (Windows ME) this input box can only take > 8 numbers per row. I know I can just make the input box bigger and press enter > after every 9 numbers, but I would like it if the cursor would jump to the > next > row by itself. Any solutions for this problem??? > > Thanks, > Erik-Jan Hello Erik, I'm not sure if this will help you or not. I had a similar problem with Windows2000 . It wouldn't jump down. Somebody told me to put returnValue(-1) after my last entry and it worked. I don't how your going to get your spacing though. Maybe getTextExtent(InputBox) Don Cole
3. Re: Win32Lib input box
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 22, 2006
- 404 views
Erik-Jan van Kampen wrote: > > Hello EUForum, > > I was trying to make an input box for numbers with Win32Lib that takes exactly > 9 rows of 9 numbers in such a way that when you type in the numbers you will > automatically go to the next line when you have entered 9 numbers. It must > also > not be possible to enter more than 9 rows. Have a look at this demo --------------------------------------- without warning include win32lib.ew integer win sequence boxes procedure KeyPress_boxes(integer self, integer event, sequence parms) integer lPos -- Only allow digits. lPos = find(parms[1], "123456789") if lPos = 0 then -- Not a digit from 1-9, however allow -- backspaces to be processed as normal if parms[1] = VK_BACKSPACE then return end if returnValue(-1) return end if -- If there is already something in the box, just stay put. if length(getText(self)) != 0 then returnValue(-1) -- Don't replace already entered data return end if -- Find out what is the next box to move to. lPos = find(self, boxes) if lPos != length(boxes) then setFocus(boxes[lPos+1]) else -- Last box gets special treatment. setFocus(self) end if end procedure procedure init() integer lTextWidth integer lMaxWidth integer lMaxHeight integer k integer top integer left win = create(Window, "Nine by Nine", 0, 0, 0, 0, 0, 0) setFont(win, "FixedSys", 16, {Bold,0,0,0,ANSI_CHARSET,0,0,0,0}) -- or any other font lMaxWidth = 0 for i = 1 to 9 do lTextWidth = getTextWidth(win, sprintf("%d", i)) if lTextWidth > lMaxWidth then lMaxWidth = lTextWidth end if end for lMaxHeight = getTextHeight(win, "|") + 5 lMaxWidth += 5 -- Make the window big enough. setClientRect(win, lMaxWidth * 9 + 15 + 15 + (3 * (9-1)), lMaxHeight * 9 + 10 + 10 + (3 * (9-1)) ) -- Draw the boxes now boxes = repeat(0, 81) k = 1 top = 10 for i = 1 to 9 do left = 15 for j = 1 to 9 do boxes[k] = create(EditText, "", win, left, top, lMaxWidth, lMaxHeight, 0) k += 1 left += lMaxWidth + 3 end for top += lMaxHeight + 3 end for -- Set the same handler for each of the boxes. setHandler( boxes, w32HKeyPress, routine_id("KeyPress_boxes")) end procedure init() WinMain({win, boxes[1]}, Normal) --------------------------------------- Hope this helps. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
4. Re: Win32Lib input box
- Posted by Erik-Jan van Kampen <e.vankampen at student.tudelft.nl> Feb 22, 2006
- 387 views
Derek Parnell wrote: > > Erik-Jan van Kampen wrote: > > > > Hello EUForum, > > > > I was trying to make an input box for numbers with Win32Lib that takes > > exactly > > 9 rows of 9 numbers in such a way that when you type in the numbers you will > > automatically go to the next line when you have entered 9 numbers. It must > > also > > not be possible to enter more than 9 rows. > > Have a look at this demo > --------------------------------------- snipped code > --------------------------------------- > > Hope this helps. > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Thanks Derek! This will do exactly what I want. The only disadvantage is that the user can no longer copy-paste a complete 9x9 grid at once, but I can always make an extra tab or option for that. Erik-Jan