PC Review


Reply
Thread Tools Rate Thread

ComboBox class, CB_INSERTSTRING , VB.NET and marshalling...

 
 
CJ Taylor
Guest
Posts: n/a
 
      1st Apr 2004
Whats your code look like for the SendMessage?

And what part are you marshalling? individual variables or an entire
structure?


"GianPiero Andreis" <(E-Mail Removed)> wrote in message
news:uNNy%(E-Mail Removed)...
> Hello All,
> let me pose a simple question about combobox and the CB_INSERTSTRING
> message.
> Suppose for instance that I already have a combobox handle, how can I
> declare and use the SendMessage function just for insert a new item into

the
> combobox ?
> Of course, the combo box DO NOT belong to my process, so I can't use the
> standard properties of that class.
> In fact, I need to "put" a new entry in the combo box of IExplorer.
> EnumWindows get me the handle of the IExplorer main window, with
> EnumChildWindows I can obtain the handle of the "www address" combo.
> At this point, I would like to put into the combo an "www address" of
> choice.
> I tried ALL the parameters of the MarshalAs attribute related to the

string,
> (with the UnmanagedType enum) but never seems to works, sometime IE
> crashes.. :-)
>
> Please, don't tell to me to use SendKeys class.
> .NET SendKeys class works well (do not alter, no more, the numlock and/or
> capslock status of my keyboard, like the older sendkeys in VB) but I need

to
> use SendMessage because I want to unterstand hot to marshalling correctly
> the parameters.
> And last, but not least, I LIKE API's...
>
> Thank You Gentleman for Your precious help.
> Best regards
>
>
> Ing. GianPiero Andreis
>
>
>
>



 
Reply With Quote
 
 
 
 
GianPiero Andreis
Guest
Posts: n/a
 
      1st Apr 2004
Hello All,
let me pose a simple question about combobox and the CB_INSERTSTRING
message.
Suppose for instance that I already have a combobox handle, how can I
declare and use the SendMessage function just for insert a new item into the
combobox ?
Of course, the combo box DO NOT belong to my process, so I can't use the
standard properties of that class.
In fact, I need to "put" a new entry in the combo box of IExplorer.
EnumWindows get me the handle of the IExplorer main window, with
EnumChildWindows I can obtain the handle of the "www address" combo.
At this point, I would like to put into the combo an "www address" of
choice.
I tried ALL the parameters of the MarshalAs attribute related to the string,
(with the UnmanagedType enum) but never seems to works, sometime IE
crashes.. :-)

Please, don't tell to me to use SendKeys class.
..NET SendKeys class works well (do not alter, no more, the numlock and/or
capslock status of my keyboard, like the older sendkeys in VB) but I need to
use SendMessage because I want to unterstand hot to marshalling correctly
the parameters.
And last, but not least, I LIKE API's...

Thank You Gentleman for Your precious help.
Best regards


Ing. GianPiero Andreis




 
Reply With Quote
 
GianPiero Andreis
Guest
Posts: n/a
 
      1st Apr 2004
Ok,
a piece of code...
This is the function I use for looping over the child windows in IE.
Everything works well except the SendMessageA function

Public Function EnumChildWindowsSub(ByVal argl_hChildWnd As IntPtr, ByVal
argl_Param As Integer) As Boolean
Dim lsb_ClassName As New StringBuilder(256)
Call GetClassNameA(argl_hChildWnd, lsb_ClassName,
lsb_ClassName.Capacity)
If (lsb_ClassName.ToString = "ComboBox") Then
SendMessageA(argl_hChildWnd.ToInt32, CB_INSERTSTRING, 0,
"www.thatsite.com")
'This just for see with Spy that the combo handle is correct
Me.Text = "I find combo with handle " &
Hex(argl_hChildWnd.ToInt32).ToString
Return False
Else
Return True
End If
End Function

And this is the prototype for the function.
Private Declare Auto Function SendMessageA Lib "user32" (ByVal hwnd As Long,
ByVal wMsg As Long, ByVal wParam As Long, <MarshalAs(UnmanagedType.LPStr)>
ByVal lParam As String) As Long

There is no need to use System.IntPtr, I don't look for system portability
at this time.

Regarding to formatted classes, at this time I don't use it because I see
Win32 APi's are working as well without the use of that encapsulation.
Maybe this is the cause of the problem, but consider that I use API very
very often in .NET (because I wrote automation programs, macro player and
so on), and everything works well without formatted classes.
I tried also the use of StringBuilder class as fouth parameter in the
SendMessageA function, but IE crashes.
If You need other informations, I would be glad to write for You forward.
Please excuse my english, is very poor, I know.

Thank You in advance, Sir.

Ing. GianPiero Andreis


"CJ Taylor" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> Whats your code look like for the SendMessage?
>
> And what part are you marshalling? individual variables or an entire
> structure?
>
>
> "GianPiero Andreis" <(E-Mail Removed)> wrote in message
> news:uNNy%(E-Mail Removed)...
> > Hello All,
> > let me pose a simple question about combobox and the CB_INSERTSTRING
> > message.
> > Suppose for instance that I already have a combobox handle, how can I
> > declare and use the SendMessage function just for insert a new item into

> the
> > combobox ?
> > Of course, the combo box DO NOT belong to my process, so I can't use the
> > standard properties of that class.
> > In fact, I need to "put" a new entry in the combo box of IExplorer.
> > EnumWindows get me the handle of the IExplorer main window, with
> > EnumChildWindows I can obtain the handle of the "www address" combo.
> > At this point, I would like to put into the combo an "www address" of
> > choice.
> > I tried ALL the parameters of the MarshalAs attribute related to the

> string,
> > (with the UnmanagedType enum) but never seems to works, sometime IE
> > crashes.. :-)
> >
> > Please, don't tell to me to use SendKeys class.
> > .NET SendKeys class works well (do not alter, no more, the numlock

and/or
> > capslock status of my keyboard, like the older sendkeys in VB) but I

need
> to
> > use SendMessage because I want to unterstand hot to marshalling

correctly
> > the parameters.
> > And last, but not least, I LIKE API's...
> >
> > Thank You Gentleman for Your precious help.
> > Best regards
> >
> >
> > Ing. GianPiero Andreis
> >
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extending ComboBox class, need to add my own items but when?? 0to60 Microsoft Dot NET Framework Forms 1 6th Nov 2007 10:22 PM
Problem with modified Combobox class Kevin Microsoft VB .NET 1 2nd Oct 2006 09:37 PM
Combobox in a Class DLL =?Utf-8?B?UmljTWFyYmxl?= Microsoft Dot NET 2 16th Jun 2004 06:13 AM
ComboBox in a Class DLL =?Utf-8?B?UmljTWFyYmxl?= Microsoft Dot NET 2 16th Jun 2004 06:13 AM
Problem with combobox filled in class Bjorn De Waele Microsoft Dot NET Framework Forms 3 16th Dec 2003 09:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:41 AM.