Results 1 to 9 of 9

Thread: Is my bitwise operation correct?

  1. #1

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Is my bitwise operation correct?

    i want to identify windows which fully or partially trasnparent. so i check those windows against WS_EX_LAYERED bit. i want to make sure below bitwise operation is correct.

    Code:
    Public Function isTrans(qhwnd As Long) As Boolean
    Dim tmp As Long
    tmp = GetWindowLong(qhwnd, GWL_EXSTYLE)
    If tmp And WS_EX_TRANSPARENT Then
       isTrans = True ' yes it is 
    Else
       isTrans = False ' no its not 
    End If
    End Function
    is this correct? can i identify windows such as shown below using this code?

    Last edited by Fazi; Aug 30th, 2009 at 10:36 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is my bitwise operation correct?

    You shouldn't have any problems with what you posted. That check does not indicate if the window is partially transparent or not, it simply means the style is applied and the window could be transparent and could also be 100% opaque. Shaped windows will use that style even though they have no intention of being partially/fully transparent.

    However, when using AND, AND NOT, I find it better to use grouping parentheses to avoid potential of VB miscalculating; especially, if you have more than one calculation in the formula:
    If (tmp And (WS_EX_TRANSPARENT Or WS_EX_WINDOWEDGE))

    Recommend when testing for a specific style, always do explicit comparisons
    If ((tmp And WS_EX_TRANSPARENT) = WS_EX_TRANSPARENT)

    By using explicit comparisions, you avoid the problem when a style is not a power of two. Button properties are an example of such a thing: BS_OWNERDRAW = 11
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Is my bitwise operation correct?

    Tx volpe for the very useful tips.
    btw spy++ programs dont show this bit set in this windows
    so how can i dentify it?




  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is my bitwise operation correct?

    There are 2 ways to get that effect:
    1. Using layered windows
    2. Using window regions. Which is what that is probably using.

    Can you tell us why you need to know if a window is shaped or not? You cannot determine that by simply looking at style bits. If window regions are used, you can determine it by comparing the window region against a rectangular window region of the window's size and see if they are equal: EqualRgn API. But that will return false positives since every XP themed window, I believe, is using window regions to round the top left/right window corners. Therefore, knowing if a window is shaped due to themes or not, may not be 100% possible. Knowing if a window is partially transparent or not by checking the style bits is not possible.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Is my bitwise operation correct?

    Can you tell us why you need to know if a window is shaped or not?
    yah, my woodpecker behaving very badly on those shaped windows.

    woodpecker in a reguler window




    in a shaped window


    i want to ignore my woodpecker from sitting in this type of windows.


    oh volpe i really forget window region
    but as you sad most of the themed window have a rounded shape also.

    am i in trouble
    Last edited by Fazi; Aug 30th, 2009 at 11:11 AM.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is my bitwise operation correct?

    There are some really odd shaped windows about. You may have trouble placing the woodpecker on all possible shapes. The right edge is an arc in your example, it could be a point if the window looked something like: <___>

    Just some thoughts...
    You can get the window region, if one is used and you can paint the region to a DC. With layered windows you can bitblt the widow to a dc and use a mask to determine its shape if not rectangular. Once you can determine the shape, I think you'd have to use a lot of trig to locate/calculate a line to place your woodpecker on. That line may be rotated at any angle, which means the woodpecker may have to be rotated too.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Is my bitwise operation correct?

    Quote Originally Posted by LaVolpe View Post
    There are some really odd shaped windows about. You may have trouble placing the woodpecker on all possible shapes. The right edge is an arc in your example, it could be a point if the window looked something like: <___>

    Just some thoughts...
    You can get the window region, if one is used and you can paint the region to a DC. With layered windows you can bitblt the widow to a dc and use a mask to determine its shape if not rectangular. Once you can determine the shape, I think you'd have to use a lot of trig to locate/calculate a line to place your woodpecker on. That line may be rotated at any angle, which means the woodpecker may have to be rotated too.
    for now i really dont want to place the wood on shaped window shown like above at all. so i will tyr your bitblt suggession to determine a windows right edge is rect or arc. that i think worth a try


  8. #8

    Thread Starter
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: Is my bitwise operation correct?

    another problem also there even with the fully rectangular shaped windows.
    for excample window7 start menu. unlike in xp, it has a diffrent rect that has a big offset from the actual right edge.


  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Is my bitwise operation correct?

    I don't have access to Win7. I suspect that the start menu is using layered windows and the extended rect is fully transparent. When a menu is selected the window is refreshed and the rect is filled in.

    Even if your woodpecker could align itself on the smaller rect, when user selects a menu, your woodpecker wouldn't know to jump to the far right. Complicates your logic quite a bit.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width