PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: C & GBS, Inc on July 08, 2010, 01:25:10 AM

Title: Handles... I cannot get a grip on them...
Post by: C & GBS, Inc on July 08, 2010, 01:25:10 AM
My program compiles... I run it... type into the text boxes, first name, middle initial and last name, click on my SAVE button but:

The following code does not write out what I type into my textboxes.  What I get are numbers... not even ascii values, just numbers... in fact, here is what is written to the file:

1313200,10291270,1508640,"Testing5"

I have tried to follow the example in the help file, but I guess that I missed something.

If someone can help, I would appreciate it... I am trying to make the transition from Basic Interpreter days.

Thanks,

Buck


'--------------------------------------------------------------------------------
Function FRMADDRESSBOOKIII_TXTFIRSTNAME_EN_CHANGE ( _
                                      ControlIndex   As Long,  _  ' index in Control Array
                                      hWndForm       As Dword, _  ' handle of Form
                                      hWndControl    As Dword, _  ' handle of Control
                                      idTextControl  As Long   _  ' identifier of text control
                                      ) As Long

End Function


'--------------------------------------------------------------------------------
Function FRMADDRESSBOOKIII_TXTLASTNAME_EN_CHANGE ( _
                                     ControlIndex   As Long,  _  ' index in Control Array
                                     hWndForm       As Dword, _  ' handle of Form
                                     hWndControl    As Dword, _  ' handle of Control
                                     idTextControl  As Long   _  ' identifier of text control
                                     ) As Long

End Function



'--------------------------------------------------------------------------------
Function FRMADDRESSBOOKIII_CMDSAVE_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

  Open "OPEN.DTA" For Append As #1
  Write #1, HWND_FRMADDRESSBOOKIII_TXTFIRSTNAME, HWND_FRMADDRESSBOOKIII_TXTMIDDLEINITIAL, HWND_FRMADDRESSBOOKIII_TXTLASTNAME, "Testing5"
  Close #1

End Function

Title: Re: Handles... I cannot get a grip on them...
Post by: Marc van Cauwenberghe on July 08, 2010, 02:56:34 AM
Hi Buck,

If you are trying to get the text from the textbox then you should use something like FF_TextBox_GetText (HWND_FRMADDRESSBOOKIII_TXTFIRSTNAME )

In the button procedure you should have

Open "OPEN.DTA" For Append As #1
  Write #1, FF_TextBox_GetText (HWND_FRMADDRESSBOOKIII_TXTFIRSTNAME), FF_TextBox_GetText (HWND_FRMADDRESSBOOKIII_TXTMIDDLEINITIAL), FF_TextBox_GetText (HWND_FRMADDRESSBOOKIII_TXTLASTNAME), "Testing5"
  Close #1


Marc
Title: Re: Handles... I cannot get a grip on them...
Post by: Rolf Brandt on July 08, 2010, 03:37:02 AM
Looks like your are coming from a VB environment where controls have a standard property (labels = caption, textboxex = text, etc.). PB (and FireFly) do not work like that. You always have to retrieve these values like Marc showed in his code example.
Title: Re: Handles... I cannot get a grip on them...
Post by: Wilko Verweij on July 08, 2010, 05:41:53 AM
Hi Buck,
Your problem is caused by the fact that you write the window handles (HWND_...). If you want the contents of the text boxes, you should not use the window handles. You can use the FF-functions to retrieve the text (like Marc proposes) or "raw" API (but FF-functions are easier IMHO).
Wilko
Title: Re: Handles... I cannot get a grip on them...
Post by: C & GBS, Inc on July 08, 2010, 09:51:19 AM
Hey Marc,

That is exactly what I needed and thanks for taking the time to "spell out" the code that I needed too, in the button code area... a great help and it WORKS.

Thanks too to Wilko and Rolf... always comfort in number...  I'm sure that I will be in touch...

Buck
Title: Re: Handles... I cannot get a grip on them...
Post by: Roger Garstang on July 08, 2010, 11:09:32 AM
Nice Thread Title (Handle...Grip...etc) ;D  It would make for a good FAQ too since coming from the Visual Studio world that would be the first thing anyone ran up against is having to go from the Object mindset to handles being a id/pointer to the control and you have to use it in a function to retrieve the values you need.