| View previous topic :: View next topic |
| Author |
Message |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Mon Feb 15, 2010 8:25 pm Post subject: Get styles of a vds window? |
|
|
hi,
is there a way to retrieve the style(s) of a vds dialog/window?
for example if the dialog was creted with "smallcap" or "notitle"
like
| Code: |
parse "%A;%B;%C;%D",@winstyles()
if @greater(@pos("smallcap",%A%B%C%D),0)
info Window has SMALLCAP style
end
|
Maybe an API-solution?
I need this for a dsu where i can not know which styles were applied.
thanks |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Mon Feb 15, 2010 11:32 pm Post subject: |
|
|
Use the windows api by loading an external dll.
user32.dll is the dll that holds the api function GetWindowLong
http://msdn.microsoft.com/en-us/library/ms633584(VS.85).aspx
You supply the window handle as the first parameter, In vds you can get windows handles by doing @winexists() and remove the # character it returns before sending the handle to the api.
-16 is the GWL_STYLE which you supply as the second parameter.
It will return back a value of the style the window has. below are the windows styles
Windows Styles:
http://msdn.microsoft.com/en-us/library/ms632600(VS.85).aspx
Some styles are WS_BORDER = $800000 , I believe this is the same as the smallborder used in vds.
Use CodeScript's Visual Dialogscript API constant reference to find other windows style id's, this file can be found on the main vdsworld.com site by doing a quick search for 'api'. |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Tue Feb 16, 2010 2:21 am Post subject: |
|
|
Thank you PGWARE for your response.
I followed your suggestion but what to do with the result?
here is a testscript i made:
| Code: |
%%Style = Smallcap
# %%Style = Notitle
# %%Style = Ontop
# %%Style = Nomin
# %%Style = Nosys
# %%Style = Invisible
# %%Style = Resizable
# %%Style = Scrollbars
# %%Style = Paint
DIALOG CREATE,Styles Test,-1,0,240,160,Class Test,nosys,%%Style
DIALOG ADD,BUTTON,Exit,114,88,64,24,Exit
DIALOG ADD,TEXT,TEXT1,36,24,,,TEXT1
DIALOG SHOW
%H = @strdel(@winexists(#Test),1,1)
loadlib user32
%R = @lib(user32,GetWindowLongA,INT:,%H,-16)
freelib user32
if @not(%%Style)
%%Style = No Style
end
clipboard set,%%Style =@tab()@tab()%R@tab()( @hex(%R) )
%L = @new(list)
list loadfile,%L,Window_Styles.txt
if @not(@match(%L,%%Style))
list add,%L,%%Style =@tab()@tab()%R@tab()( @hex(%R) )
list savefile,%L,Window_Styles.txt
end
list close,%L
run notepad.exe Window_Styles.txt
wait 2
info %%Style = %R ( @hex(%R) )
exit
|
the results for the different styles are:
| Quote: |
No Style = 382337024 ( 16CA0000 )
Smallcap = 382205952 ( 16C80000 )
Notitle = -1778384896 ( 96000000 )
Ontop = 382337024 ( 16CA0000 )
Nomin = 382205952 ( 16C80000 )
Nosys = 381812736 ( 16C20000 )
Invisible = 382337024 ( 16CA0000 )
Resizable = 382664704 ( 16CF0000 )
Scrollbars = 382599168 ( 16CE0000 )
Paint = 382337024 ( 16CA0000 )
Nosys,Smallcap = 381681664 ( 16C00000 )
|
if i combine different styles some values change, some not.
I found nowhere on the net what those values correspond with.
Please help, how to determine the window styles from these values.
thank you in advance |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Feb 16, 2010 3:30 pm Post subject: |
|
|
Even though you may have not added any styles in your VDS script, the actual dialog still has to have some, or else it wouldn't even be visible.
So what you are seeing is always a combination of at least 2 styles together.
I've done what you are wanting to do in C before, I will see if I can do it in VDS. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Feb 16, 2010 5:00 pm Post subject: |
|
|
This will give you the actual Windows API names of the Window Styles of your VDS Dialog. It doesn't contain every style, but probably has more than you will use in VDS.
If you have any questions about it let me know.
| Code: |
REM For more information on these commands:
REM http://www.vdsworld.com/forum/viewtopic.php?t=1860
#DEFINE FUNCTION,SSBitAND
#DEFINE FUNCTION,SSDec2Bin
#DEFINE FUNCTION,SSBin2Dec
option decimalsep,"."
REM This code should check for the existance of each style in List #1, and then
REM find the name of that style in List #2, this should reduce the amount of
REM code to check each style and see which one it is.
REM Extended window styles are in List #3 and #4
REM Regular Styles put in as Decimal
list create,1
list loadtext,1
"268435456
"8388608
"12582912
"131072
"524288
"33554432
"67108864
"134217728
"4194304
"131072
"1048576
"2097152
"65536
"2147483648
list create,2
list loadtext,2
"WS_VISIBLE
"WS_BORDER
"WS_CAPTION
"WS_MINIMIZEBOX
"WS_SYSMENU
"WS_CLIPCHILDREN
"WS_CLIPSIBLINGS
"WS_DISABLED
"WS_DLGFRAME
"WS_GROUP
"WS_HSCROLL
"WS_VSCROLL
"WS_MAXIMIZEBOX
"WS_POPUP
REM Extended Styles put in as decimal
list create,3
list loadtext,3
"16
"262144
"512
"1024
"65536
"524288
"1
"16384
"64
"4
"4096
"8192
"131072
"128
"8
"32
"256
list create,4
list loadtext,4
"WS_EX_ACCEPTFILES
"WS_EX_APPWINDOW
"WS_EX_CLIENTEDGE
"WS_EX_CONTEXTHELP
"WS_EX_CONTROLPARENT
"WS_EX_LAYERED
"WS_EX_DLGMODALFRAME
"WS_EX_LEFTSCROLLBAR
"WS_EX_MDICHILD
"WS_EX_NOPARENTNOTIFY
"WS_EX_RIGHT
"WS_EX_RTLREADING
"WS_EX_STATICEDGE
"WS_EX_TOOLWINDOW
"WS_EX_TOPMOST
"WS_EX_TRANSPARENT
"WS_EX_WINDOWEDGE
DIALOG CREATE,Window Styles Check,-1,0,307,271,CLASS WindowStyleCheckWnd,SMALLCAP
REM *** Modified by Dialog Designer on 2/16/2010 - 11:56 ***
DIALOG ADD,BUTTON,BUTTON1,240,31,110,24,Get Regular Styles
DIALOG ADD,BUTTON,BUTTON2,240,165,110,24,Get Extended Styles
DIALOG ADD,LIST,LIST1,21,21,126,202
DIALOG ADD,LIST,LIST2,21,157,126,202
DIALOG SHOW
loadlib user32.dll
%%hwnd = @strdel(@winexists(#WindowStyleCheckWnd),1,1)
%%Styles = @lib(user32,GetWindowLongA,INT:,%%hwnd,-16)
%%ExtStyles = @lib(user32,GetWindowLongA,INT:,%%hwnd,-20)
:evloop
wait event
goto @event()
:BUTTON1BUTTON
gosub CheckStyles
goto evloop
:BUTTON2BUTTON
gosub CheckExtStyles
goto evloop
:Close
freelib user32.dll
exit
:CheckStyles
list clear,LIST1
REM Loop through the window style list and see if that style is in the current
REM Window's styles.
%x = 0
repeat
REM if ((windowStyles & stylefromList) == styleFromList)
if @equal(@SSBitAnd(%%Styles,@item(1,%x)),@item(1,%x))
list add,LIST1,@item(2,%x)
end
%x = @succ(%x)
until @equal(%x,@pred(@count(1)))
exit 1
:CheckExtStyles
list clear,LIST2
REM Loop through the window extended style list and see if that style is in
REM the current Window's extended styles.
%x = 0
repeat
REM if ((windowExtStyles & extstylefromList) == extstyleFromList)
if @equal(@SSBitAnd(%%ExtStyles,@item(3,%x)),@item(3,%x))
list add,LIST2,@item(4,%x)
end
%x = @succ(%x)
until @equal(%x,@pred(@count(3)))
exit 1
REM The routines below are needed for bitwise operations on the styles.
:SSBitAnd
%%SSBAresult = ""
%%SSBA1 = @SSDec2Bin(%1)
%%SSBA2 = @SSDec2Bin(%2)
IF @GREATER(@LEN(%%SSBA1),@LEN(%%SSBA2))
%%SSBAStop = @LEN(%%SSBA1)
%%SSBACheck = 1
ELSE
%%SSBAStop = @LEN(%%SSBA2)
%%SSBACheck = 2
END
WHILE @NOT(@EQUAL(@LEN(%%SSBA2),@LEN(%%SSBA1)))
IF @EQUAL(%%SSBACheck,1)
%%SSBA2 = "0"%%SSBA2
ELSE
%%SSBA1 = "0"%%SSBA1
END
WEND
%%SSBAX = 1
REPEAT
IF @BOTH(@EQUAL(@SUBSTR(%%SSBA1,%%SSBAX,%%SSBAX),1),@EQUAL(@SUBSTR(%%SSBA2,%%SSBAX,%%SSBAX),1))
%%SSBAResult = %%SSBAResult"1"
ELSE
%%SSBAResult = %%SSBAResult"0"
END
%%SSBAX = @SUCC(%%SSBAX)
UNTIL @GREATER(%%SSBAX,%%SSBAStop)
%%SSBAresult = @SSBin2Dec(%%SSBAresult)
exit %%SSBAresult
:SSDec2Bin
%%SSD2Bresult = ""
%%SSD2BintValue = %1
While @GREATER(%%SSD2BintValue,0)
%%SSD2Bi = @MOD(%%SSD2BIntValue,2)
%%SSD2Bi = @FADD(%%SSD2Bi,1)
%%SSD2BintValue = @DIV(%%SSD2BintValue,2)
%%SSD2Bresult = @SUBSTR("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",%%SSD2Bi,%%SSD2Bi)%%SSD2Bresult
WEND
exit %%SSD2Bresult
:SSBin2Dec
%%SSB2DResult = 0
%%SSB2DX = 1
%%SSB2DStrValue = %1
REPEAT
%%SSB2DCharValue = @POS(@UPPER(@SUBSTR(%%SSB2DStrValue,%%SSB2DX,%%SSB2DX)),"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#return -1 if character is not supported by base
If @GREATER(%%SSB2DCharValue,2)
%%SSB2DResult = -1
%%SSB2DX = @SUCC(@LEN(%%SSB2DStrValue))
END
%%SSB2DResult = @FADD(@FMUL(%%SSB2DResult,2),@FSUB(%%SSB2DcharValue,1))
%%SSB2DX = @SUCC(%%SSB2DX)
UNTIL @GREATER(%%SSB2DX,@LEN(%%SSB2DStrValue))
exit %%SSB2DResult
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Wed Feb 17, 2010 4:28 am Post subject: |
|
|
Thanks a lot, SnarlingSheep.
That's great, exactly what i've been looking for.
I just made a function from it that returns the styles as a string of styles separated by the current fieldsep.
It now uses only one list and no global variables.
here it is: (please note that VDS 6 is required)
| Code: |
#
# Function WStyles - bornSoft - from original code by SnarlingSheep
# -----------------------------------------------------------------
#
# This function returns a string containing the WS_ styles or WS_EX_ styles
# of a specified window separated by the current field separator.
#
#
# Usage: %S = @WStyles( <#WINDOWCLASSNAME> [ ,EXT ] )
#
#
# The class name of the window must be prefixed by "#".
#
# If the optional argument EXT is given, the WS_EX_ styles are returned
# instead of the normal styles.
#
#
#DEFINE FUNCTION,WStyles
#DEFINE FUNCTION,WStyles_BitAnd
#DEFINE FUNCTION,WStyles_D2B
#DEFINE FUNCTION,WStyles_B2D
:WStyles
%H = @strdel(@winexists(%1),1,1)
if @not(%H)
if %%Debug
warn "Error in function [ WStyle ]"@cr()@cr()"Window does not exist ( "%1" ) "@tab()
end
Error 13
exit
end
%D = @substr(@fdiv(1,2),2)
option decimalsep,"."
%F = @fsep()
option fieldsep,"="
%L = @new(list)
list loadtext,%L
"WS_VISIBLE=268435456
"WS_BORDER=8388608
"WS_CAPTION=12582912
"WS_MINIMIZEBOX=131072
"WS_SYSMENU=524288
"WS_CLIPCHILDREN=33554432
"WS_CLIPSIBLINGS=67108864
"WS_DISABLED=134217728
"WS_DLGFRAME=4194304
"WS_GROUP=131072
"WS_HSCROLL=1048576
"WS_VSCROLL=2097152
"WS_MAXIMIZEBOX=65536
"WS_POPUP=2147483648
"###ExtendedStyles########
"WS_EX_ACCEPTFILES=16
"WS_EX_APPWINDOW=262144
"WS_EX_CLIENTEDGE=512
"WS_EX_CONTEXTHELP=1024
"WS_EX_CONTROLPARENT=65536
"WS_EX_LAYERED=524288
"WS_EX_DLGMODALFRAME=1
"WS_EX_LEFTSCROLLBAR=16384
"WS_EX_MDICHILD=64
"WS_EX_NOPARENTNOTIFY=4
"WS_EX_RIGHT=4096
"WS_EX_RTLREADING=8192
"WS_EX_STATICEDGE=131072
"WS_EX_TOOLWINDOW=128
"WS_EX_TOPMOST=8
"WS_EX_TRANSPARENT=32
"WS_EX_WINDOWEDGE=256
%m = @match(%L,ExtendedStyles)
%i = @index(%L)
loadlib user32.dll
if @equal(@substr(%2,1,3),Ext)
%K = @lib(user32,GetWindowLongA,INT:,%H,-20)
%x = @succ(%i)
%y = @pred(@count(%L))
else
%K = @lib(user32,GetWindowLongA,INT:,%H,-16)
%x = 0
%y = %i
end
freelib user32.dll
repeat
parse "%W;%N",@item(%L,%x)
if @equal(@WStyles_BitAnd(%K,%N),%N)
%R = %R%W%F
end
%x = @succ(%x)
until @equal(%x,%y)
option decimalsep,%D
option fieldsep,%F
list close,%L
if @equal(@strdel(%R,1,-1),%F)
%R = @substr(%R,1,-1)
end
exit %R
:WStyles_BitAnd
%A = @WStyles_D2B(%1)
%B = @WStyles_D2B(%2)
IF @GREATER(@LEN(%A),@LEN(%B))
%S = @LEN(%A)
%C = 1
ELSE
%S = @LEN(%B)
%C = 2
END
WHILE @NOT(@EQUAL(@LEN(%B),@LEN(%A)))
IF @EQUAL(%C,1)
%B = "0"%B
ELSE
%A = "0"%A
END
WEND
%x = 1
REPEAT
IF @BOTH(@EQUAL(@SUBSTR(%A,%x,%x),1),@EQUAL(@SUBSTR(%B,%x,%x),1))
%R = %R"1"
ELSE
%R = %R"0"
END
%x = @SUCC(%x)
UNTIL @GREATER(%x,%S)
%R = @WStyles_B2D(%R)
exit %R
:WStyles_D2B
While @GREATER(%1,0)
%B = @MOD(%1,2)
%B = @FADD(%B,1)
%1 = @DIV(%1,2)
%R = @SUBSTR("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",%B,%B)%R
WEND
exit %R
:WStyles_B2D
%R = 0
%x = 1
REPEAT
%C = @POS(@UPPER(@SUBSTR(%1,%x,%x)),"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
If @GREATER(%C,2)
%R = -1
%x = @SUCC(@LEN(%1))
END
%R = @FADD(@FMUL(%R,2),@FSUB(%C,1))
%x = @SUCC(%x)
UNTIL @GREATER(%x,@LEN(%1))
exit %R
|
To test it:
| Code: |
#INCLUDE WStyles.dsc
%%Debug = 1
DIALOG CREATE,Window Styles Check,-1,0,307,100,CLASS WStylesTest,SMALLCAP
DIALOG ADD,BUTTON,Reg,40,31,110,24,Get Regular Styles
DIALOG ADD,BUTTON,Ext,40,165,110,24,Get Extended Styles
DIALOG SHOW
:evloop
wait event
goto @event()
:RegBUTTON
info @WStyles(#WStylesTest)
goto evloop
:ExtBUTTON
info @WStyles(#WStylesTest,Ext)
goto evloop
:Close
exit
|
. |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Wed Feb 17, 2010 4:31 pm Post subject: |
|
|
hello snarlinsheep,
when testing I encountered two errors. maybe you can help me again:
if the "notitle" style is set for the dielog, the returnvalue of
| Code: |
%K = @lib(user32,GetWindowLongA,INT:,%H,-16)
|
is negative ( -1778384896 ) and an error "missing parameters" is produced.
The other thing is that if the "nosys" style is set, still "WS_MINIMIZEBOX" is returned.
Any ideas?
thank you. |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Feb 17, 2010 5:23 pm Post subject: |
|
|
With a quick look I can see that you will run into problems using @match(), as it may match "8192" when you are only looking for "8".
Another problem is that some of the extended style numbers are the same as the regular style numbers, which is why there are separate calls for each.
I can see why you tried to streamline it, but I don't see it working that way.
The above is why you are getting the NOSYS problem.
I also don't have the NOTITLE problem with my code, so it must be because of what you changed. It just shows no regular window styles.
*Edit:* I believe it should at least show WS_VISIBLE even with NOTITLE _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Wed Feb 17, 2010 6:59 pm Post subject: |
|
|
thank you snarlingsheep,
but please take a more careful look again. @match() is only used once - just to find the line "###ExtendedStyles########" which marks the end index for regular styles and the beginning index of extended styles. Nothing more, there is no comparison on numbers.
the negative result of "GetWindowLongA" always appears at notitle-style independently of using my function or not.
The other thing you mentioned - same style-numbers for reg. and ext. styles - should be eliminated by the @match() thing from above, i think.
everything works correct except the negative value and if i set "...,nosys,nomin" it's ok.
maybe if "nosys" is set, the minimize-button is still there but hidden, this would mean "WS_MINIMIZEBOX" style is still applied and the result is correct.
greetings from cold europe |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Wed Feb 17, 2010 7:44 pm Post subject: |
|
|
Yes I should have looked more closely.
Just so I know we are looking at this the same way, you DO have the negative number issue with my code also? I don't seem to have this problem here, so it may be an issue with VDS 6?
*Edit:* I get the same result as you do, -1778384896, but no errors here.
I believe the problem with WS_MINIMIZEBOX is that it shares the same constant as WS_GROUP. WS_MAXIMIZEBOX shares the same as WS_TABSTOP also, seems like Microsoft could have used a couple more numbers. So you may not want to check for these. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
bornsoft Contributor

Joined: 19 Feb 2009 Posts: 113 Location: Germany
|
Posted: Wed Feb 17, 2010 8:25 pm Post subject: |
|
|
i tested your code again with "notitle" and if i press the regular-button it runs into nirvana.
so it seems definately to be an issue with the negative prefix.
I don't know if the result would be falsified if we just eliminate the "-" and take the return as positive?
Edit: Sorry - your code does work, it doesn't hang, but it just finds no style at all and so it looks like hanging.
is it a normal behaviour that with "notitle" no regular styles are assigned to a window? i think at least "WS_VISIBLE" should appear.
So there seems to go something wrong with the "-" anyway.
Edit again:
I just tested your code with these additional lines:
| Code: |
if @equal(@substr(%%Styles,1),"-")
%%Styles = @strdel(%%Styles,1)
end
|
The styles i get are "WS_CLIPCHILDREN" and "WS_DISABLED".
I think if "WS_VISIBLE" doesn't appear, the result can not be correct. |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Thu Feb 18, 2010 2:16 pm Post subject: |
|
|
Yeah it looks like the negative number is giving us problems, but getting rid of the "-" will not help.
With a regular dialog with no extra styles we should be getting:
| Code: | | WS_VISIBLE|WS_BORDER|WS_CAPTION|WS_MINIMIZEBOX|WS_SYSMENU|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_DLGFRAME |
With NOTITLE we should be getting:
| Code: | WS_VISIBLE|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_POPUP
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|