View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default HWND of Listbox in UserForm in Excel macro

Distinguishing the different listboxes won't be a problem.
You could use the GetWindowRect API.

RBS

"Jozsef Bekes" wrote in message
...
Hi RB and Nick,

Thank you for your answers. FindWindow could become complicated, as I have
more than one listbox, I do not know if it is easy to distinguish them (I
do not have the software right now, I will check it out - maybe a unique
window name would offer the solution)

I will consider using listview as well.

Thank you!

Jozsi

"NickHK" wrote in message
...

Whilst the listbox does not expose a .Hwnd property, it can be found.
Using
Spy++, it is indicated as "F3 Server 028c0000" class.
Using the APIs FindWindow and FindWindowEx, you could get its HWnd.

However, if you need a lot of "non trivial" changes to this control,
maybe
you should use something else.
RBS has suggested the ListView or maybe you should write a custom
control.

Depends what you are trying to do .

NickHK

"Jozsef Bekes" wrote in message
...
Hi All,

I have created a wizzard like Excel macro application that uses
UserForms

as
dialogs. I have some listboxes on these dialogs. I would like to use
SendMessage to do some non trivial tasks on my control. All the examples
I
have found on the Internet show that there is a hWnd property that

contains
this value, but for my instance of Listbox vb complains that there is no
such property.

I have found this information at
http://forums.devx.com/archive/index.php/t-79377.html:

"The UserForm controls do not have a window handle property and the
Forms
ListBox doesn't implement
the standard ListBox class."

My question is how to get the hwnd then, because this location does not
mention a way.

Thank you for all answers!

Regards,
Jozsi