PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: mikedoty on March 04, 2007, 01:55:20 PM

Title: Calling custom controls
Post by: mikedoty on March 04, 2007, 01:55:20 PM
Does Firefly automatically create the virtual listbox custom control?
Where does the code show up at?
If I have a command button, how would I fill a virtual list box?
Here is how I do it without Firefly.  I'm trying to follow the docs, but
haven't trouble getting up to speed. I've drawn the control onto the form and created a button.
Where would I  place GLOBAL A() AS STRING?
I should be using egrid32, but that is another subject.

In PbForms i create a ListBox and later read its parameters
for the create statement, then Kill the ListBox.  
hVList1 = CreateVirtualList(h, %IDC_LISTBOX1, x1,y1, x2,y2, %TRUE)

Also, if the vendors of these custom controls update the code what do
I have to update in Firefly?  I'm obviously a newbie and have used
PBForms for years.  Really want to get into Firefly.



hVList1 = CreateVirtualList(h, %IDC_LISTBOX1, x1,y1, x2,y2, %TRUE)
 MOUSEPTR 11
 REDIM A(0 TO PRINTERCOUNT+3) AS STRING
 FOR i = 0 TO 3
   a(i) = "LPT" + FORMAT$(i+1)
 NEXT
 FOR i = 1 TO PRINTERCOUNT
   a(i+3) = PRINTER$(NAME, i)
 NEXT


 SendMessage hVList1, %VLB_SETARRAY, VARPTR(A(0)), UBOUND(A)  'set array
 IF LEN(txt) THEN
   FOR i = 0 TO UBOUND(a)
     IF txt = a(i) THEN
          i = SendMessage(hVList1, %VLB_SETSELECTED, i, %TRUE)   'select item
       EXIT FOR
     END IF
   NEXT
 'else
   'file did not exist
 END IF

 SendMessage hVList1, %VLB_REFRESH, 0, 0
 SetFocus hVList1
 MOUSEPTR 0
END SUB
Title: Calling custom controls
Post by: TechSupport on March 04, 2007, 06:34:19 PM
Hi Mike,

Great to hear from you. Nice to have you here.  

Below is the code that you need. It is pretty simple really. When the command button is clicked (BN_CLICKED) it creates and loads the global A() string array. You can define the GLOBAL A() AS STRING at the top of the code window (i.e. the "General", "(Other Code)" area - similar to Visual Basic). You could also put all of your globals into a separate module if you wish.

FireFly takes care of generating the DECLARES for you so you need not worry what order you enter you code (notice that I put the LoadVirtualListBox function code after it is first referenced in the BN_CLICKED event).

Updating custom controls is pretty easy in FireFly. The author simply needs to ensure that new versions of their control is compatible with previous versions (or they should advise their customers accordingly). The controls themselves are found in the \CustomControls subdirectories. All interaction between the custom control and the FireFly Designer is handled through the appropriate .ctl file (e.g. pbvList.ctl). Those are simple ascii text files that define messages and events that the control can handle.

Custom Controls can be DLL based or pure source code. Borje's Virtual Listbox is code based. When FireFly generates the project it will automatically include the pbvList.inc source file. No need for the programmer to manually include it.


Global a() As String

'------------------------------------------------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                  ControlIndex     As Long,  _  ' index in Control Array
                                  hWndForm         As Dword, _  ' handle of Form
                                  hWndControl      As Dword, _  ' handle of Control
                                  idButtonControl  As Long   _  ' identifier of button
                                  ) As Long                              
                                 
  ' Create and populate the global A() array that holds the Printer names
  LoadVirtualListBox              
 
End Function
                     
                     

'------------------------------------------------------------------------------------------------------------------------
Function LoadVirtualListBox() As Long

 Local txt As String
 Local i   As Long
 
 MousePtr 11
 ReDim A(0 To PrinterCount+3) As Global String
 FOR i = 0 TO 3
   a(i) = "LPT" + FORMAT$(i+1)
 NEXT
 FOR i = 1 TO PRINTERCOUNT
   a(i+3) = PRINTER$(NAME, i)
 NEXT


 SendMessage HWND_FORM1_PBVLIST1, %VLB_SETARRAY, VarPtr(A(0)), UBound(A)  'set array
 IF LEN(txt) THEN
   FOR i = 0 TO UBOUND(a)
     IF txt = a(i) THEN
          i = SendMessage(HWND_FORM1_PBVLIST1, %VLB_SETSELECTED, i, %TRUE)   'select item
       EXIT FOR
     END IF
   NEXT
 'else
   'file did not exist
 END IF

 SendMessage HWND_FORM1_PBVLIST1, %VLB_REFRESH, 0, 0
 SetFocus HWND_FORM1_PBVLIST1
 MousePtr 0

End Function
Title: Calling custom controls
Post by: mikedoty on March 04, 2007, 06:38:27 PM
Wow, that was easy.
Thanks a bunch.
Mike