user32.dll - messages

M

Martin Priebe

Hi,

i use visual studio 2005 with c#

i try to to locate windows and controls in the window.

when i use the function GetClassName (located in user32.dll) i get the
Class.
Button, ComboBox or Edit ...

But i have the problem with checkbox and radio buttons.
These are Buttons too.

How can i read the kind of button ?

When I use Spy++ i see the styles of the controls.
Maybe i could use the style to figure it out.

But how ?

How can i get the style of a control ?


The windows i read out are not build from my application !

thx a lot
Martin
 
M

Martin Priebe

Hi again,

i tried to use GetWindowLong.

but with this function i get a parameter. (type - long)

but i don´t know what can i do with this parameter
 
N

Nicholas Paldino [.NET/C# MVP]

Martin,

What is your declaration of GetWindowLongPtr? You can probably get it
(or the definition of GetWindowLong) from http://www.pinvoke.net.

There are two parameters, the window handle (which should be an IntPtr)
and an integer (of type int). The return value will return the window
styles to you, assuming you pass the value of GWL_STYLE.

You might want to call it twice, in order to get the extended window
styles as well.
 
M

Martin Priebe

Hi,

ok. i get the return value 8403211231 for example.
what does that means ?

i don´t understand the difference between int and style ?

when i get the return value 8403211231, how can i see that this style is for
a checkbox or for a pushbutton ?


greetings
Martin

Nicholas Paldino said:
Martin,

What is your declaration of GetWindowLongPtr? You can probably get it
(or the definition of GetWindowLong) from http://www.pinvoke.net.

There are two parameters, the window handle (which should be an IntPtr)
and an integer (of type int). The return value will return the window
styles to you, assuming you pass the value of GWL_STYLE.

You might want to call it twice, in order to get the extended window
styles as well.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)



Martin Priebe said:
Hi again,

i tried to use GetWindowLong.

but with this function i get a parameter. (type - long)

but i don´t know what can i do with this parameter
 
W

Willy Denoyette [MVP]

Martin Priebe said:
Hi,

ok. i get the return value 8403211231 for example.
what does that means ?

i don´t understand the difference between int and style ?

when i get the return value 8403211231, how can i see that this style is
for a checkbox or for a pushbutton ?

There must be something wrong with your return value declaration, 8403211231
is not a valid int32 value.
Anyway, the return value need to be masked out to get the valid button
styles from it,



int BS_TYPEMASK = 0x0000000F;
int GWL_STYLE = -16;
enum ButtonStyle
{
BS_CHECKBOX 0x2;
BS_AUTOCHECKBOX = 0x3;
....
}

int buttonStyle = GetWindowLong (hwndControl, GWL_STYLE) & BS_TYPEMASK;
Use as follows:
If (buttonStyle == (int)ButtonStyle.BS_AUTOCHECKBOX)
.....
If (buttonStyle == (int)ButtonStyle.BS_CHECKBOX)


Please check the Platform sdk docs on MSDN for the other possible button
style BS_**

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top