PlanetSquires Forums

Support Forums => General Board => Topic started by: Dan English on August 10, 2011, 05:54:18 PM

Title: How can I create HWND definitions dynamically?
Post by: Dan English on August 10, 2011, 05:54:18 PM
I am creating a series of FireLink controls via a loop.  I would like each one to be labeled HWND_FRMMAIN_FLK00x (with "x") being the loop iteration value.  So:

HWND_FRMMAIN_FLK001
HWND_FRMMAIN_FLK002
HWND_FRMMAIN_FLK003
etc...

How can I do this on the fly in code?  Here's what I have so far.  I've marked my area of trouble with the comment "HELP!!".  Am I going about this the right way?


        topLocation = 10
        leftMargin = 10

        For j = 0 To 9
                hWndControl = FIRELINK(hWndForm, 1000 + j, "label " + Str$(j), leftMargin, FLY_ClientOffset + topLocation, 245, 16, _
                                            %WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN, %WS_EX_LEFT Or %WS_EX_LTRREADING)


                ' HELP!!
                HWND_FRMPAYMAINJ_FLK00x = hWndControl

           
                ' Set the properties (if applicable) for this External Control   
                ff = FLY_SetControlData( hWndControl, %TRUE, %TRUE, _
                             "Tahoma,-11,0,0,0,400,0,0,0,0,0,0,0,0", 0, %FALSE, _
                             %FALSE, %FALSE, %FALSE, _
                             %FALSE, -1, CodePtr(FRMPAYMAINJ_CODEPROCEDURE), "FL,FT,FL,FT" )

                topLocation = topLocation + 18
        Next j
Title: Re: How can I create HWND definitions dynamically?
Post by: Wilko Verweij on August 10, 2011, 06:13:57 PM
Dear Dan,
Why do you not want create an array? HWND_FRMMAIN_FLK(j)=...
Or do I understand you incorrectly?
Wilko
Title: Re: How can I create HWND definitions dynamically?
Post by: Dan English on August 10, 2011, 07:06:43 PM
Well I certainly don't have any aversions to arrays.  I never would have thought to use an array in this case.  Is it good programming form to do this in this circumstance?
Title: Re: How can I create HWND definitions dynamically?
Post by: Dan English on August 10, 2011, 08:21:52 PM
Ok, I tried using an array here.  The line now reads:

HWND_FRMMAIN_FLK(j) = hWndControl

I've also added the following event to handle the clicking of the FireLink controls:


Function FRMMAIN_FLK_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

    MsgBox Str$(ControlIndex)

End Function


Unfortunately no MsgBox appears upon clicking... have I missed an important step?
Title: Re: How can I create HWND definitions dynamically?
Post by: Dan English on August 11, 2011, 09:27:42 AM
Just as a test, I added two FireLink controls via Firefly's Tools (in the Workspace), and made then arrays (ControlIndex 0 and 1).

I then added a BN_CLICKED event for these (double-clicked the control) and they worked fine.

Why aren't my dynamically created FireLink controls firing any events?
Title: Re: How can I create HWND definitions dynamically?
Post by: Wilko Verweij on August 11, 2011, 02:29:15 PM
I don't have experience with the FireLink control but obviously the problem is that the way you create your control clicking does not trigger the clicked event.
I made a form with two firelink-controls (control array) created at design time, and 10 dynamically created the way you did. The first and second dynamically created controls now display "-1" at the line MsgBox Str$(controlindex). The others don't react. I guess there must be people around here who can help you with this problem...
Wilko
Title: Re: How can I create HWND definitions dynamically?
Post by: Paul Squires on August 11, 2011, 03:05:35 PM
Sorry - you can not create control arrays at run time. FireFly creates the necessary code at design time.
Title: Re: How can I create HWND definitions dynamically?
Post by: Dan English on August 11, 2011, 11:23:12 PM
Hmm, ok -- thanks Paul.

A sort of/somewhat related query -- would you know how I can disable (via code at runtime) the underline on a FireLink upon hovering?
Title: Re: How can I create HWND definitions dynamically?
Post by: Paul Squires on August 12, 2011, 11:09:05 AM
You would need to create a font in your program that is not underlined and simply pass that handle to the control.

SendMessage HWND_FORM1_FIRELINK1, %FIRELINK_SETHOTFONT, hFont, 0
Title: Re: How can I create HWND definitions dynamically?
Post by: David Kenny on August 12, 2011, 12:27:48 PM
Dan,

Is creating them dynamically important?  Can you create an array with enough at design time and simply hide them?  Then just show them one at a time - at the time you wanted to "create one" dynamically.

Just a thought.

David
Title: Re: How can I create HWND definitions dynamically?
Post by: Dan English on August 12, 2011, 11:33:33 PM
Paul:  Thanks, I'll give that a shot!

David:  It's not terribly important, but the x/y co-ordinates of the FireLink controls can change depending on which ones are to be shown.  I'm building a bulleted list of links, not all of which may be available for a particular install.  If one item in the middle of the list is to be hidden, I want all the following ones moved up to eliminate the gap.  Unless I can move the location of controls via code, I'm not sure it would work. (Hopefully I'm explaining myself clearly!)