curly
Full Member
Posts: 161
|
Post by curly on Jul 7, 2021 7:27:55 GMT -5
Hi again,
Can data entry into a combobox be limited to just selecting from the drop down list, and preventing typing direct?
I've found you can type rubbish into a combobox that stays put, but when you interogate it to get it's contents, it simply returns a nul value?
I have a few Yes No N/A N/V boxes and during testing to try and break the programme, I discovered I can type Yes or No into the box, which is 'valid' data, but it is not recognised when I interrogate it?
Would this be something to do with DoubleClick? I haven't got to grips with the implicatins of DoubleClick? Can you have a combobox without DoubleClick?
Kind regards, David
|
|
|
Post by Chris Iverson on Jul 7, 2021 11:20:27 GMT -5
Try adding the _CBS_DROPDOWNLIST style to the combobox using STYLEBITS.
'Form created with the help of Freeform 3 v07-15-08 'Generated on Jul 07, 2021 at 11:18:39
array$(0) = "Test" array$(1) = "Line"
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
stylebits #main.combobox1, _CBS_DROPDOWNLIST, 0, 0, 0 combobox #main.combobox1, array$(, [combobox1DoubleClick], 30, 12, 150, 100
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event wait
[combobox1DoubleClick] 'Perform action for the combobox named 'combobox1'
'Insert your own code here
wait
[quit.main] 'End the program close #main end
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 7, 2021 13:18:48 GMT -5
Hi Chris, Brilliant, but, the combobox has changed colour from white to buttonface? Can I correct that? Does the window need to be open for me to change it to white? Thank you, kind regards, David
|
|
|
Post by Walt Decker on Jul 7, 2021 13:20:06 GMT -5
I think this:
stylebits #main.combobox1, _CBS_DROPDOWNLIST, 0, 0, 0
should be this:
stylebits #main.combobox1, _CBS_DROPDOWNLIST, _CBS_DROPDOWN, 0, 0
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 7, 2021 13:30:50 GMT -5
Hi Walt, Can I ask what the difference will be please?
and what are the inplications of DoubleClick and can I have a combobox without DoubleClick? Clearly not relevant in this scenario but I am intrigued?
Kind regards, David
|
|
|
Post by Chris Iverson on Jul 7, 2021 13:43:24 GMT -5
There's not an easy way to change it, especially not native to LB.
The reason the color changes is because the control itself literally changes.
Textboxes have white backgrounds. (COLOR_WINDOW by default, IIRC.) Static text lables have buttonface backgrounds. (COLOR_BACKGROUND, I think?)
The reason for the difference is spelled out in MSDN, where I got the style from.
The description:
So, a regular combobox is a combination of an editbox(textbox in LB nomenclature), a listbox, and a button to handle the dropdown(if it's a dropdown type).
It's actually literally implemented as exactly that internally, and you can poke at the different controls(the edit box, the list box, etc) separately.
If you use the CBS_DROPDOWNLIST style, the edit box is replaced with a static text label. Meaning the color of the background is changed.
There's two ways to work around that, but I'm not sure I'd recommend either for this, especially since a white background will indicate to the user that they CAN edit it when they can't.
The first can't be done in native LB, and needs a DLL helper. You would need to use WMLiberty or another helper DLL to watch for a specific window message when the static text gets painted, and change the color it's painting with. A bit complicated for something like that.
The other option is to NOT use the CBS_DROPDOWNLIST style, and instead find the handle to the textbox that's part of the combobox, and change THAT control's style to add ES_READONLY, which makes a textbox that can't be typed in.
I wouldn't recommend that option either, since the textbox is directly controlled by the combobox internally, and I don't know if that would interfere with anything.
You would still need to use a couple API calls to do this, but you wouldn't need a helper DLL.
We can use the GetComboBoxInfo() API to get the handles of the combobox's internal windows, including the handle to the editbox or statictext.
Once we have that handle, we can change the style on it to add ES_READONLY.
We can't actually do that directly by manipulating the style; according to MSDN, if we want to add or remove ES_READONLY to/from an editbox that's already open, we should send the EM_SETREADONLY message instead. Let me put together a sample to do that.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 7, 2021 13:45:52 GMT -5
Hi alincon, I've got too many to consider changing them now. I haven't finished my application, but have reached a milestaone point, and am doing everything I can to break it, and then fix it, and then break it again until I can't break it (hopefully), and then I'll continue. I'm up to about 4500 lines of code so far. Is there a statistic for how many bugs remain per 1000 lines of code in finished applications? That would be really interesting.
|
|
|
Post by Chris Iverson on Jul 7, 2021 13:50:05 GMT -5
Hi Walt, Can I ask what the difference will be please? Functionally, there's currently not a difference, but that's pretty much by accident. He's correct that the CBS_DROPDOWN style should be removed, that was an oversight on my part. CBS_DROPDOWN is the style that makes it a drop down in the first place, and so it doesn't have the list box on screen permanently. The reason for removing it is that LB adds it by default, and the three main combobox behavior styles(CBS_SIMPLE, CBS_DROPDOWN, and CBS_DROPDOWNLIST) should be considered mutually exclusive. Essentially, it's just making sure things are done properly. The descriptions from MSDN for the styles are below. CBS_SIMPLE: CBS_DROPDOWN: CBS_DROPDOWNLIST:
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 7, 2021 13:59:31 GMT -5
Chris, I had to read that three times! OK. I'm plucking something out of the air here without searching LB help - I declare all my comboboxes in one routine. Can I change the backgound color for static text immediately before declaring the comboboxes, and then change it back immediately after? If not, I will leave one combobox with the stylebits extra and see how it plays out before making a firm choice.
Thank you very much, David
ps Is the photo of you many years ago at school, or maybe is it your kids, or are you really going to make me feel totally inadequate by telling me it is you now?
|
|
|
Post by Chris Iverson on Jul 7, 2021 14:11:31 GMT -5
Changing statictext color I don't think would affect these, since it works internally, and not directly tied into LB's statictext creation. I could be mistaken.
I made the example I was talking about, but even that doesn't work perfectly, because of the way Windows handles read-only textboxes. It greys them out by default, to indicate to the user that it's not editable.
If you click into it, it'll turn white, and provide an edit caret, but it won't actually let you type/change anything. If you focus somewhere else, I suspect it would turn grey again.
'Form created with the help of Freeform 3 v07-15-08 'Generated on Jul 07, 2021 at 11:18:39
array$(0) = "Test" array$(1) = "Line"
struct COMBOBOXINFO,_ size as ulong,_ itemLeft as ulong, itemTop as ulong, itemRight as ulong, itemBottom as ulong,_ buttonLeft as ulong, buttonTop as ulong, buttonRight as ulong, buttonBottom as ulong,_ buttonState as ulong, hwndCombo as ulong,_ hwndItem as ulong, hwndList as ulong
COMBOBOXINFO.size.struct = len(COMBOBOXINFO.struct)
[setup.main.Window]
'-----Begin code for #main
nomainwin WindowWidth = 550 WindowHeight = 410 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2)
'-----Begin GUI objects code
'ComboboxColor$ = "white" 'stylebits #main.combobox1, _CBS_DROPDOWNLIST, _CBS_DROPDOWN, 0, 0 combobox #main.combobox1, array$(, [combobox1DoubleClick], 30, 12, 150, 100
'-----End GUI objects code
open "untitled" for window as #main print #main, "font ms_sans_serif 10" print #main, "trapclose [quit.main]"
[main.inputLoop] 'wait here for input event
hwndCB = hwnd(#main.combobox1) a = GetComboBoxInfo(hwndCB)
hTxt = COMBOBOXINFO.hwndItem.struct
a = SendMessage(hTxt, _EM_SETREADONLY, 1, 0) wait
[combobox1DoubleClick] 'Perform action for the combobox named 'combobox1'
'Insert your own code here
wait
[quit.main] 'End the program close #main end
Function GetComboBoxInfo(hWnd) CallDLL #user32, "GetComboBoxInfo",_ hWnd as ulong,_ COMBOBOXINFO as struct,_ GetComboBoxInfo as long End Function
Function SendMessage(hWnd, uMsg, wParam, lParam) CallDLL #user32, "SendMessageA",_ hWnd as ulong,_ uMsg as ulong,_ wParam as ulong,_ lParam as ulong,_ SendMessage as long End Function
Quite frankly, I still say the best choice would be to simply use the CBS_DROPDOWNLIST style, and ignore the color.
As for the photo, it is indeed me, and there's a very good chance that it is me when I was literally half the age I am now.
|
|
|
Post by Walt Decker on Jul 10, 2021 11:27:12 GMT -5
Here are 3 short demos I lifted out of Things You Don't Want to Know:
' '###################################################################### ' DEMONSTRATE THE DIFFERENT STYLES ' OF COMBOBOXS ' ' LEFT = CBS.SIMPLE ' MIDDLE = CBS.DROPDOWN ' RIGHT = CBS.DROPDOWONLIST '######################################################################
WS.EX.DLGMODALFRAME = HEXDEC("&H00000001") WS.EX.STATICEDGE = HEXDEC("&H00020000")
CBS.SIMPLE = HEXDEC("&H0001") CBS.DROPDOWN = HEXDEC("&H0002") CBS.DROPDOWNLIST = HEXDEC("&H0003") CBS.AUTOHSCROLL = HEXDEC("&H0040") CBS.SORT = HEXDEC("&H0100") CBS.HASSTRINGS = HEXDEC("&H0200") WS.TABSTOP = HEXDEC("&H00010000")
CB.SHOWDROPDOWN = HEXDEC("&H014F")
GLOBAL SimpHndl, _ DropHndl, _ ListHndl
Style = 0 StyleEx = 0 RetVal = 0
DIM Simp$(-1) DIM Drop$(-1) DIM List$(-1)
STYLEBITS #DMO.SIMP, CBS.SIMPLE OR CBS.HASSTRING OR CBS.SORT OR WS.TABSTOP, CBS.DROPDOWN, _ WS.EX.STATICEDGE, 0 COMBOBOX #DMO.SIMP, Simp$(), GET.LIST, 5, 5, 50, 100 '<--- SIMPLE STYLE
COMBOBOX #DMO.DROP, Drop$(), GET.LIST, 60, 5, 50, 100 '<--- DROPDOWN STYLE
STYLEBITS #DMO.LIST, CBS.DROPDOWNLIST OR CBS.HASSSTRING OR WS.TABSTOP, CBS.DROPDOWN, _ WS.EX.DLGMODALFRAME, 0 COMBOBOX #DMO.LIST, List$(), GET.LIST, 115, 5, 50, 100 '<--- DROPDOWN-LIST STYLE
OPEN "CMBO DMO" FOR WINDOW AS #DMO SimpHndl = HWND(#DMO.SIMP) DropHndl = HWND(#DMO.DROP) ListHndl = HWND(#DMO.LIST)
PRINT #DMO, "TRAPCLOSE DEMO.END" WAIT
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB DEMO.END WinHndl$
CLOSE #DMO END
END SUB
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB GET.LIST CtlHndl$
END SUB
===================================================================================
COMBOBOX INSERT FROM TEXT FIELD
'################################################################################ ' DEMONSTRATES HOW TO INSET ITEMS INTO A COMBOBOX LIST FROM THE ' COMBOBOX EDIT FIELD. USES THE CB.SIMPLE STYLE FOR THE ' DEMONSTRATION '################################################################################
WS.EX.DLGMODALFRAME = HEXDEC("&H00000001") WS.EX.STATICEDGE = HEXDEC("&H00020000")
CBS.SIMPLE = HEXDEC("&H0001") CBS.DROPDOWN = HEXDEC("&H0002") CBS.DROPDOWNLIST = HEXDEC("&H0003") CBS.AUTOHSCROLL = HEXDEC("&H0040") CBS.SORT = HEXDEC("&H0100") CBS.HASSTRINGS = HEXDEC("&H0200")
WS.TABSTOP = HEXDEC("&H00010000") WS.HSCROLL = HEXDEC("&H00100000")
BS.PUSHBUTTON = HEXDEC("&H00000000") BS.DEFPUSHBUTTON = HEXDEC("&H00000001")
CB.SETHORIZONTALEXTENT = HEXDEC("&H015E")
GWL.STYLE = -16 GWL.EXSTYLE = -20
GLOBAL SimpHndl, _ BtnHndl
Style = 0 StyleEx = 0 RetVal = 0
DIM Simp$(-1)
[DECLARATIONS] OPEN "User32" FOR DLL AS #USER
STYLEBITS #DMO.APPLY, BS.PUSHBUTTON OR BS.DEFPUSHBUTTON, 0, 0, 0 BUTTON #DMO.APPLY, "APPLY", APPLY.BTN, UL, 5, 5, 50, 25
Style = CBS.SIMPLE OR CBS.HASSTRING OR CBS.SORT OR WS.TABSTOP OR WS.HSCROLL Style$x = WS.EX.STATICEDGE STYLEBITS #DMO.SIMP, Style, _ '<--- Add style CBS.DROPDOWN, _ '<--- Remove style StyleEx, _ '<--- Add extended style 0 '<--- Remove extended style
COMBOBOX #DMO.SIMP, Simp$(), GET.LIST, 5, 35, 50, 100 '<--- SIMPLE STYLE
OPEN "POP" FOR WINDOW AS #DMO SimpHndl = HWND(#DMO.SIMP) BtnHndl = HWND(#DMO.APPLY)
CALLDLL #USER, "SendMessageA", SimpHndl AS ULONG, CB.SETHORIZONTALEXTENT AS ULONG, _ 600 AS LONG, 0 AS LONG, RetVal AS VOID '<--- set scroll width
PRINT #DMO, "TRAPCLOSE DEMO.END" WAIT
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB DEMO.END WinHndl$
CLOSE #USER CLOSE #DMO END
END SUB
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB GET.LIST CtlHndl$
END SUB
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB APPLY.BTN BtnHndl$
CB.GETCOUNT = HEXDEC("&H0146") CB.ADDSTRING = HEXDEC("&H0143") CB.GETLBTEXT = HEXDEC("&H0148") CB.GETLBTEXTLEN = HEXDEC("&H0149")
NumChrs = 0 ItemCnt = 0 I = 0
TxtIn$ = ""
'<------------ get text length of edit field ----------> CALLDLL #USER, "GetWindowTextLengthA", SimpHndl AS ULONG, NumChrs AS LONG
'<------------ get text from edit field ------------> NumChrs = NumChrs + 1 '<--- Add one to account for CHR$(0) TxtIn$ = SPACE$(NumChrs) CALLDLL #USER, "GetWindowTextA", SimpHndl AS ULONG, TxtIn$ AS PTR, _ NumChrs AS LONG, NumChrs AS LONG TxtIn$ = LEFT$(TxtIn$, NumChrs)
'<------------ add text to combobox list ----------> CALLDLL #USER, "SendMessageA", SimpHndl AS ULONG, CB.ADDSTRING AS ULONG, 0 AS LONG, _ TxtIn$ AS PTR, RetVal AS VOID
'<----------- get number of items in the list and redim the array -------> CALLDLL #USER, "SendMessageA", SimpHndl AS ULONG, CB.GETCOUNT AS ULONG, 0 AS LONG, _ 0 AS LONG, ItemCnt AS LONG ItemCnt = ItemCnt - 1 REDIM Simp$(ItemCnt)
'<----------- set the contents of the array -----------> FOR I = 0 TO ItemCnt CALLDLL #USER, "SendMessageA", SimpHndl AS ULONG, CB.GETLBTEXTLEN AS ULONG, _ 0 AS LONG, 0 AS LONG, NumChrs AS LONG TxtIn$ = SPACE$(NumChrs) CALLDLL #USER, "SendMessageA", SimpHndl AS ULONG, CB.GETLBTEXT AS ULONG, _ I AS LONG, TxtIn$ AS PTR, NumChrs AS LONG Simp$(I) = TxtIn$ NEXT I
PRINT #DMO.SIMP, "reload"
END SUB
===================================================================================
COMBOBOX SEARCH FROM TEXT FIELD
'################################################################################ ' MONITORS THE COMBOBOX EDIT FIELD AND SEARCHES THE LISTBOX ' FOR A MATCH. '################################################################################
WS.EX.DLGMODALFRAME = HEXDEC("&H00000001") WS.EX.STATICEDGE = HEXDEC("&H00020000")
CBS.AUTOHSCROLL = HEXDEC("&H0040") CBS.SORT = HEXDEC("&H0100") CBS.HASSTRINGS = HEXDEC("&H0200")
WS.TABSTOP = HEXDEC("&H00010000") WS.HSCROLL = HEXDEC("&H00100000")
BS.PUSHBUTTON = HEXDEC("&H00000000") BS.DEFPUSHBUTTON = HEXDEC("&H00000001")
CB.SETHORIZONTALEXTENT = HEXDEC("&H015E")
GLOBAL DropHndl, _ BtnHndl, _ DoneFlg
Style = 0 StyleEx = 0 RetVal = 0 Hndl = 0
DIM Drop$(-1)
[DECLARATIONS] OPEN "User32" FOR DLL AS #USER
STYLEBITS #DMO.APPLY, BS.PUSHBUTTON OR BS.DEFPUSHBUTTON, 0, 0, 0 BUTTON #DMO.APPLY, "DONE", DEMO.END, UL, 5, 5, 50, 25
Style = CBS.AUTOHSCROLL OR CBS.HASSTRING OR CBS.SORT OR WS.TABSTOP OR WS.HSCROLL Style$x = WS.EX.STATICEDGE STYLEBITS #DMO.DROP, Style, _ '<--- Add style CBS.DROPDOWN, _ '<--- Remove style StyleEx, _ '<--- Add extended style 0 '<--- Remove extended style
COMBOBOX #DMO.DROP, Drop$(), GET.LIST, 5, 35, 150, 100 '<--- DROPDOWN STYLE
OPEN "POP" FOR WINDOW AS #DMO DropHndl = HWND(#DMO.DROP) BtnHndl = HWND(#DMO.APPLY)
CALLDLL #USER, "SendMessageA", DropHndl AS ULONG, CB.SETHORIZONTALEXTENT AS ULONG, _ 250 AS LONG, 0 AS LONG, RetVal AS VOID '<--- set scroll width
PRINT #DMO, "TRAPCLOSE DEMO.END"
Hndl = DropHndl RetVal = FN.PopulateListbox(Hndl) RetVal = FN.SetArray(Hndl) RetVal = FN.FindItem(Hndl) WAIT
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB DEMO.END WinHndl$
DoneFlg = 1
CLOSE #USER CLOSE #DMO END
END SUB
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
SUB GET.LIST CtlHndl$
DoneFlg = 1 END SUB
'-------------------------------------------------------------------------- '--------------------------------------------------------------------------
FUNCTION FN.FindItem(Hndl) '/=========================================================================/' ' SINCE LIBERTY BASIC HIDES THE CALLBACK FUNCTION A METHOD IS REQUIRED TO ' MONITOR THE EDIT FIELD OF THE COMBOBOX FOR THE CBN.CHANGE MESSAGE. ' THIS PSEUDO-CALLBACK PERFORMS THAT TASK IN A ROUND-ABOUT WAY. '/=========================================================================/'
CB.GETCOUNT = HEXDEC("&H0146") CB.GETLBTEXT = HEXDEC("&H0148") CB.GETLBTEXTLEN = HEXDEC("&H0149") CB.GETDROPPEDSTATE = HEXDEC("&H0157") CB.SHOWDROPDOWN = HEXDEC("&H014F") CB.SETCURSEL = HEXDEC("&H014E")
TxtLen = 0 NunChrs = 0 ItemCnt = 0 I = 0
CurTxt$ = "" LstTxt$ = "" TxtIn$ = ""
'<--------- get the number of items in the list --------------> CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETCOUNT AS ULONG, _ 0 AS LONG, 0 AS LONG, ItemCnt AS LONG
[CHECK.INPUT]
SCAN '<--- I think this is equivalent to PeekMessage() with PN_NOREMOVE
IF DoneFlg THEN EXIT FUNCTION '<--- exit if app done or item clicked
'<---- get the length of the text in the edit field ------> CALLDLL #USER, "GetWindowTextLengthA", Hndl AS ULONG, 0 AS LONG, _ 0 AS LONG, TxtLen AS LONG IF TxtLen THEN CurTxt$ = SPACE$(TxtLen) TxtLen = TxtLen + 1
'<--- get the current text in the edit field ---> CALLDLL #USER, "GetWindowTextA", Hndl AS ULONG, CurTxt$ AS PTR, _ TxtLen AS LONG, TxtLen AS LONG
IF CurTxt$ <> LstTxt$ THEN RetVal = FN.ScanList(Hndl, ItemCnt, CurTxt$) IF RetVal > -1 THEN '<---- set the selection to the found item ---------> CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.SETCURSEL AS ULONG, _ RetVal AS LONG, 0 AS LONG, RetVal AS LONG
'<----- is the listbox visible? -----> CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETDROPPEDSTATE AS ULONG, _ 0 AS LONG, 0 AS LONG, RetVal AS BOOLEAN
IF RetVal = 0 THEN '<-------- show the list box -------------------> CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.SHOWDROPDOWN AS ULONG, _ -1 AS LONG, 0 AS LONG, RetVal AS VOID END IF LstTxt$ = CurTxt$ END IF
END IF END IF
GOTO [CHECK.INPUT]
END FUNCTION
'-------------------------------------------------------------- '--------------------------------------------------------------
FUNCTION FN.ScanList(Hndl, NumItems, NewTxt$) '/========================================================================/' ' SEARCH THE LIST FOR A MATCH. THE SEARCH IS CASE INSENSITIVE '/========================================================================/'
CB.GETLBTEXT = HEXDEC("&H0148") CB.GETLBTEXTLEN = HEXDEC("&H0149")
Found = 0 NumChrs = 0 I = 0
TxtIn$ = ""
NewTxt$ = UPPER$(NewTxt$)
Found = -1
FOR I = 0 TO NumItems CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETLBTEXTLEN AS ULONG, _ I AS LONG, 0 AS LONG, NumChrs AS LONG TxtIn$ = SPACE$(NumChrs) CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETLBTEXT AS ULONG, _ I AS LONG, TxtIn$ AS PTR, NumChrs AS LONG TxtIn$ = UPPER$(TxtIn$) IF INSTR(TxtIn$, NewTxt$) THEN Found = I EXIT FOR END IF NEXT I
FN.ScanList = Found END FUNCTION
'-------------------------------------------------------------- '--------------------------------------------------------------
FUNCTION FN.PopulateListbox(Hndl)
DATA "Peter" DATA "Piper" DATA "picked" DATA "a peck" DATA "of pickled" DATA "peppers." DATA "If Peter" DATA "Piper" DATA "picked" DATA "a peck" DATA "of pickled" DATA "peppers," DATA "how many" DATA "pickled" DATA "peppers" DATA "did Peter" DATA "Piper" DATA "pick?" DATA "999"
CB.ADDSTRING = HEXDEC("&H0143")
RetVal = 0 Cnt = -1
Txt$ = ""
[POP.BEGIN] '=========================================================== ' read the data and add it to the list box. This is what ' LB does with the supplied array if it has data '=========================================================== READ Txt$
IF Txt$ = "999" THEN EXIT FUNCTION END IF
CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.ADDSTRING AS LONG, _ 0 AS LONG, Txt$ AS PTR, RetVal AS LONG Cnt = Cnt + 1 GOTO [POP.BEGIN]
END FUNCTION
'--------------------------------------------------------------------- '---------------------------------------------------------------------
FUNCTION FN.SetArray(Hndl)
CB.GETCOUNT = HEXDEC("&H0146") CB.GETLBTEXT = HEXDEC("&H0148") CB.GETLBTEXTLEN = HEXDEC("&H0149")
ItemCnt = 0 I = 0
TxtIn$ = ""
CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETCOUNT AS ULONG, _ 0 AS LONG, 0 AS LONG, ItemCnt AS LONG
ItemCnt = ItemCnt - 1 REDIM Drop$(ItemCnt)
'<----------- set the contents of the array -----------> FOR I = 0 TO ItemCnt CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETLBTEXTLEN AS ULONG, _ I AS LONG, 0 AS LONG, NumChrs AS LONG TxtIn$ = SPACE$(NumChrs) CALLDLL #USER, "SendMessageA", Hndl AS ULONG, CB.GETLBTEXT AS ULONG, _ I AS LONG, TxtIn$ AS PTR, NumChrs AS LONG Drop$(I) = TxtIn$ NEXT I
PRINT #DMO.DROP, "reload"
END FUNCTION '
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jul 11, 2021 5:11:10 GMT -5
Hi Walt, Thank you for this, but I can't get it to do anything? I copied the code, pasted it into an untitled LB window, but nothing happens when I click the run or Debug icons? ...and looking through it, the coding has blown my mind? ....and what does it mean to dimension an array with -1 entries? the bottom line of the LB window says, BASIC Compile Halted: sub DEMO END is already defined
Ahhhhh, is this three separate programmes?
Kind regards,
David
|
|