I'm capturing WM_CREATE messages by overriding WndProc in C#/.NET.
How do I then convert the CREATESTRUCT* that GetLParam() would return to an
object that I can use in my code ?

protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == Convert.ToInt32(WindowsMessages.WM_CREATE))
{
StringBuilder text = new StringBuilder("msg = " + m.Msg.ToString() +
"wParam=" + m.WParam.ToString() + ", lparam=" +
m.LParam.ToString());

// call m.GetLParam() - gets a pointer to CREATESTRUCT;
}

base.WndProc (ref m);
}

Re: How to convert Message.LParam pointer to CREATESTRUCT to an object by Stoitcho

Stoitcho
Mon Feb 27 09:06:54 CST 2006

leightonr,

To get the CREATESTRUCT you first need to declare such a type with all the
fileds with proper types and propertly attributed for marshaling and then
call
*Marshal.PtrToStructure* to get the data from the unmanaged memory.
If you google you can probably find somewhere the .NET declaration of this
structure.

I don't know what your goal is, but take a look at the CreateParmas
protected virtual property. This property is called just before the native
windows is created and has to return the data that is going to be used when
calling CreateWindowEx to create the underlying native window. When you
override this poprerty first call the base implementation then tweak the
data and return the result.

What piece of info you are interested in from that structure? There might be
another way to get it.


--
HTH
Stoitcho Goutsev (100)

"leightonr" <leightonr@discussions.microsoft.com> wrote in message
news:3E0558DA-6560-49C4-9542-B039445ED29C@microsoft.com...
> I'm capturing WM_CREATE messages by overriding WndProc in C#/.NET.
> How do I then convert the CREATESTRUCT* that GetLParam() would return to
> an
> object that I can use in my code ?
>
> protected override void WndProc(ref System.Windows.Forms.Message m)
> {
> if (m.Msg == Convert.ToInt32(WindowsMessages.WM_CREATE))
> {
> StringBuilder text = new StringBuilder("msg = " + m.Msg.ToString()
> +
> "wParam=" + m.WParam.ToString() + ", lparam=" +
> m.LParam.ToString());
>
> // call m.GetLParam() - gets a pointer to CREATESTRUCT;
> }
>
> base.WndProc (ref m);
> }



Re: How to convert Message.LParam pointer to CREATESTRUCT to an ob by leightonr

leightonr
Thu Mar 02 06:33:27 CST 2006

Thanks Stoitcho,

the information I am trying to get is the name of the new window and its x
and y coordinates.



"Stoitcho Goutsev (100)" wrote:

> leightonr,
>
> To get the CREATESTRUCT you first need to declare such a type with all the
> fileds with proper types and propertly attributed for marshaling and then
> call
> *Marshal.PtrToStructure* to get the data from the unmanaged memory.
> If you google you can probably find somewhere the .NET declaration of this
> structure.
>
> I don't know what your goal is, but take a look at the CreateParmas
> protected virtual property. This property is called just before the native
> windows is created and has to return the data that is going to be used when
> calling CreateWindowEx to create the underlying native window. When you
> override this poprerty first call the base implementation then tweak the
> data and return the result.
>
> What piece of info you are interested in from that structure? There might be
> another way to get it.
>
>
> --
> HTH
> Stoitcho Goutsev (100)
>
> "leightonr" <leightonr@discussions.microsoft.com> wrote in message
> news:3E0558DA-6560-49C4-9542-B039445ED29C@microsoft.com...
> > I'm capturing WM_CREATE messages by overriding WndProc in C#/.NET.
> > How do I then convert the CREATESTRUCT* that GetLParam() would return to
> > an
> > object that I can use in my code ?
> >
> > protected override void WndProc(ref System.Windows.Forms.Message m)
> > {
> > if (m.Msg == Convert.ToInt32(WindowsMessages.WM_CREATE))
> > {
> > StringBuilder text = new StringBuilder("msg = " + m.Msg.ToString()
> > +
> > "wParam=" + m.WParam.ToString() + ", lparam=" +
> > m.LParam.ToString());
> >
> > // call m.GetLParam() - gets a pointer to CREATESTRUCT;
> > }
> >
> > base.WndProc (ref m);
> > }
>
>
>

Re: How to convert Message.LParam pointer to CREATESTRUCT to an ob by Stoitcho

Stoitcho
Thu Mar 02 08:15:25 CST 2006

Why don't you just handle one of the events there and check the Text and
Location properties?

--

Stoitcho Goutsev (100)

"leightonr" <leightonr@discussions.microsoft.com> wrote in message
news:D4416E1B-24CE-480E-A5B3-F090CB8EE7DF@microsoft.com...
> Thanks Stoitcho,
>
> the information I am trying to get is the name of the new window and its x
> and y coordinates.
>
>
>
> "Stoitcho Goutsev (100)" wrote:
>
>> leightonr,
>>
>> To get the CREATESTRUCT you first need to declare such a type with all
>> the
>> fileds with proper types and propertly attributed for marshaling and then
>> call
>> *Marshal.PtrToStructure* to get the data from the unmanaged memory.
>> If you google you can probably find somewhere the .NET declaration of
>> this
>> structure.
>>
>> I don't know what your goal is, but take a look at the CreateParmas
>> protected virtual property. This property is called just before the
>> native
>> windows is created and has to return the data that is going to be used
>> when
>> calling CreateWindowEx to create the underlying native window. When you
>> override this poprerty first call the base implementation then tweak the
>> data and return the result.
>>
>> What piece of info you are interested in from that structure? There might
>> be
>> another way to get it.
>>
>>
>> --
>> HTH
>> Stoitcho Goutsev (100)
>>
>> "leightonr" <leightonr@discussions.microsoft.com> wrote in message
>> news:3E0558DA-6560-49C4-9542-B039445ED29C@microsoft.com...
>> > I'm capturing WM_CREATE messages by overriding WndProc in C#/.NET.
>> > How do I then convert the CREATESTRUCT* that GetLParam() would return
>> > to
>> > an
>> > object that I can use in my code ?
>> >
>> > protected override void WndProc(ref System.Windows.Forms.Message m)
>> > {
>> > if (m.Msg == Convert.ToInt32(WindowsMessages.WM_CREATE))
>> > {
>> > StringBuilder text = new StringBuilder("msg = " +
>> > m.Msg.ToString()
>> > +
>> > "wParam=" + m.WParam.ToString() + ", lparam=" +
>> > m.LParam.ToString());
>> >
>> > // call m.GetLParam() - gets a pointer to CREATESTRUCT;
>> > }
>> >
>> > base.WndProc (ref m);
>> > }
>>
>>
>>