Liberty BASIC Community Forum
« place listbox selection in a random textbox »

Welcome Guest. Please Login or Register.
Nov 24th, 2017, 10:56am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: place listbox selection in a random textbox  (Read 231 times)
G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1146
xx place listbox selection in a random textbox
« Thread started on: Jul 2nd, 2017, 8:08pm »

Code:
textbox #g.t1, 10,10, 100,30
textbox #g.t2, 10,70, 100,30
textbox #g.t3, 10,130, 100,30

a$(1) = "aap" : a$(2) = "noot": a$(3) = "mies"

listbox #g.lb1, a$(),[keuze],150,10,100,150

open "grafisch venster" for graphics as #g
#g.lb1 "singleclickselect"
wait

[keuze]
#g.lb1 "selection? sel$"
'print sel$ 
timer 2500, [test]
wait

[test]
CallDLL #user32, "GetFocus", handle as long

calldll #user32, "SetWindowTextA",_
handle as ulong,_     'handle of button control
sel$ as ptr,_         'text string
result as long        'no return
'print result

timer 0
wait

 


Is there an easier or a more elegant way?

p.s. I debugged the textbox handles.
I issued a timer 0 to prevent LB or Windows to get wild.

Gordon
« Last Edit: Jul 3rd, 2017, 09:48am by G. Rahman » User IP Logged

Gordon Rahman

http://www.libertybasic.nl
G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1146
xx Re: place listbox selection in a random textbox
« Reply #1 on: Jul 3rd, 2017, 09:43am »


The bottom line to my problem is:
(1) How do I find out (easy) what the LB handle-name of the
focused textbox is?
(2) Or when I use the User32-dll, how do I prevent Windows to
focus the underlying or next device to get an input focus?

Gordon
User IP Logged

Gordon Rahman

http://www.libertybasic.nl
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5567
xx Re: place listbox selection in a random textbox
« Reply #2 on: Jul 3rd, 2017, 10:01am »

Not sure I understand the task but does this help any?

Code:
textbox #g.t1, 10,10, 100,30
textbox #g.t2, 10,70, 100,30
textbox #g.t3, 10,130, 100,30

a$(1) = "aap" : a$(2) = "noot": a$(3) = "mies"

listbox #g.lb, a$(),[keuze],150,10,100,150

open "grafisch venster" for graphics as #g
#g.lb "singleclickselect"
wait

[keuze]
#g.lb "selection? sel$"
'print sel$ 
r=int(rnd(0)*3+.5)
select case r
    case 1
    #g.t1 sel$
    case 2
    #g.t2 sel$
    case 3
    #g.t3 sel$
end select
#g.lb "setfocus"
wait

 
User IP Logged

G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1146
xx Re: place listbox selection in a random textbox
« Reply #3 on: Jul 3rd, 2017, 10:20am »


Hi Rod,

That works .... but the homework-task (we have a LB work-shop on almost novice level here) was to point (select a random) at a textbox and display the selected listbox item in that selected textbox.

Gordon
User IP Logged

Gordon Rahman

http://www.libertybasic.nl
G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1146
xx Re: place listbox selection in a random textbox
« Reply #4 on: Jul 3rd, 2017, 1:56pm »


Oops I figured it out.
I should have try this first ....
Get focus on the same DC handle after using it.

Code:
textbox #g.t1, 10,10, 100,30
textbox #g.t2, 10,70, 100,30
textbox #g.t3, 10,130, 100,30

a$(1) = "aap" : a$(2) = "noot": a$(3) = "mies"

listbox #g.lb1, a$(),[keuze],150,10,100,150


open "grafisch venster" for graphics as #g
#g.lb1 "singleclickselect"
wait

[keuze]
#g.lb1 "selection? sel$"
timer 5500, [test]
wait

[test]
CallDLL #user32, "GetFocus", handle as long
calldll #user32, "SetWindowTextA",_
handle as ulong,_
sel$ as ptr,_
result as long
CallDLL #user32, "GetFocus", handle as long
timer 0
wait
 


Gordon
User IP Logged

Gordon Rahman

http://www.libertybasic.nl
Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5567
xx Re: place listbox selection in a random textbox
« Reply #5 on: Jul 3rd, 2017, 1:58pm »

Still not sure what hou mean, you click on the text box or the list box first? Then what happens?
User IP Logged

G. Rahman
Guru
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 1146
xx Re: place listbox selection in a random textbox
« Reply #6 on: Jul 3rd, 2017, 2:07pm »


smiley

You have to choose an item from the list-box first and then choose a text-box where to place your listbox choice.

At the LB workshop I gave a picture of a human hart with textboxes on the various parts of the hart (aorta, septum and so on)

Now the programmers (students) had to place a listbox with the several hart items in it. The user have to choose an item and place it at the right place.
The purpose of the lesson was to use handle variables to build up the textboxes.

Gordon
« Last Edit: Jul 3rd, 2017, 2:10pm by G. Rahman » User IP Logged

Gordon Rahman

http://www.libertybasic.nl
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls