Post by gaslouk on Mar 11, 2022 13:05:32 GMT -5
Good evening from Greece. I will also quote the code. I have made a status bar with six parts. One of them indicates whether the insert key is on or off. and two more for caps and numlock. Caps and numlock work well but the insert does not show the actual status of the key.
I do not know how to fix it.
I am self-taught.
Thank you very much in advance.
Yours sincerely.
Translated by Google Translator
My English is very bad
Thanks.
NOMAINWIN
[main.open]
WindowWidth = 400
WindowHeight = 220
UpperLeftX = INT((DisplayWidth - WindowWidth) / 2)
UpperLeftY = INT((DisplayHeight - WindowHeight) / 2)
MENU #main, "ÖÜêåëïò", "Åßóïäïò", [WindowSetupEntrance], |, "¸îïäïò", [quit]
MENU #main, "Ðåñß", "Ðåñß", [about]
STATICTEXT #main.st1, "ÐÑÏ-ÐÏ 1×2", Int(WindowWidth / 2)-130, 30, 260, 55
BUTTON #main.bt1, "Åßóïäïò", [WindowSetupEntrance], UR, 80, 105, 80, 25
BUTTON #main.bt2, "¸îïäïò", [quit], UL, 50, 105, 80, 25
OPEN "ÐÑÏ - ÐÏ 1×2" FOR window_nf AS #main
#main "trapclose [quit]"
#main "resizehandler [main.resize]"
#main.st1 "!font Consolas bold 36"
#main.bt1 "!font Consolas bold 12"
#main.bt2 "!font Consolas bold 12"
WAIT
[main.resize]
PosY = WindowHeight-22
CALLDLL #user32, "MoveWindow", hstat AS LONG, 0 AS LONG, PosY AS LONG, WindowWidth AS LONG, 22 AS LONG, 1 AS BOOLEAN, ret AS BOOLEAN
WAIT
[WindowSetupEntrance]
NOMAINWIN
WindowWidth = 800 : WindowHeight = 400
UpperLeftX = INT((DisplayWidth - WindowWidth) / 2)
UpperLeftY = INT((DisplayHeight - WindowHeight) / 2)
[ControlSetupEntrance]
MENU #entrance, "ÅéóáãùãÞ Ìåôáâëçôþí", "ÅéóáãùãÞ ÓôáèåñÞò ÓôÞëçò", [eisagStaSthl], "ÅéóáãùãÞ ÓõóôÞìáôïò", [eisagSist], "ÅéóáãùãÞ Ðåñéïñéóìþí", [eisagPerior], "ÅéóáãùãÞ ÍéêÞôñéáò ÓôÞëçò", [EisagNikitrSthl], "ÁíÜëçóç Óôçëþí", [analStilon], "Åêôýðùóç Óôçëþí", [ektipSthl]
MENU #entrance, "ÅðéóôñïöÞ", "ÅðéóôñïöÞ", [return]
STYLEBITS #entrance.bt3, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt3, "¢êõñï", [cancel], UL, 30, 250, 80, 25
STYLEBITS #entrance.entrance, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.entrance, "ÅðéóôñïöÞ", [return], UL, 130, 250, 80, 25
STYLEBITS #entrance.bt5, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt5, "ÅéóáãùãÞ ÓôáèåñÞò ÓôÞëçò", [eisagStaSthl], UL, 70, 20, 200, 25
STYLEBITS #entrance.bt6, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt6, "ÅéóáãùãÞ ÓõóôÞìáôïò", [eisagSist], UL, 70, 55, 200, 25
STYLEBITS #entrance.bt7, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt7, "ÅéóáãùãÞ ðåñéïñéóìþí", [eisagPerior], UL, 70, 90, 200, 25
STYLEBITS #entrance.bt8, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt8, "ÅéóáãùãÞ ÍéêÞôñéáò ÓôÞëçò", [EisagNikitrSthl], UL, 70, 125, 200, 25
STYLEBITS #entrance.bt9, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt9, "ÁíÜëçóç Óôçëþí", [analStilon], UL, 70, 160, 200, 25
STYLEBITS #entrance.bt10, _BS_MULTILINE, 0, 0, 0
BUTTON #entrance.bt10, "Åêôýðùóç Óôçëþí", [ektipSthl], UL, 70, 195, 200, 25
STYLEBITS #entrance.bt11, _BS_MULTILINE, 0, 0, 0
button #entrance.bt11, "Update", [update], UL, 230, 250, 80, 25
OPEN "ÅðéëïãÝò" for Window as #entrance
#entrance "trapclose [cancel]"
#entrance "font Consolas bold 10"
#entrance.bt11 "!font Consolas bold 10"
' * * Change statusbar message at any time with sub ChangeStatusText
' * * Call ChangeStatusText hStatus, ID_of_Panel, NewText$
' * * The handle of the statusbar is hStatus
hStatus = MakeStatusBar(HWND(#entrance), "StatusBar")
Call SetText hStatus,0,"StatusBar Test"
Call SetText hStatus,4,time$()
Call SetText hStatus,5,date$()
timer 100, [changeTime]
#entrance "resizehandler [ResizeStatus]"
waIt
[eisagStaSthl]
'place code here
WAIT
[eisagSist]
'place code here
WAIT
[eisagPerior]
'place code here
WAIT
[EisagNikitrSthl]
'place code here
WAIT
[analStilon]
'place code here
WAIT
[ektipSthl]
'place code here
WAIT
[return]
'place code here
WAIT
[changeTime]
Call SetText hStatus,4,time$()
Call SetText hStatus,5,date$()
ins = GetKeyState(_VK_INSERT)
if ins = 0 then
call SetText hStatus, 1, "INS OFF"
else
call SetText hStatus, 1, "INS ON"
end if
cupsLock = GetKeyState(_VK_CAPITAL)
if cupsLock = 0 then
call SetText hStatus, 2, "CUPS OFF"
else
call SetText hStatus, 2, "CUPS ON"
end if
numLock = GetKeyState(_VK_NUMLOCK)
if numLock = 0 then
call SetText hStatus, 3, "NUM OFF"
else
call SetText hStatus, 3, "NUM ON"
end if
wait
[update]
updateTotal=updateTotal+1
update$="Message updated ";str$(updateTotal);" times."
call SetText hStatus,0,update$
wait
[font]
calldll #user32, "SendMessageA",_
hStatus as ulong,_WM_SIZE as long,_
0 as long, WindowWidth as long,_
re as long
wait
[quit]
CALLDLL #user32, "MessageBeep", _MB_ICONEXCLAMATION as long, beepResult as boolean
mbflags = _MB_ICONEXCLAMATION OR _MB_YESNO
CALLDLL #user32, "MessageBoxA", 0 as long, "¸îïäïò !" as ptr, "Notice" as ptr, mbflags as long, mbResult as long
IF mbResult = 7 then
wait
ELSE
CLOSE #main : END
END if
'mbResult CODES: 1 = ok 2 = cancel 3 = abort 4 = retry 5 = ignore 6 = yes 7 = noend
[cancel]
CALLDLL #user32, "MessageBeep", _MB_ICONEXCLAMATION as long, beepResult as boolean
mbflags = _MB_ICONEXCLAMATION OR _MB_YESNO
CALLDLL #user32, "MessageBoxA", 0 as long, "¸îïäïò ÷ùñßò óþóéìï. ¼ðïéáäÞðïôå áëëÜãç èá ÷áèåß." as ptr, "Notice" as ptr, mbflags as long, mbResult as long
IF mbResult = 7 then
WAIT
ELSE
updateTotal = 0
CLOSE #entrance
END if
'mbResult CODES: 1 = ok 2 = cancel 3 = abort 4 = retry 5 = ignore 6 = yes 7 = noend
[ResizeStatus] 'resize status bar when window is resized
SB.SETPARTS = 1028
STRUCT prt,edge1 as long,edge2 as long,edge3 as long,edge4 as long,edge5 as long,edge6 as long
'change measurements below as needed:
sizePanel = Int(WindowWidth / 30) 'divide WindowWidth by number of panels
prt.edge1.struct = sizePanel * 12
prt.edge2.struct = sizePanel * 15
prt.edge3.struct = sizePanel * 18
prt.edge4.struct = sizePanel * 22
prt.edge5.struct = sizePanel * 26
prt.edge6.struct = -1
numParts = 6
CALLDLL #user32, "SendMessageA", hStatus as long, SB.SETPARTS as long, numParts As Long, prt As struct, r As Long
CALLDLL #user32, "SendMessageA", hStatus as long, _WM_SIZE as long, 0 as long, WindowWidth as long, re as long
WAIT
FUNCTION MakeStatusBar(hWin, caption$)
style = _WS_VISIBLE or _WS_CHILD
CALLDLL #comctl32,"InitCommonControls", re as void
CALLDLL #comctl32,"CreateStatusWindow", style as long, caption$ as ptr, hWin as long, 22 as long, hBar as long
SB.SETPARTS = 1028
STRUCT prt,edge1 as long,edge2 as long,edge3 as long,edge4 as long,edge5 as long,edge6 as long
'change measurements below as needed:
sizePanel = Int(WindowWidth / 30) 'divide WindowWidth by number of panels
prt.edge1.struct = sizePanel * 12
prt.edge2.struct = sizePanel * 15
prt.edge3.struct = sizePanel * 18
prt.edge4.struct = sizePanel * 22
prt.edge5.struct = sizePanel * 26
prt.edge6.struct = -1
numParts = 6
CALLDLL #user32, "SendMessageA", hBar as long, SB.SETPARTS as long, numParts As Long, prt As struct, r As Long
MakeStatusBar = hBar
END FUNCTION
Sub SetText hWnd,segID,txt$
SB.SETTEXT = 1025
calldll #user32, "SendMessageA",_
hWnd as ulong,SB.SETTEXT as long,_
segID as long,txt$ as ptr,r as long
End Sub
Function GetKeyState(key)
CallDLL #user32, "GetKeyState",key As long,_
GetKeyState As long
End Function
I do not know how to fix it.
I am self-taught.
Thank you very much in advance.
Yours sincerely.
Translated by Google Translator
My English is very bad
Thanks.