ccrpminilogo.gif (1886 bytes)  Knowledge Base
 KB Index    FAQ Index    Controls  
  
CCRP General Development FAQ
Tuesday, January 06, 2004

INDEX
CCRP FAQ Index

hWnd property exposed by CCRP controls
25th February 1998
The CCRP Team
Copyright © 1998-2004 Common Controls Replacement Project

   

All CCRP controls expose a hWnd property. However, care must be taken when using this property.

Firstly, never save the contents of the hWnd property to a variable. Due to limitations in comctl32.dll, certain styles can only be applied on some controls when the control is created. (This destroy/recreation can be observed in the standard VB design environment, for example, by those controls that set design-time only properties, such as the listbox sorted style). To work around this limitation, the CCRP controls may also destroy and recreate the control in order to change a style (just as VB does in the design environment). For this reason, the the CCRP hWnd property may change during the runtime of the control.

Secondly, the hWnd property returns the hWnd of the common control, not the usercontrol on which it is sited. This causes problems when using calls such as SetParent. One user was attempting to use this to move and align a progress bar into a status bar panel. Whilst the SetParent call works without a problem, subsequent calling of the move method of the control has no effect and the result is that the progress bar appears permanently in the upper-left hand corner of the status bar. If you wish to do this, you will need to use the MoveWindow or a similar API call to move the window. Alternatively, you can use SetParent on the UserControl (and the child common control). To retrieve the hWnd of the UserControl given the hWnd of the common control you will need to call GetParent. This will return the hWnd of the UserControl and you can then use SetParent on this handle. You can then use the Move method of the CCRP controls to position the control.

The hWnd property is provided for you to use but we will not support its use in the same way that we support the rest of the properties in the controls. If you use it and it goes wrong, it is your problem - feel free to contact the author and ask if they can see anything obvious that could be causing problems, but it remains up to the author whether or not to investigate the problem further.