PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Robert Rioja on February 03, 2016, 09:33:42 PM

Title: hWndControl parameter parsing
Post by: Robert Rioja on February 03, 2016, 09:33:42 PM
I want to create a function that modifies a control such as a textbox.  I want to pass to it the hWndControl parameter to identify the control, like with other FF functions.  But this function will call PB functions that require the control's IDC number.  How can the function determine the hWndForm for the form and the IDC for the control from the hWndControl parameter?
Title: Re: hWndControl parameter parsing
Post by: Paul Squires on February 03, 2016, 11:00:02 PM
In general, you should be able to get the hWndForm for the control by using the api GetParent. Most times, the parent of a control is the form that it is on.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms633510(v=vs.85).aspx

To get the IDC of the control from the hWndControl you can use the api GetDlgCtrlId
https://msdn.microsoft.com/en-us/library/windows/desktop/ms645478(v=vs.85).aspx
Title: Re: hWndControl parameter parsing
Post by: Paul Squires on February 03, 2016, 11:02:25 PM
Also, I would be careful using PB functions that manipulate controls when using FireFly. I have read posts on PB forum that sometimes the PB functions expect the controls to have been created using DDT. Obviously FireFly uses WinAPI rather than DDT.
Title: Re: hWndControl parameter parsing
Post by: Paul Squires on February 03, 2016, 11:03:00 PM
There is nothing that the PB statements can do that you can not do with just plain WinAPI functions.
Title: Re: hWndControl parameter parsing
Post by: Robert Rioja on February 04, 2016, 11:55:00 PM
Paul,
Thank you for all of your replies!!!

For years I have used the TreeView control with a combination of FF and PB statements without any problems.  The problem is that there are many PB statements for Treeviews that FF does not have.

Now I wrote some routines and I am trying to simplify their interface.

I will try your suggestions.  Thanks again.

Robert
Title: Re: hWndControl parameter parsing
Post by: José Roca on February 05, 2016, 01:10:14 AM
> The problem is that there are many PB statements for Treeviews that FF does not have.

Which ones? In the file TreeViewCtrl.inc of my include files you have all of them and many more.
Title: Re: hWndControl parameter parsing
Post by: Paul Squires on February 05, 2016, 08:45:44 AM
Quote from: Jose Roca on February 05, 2016, 01:10:14 AM
> The problem is that there are many PB statements for Treeviews that FF does not have.

...In the file TreeViewCtrl.inc of my include files you have all of them and many more.


Exactly! Jose has hundreds of very useful functions for all types of controls and general Windows things. His code is an invaluable resource for anyone programming in PB.
Title: Re: hWndControl parameter parsing
Post by: Robert Rioja on February 05, 2016, 07:28:25 PM
Thank you for the tip.  I looked through the documentation and could not find a wrapper equivalent to the PB "Treeview Set User" and "Treeview Get User" functions.  What would be even better would be a way of having a user defined string, not just a number.
Title: Re: hWndControl parameter parsing
Post by: José Roca on February 06, 2016, 12:28:00 AM
The member lParam of the TVITEM structure used by TreeView_SetItem and TreeView_GetItem can be used for that purpose.
Title: Re: hWndControl parameter parsing
Post by: Robert Rioja on February 06, 2016, 04:09:20 PM
Thank you Jose.