Author |
Topic: Grid of Textboxes using Windows API (Read 88 times) |
|
Alincon
Full Member
member is offline


Posts: 147
|
 |
Re: Grid of Textboxes using Windows API
« Reply #24 on: Aug 19th, 2016, 4:20pm » |
|
I am not trying to break any rules or use undocumented features. Certainly Richard, as the creator of LBB, knows more about it than I. tsh73 is also a respected programmer in both LB and LBB. I do not wish to argue with or upset either one.
Nevertheless, the code I showed earlier works as the included comments state, at least on my machine.
I understood Richard's insistence that the 'window' maphandle instruction should be placed AFTER the open statement. But, in my code, on my machine, that just does not work.
The only combination that does work on my machine is to place the call to the sub, and the 'windows' maphandle command BEFORE the statictext items, and BEFORE the 'open' statement.
"Your results may differ"
r.m.
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline


Gender: 
Posts: 210
|
 |
Re: Grid of Textboxes using Windows API
« Reply #25 on: Aug 19th, 2016, 5:57pm » |
|
Alincon, line by line: Quote:| I am not trying to break any rules or use undocumented features. |
|
I myself see nothing bad in using undocumented features. If they work, that is.
Quote:| I do not wish to argue with or upset either one. |
|
LOL This is programmer's forum. People come not to quarrel, but to help. (ideally it is)
Quote:I understood Richard's insistence that the 'window' maphandle instruction should be placed AFTER the open statement. But, in my code, on my machine, that just does not work. |
|
You agree that Richard likely "knows more about it" But following his advice "just does not work." I see two possible reasons: 1) somewhere you made a mistake in coding. It happens. You might find it. If you post more code, we might help you (or might not). 2) your code is correct but there is an error in LBB. In this case, Richard probably very interested in finding it out . But he would needs an example that shows this error - that is, your code.
Now, if you interested in finding things out, post your code that didn't work.
If you found a way around it and don't mind leaving this mystery - use your workaround.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Grid of Textboxes using Windows API
« Reply #26 on: Aug 19th, 2016, 6:44pm » |
|
on Aug 19th, 2016, 4:20pm, Alincon wrote:| The only combination that does work on my machine is to place the call to the sub, and the 'windows' maphandle command BEFORE the statictext items, and BEFORE the 'open' statement. |
|
So, are you saying that the code I most recently listed (which follows all my recommendations, including putting the 'maphandle' AFTER the 'open') does not work on your PC? If so in what way doesn't it work? What precisely happens?
Richard.
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline


Posts: 147
|
 |
Re: Grid of Textboxes using Windows API
« Reply #27 on: Aug 21st, 2016, 01:35am » |
|
Richard's code works on my machine and produces the same result as my code, which works and is shorter.
My whole reason for using maphandle is to avoid coding a stylebits command for every textbox to limit characters to numbers since LBB cannot do this: (it works in LB) Code:
for x = 1 to lmt
var$ = pfx$+right$("0"+str$(x),2)
stylebits #var$, _ES_NUMBER, 0, 0, 0
next
I'm thinking now that requiring so many commands to use maphandle is more trouble than coding all the stylebits commands.
regards, r.m.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Grid of Textboxes using Windows API
« Reply #28 on: Aug 21st, 2016, 09:28am » |
|
on Aug 21st, 2016, 01:35am, Alincon wrote:| Richard's code works on my machine and produces the same result as my code, which works and is shorter. |
|
Yours may be a little shorter, but it relies on undocumented behavior. It's up to you whether you want to take the risk.
Quote:| LBB cannot do this: (it works in LB) |
|
Hmm, interesting! That's an incompatibility I was unaware of: I didn't know that LB 4 would accept a handle variable in a STYLEBITS statement. I'll try to fix this in a future release of LBB (it could only work if the STYLEBITS comes after the TEXTBOX).
Quote:| I'm thinking now that requiring so many commands to use maphandle is more trouble than coding all the stylebits commands. |
|
I would still expect the LBB solution to be shorter, because you can create the controls in a loop (and put the STYLEBITS in the loop), something that you cannot do in LB:
LB solution (STYLEBITS in a loop) Code: textbox #w.tb01, 10, 10, 100, 25
textbox #w.tb02, 10, 40, 100, 25
textbox #w.tb03, 10, 70, 100, 25
textbox #w.tb04, 10, 100, 100, 25
textbox #w.tb05, 10, 130, 100, 25
textbox #w.tb06, 10, 160, 100, 25
for x = 1 to 6
var$ = "#w.tb0" + right$(str$(x),2)
stylebits #var$, _ES_NUMBER, 0, 0, 0
next x
open "Test" for dialog as #w
wait LBB solution (using MAPHANDLE) Code: for x = 1 to 6
textbox #w.tb, 10, x*30-20, 100, 25
stylebits #w.tb, _ES_NUMBER, 0, 0, 0
var$ = "#w.tb0" + right$(str$(x),2)
maphandle #w.tb, var$
next x
open "Test" for dialog as #w
wait Richard.
|
|
Logged
|
|
|
|
CryptoMan
New Member
member is offline


Gender: 
Posts: 46
|
 |
Re: Grid of Textboxes using Windows API
« Reply #29 on: Aug 21st, 2016, 4:34pm » |
|
Richard,
What I am missing in LB and LBB is using arrays on these and also passing arrays and structs to SUBs and FUNCTIONs and returning ARRAYSs or STRUCTs. And ARRAYS of STRUCTS. And STRUCTS like PASCAL and C.
Is this too difficult to implement in LBB?
Ofcourse, it will not be compatible with LBB but if anybody wants to use a SUPER LB can use it with LBB.
What stops us from
textbox #w.tb[i], 10, x*30-20, 100, 25 ?
I realize that this MAPHANDLE emulates this objective quite elegantly but why not arrays?
Or, like create a syntax like this but hidden in the BBC conversion translate it into MAPHANDLEs behind the scene.
Maybe, too much stunt?
But, I really liked the MAPHANDLE trick. Quite awesome.
|
| « Last Edit: Aug 21st, 2016, 4:38pm by CryptoMan » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Grid of Textboxes using Windows API
« Reply #30 on: Aug 21st, 2016, 5:24pm » |
|
on Aug 21st, 2016, 4:34pm, CryptoMan wrote:| Is this too difficult to implement in LBB? |
|
Two of the features you asked for are already implemented (and documented) in LBB: passing arrays into SUBs and FUNCTIONs, and arrays of STRUCTS:
Passing Arrays Code: dim MyArray$(100)
MyArray$(50) = "Fifty"
call MySub MyArray$()
dummy = MyFunc(MyArray$())
end
sub MySub localarray1$()
print localarray1$(50)
end sub
function MyFunc(localarray2$())
print localarray2$(50)
end function Array of Structures Code: struct MyStructArray(100) one as long, two as ptr, three as char[13]
MyStructArray(50).three.struct = "Hello world!"
print MyStructArray(50).three.struct Richard.
|
|
Logged
|
|
|
|
|