TinyDialog a simple Windows and Linux user interface.
Re: TinyDialog a simple Windows and Linux user interface.
Thank you for this neat set of routines. I copied it over to my directory and it worked first time. Quite nice to see.
I do have a question. I have a fbgfx window with takes up the entire screen
ScreenRes ii, jj, 32 , 4, FB.GFX_WINDOWED
ScreenControl FB.SET_WINDOW_POS, 0,0
That gets displayed and displays the initial screen, then I call up a routine that puts up a copy of the test01.bas dialog(I was testing to see if it all worked together). The problem is the I cannot see the dialog, it is behind the main screen. I used the bottom of the screen to bring the window up and from that point in time, all dialogs show up on top of the fbgfx window. It is only the first time that it is hidden.
Windows 7, fbc 0.23, fbedit
Any suggestions to get the dialog to appear on top of the fbgfx window the first time it is called.
Thanks again for this neat set of routines.
I do have a question. I have a fbgfx window with takes up the entire screen
ScreenRes ii, jj, 32 , 4, FB.GFX_WINDOWED
ScreenControl FB.SET_WINDOW_POS, 0,0
That gets displayed and displays the initial screen, then I call up a routine that puts up a copy of the test01.bas dialog(I was testing to see if it all worked together). The problem is the I cannot see the dialog, it is behind the main screen. I used the bottom of the screen to bring the window up and from that point in time, all dialogs show up on top of the fbgfx window. It is only the first time that it is hidden.
Windows 7, fbc 0.23, fbedit
Any suggestions to get the dialog to appear on top of the fbgfx window the first time it is called.
Thanks again for this neat set of routines.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: TinyDialog a simple Windows and Linux user interface.
You have to use the windows API
#include once "windows.bi"
' get the handle from window by title normaly "Tiny Dialog"
hwnd = FindWindow(NULL,@"Tiny Dialog")
' set it on top
if hwnd<>NULL then
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0,0, SWP_NOMOVE Or SWP_NOSIZE)
end if
I can't test it here I'm on Linux with ARM CPU and FreeBASIC
Joshy
#include once "windows.bi"
' get the handle from window by title normaly "Tiny Dialog"
hwnd = FindWindow(NULL,@"Tiny Dialog")
' set it on top
if hwnd<>NULL then
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0,0, SWP_NOMOVE Or SWP_NOSIZE)
end if
I can't test it here I'm on Linux with ARM CPU and FreeBASIC
Joshy
Last edited by D.J.Peters on Jul 26, 2013 18:27, edited 1 time in total.
Re: TinyDialog a simple Windows and Linux user interface.
Thanks for the suggestion. I assume you meant FindWindow not FindWidow.
But the problem is that prior to calling dlg.show the first time the window (TinyDialog) does not exist and FindWindow cannot find it. After the call to dlg.show it is too late because dlg.show does not return until the user has clicked OK or CANCEL in the window.
Any other suggestions would be appreciated.
I have now upgraded to FBC 0.91 and after finding the librarys I needed, the problem still exists.
But the problem is that prior to calling dlg.show the first time the window (TinyDialog) does not exist and FindWindow cannot find it. After the call to dlg.show it is too late because dlg.show does not return until the user has clicked OK or CANCEL in the window.
Any other suggestions would be appreciated.
I have now upgraded to FBC 0.91 and after finding the librarys I needed, the problem still exists.
Re: TinyDialog a simple Windows and Linux user interface.
Try seeing what happens if you use FindWindow on the window created by fbgfx and in SetWindowPos use HWND_BOTTOM instead of HWND_TOP
Re: TinyDialog a simple Windows and Linux user interface.
When I call the TinyDialog window, I tried setting HWND_BOTTOM to the fbgfx window, and then the fbgfx window disappears (actually its below the other 7 windows I had open at the time) and my fbEdit window appears, and the TinyDialog window is beneath that one.
I suspect that the routine that is called by dlg.show in my code is where the fix is needed. Since I lose control until the TinyDialog window quits, I think that routine needs to make TinyDialog topmost window when it creates it.
I suspect that the routine that is called by dlg.show in my code is where the fix is needed. Since I lose control until the TinyDialog window quits, I think that routine needs to make TinyDialog topmost window when it creates it.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: TinyDialog a simple Windows and Linux user interface.
speudo code
Code: Select all
your_thread_proc(param as any ptr)
DialogIsOpen = 1
open doalog
DialogIsOpen = 0
end_thread_proc
dim as integer DialogIsOpen
create_thread @your_thred_proc,@DialogIsOpen)
whil DialogIsOpen=0 : sleep 500 : wend
sleep 500
hwnd = FindWindow(NULL,@"TinyDialog")
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0,0, SWP_NOMOVE Or SWP_NOSIZE)
while DialogIsOpen : sleep 500 :wend
get params from dialog
...
...
...
Re: TinyDialog a simple Windows and Linux user interface.
Don't know if this will work or if it'll end up the same as my last suggestion, but maybe try HWND_NOTOPMOST on the fbgfx window.
Re: TinyDialog a simple Windows and Linux user interface.
HSND_NOTOPMOST does not help. Thanks for the suggestions.
Re: TinyDialog a simple Windows and Linux user interface.
Having the Tiny Dialog as a separate thread works great. Thank you very much for the suggestion.
Thank you to everyone that made a suggestion. It was very helpful.
Wally
Thank you to everyone that made a suggestion. It was very helpful.
Wally
Re: TinyDialog a simple Windows and Linux user interface.
Last for now, example of TinyDialog ;)
Full app skeleton working.
Select 2 players from list.
"players2.bas"
Note:
Selecting 2 players from list of a few thousands items with TinyDialog is not speedy and comfortable (I don't see this feature), but possible.
Better way is to use own user routine; I awake that I can use slightly modified "mouse scrollbar" method I wrote maybe a year back.Sothat brutal selecting speed obtained now |D
Full app skeleton working.
Select 2 players from list.
"players2.bas"
Code: Select all
' my using this nice TinyDialog with FBGFX graphics window...
' tested on linux puppy Slacko
declare sub playerListIs()
declare sub compare2players()
declare function finitedTD() as integer
#Include "fbgfx.bi"
'#include once "TinyDialog.bi" 'original
#include once "TinyDialog_patched.bi" 'patched - viz my previous posts
ScreenRes 800,688,32,2,FB.GFX_windowed
Width 100,43
const cBlack=rgb(0,0,0)
const cGold=rgb(128,128,0)
dim as integer gogoIs
color cGold,cBlack
WindowTitle "tenis on linux .."
labStart:
cls
?:? "main window ..":?
scope
dim as TinyDialog dlg1
dlg1.Title = "^^ Main menu ^^"
dlg1.addSeperator "tournaments:"
var Option1 = dlg1.addOptions("options:"," ATP | WTA | ATP + WTA ",1,"tip: select one")
dlg1.addSeperator "actions:"
var List1 = dlg1.addList("actions:"," END..ing| player's dB| compare players",0,"tip: some item")
dlg1.show()
gogoIs=dlg1.GetInteger(List1)+1
' ? "gogoIs";gogoIs
select case gogoIs
case 1
if finitedTD()=0 then
'goto labStart
else
end
end if
case 2
playerListIs()
'goto labStart
case 3
compare2players()
' goto labStart
end select
end scope
goto labStart
function finitedTD() as integer
'start-TinyDialog window
dim as TinyDialog dlg
dlg.Title = "Finishing..."
dlg.addSeperator "^ Warning !"
var Bool0 = dlg.addBoolean("E X I T of program:",0,"no","yes","boolean!")
dlg.addSeperator "Will be ended ?"
dlg.show()
return dlg.GetInteger(Bool0)
end function
sub playerListIs()
? "player's are:"
' add your code
? "player 1,";" player 2,";" ...,player N"
?:? "press a key..."
sleep
?
end sub
sub compare2players()
? "select 2 players and compare ..."
' add your code
? "player 1","player 2"
? "profiles ..."
?:? "press a key..."
sleep
?
end sub
Selecting 2 players from list of a few thousands items with TinyDialog is not speedy and comfortable (I don't see this feature), but possible.
Better way is to use own user routine; I awake that I can use slightly modified "mouse scrollbar" method I wrote maybe a year back.Sothat brutal selecting speed obtained now |D
Last edited by petan on Aug 19, 2013 23:32, edited 3 times in total.
Interactive selecting string from list ( SOLVED )
Could you write example for context intuitive selection an item from string array ( roll-out style like Launchy) ??
I mean selecting a name from name array by typing a few start letters;
e.g. all player names - a few thousands
If typing "f" - getting results "245x"
If typing "fe" - getting results "48x"
If typing "fed" - getting result "Federer, Roger"
Selecting item "Federer, Roger".
Ok button pressed.
(Writing sum XYZx only if too much results exist yet for printing in list, otherwise printing a list of items)
(NO sorting needed, called array must be pre-sorted. )
This possibility is highly missing in your nice library.
Thanks for answer.
edit-
Used own massive selecting routine, based on http://www.freebasic.net/forum/viewtopi ... =3&t=19929 .
Problem fixed.
Re: TinyDialog a simple Windows and Linux user interface.
Well guys, having good night with stars, I wrote code for player's selection even in pure TinyDialog.
Here is:
Select 2 players from list.
"players2-sorted.bas"
Note- I 'll play with code for both un+sorted array names
Wow, founded solution.Surprized, easy job on unsorted array.
Here is:
Select 2 players from list.
"players2-sorted.bas"
Code: Select all
'plajerName(1 to N) is shared and sorted
sub compare2players()
dim as string player1, player2, player1alias,player2alias, ssumName1, ssumName2
dim as integer kj4,pozi1,pozi2
dim as integer cf, klm22
? "select 2 players and compare ..."
scope
dim as TinyDialog dlg2
dlg2.Title = "^^ Select player's alias ^^"
dlg2.addSeperator "1.player alias:"
var String1 = dlg2.addString("first letters:","")
dlg2.addSeperator "2.player alias:"
var String2 = dlg2.addString("first letters:","")
dlg2.show()
player1alias=dlg2.GetString(String1)
player2alias=dlg2.GetString(String2)
end scope
ssumName1=""
pozi1=0
' names must be sorted !!
for cf=lbound(plajerName) to ubound(plajerName)
if left(lcase(plajerName(cf)),len(player1alias))=lcase(player1alias) then
ssumName1+=plajerName(cf)+"|"
if pozi1=0 then pozi1=cf
end if
next
if len(ssumName1)>0 then ssumName1=left(ssumName1,len(ssumName1)-1) ' "|" cut-off
ssumName2=""
pozi2=0
' names must be sorted !!
for cf=lbound(plajerName) to ubound(plajerName)
if left(lcase(plajerName(cf)),len(player2alias))=lcase(player2alias) then
ssumName2+=plajerName(cf)+"|"
if pozi2=0 then pozi2=cf
end if
next
if len(ssumName2)>0 then ssumName2=left(ssumName2,len(ssumName2)-1) ' "|" cut-off
scope
dim as TinyDialog dlg3
dlg3.Title = "^^ Select player's name ^^"
dlg3.addSeperator "1.player :"
var List1 = dlg3.addList("dB:",ssumName1,0,"tip: some name")
dlg3.addSeperator "2.player :"
var List2 = dlg3.addList("dB:",ssumName2,0,"tip: some name")
dlg3.show()
kj4=dlg3.GetInteger(List1)+1
player1=plajerName(kj4+pozi1-1)
'? "kj4 ";kj4
kj4=dlg3.GetInteger(List2)+1
player2=plajerName(kj4+pozi2-1)
'? "kj4 ";kj4
end scope
'? "pozi1,pozi2 ";pozi1,pozi2
? "player 1 player 2 = ",player1;" "; player2
'? "profiles ..."
?:? "press a key..."
sleep
?
end sub
Note- I 'll play with code for both un+sorted array names
Wow, founded solution.Surprized, easy job on unsorted array.
Last edited by petan on Aug 19, 2013 23:34, edited 2 times in total.
Re: TinyDialog a simple Windows and Linux user interface.
Mhmm, now playing with wildy names..
Dialog may looks now (sharp names) as
Dialog may looks now (sharp names) as
Re: TinyDialog a simple Windows and Linux user interface.
Code for unsorted name arrays ;D
Select 2 players from ANY names list, t.m. sorted or not sorted.
- halfselection allowed
- two windows again
- harder search added
"players2-unsorted.bas"
Enjoy !
Select 2 players from ANY names list, t.m. sorted or not sorted.
- halfselection allowed
- two windows again
- harder search added
"players2-unsorted.bas"
Code: Select all
'plajerName(N) is shared and can be unsorted, 1-N are data,0 is empty item
function noPlajerSelected(byval player1 as string,byval player2 as string) as integer
if player1<>"" and player2<>"" then return 2
if player1="" and player2="" then return 0
if player1="" or player2="" then return 1
end function
sub compare2players2x()
dim as string player1, player2, player1alias,player2alias
dim as integer pozi1=0,pozi2=0,nameAgain
dim as integer whichName=0
dim as integer inDirection=0
? "select 2 players and compare ..."
if ubound(plajerName)>1 then
labAlias33:
select2plajersAliases(player1alias,player2alias, whichName,inDirection)
select2plajers(player1alias,player2alias,player1,player2,pozi1,pozi2,nameAgain,whichName,inDirection)
'? "nameAgain"; nameAgain
if nameAgain=1 then
pozi1=0: pozi2=0
player1="": player2=""
goto labAlias33
end if
select case noPlajerSelected(player1,player2)
case 0
' checking dialog added
scope
dim as TinyDialog dlg
dlg.Title = "NO players selected ... !!"
dlg.addSeperator ""
var Bool0 = dlg.addBoolean("BACK to selection ?",0,"yes","no","boolean!")
dlg.addSeperator "Are you sure ?"
dlg.show()
if dlg.GetInteger(Bool0)=0 then goto labAlias33
end scope
case 1
goto labAlias33
case 2
'OK continued
end select
? "pozi1,pozi2 ";pozi1,pozi2
? "player 1 player 2 = ",player1;" "; player2
? "profiles ..."
else
? "no names loaded from file yet.."
end if
?:? "press a key...": sleep
?
end sub
sub select2plajersAliases(byref player1alias as string,byref player2alias as string,byref whichName as integer,byref inDirection as integer)
dim as TinyDialog dlg2
'dlg2.Title = "^^ 1.step - select players Alias ^^"
dlg2.Title = " 1.step - select players Alias"
dlg2.addSeperator "1.player alias:"
var String1 = dlg2.addString("first letters:","")
dlg2.addSeperator "2.player alias:"
var String2 = dlg2.addString("first letters:","")
dlg2.addSeperator ""
dlg2.addSeperator "Search alias in:"
var Option1 = dlg2.addOptions("name:"," full | last | first | mid",1,"tip: select one")
var Option2 = dlg2.addOptions("direction:"," from left | compact",1,"tip: select one")
dlg2.show()
player1alias=dlg2.GetString(String1)
player2alias=dlg2.GetString(String2)
if dlg2.GetInteger(Option1)+1<>whichName then whichName=dlg2.GetInteger(Option1)+1
? "whichName",whichName
if dlg2.GetInteger(Option2)+1<>inDirection then inDirection=dlg2.GetInteger(Option2)+1
? "inDirection",inDirection
end sub
sub select2plajers(byval player1alias as string,byval player2alias as string,byref player1 as string,byref player2 as string,byref pozi1 as integer,byref pozi2 as integer,byref nameAgain as integer,byval whichName as integer,byval inDirection as integer)
dim as string ssumName1, ssumName2
dim as integer kj4,kj6
redim as integer naPozi1(0) 'pozisn
redim as integer naPozi2(0) 'pozisn
? "select2plajers .. passed values ->"
? "player1 ";player1,
? "player2 ";player2
? ,"pozi1 pozi2 ";pozi1,pozi2
? ,,"player1 alias ";player1alias,
? "player2 alias ";player2alias
? "nameAgain ";nameAgain
if player1alias<>"" then
ssumName1=""
redim as integer naPozi1(1)
sumNameIs(player1alias, naPozi1(), ssumName1, whichName,inDirection)
? "player1 alias",player1alias
end if
if player2alias<>"" then
ssumName2=""
redim as integer naPozi2(1)
sumNameIs(player2alias, naPozi2(), ssumName2, whichName,inDirection)
? "player2 alias",player2alias
end if
dim as TinyDialog dlg3
'dlg3.Title = "^^ 2.step - select players name ^^"
dlg3.Title = " 2.step - select players name"
if player1<>"" then
dlg3.addSeperator "1.player == "+player1
else
dlg3.addSeperator "1.player :"
end if
var List1 = dlg3.addList("dB:",ssumName1,0,"tip: some name")
if player2<>"" then
dlg3.addSeperator "2.player == "+player2
else
dlg3.addSeperator "2.player :"
end if
var List2 = dlg3.addList("dB:",ssumName2,0,"tip: some name")
dlg3.addSeperator ""
var Bool0 = dlg3.addBoolean("Change players names:",0,"no","yes","boolean!")
dlg3.show()
nameAgain=dlg3.GetInteger(Bool0)
? "nameAgain ";nameAgain
kj4=dlg3.GetInteger(List1)+1
kj6=dlg3.GetInteger(List2)+1
? "kj4 ";kj4, "kj6 ";kj6
if player1="" then
player1=plajerName(naPozi1(kj4)).fullName
pozi1=naPozi1(kj4)
else
'none - halfselection
end if
if player2="" then
player2=plajerName(naPozi2(kj6)).fullName
pozi2=naPozi2(kj6)
else
'none - halfselection
end if
end sub
sub sumNameIs(byval player1alias as string, naPozi1() as integer, byref ssumName1 as string, byval whichName as integer, byval inDirection as integer)
dim as integer cf,upGrowin
if player1alias<>"" then
ssumName1=""
redim as integer naPozi1(1)
' names array - sorted or not - no problem
upGrowin=0
'select by inDirection - inactive yet
for cf=lbound(plajerName) to ubound(plajerName)
select case whichName
case 3
if left(lcase(plajerName(cf).firstName),len(player1alias))=lcase(player1alias) then
ssumName1+=plajerName(cf).fullName+"|"
upGrowin+=1
redim preserve as integer naPozi1(1 to upGrowin)
naPozi1(upGrowin)=cf
end if
case 4
if left(lcase(plajerName(cf).midName),len(player1alias))=lcase(player1alias) then
ssumName1+=plajerName(cf).fullName+"|"
upGrowin+=1
redim preserve as integer naPozi1(1 to upGrowin)
naPozi1(upGrowin)=cf
end if
case 2
if left(lcase(plajerName(cf).lastName),len(player1alias))=lcase(player1alias) then
ssumName1+=plajerName(cf).fullName+"|"
upGrowin+=1
redim preserve as integer naPozi1(1 to upGrowin)
naPozi1(upGrowin)=cf
end if
case 1
if instr(lcase(plajerName(cf).fullName),lcase(player1alias)) then
ssumName1+=plajerName(cf).fullName+"|"
upGrowin+=1
redim preserve as integer naPozi1(1 to upGrowin)
naPozi1(upGrowin)=cf
end if
end select
next
if len(ssumName1)>0 then ssumName1=left(ssumName1,len(ssumName1)-1) ' "|" cut-off
end if
end sub
Last edited by petan on Aug 22, 2013 13:29, edited 1 time in total.
Re: TinyDialog a simple Windows and Linux user interface.
How is interpreted chr(174) in strings ??
e.g.
Not as ASCII char 174 , I see "R" in circle. What type of charset is it ??
e.g.
Code: Select all
dlg.addSeperator chr(174)+" blabla"