|
Post by alincon on Jul 27, 2019 21:11:21 GMT -5
I want to print hours between each list box, but I have not gotten this to work:
[appointments]
WindowWidth = DisplayWidth : WindowHeight = DisplayHeight
BackgroundColor$ = "green"
statictext #appt.st2, "Monday", 75, 20, 120, 20
statictext #appt.st3, "Tuesday", 315, 20, 120, 20
statictext #appt.st4, "Wednesday", 565, 20, 130, 20
statictext #appt.st5, "Thursday", 815, 20, 130, 20
statictext #appt.st6, "Friday" , 1065, 20, 130, 20
t$="0800 0900 1000 1100 1200 0100 0200 0300 0400"
t1 = 0 : t2 = 0
for n = 60 to 316 step 32
t1 = t1 + 1 : t1$ = word$(t$,t1)
for m = 235 to 850 step 250
statictext #appt.stx, t1$, m,n,40,20
next m
next n
listbox #appt.lbMon, mon$(, apptDel, 40,50,190,325
Stylebits #appt.lbMon, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbTue, tue$(, apptDel, 290,50,190,325
Stylebits #appt.lbTue, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbWed, wed$(, apptDel, 540,50,190,325
Stylebits #appt.lbWed, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbThu, thu$(, apptDel, 790,50,190,325
Stylebits #appt.lbThu, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbFri, fri$(, apptDel, 1040,50,190,325
Stylebits #appt.lbFri, _WS_HSCROLL, _WS_VSCROLL, 0, 0
button #appt.btn1,"<Last Week", [lastWeek], UL,330,440
button #appt.btn2,"Next Week>", [nextWeek], UL,570,440
button #appt.btn2," Enter ", [apptEnter], UL,450,440
open "APPOINTMENTS" for window as #appt
#appt, "trapclose [apptQuit]"
#appt, "font ms_sans_serif 10"
appt.open = 1
wait
|
|
|
Post by Rod on Jul 28, 2019 6:03:47 GMT -5
Well it cant be done. You would have to create all of the statictext as literals then use handle variables to address them. Way too much code.
An alternative approach. Why not make the first five characters of your appointment record state the time. That might help when processing records later on.
Actually each record should probably start with YYYYMMDDHHMM. Then you can easily sort or find a record by date and or time.
[appointments]
WindowWidth = DisplayWidth : WindowHeight = DisplayHeight
BackgroundColor$ = "green"
statictext #appt.st2, "Monday", 75, 20, 120, 20
statictext #appt.st3, "Tuesday", 315, 20, 120, 20
statictext #appt.st4, "Wednesday", 565, 20, 130, 20
statictext #appt.st5, "Thursday", 815, 20, 130, 20
statictext #appt.st6, "Friday" , 1065, 20, 130, 20
mon$(1)="08:00" mon$(2)="09:00" mon$(3)="10:00" mon$(4)="11:00" mon$(5)="12:00" mon$(6)="13:00" mon$(7)="14:00" mon$(8)="15:00" mon$(9)="16:00"
listbox #appt.lbMon, mon$(, apptDel, 40,50,190,325
Stylebits #appt.lbMon, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbTue, tue$(, apptDel, 290,50,190,325
Stylebits #appt.lbTue, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbWed, wed$(, apptDel, 540,50,190,325
Stylebits #appt.lbWed, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbThu, thu$(, apptDel, 790,50,190,325
Stylebits #appt.lbThu, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbFri, fri$(, apptDel, 1040,50,190,325
Stylebits #appt.lbFri, _WS_HSCROLL, _WS_VSCROLL, 0, 0
button #appt.btn1,"<Last Week", [lastWeek], UL,330,440
button #appt.btn2,"Next Week>", [nextWeek], UL,570,440
button #appt.btn2," Enter ", [apptEnter], UL,450,440
open "APPOINTMENTS" for window as #appt
#appt, "trapclose [apptQuit]"
#appt, "font ms_sans_serif 10"
appt.open = 1
wait
[apptQuit] close #appt end
|
|
|
Post by metro on Jul 28, 2019 7:07:11 GMT -5
Rod's suggestion is better but if you wanted one way to display the info along the side of the listbox's this may help However with a green background you will see not just the text ....STATIC Designates a simple text field, box, or rectangle used to label, box, or separate other controls. Static controls take no input and provide no output.
Someone smarter than me may have a work around
[appointments]
WindowWidth = DisplayWidth/2: WindowHeight = DisplayHeight/2
BackgroundColor$ = "Buttonface"
CallDLL #kernel32, "GetModuleHandleA", _ _NULL As ULong, _ g.hInstance As ULong
open "STATICTEXT ARRAY" for window as #appt hWnd = HWnd(#appt) #appt, "trapclose [apptQuit]"
t$="0800 0900 1000 1100 1200 0100 0200 0300 0400"
dwStyle = _WS_CHILD Or _WS_VISIBLE nWidth =40: nHeight = 20: x = 1 : y = 80
for n = 1 to 8 t1$(n) = word$(t$,n," ") hwndStatic(n) = CreateWindowEx(0, "STATIC", t1$(n),dwStyle, x, y, nWidth, nHeight, hWnd, 0, g.hInstance, 0) y=y+40 next n WAIT
[apptQuit] close #appt end
Function CreateWindowEx( StyleEx, Class$, Text$, Style, X, Y, Width, Height, Parent, ID, Instance, Param ) CallDLL #user32, "CreateWindowExA", _ StyleEx As ULong, Class$ As Ptr, Text$ As Ptr, Style As ULong, _ X As Long, Y As Long, Width As ULong, Height As ULong, _ Parent As ULong, ID As ULong, Instance As ULong, _ Param As ULong, CreateWindowEx As ULong End Function
|
|
|
Post by alincon on Jul 28, 2019 9:55:34 GMT -5
"Can't be done?" Perhaps I was not clear in explaining what I want to do. The hour numbers are just labels for entries in the list boxes. This code does what I wanted the for-next loops to do.
r.m.
statictext #appt.st8, "0800", 248, 60, 40, 20 : statictext #appt.st81, "0800", 490, 60, 40, 20 statictext #appt.st9, "0900", 248, 92, 40, 20 : statictext #appt.st91, "0900", 490, 92, 40, 20 statictext #appt.st10, "1000", 248, 124, 40, 20 : statictext #appt.st101, "1000", 490, 124, 40, 20 statictext #appt.st11, "1100", 248, 156, 40, 20 : statictext #appt.st111, "1100", 490, 156, 40, 20 statictext #appt.st11, "1200", 248, 188, 40, 20 : statictext #appt.st121, "1200", 490, 188, 40, 20 statictext #appt.st01, "0100", 248, 220, 40, 20 : statictext #appt.st011, "0100", 490, 220, 40, 20 statictext #appt.st02, "0200", 248, 252, 40, 20 : statictext #appt.st021, "0200", 490, 252, 40, 20 statictext #appt.st03, "0300", 248, 284, 40, 20 : statictext #appt.st021, "0300", 490, 284, 40, 20 statictext #appt.st04, "0400", 248, 316, 40, 20 : statictext #appt.st021, "0400", 490, 316, 40, 20 statictext #appt.st8, "0800", 740, 60, 40, 20 : statictext #appt.st81, "0800", 990, 60, 40, 20 statictext #appt.st9, "0900", 740, 92, 40, 20 : statictext #appt.st91, "0900", 990, 92, 40, 20 statictext #appt.st10, "1000", 740, 124, 40, 20 : statictext #appt.st101, "1000", 990, 124, 40, 20 statictext #appt.st11, "1100", 740, 156, 40, 20 : statictext #appt.st111, "1100", 990, 156, 40, 20 statictext #appt.st11, "1200", 740, 188, 40, 20 : statictext #appt.st121, "1200", 990, 188, 40, 20 statictext #appt.st01, "0100", 740, 220, 40, 20 : statictext #appt.st011, "0100", 990, 220, 40, 20 statictext #appt.st02, "0200", 740, 252, 40, 20 : statictext #appt.st021, "0200", 990, 252, 40, 20 statictext #appt.st03, "0300", 740, 284, 40, 20 : statictext #appt.st021, "0300", 990, 284, 40, 20 statictext #appt.st04, "0400", 740, 316, 40, 20 : statictext #appt.st021, "0400", 990, 316, 40, 20
|
|
|
Post by Rod on Jul 28, 2019 13:39:07 GMT -5
Yes, literal statements. You can't currently create controls programmatically with native code though metro shows a workround.
Perhaps more time thinking about your data model will show the benefit of date time tagging of records. The listbox entry need not be YYYYMMDDHHMM it could be an extract, HHMMAPOINTMENTDATA
|
|
|
Post by metro on Jul 29, 2019 3:18:10 GMT -5
using Buttonface this doesn't look too bad
[appointments]
WindowWidth = DisplayWidth : WindowHeight = DisplayHeight
BackgroundColor$ = "Buttonface"
statictext #appt.st2, "Monday", 75, 20, 120, 20
statictext #appt.st3, "Tuesday", 315, 20, 120, 20
statictext #appt.st4, "Wednesday", 565, 20, 130, 20
statictext #appt.st5, "Thursday", 815, 20, 130, 20
statictext #appt.st6, "Friday" , 1065, 20, 130, 20
t$="0800 0900 1000 1100 1200 0100 0200 0300 0400"
t1 = 0 : t2 = 0
for n = 60 to 316 step 32
t1 = t1 + 1 : t1$ = word$(t$,t1)
for m = 235 to 850 step 250
statictext #appt.stx, t1$, m,n,40,20
next m
next n
listbox #appt.lbMon, mon$(, apptDel, 40,50,190,325
Stylebits #appt.lbMon, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbTue, tue$(, apptDel, 290,50,190,325
Stylebits #appt.lbTue, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbWed, wed$(, apptDel, 540,50,190,325
Stylebits #appt.lbWed, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbThu, thu$(, apptDel, 790,50,190,325
Stylebits #appt.lbThu, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbFri, fri$(, apptDel, 1040,50,190,325
Stylebits #appt.lbFri, _WS_HSCROLL, _WS_VSCROLL, 0, 0
button #appt.btn1,"<Last Week", [lastWeek], UL,330,440
button #appt.btn2,"Next Week>", [nextWeek], UL,570,440
button #appt.btn2," Enter ", [apptEnter], UL,450,440
open "APPOINTMENTS" for window as #appt
#appt, "trapclose [apptQuit]"
#appt, "font ms_sans_serif 10"
appt.open = 1 hWnd = HWnd(#appt) #appt, "trapclose [apptQuit]"
t$="0800 0900 1000 1100 1200 0100 0200 0300 0400"
dwStyle = _WS_CHILD Or _WS_VISIBLE nWidth =35: nHeight = 20: x = 1 : y =55 for m = 1 to 5 for n = 1 to 9 t1$(n) = word$(t$,n," ") hwndStatic(n) = CreateWindowEx(0, "static", t1$(n),dwStyle, x, y, nWidth, nHeight, hWnd, 0, g.hInstance, 0) y=y+32 next n x= x+250 y=55 next m wait
[apptQuit] close #appt end
Function CreateWindowEx( StyleEx, Class$, Text$, Style, X, Y, Width, Height, Parent, ID, Instance, Param ) CallDLL #user32, "CreateWindowExA", _ StyleEx As ULong, Class$ As Ptr, Text$ As Ptr, Style As ULong, _ X As Long, Y As Long, Width As ULong, Height As ULong, _ Parent As ULong, ID As ULong, Instance As ULong, _ Param As ULong, CreateWindowEx As ULong End Function
|
|
|
Post by metro on Jul 29, 2019 5:49:18 GMT -5
Well got a bit bored today (despite having more important things to do) I thought I'd have some fun with this.it may or may not be useful. to be placed in the working folder. I do not understand why the [finish] branch label is not found (not valid).....time for a glass of red. may try solving it tomorrow
'adapted from ' Dynamic Buttons Demo ' By Brent D. Thorn, 2006 nomainwin
WindowWidth = DisplayWidth : WindowHeight = DisplayHeight
BackgroundColor$ = "Buttonface" statictext #appt.st2, "Monday", 75, 20, 120, 20 statictext #appt.st3, "Tuesday", 315, 20, 120, 20 statictext #appt.st4, "Wednesday", 565, 20, 130, 20 statictext #appt.st5, "Thursday", 815, 20, 130, 20 statictext #appt.st6, "Friday" , 1065, 20, 130, 20 StaticText #appt.stc,"",4,4,300,20 listbox #appt.lbMon, mon$(, apptDel, 40,50,190,325
Stylebits #appt.lbMon, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbTue, tue$(, apptDel, 290,50,190,325
Stylebits #appt.lbTue, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbWed, wed$(, apptDel, 540,50,190,325
Stylebits #appt.lbWed, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbThu, thu$(, apptDel, 790,50,190,325
Stylebits #appt.lbThu, _WS_HSCROLL, _WS_VSCROLL, 0, 0
listbox #appt.lbFri, fri$(, apptDel, 1040,50,190,325
Stylebits #appt.lbFri, _WS_HSCROLL, _WS_VSCROLL, 0, 0
button #appt.btn1,"<Last Week", [lastWeek], UL,330,440
button #appt.btn2,"Next Week>", [nextWeek], UL,570,440
button #appt.btn2," Enter ", [apptEnter], UL,450,440
Global g.hInstance Global g.nButtons
CallDLL #kernel32, "GetModuleHandleA", _ _NULL As ULong, _ g.hInstance As ULong g.nButtons = 45
Dim hwndButtons(g.nButtons)
Open "WMLiberty" For DLL As #wmlib
StaticText #aapt.stc,"",4,4,300,20
open "APPOINTMENTS" for window as #appt #appt, "TrapClose demo.Close"
hWnd = HWnd(#appt) Callback lpfn, OnCommand(ULong,ULong,ULong,ULong),Long
CallDLL #wmlib, "SetWMHandler", _ hWnd As ULong, _ _WM_COMMAND As ULong, _ lpfn As ULong, _ -1 As Long, _ ret As Long
CallDLL #gdi32, "GetStockObject", _ _DEFAULT_GUI_FONT As Long, _ hFont As ULong
dwStyle = _WS_CHILD Or _WS_VISIBLE Or _BS_PUSHBUTTON nWidth = 35 nHeight = 20 x = 1 y = 55 t$="0800 0900 1000 1100 1200 0100 0200 0300 0400" ' For b = 1 To g.nButtons b=0 for m = 1 to 5
for n = 1 to 9 b=b+1 t1$(n) = word$(t$,n," ") hwndButtons(b) = CreateWindowEx(0, "BUTTON", t1$(n), _ dwStyle, x, y, nWidth, nHeight, _ hWnd, 0, g.hInstance, 0) Call SendMessageLong hwndButtons(b), _WM_SETFONT, hFont, 1
y = y + 32 Next n x= x+250: y=55 next m
Call DoEvents
Sub DoEvents [localLoop] Scan CallDLL #kernel32, "Sleep", 50 As Long, ret As Void GoTo [localLoop] End Sub WAIT
Function OnCommand( hWnd, uMsg, wParam, lParam ) Select Case HIWORD(wParam) Case _BN_CLICKED For b = 1 To g.nButtons If hwndButtons(b) = lParam Then Exit For Next If b <= g.nButtons Then notice "You clicked Button #";b;"." #appt.stc "You clicked Button #";b;"." End If End Select End Function
Function CreateWindowEx( StyleEx, Class$, Text$, Style, X, Y, Width, Height, Parent, ID, Instance, Param ) CallDLL #user32, "CreateWindowExA", _ StyleEx As ULong, Class$ As Ptr, Text$ As Ptr, Style As ULong, _ X As Long, Y As Long, Width As ULong, Height As ULong, _ Parent As ULong, ID As ULong, Instance As ULong, _ Param As ULong, CreateWindowEx As ULong End Function
Sub SendMessageLong hWnd, uMsg, wParam, lParam CallDLL #user32, "SendMessageA", _ hWnd As ULong, uMsg As ULong, _ wParam As ULong, lParam As ULong, _ ret As Long End Sub
Function HIWORD( dw ) HIWORD = (dw And 4294901760) / 65536 End Function
Function LOWORD( dw ) LOWORD = (dw And 65535) End Function
Sub demo.Close me$ close #appt Close #wmlib End End Sub
|
|
|
Post by Rod on Jul 29, 2019 6:52:14 GMT -5
Well you are constantly in the sub doevents so you need the trapclose to call a sub
sub finish h$ close #wmlib close #appt End end sub
However you will notice a delay in closing, I believe it is queued messages that Liberty isn't handling but I am not sure. One of the downsides of stepping outside Liberty.
|
|
|
Post by metro on Jul 29, 2019 7:33:29 GMT -5
Well you are constantly in the sub doevents so you need the trapclose to call a sub sub finish h$ close #wmlib close #appt End end sub
However you will notice a delay in closing, I believe it is queued messages that Liberty isn't handling but I am not sure. One of the downsides of stepping outside Liberty. Ahhh that makes sense , thanks Rod
my apologies for inflicting my doodling's upon you all. I sometimes think I have ADHD
|
|
|
Post by Rod on Jul 29, 2019 12:20:43 GMT -5
Doodle away till your hearts content!
|
|
|
Post by alincon on Jul 29, 2019 18:48:28 GMT -5
Well this code puts the hour 'labels' between the listboxes, and that's all I wanted. Notice the dimensions of the statictext controls.
r.m.
statictext #appt.st8, " 0800 0900 1000 1100 1200 0100 0200 0300 0400",245,50,30,300 statictext #appt.st8, " 0800 0900 1000 1100 1200 0100 0200 0300 0400",500,50,30,300 statictext #appt.st8, " 0800 0900 1000 1100 1200 0100 0200 0300 0400",745,50,30,300 statictext #appt.st8, " 0800 0900 1000 1100 1200 0100 0200 0300 0400",990,50,30,300
|
|
|
Post by Rod on Jul 31, 2019 6:17:21 GMT -5
Clever fix.
|
|