curly
Full Member
Posts: 161
|
Post by curly on Aug 15, 2021 6:46:53 GMT -5
Hi,
Back in July Chris Iverson helped me out in preventing users typing non compliant rubbish into a Combobox and then complaining because it wasn't used? I have applied stylebits #DataIn.ComboboxX, _CBS_DROPDOWNLIST, _CBS_DROPDOWN, 0, 0 as supplied to all my comboboxes and it totally solves that problem. However, it has created another as I now find control no longer jumps to the Branch Label associated with the combobox when a slection is made.
So, can I have my cake and also eat it? Can my comboboxes be set so one can only select from the list, i.e. one cannot type directly into the combobox, and have control jump to the associted Branch Label as in a regulat combobox?
Kind regards, David
|
|
|
Post by Walt Decker on Aug 15, 2021 10:58:39 GMT -5
' CBS.DROPDOWN = HEXDEC("&H0002") CBS.DROPDOWNLIST = HEXDEC("&H0003")
OPEN "User32.dll" FOR DLL AS #USER
GLOBAL LastItem$
DIM Lst$(-1)
A = 0
A = FN.PackList()
STYLEBITS #DMO.CMBO, CBS.DROPDOWNLIST, CBS.DROPDOWN, 0, 0 COMBOBOX #DMO.CMBO, Lst$(), CHOOSE, 5, 5, 100, 100
OPEN "DEMO" FOR WINDOW AS #DMO PRINT #DMO, "TRAPCLOSE DMO.DONE"
TIMER, 250, [CHECK.CMBO.SEL]
[WAIT.TIMER] WAIT
'----------------------------------------------------------------------------- '-----------------------------------------------------------------------------
[CHECK.CMBO.SEL] CB.GETCURSEL = HEXDEC("&H0147") CB.GETLBTEXT = HEXDEC("&H0148")
Hndl = HWND(#DMO.CMBO)
NumChrs = 0
SelItem$ = "" SelItem$ = SPACE$(120) CALLDLL #USER, "GetWindowTextA", Hndl AS ULONG, SelItem$ AS PTR, _ 120 AS LONG, NumChrs AS LONG
IF NumChrs < 1 THEN GOTO [WAIT.TIMER]
IF LastItem$ = SelItem$ THEN GOTO [WAIT.TIMER] SelItem$ = LEFT$(SelItem$, NumChrs) LastItem$ = SelItem$
PRINT "You chose "; SelItem$ GOTO [WAIT.TIMER]
'----------------------------------------------------------------------------- '-----------------------------------------------------------------------------
SUB CHOOSE Cmbo$
PRINT "CHOSEN" END SUB
'--------------------------------------------------------------------------- '---------------------------------------------------------------------------
SUB DMO.DONE WinHndl$
CLOSE #DMO END
END SUB
'--------------------------------------------------------------------------- '---------------------------------------------------------------------------
FUNCTION FN.PackList()
REDIM Lst$(50) FOR I = 0 TO 50 Lst$(I) = "This is Item " + STR$(I) NEXT I
END FUNCTION '
Alternatively you can put an "APPLY" button on the form to get the selected item.
What is the purpose of the combobox?
Does a selection from the combobox have to be made before another action can be accomplished?
|
|
|
Post by Brandon Parker on Aug 15, 2021 18:44:05 GMT -5
Would you be willing to use WMLiberty.dll to achieve what you want? You would have to use one TextBox and one ListBox for each ComboBox you want to replace.
{:0)
Brandon Parker
|
|
|
Post by Walt Decker on Aug 15, 2021 19:57:44 GMT -5
One can also use a CBS.DROPDOWN style and monitor the input field, search for a match in the string, and when found select the match. Might be just a bit faster once the end user gets the hang of it.
That is what I do in the WIN_API_.EXE in the index tab.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Aug 16, 2021 3:44:38 GMT -5
Hi, Once we have identified the fuseboard, we start filing it. The Combobox is used to select the next item, that could be a main switch, and RCD, a spare way, or a circuit description, for example FirstFloor Lighting. Control than moves to the Branch Label where other options are offered, depending upon what was selected.
The issue I had was that with a mix of text and comboboxes, someone could type something into the Combobox box by mistake, and it would be ignored, resulting in a complaint that the programme isn't working correctly. The option given by Chris I prevented that, but also stops control going to the Branch Label? I can work around it by leaving some of the Comboboxes as they were, and using a 'notice' as a reminder to give instructions. I have allowed the user to switch their reminders on or off in a subroutine called settings.
So Walt, it is the initiating start to defining a circuit, and everything else follows on from this selection. If it's not a simple fix without extra buttons or boxes, I'll use the reminder notice?
Kind regards,
David
|
|
|
Post by Walt Decker on Aug 16, 2021 8:34:30 GMT -5
Suit yourself, but I think that, in the long run, you are shooting yourself in the foot.
I gave you a solution. Several other options are proposed. If you do not want to use any of them, that is up to you.
|
|
|
Post by Brandon Parker on Aug 16, 2021 20:28:13 GMT -5
For reference, here is what my solution looks like. You could style them differently with Stylebits obviously. The TextBox is read-only, and the ListBox shows/hides when you click on or off of the TextBox. The "Key in search data" is just leftover from the original example where typing was allowed and partial matches would start jumping to the appropriately matched item as one typed. Going a different route, you could just check whether what the person entered into the ComboBox was within the array prior to doing anything. If it is not then set the ComboBox back to the first item and pop up a notice. {:0) Brandon Parker
|
|