Post by metro on Nov 23, 2021 1:10:44 GMT -5
In need of some help,.
I am creating a report that will extract information from an SQLite DB, this report requires a date range
I was hoping to reduce my code by using the same SUB to create two calendars.
I can set the focus to the first calendar, but it is not obvious that the focus is there (Mint Linux here, so may display differently on Windoze)
My two questions,
- how can I highlight (select) part of the date (or all of it) in the first calendar upon focus
- How can I Tab to the next calendar, or how can I have the two controls included in the tab order
Thanks in advance
'nomainwin
'cut down code no itemcode$(10) is loaded
GLOBAL StartDate$,EndDate$,cn,z,zn,sel$,todate,fromdate
MainWinWidth = 420
MainWinHeight = 400
[SELECTDATE]
Struct icex, _
dwSize As ulong, _
dwICC As ulong
icex.dwSize.struct = Len(icex.struct)
icex.dwICC.struct = HexDec("100") 'ICC_DATE_CLASSES
CallDLL #comctl32, "InitCommonControlsEx", _
icex As struct, _
r As long
WindowWidth = MainWinWidth' * .4
WindowHeight = MainWinHeight' * .2
UpperLeftX = (MainWinWidth-WindowWidth)/2
UpperLeftY = (MainWinHeight-WindowHeight)/2
Statictext #dlg2.txt, "Select Code",20, 18, 100, 20
Statictext #dlg2.txt1, "START date ",35, 55, 80, 20
Statictext #dlg2.txt2, "END date ",180, 55, 80, 20
Statictext #dlg2.txt3, "Press ESC to Cancel.",280, 5, 130, 20
COMBOBOX #dlg2.combo,itemcode$(),[SelItem],120, 15, 120, 25
Button #dlg2.default, " Okay ", [OkayButton], UL, 285, 70,80,20
Open "Select Date" for Dialog as #dlg2
print #dlg2, "trapclose [ExitDate]"
h1 = HWnd(#dlg2)
CALL MAKECAL h1,20,70,0
CALL MAKECAL h1,150,70,2
call SetFocus fromdate
WAIT
[ExitDate]
Close #dlg2
End
SUB MAKECAL byref h1,x,y,flag
CallDLL #user32, "GetWindowLongA", h1 As long, _GWL_HINSTANCE As long, hInst As long
style = _WS_VISIBLE Or _WS_CHILD
CallDLL #user32, "CreateWindowExA", _
0 As long, _
"SysDateTimePick32" As ptr, _
"DateTime" As ptr, _
style As long, _
x As long, _
y As long, _
120 As long, _
20 As long, _
h1 As long, _
0 As long, _
hInst As long, _
0 As long, _
hwndDTP As long
if flag = 0 then fromdate = hwndDTP
if flag = 2 then todate = hwndDTP
END SUB
[OkayButton]
StartDate$ = GetWindowText$(fromdate)
EndDate$ = GetWindowText$(todate)
print SQLDate$(StartDate$); " start"
print SQLDate$(EndDate$); " end"
WAIT
FUNCTION GetWindowText$(hWnd)
str$ = space$(100)
lenStr = len(str$)
CallDLL #user32, "GetWindowTextA",_
hWnd as ulong,_
str$ as ptr,_
lenStr as long,_
ret as long
GetWindowText$ = left$(str$, ret)
END FUNCTION
FUNCTION SQLDate$(adate$)
Year$ = Word$(adate$ , 3, "/")
Month$ = Word$(adate$ , 2, "/")
Day$ = Word$(adate$ , 1, "/")
SQLDate$= Year$;"-";Month$;"-";Day$
END FUNCTION
FUNCTION strRep$(str$,rep$,with$)
ln = len(rep$)
ln1 = ln - 1
i = 1
while i <= len(str$)
if mid$(str$,i,ln) = rep$ then
strRep$ = strRep$ + with$
i = i + ln1
else
strRep$ = strRep$ + mid$(str$,i,1)
end if
i = i + 1
WEND
END FUNCTION
SUB SetFocus hWnd
calldll #user32, "SetFocus", hWnd as long,_
result as long
END SUB