PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Montenigro on October 04, 2013, 06:59:38 PM

Title: Combobox behavior
Post by: John Montenigro on October 04, 2013, 06:59:38 PM
I have a small project that I use to learn new FF features. Just has a frmMain, frmHelp, and a frmTest. I use these to check my coding commands and structures before putting them to use in a "real" project... I call it my "sand box".


OK, so on frmMain, I added a Combobox and figured I'd learn how to fill it out later, but just to have a placeholder, I set "Workspace-> Properties -> (Custom) ... Item" = John  (no quotes) 
This was the first and only Item in the list, and the program compiled without errors. When the combobox dropped down, the name John occupied the first (top) line in the list.

So, then I started playing with the new DotObject notation, and I figured I'd try some hunches, and in the Create procedure, I tried:      frmMain.cmboNames.AddItem = "Matthew" 
But that didn't compile.

OK, so to get more names into the combobox, I used:
   Local lRet As Long
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Matthew")
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Mark")
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Luke")

and the app compiled and ran OK, and the names were all there. But I wanted to put them in "proper order", so I added the next line:
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "John")

but now I had duplicates of "John", so I went back to the Workspace-> (Custom) and deleted the item.

But now after I compile and run, the list that drops down has an invisible/blank top line, and I can't seem to clear it. I've gone back to (Custom) and tried all kinds of things, but that blank top line persists...
It seems like I'm forever stuck with "Item Data 0" that has no text string...

How can I clear that?

Thanks,
-John

Also, I added
     ? Str$(lRet)
after "Matthew", and it displays 1
Title: Re: Combobox behavior
Post by: David Kenny on October 04, 2013, 07:14:30 PM
Well, until we get input from Paul, you could do this:
   Local lRet As Long
   FF_ComboBox_ResetContent(hWnd_frmMain_cmboNames)
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Matthew")
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Mark")
   lRet = FF_ComboBox_AddString(hWnd_frmMain_cmboNames, "Luke")

David

But, you are probably not looking for a workaround when working with a test program anyway... :P
Title: Re: Combobox behavior
Post by: Eddy Van Esch on October 04, 2013, 07:17:07 PM
John, just a quick tip (probably without even adressing your actual problem).
If you are going to manipulate and/or modify combobox data, I suggest to grab the combobox data and store it in an array (if it wasn't there already in the first place), manipulate the data in the array, clear the combobox and dump the array data in the combobox.
As a general rule: controls are not a good place to mess around with data. Manipulate the data in an array, then dump it into the control. Just for one reason: adding or removing data from a control (combobox, listbox, treeview,...) becomes (very) slow if there are many data items in the control.

Kind regards
Eddy

Title: Re: Combobox behavior
Post by: David Warner on October 04, 2013, 07:24:30 PM
dot notation combobox example (also works for listbox control) ...

If Form1.Combo1.ListCount = 0 Then
    Form1.Combo1.AddItem("Combo Item 1")
    Form1.Combo1.AddItem("Combo Item 2")
    Form1.Combo1.AddItem("Combo Item 3")
    Form1.Combo1.AddItem("Combo Item 4")
    Form1.Combo1.AddItem("Combo Item 5")
End If


Also works with FF function...
Local lRet As Long
lRet = FF_ComboBox_AddString(Form1.Combo2.hWnd, "Matthew")
lRet = FF_ComboBox_AddString(Form1.Combo2.hWnd, "Mark")
lRet = FF_ComboBox_AddString(Form1.Combo2.hWnd, "Luke")
lRet = FF_ComboBox_AddString(Form1.Combo2.hWnd, "John")



QuoteHow can I clear that?
Yes I see that too, Pauls input needed here I think.

Title: Re: Combobox behavior
Post by: Carl Oligny on October 04, 2013, 07:52:41 PM
I was able to duplicate the issue and could not get rid of it until I closed FF and edited the form file outside of FF.

Open your frmMain file in a test editor and search for your combox box control

Check the custom section for the combobox:

[ControlType] ComboBox | PropertyCount=19 | zorder=1 | tabindex=3 |
name=cboType
windowstyles=WS_CHILD, WS_VISIBLE, WS_VSCROLL, WS_TABSTOP, CBS_DROPDOWNLIST|WS_EX_CLIENTEDGE, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
custom=John|0


Remove 'John|0' so that you have this: custom=

Save the file. Start FF and recompile.

Hope this helps.
Title: Re: Combobox behavior
Post by: Carl Oligny on October 04, 2013, 07:54:07 PM
Meant text editor, not test
Title: Re: Combobox behavior
Post by: John Montenigro on October 04, 2013, 07:56:24 PM
You guys are GREAT!  Thanks for the quick responses!

@David K: Yes, I did try reset, but forgot to add it to the post. It did not change the blank line at the top of the list...

@Eddy: I cannot tell you how much I appreciate that advice! That will save me hours of re-writing later!!!

@David: Thank you for clarifying the proper use of the Dot Notation; I never thought to use the parentheses, I had it stuck in my head that it should understand "assignment", as in:     = "name"

@Carl: That's great info to keep in mind, although I would consider it a workaround, and that Paul should be aware of the unusual behavior so he can ponder it when he has nothing else to do!


So again, thank you!

Stay tuned; this week I'll also be trying my first use of MLG! I'm sure I'll have questions!

Best regards,
-John
Title: Re: Combobox behavior
Post by: John Montenigro on October 04, 2013, 08:00:15 PM
Yup, in the .frm file, it was
  custom=|0

so I deleted the  |0

and compiled and ran, and the blank line is gone.

Nice!

Thanks,
-John
Title: Re: Combobox behavior
Post by: John Montenigro on October 14, 2013, 10:01:17 AM
Paul,

I'm not sure if this is 100% a FF problem, but just in case, I'm bumping this thread to raise awareness of the situation. (Would this constitute a "bug report"? )

-John
Title: Re: Combobox behavior
Post by: Paul Squires on October 14, 2013, 12:09:29 PM
I thought that I had logged this bug in my bug tracker. Looks like I didn't. It's there now so I'll look into it.
Thanks!
Title: Re: Combobox behavior
Post by: John Montenigro on October 14, 2013, 04:00:14 PM
Yeah, I've observed that you are usually very explicit about logging issues, so when I didn't see that, I figured it might be wise to bump it...

-John