How do you tell , which button is pressed?
Code: Select all
#define WIN_INCLUDEALL
#include once "windows.bi"
#include once "win\commctrl.bi"
'===============================================================================
'===============================================================================
Private function fb_Set_Font (Font As String,Size As Integer,Bold As Integer,Italic As Integer,Underline As Integer,StrikeThru As Integer) As HFONT
Dim As HDC hDC=GetDC(HWND_DESKTOP)
Dim As Integer CyPixels=GetDeviceCaps(hDC,LOGPIXELSY)
ReleaseDC(HWND_DESKTOP,hDC)
Return CreateFont(0-(Size*CyPixels)/72,0,0,0,0,0,0,StrikeThru, ANSI_CHARSET _
,OUT_TT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,Font)
End Function
'===============================================================================
'===============================================================================
Dim Shared As string meanings(1 To 22, 1 to 16)
open "Words_Out.txt" for input as #1
for a as integer = 1 to 22
for b as integer = 1 to 16
line input #1, meanings(a,b)
if meanings(a,b)="" then
line input #1, meanings(a,b)
end if
meanings(a,b) = mid(meanings(a,b),instr(1,meanings(a,b)," ")+1)
next
next
close #1
Dim Shared As string numbers(1 To 4, 1 to 10)
open "Numbers.txt" for input as #1
for a as integer = 1 to 4
for b as integer = 1 to 10
line input #1, numbers(a,b)
if numbers(a,b)="" then
line input #1, numbers(a,b)
end if
numbers(a,b) = mid(numbers(a,b),instr(1,numbers(a,b)," ")+1)
next
next
close #1
Dim Shared As String consonants(1 To 22)
Dim Shared As String vowels(1 To 16)
consonants(01) = "H"
consonants(02) = "Y"
consonants(03) = "W"
consonants(04) = "R"
consonants(05) = "S"
consonants(06) = "Z"
consonants(07) = "K"
consonants(08) = "G"
consonants(09) = "F"
consonants(10) = "V"
consonants(11) = "L"
consonants(12) = "Th"
consonants(13) = "B"
consonants(14) = "P"
consonants(15) = "M"
consonants(16) = "N"
consonants(17) = "D"
consonants(18) = "T"
consonants(19) = "Ch"
consonants(20) = "J"
consonants(21) = "Sh"
consonants(22) = "Zh"
vowels(01) = "uh" ' hut
vowels(02) = "ah" ' tah
vowels(03) = "ew" ' too
vowels(04) = "oh" ' go
vowels(05) = "ow" ' how
vowels(06) = "oo" ' foot
vowels(07) = "aw" ' paw
vowels(08) = "iw" ' elmer fudd "hill"
vowels(09) = "a" ' at
vowels(10) = "eh" ' hell
vowels(11) = "ih" ' hill
vowels(12) = "ay" ' hay
vowels(13) = "ie" ' pie
vowels(14) = "ee" ' pee
vowels(15) = "au" ' bostonian O , aw with your lips pushed out
vowels(16) = "oi" ' boy
Dim Shared As String num_consonants(1 To 10)
Dim Shared As String num_vowels(1 To 4)
num_consonants(01) = "H"
num_consonants(02) = "Y"
num_consonants(03) = "W"
num_consonants(04) = "R"
num_consonants(05) = "S"
num_consonants(06) = "Z"
num_consonants(07) = "K"
num_consonants(08) = "G"
num_consonants(09) = "F"
num_consonants(10) = "V"
num_vowels(1) = "ur"
num_vowels(2) = "awn"
num_vowels(3) = "in"
num_vowels(4) = "en"
Dim As HFONT fonthdl_1
Dim As String fontname_1
Dim As Integer fontsize_1 = 10
fontname_1 = "Consolas"
fonthdl_1 = fb_Set_Font(fontname_1,fontsize_1,0,0,0,0)
Dim As MSG msg
Dim Shared As HWND hWnd, statics , characters(1 To 352) , edits(1 to 352) , Huh_Yuh(1 to 352) , nums(1 to 40) , num_edit(1 to 40)
dim as point ep
' Create window
hWnd = CreateWindowEx( 0, "#32770", "Huh-Yuh Language 2000-2019", WS_OVERLAPPEDWINDOW Or WS_VISIBLE , 100, 0, 800, 600, 0, 0, 0, 0 )
statics = CreateWindowEx( 0, "STATIC", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD , 10 , 10 , 2300 , 1400 , hWnd, 0, 0, 0 )
'create buttons for each syllable
Dim Shared As Integer button , x_pos , y_pos , vowel
button= 1
x_pos = 1
y_pos = 1
vowel = 1
dim as longint EUDC = 33'2&H0010
For y As Integer = 1 To 16
x_pos = 10
vowel = y
For x As Integer = 1 To 22
characters(button) = CreateWindowEx( 0, "BUTTON", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD or ANSI_CHARSET , x_pos , y_pos , 80 , 20 , statics, 0, 0, 0 )
SetWindowText( characters(button) , consonants(x) + vowels(vowel) )
'SendMessage(characters(button),WM_SETFONT , Cast(WPARAM,fonthdl_1),1 )
edits(button) = CreateWindowEx( 0, "EDIT", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD or ANSI_CHARSET or ES_CENTER , x_pos , y_pos+22 , 100 , 20 , statics, 0, 0, 0 )
SetWindowText(edits(button) , meanings(x,y))
SendMessage(edits(button),WM_SETFONT , Cast(WPARAM,fonthdl_1),1 )
Huh_Yuh(button) = CreateWindowEx( 0, "BUTTON", wchr(EUDC) , WS_BORDER Or WS_VISIBLE Or WS_CHILD or ANSI_CHARSET or ES_READONLY , x_pos+80 , y_pos , 20 , 20 , statics, 0, 0, 0 )
SendMessage(Huh_Yuh(button),WM_SETFONT , Cast(WPARAM,fonthdl_1),1 )
button+=1
x_pos+=100
EUDC+=1
if consonants(x) = "Y" then x_pos+=10
if Consonants(x) = "R" then x_pos+=10
if Consonants(x) = "Z" then x_pos+=10
if Consonants(x) = "G" then x_pos+=10
if Consonants(x) = "V" then x_pos+=10
if Consonants(x) = "Th" then x_pos+=10
if Consonants(x) = "M" then x_pos+=10
if Consonants(x) = "T" then x_pos+=10
Next
y_pos+=70
Next
button = 1
For y As Integer = 1 To 4
x_pos = 10
For x As Integer = 1 To 10
num_edit(button) = CreateWindowEx( 0, "BUTTON", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD or ANSI_CHARSET , x_pos , y_pos , 80 , 20 , statics, 0, 0, 0 )
SetWindowText( num_edit(button) , num_consonants(x) + num_vowels(y) )
nums(button) = CreateWindowEx( 0, "EDIT", "" , WS_BORDER Or WS_VISIBLE Or WS_CHILD or ANSI_CHARSET or ES_CENTER , x_pos , y_pos+22 , 100 , 20 , statics, 0, 0, 0 )
SetWindowText(nums(button) , numbers(y,x))
SendMessage(nums(button),WM_SETFONT , Cast(WPARAM,fonthdl_1),1 )
button+=1
x_pos+=100
if num_consonants(x) = "Y" then x_pos+=10
if num_Consonants(x) = "R" then x_pos+=10
if num_Consonants(x) = "Z" then x_pos+=10
if num_Consonants(x) = "G" then x_pos+=10
if num_Consonants(x) = "V" then x_pos+=10
Next
y_pos+=70
Next
ep.x = 0
ep.y = 0
dim as longint mouse_x
dim as longint mouse_y
While GetMessage( @msg, 0, 0, 0 )
TranslateMessage( @msg )
DispatchMessage( @msg )
mouse_x = LoWord(msg.LPARAM)
mouse_y = HiWord(msg.LPARAM)
Select Case msg.hwnd
Case hWnd
Select Case msg.message
Case 273 : PostQuitMessage(0)
End Select
Select Case msg.hwnd
case hwnd
if msg.message = WM_MOUSEMOVE then
'print "ep.x = " ; ep.x , mouse_x
'print "ep.y = " ; ep.y , mouse_y
Dim As rect r
getwindowrect(hWnd,@r)
var w_wide = r.right-r.left
var w_high = r.bottom-r.top
getwindowrect(statics,@r)
var s_wide = r.right-r.left
var s_high = r.bottom-r.top
if mouse_x >= w_wide-50 then
if ep.x <= (s_wide-mouse_x) then ep.x+=20
movewindow(statics, -ep.x,-ep.y,s_wide,s_high,1)
updatewindow(statics)
end if
if mouse_x <= 50 then
if ep.x >= 0 then ep.x-=20
movewindow(statics, -ep.x,-ep.y,s_wide,s_high,1)
updatewindow(statics)
end if
if mouse_y >= w_high-50 then
if ep.y <= (s_high-mouse_y) then ep.y+=20
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
updatewindow(statics)
end if
if mouse_y <= 50 then
if ep.y >= 0 then ep.y-=20
movewindow(statics,-ep.x,-ep.y,s_wide,s_high,1)
updatewindow(statics)
end if
end if
end select
End Select
Wend
PostQuitMessage(0)
End