Handles... I cannot get a grip on them...

Started by C & GBS, Inc , July 08, 2010, 01:25:10 AM

Previous topic - Next topic

C & GBS, Inc

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


Marc van Cauwenberghe

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

Rolf Brandt

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.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

Wilko Verweij

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

C & GBS, Inc

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

Roger Garstang

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.