Results 1 to 9 of 9

Thread: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Resolved [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Hello Everyone, So, i've done my research and my appbar is working "almost" perfect. The problem i'm having is that when the System.Windows.Forms.CreateParams.ExStyle property is set to &H80, I am unable to set form opacity which is truely what this project needs.

    I've tried a lot of things but I'm open to suggestions even IF i've already tried them.

    Here is how you can replicate the error.

    1. Create a new VB.NET 2005 Windows Application.

    2. Paste this code within the class in form1.vb

    VB Code:
    1. Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
    2.         Get
    3.             Dim cp As CreateParams = MyBase.CreateParams
    4.             cp.Style = &HC00000 ' WS_CAPTION
    5.             cp.Style = &H800000 ' WS_BORDER  
    6.             cp.ExStyle = &H80& Or &H8& ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST
    7.  
    8. 'Me.Opacity = 0.75
    9.  
    10.             Return cp
    11.         End Get
    12.     End Property

    Again, this is for an AppBar program. I am just totally stuck on this. I needed to remove the titlebar... that's why I have the .Styles there. Opacity works fine when I take away the .ExStyle property, but as soon as I turn the form into a toolwindow using &H80 or &H8, the opacity property doesn't work.

    Is there a work around to get the opacity to show up on the form?

    By the way,
    VB Code:
    1. cp.ExStyle = &H80& Or &H8& ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST

    is required for the rest of the program to function properly. Removing that line for the opacity is not an option.
    Last edited by La Jiraffa; Dec 19th, 2006 at 01:26 AM.
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Re: [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Is anyone out there with experience of Appbars?
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Re: [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Alright, well... I found the answer to my question out of trial and error. It came to be that I really did not need
    VB Code:
    1. cp.ExStyle = &H80& Or &H8& ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST

    However, what I did have to do is add another Case entry into the code... here it is..

    VB Code:
    1. Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    2.         If m.Msg = uCallBack Then
    3.             Select Case IntPtr.Size 'm.WParam.ToInt32()
    4.                 Case CInt(ABNotify.ABN_POSCHANGED)
    5.                     ABSetPos()
    6.                     'The Case Else did the trick... this made the bar mount and stay in position.
    7.                 Case Else
    8.                     ABSetPos()
    9.             End Select
    10.         End If
    11.  
    12.         MyBase.WndProc(m)
    13.     End Sub 'WndProc

    As for what I was actually doing... well here.. check it out. If anyone wants to see a copy of the program ill be happy to post all of the source. This one I can say was truely built by myself using a translator from C# to VB.net in an article pulled out of the MSDN library.

    What the program actually does, it makes an AppBar very similar to the Windows Taskbar. It mounts on top, left right, and on the bottom of the screen. The bar provides a way to display the current classification of a Government computer... Unclassified, Secret, and Top Secret. The bar is able to have transparency, and it is always on top. If a window somehow manages to get behind the bar, you can double click the bar and slide the window out of the way. The best thing of all is that it pushes the icons down, up, left, or right... However the bar is mounted.. the icons will move out of the way. It truely is a first step to make something very usable and customizable.
    Attached Images Attached Images  
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  4. #4
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    I'm interested in the source code for this program, can you send it to me?
    MyEmail

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Quote Originally Posted by TTn
    I'm interested in the source code for this program, can you send it to me?
    MyEmail
    I'll do even more than that... I'll post it here so everyone can use it. It took me forever to figure this thing out and I'm sure someone will appreciate the fine example I made. I just hope my comments are sufficient enough.

    This is a VB.NET 2005 working example. Open the .sln file, build it, and run the app. Have fun guys! Make sure you rate this post if it helped you!
    Attached Files Attached Files
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  6. #6
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    I've checked out the source. You do have some skills.

    In my humble opinion, this should not be used for real top secret stuff, nor should you post that sort of thing in public.

    Here are just a couple of minor things I saw that may need tending to.
    'You may want to place a SaveSettings(), when the user changes positions or settings, instead of having a button.
    'Unless thats your intention.
    Most applications automatically save a change.

    'Why use Sleep API?
    'This should work as good
    VB Code:
    1. System.Threading.Thread.Sleep(0)

    'Dont assume that if user admin fails, then it's a power user. Why not check since you've already written the code.
    'Change to this:
    VB Code:
    1. If My.User.IsInRole(useradmin) = True Then
    2.     ContextMenuStrip.Enabled = True
    3. ElseIf My.User.IsInRole(userpower) = True Then
    4.     ContextMenuStrip.Enabled = False
    5. Else
    6.     MessageBox.Show("Unknown user")
    7. End If


    Well done!
    Thanks, I learned a few things!

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    I've checked out the source. You do have some skills.

    In my humble opinion, this should not be used for real top secret stuff, nor should you post that sort of thing in public.
    This is in no way a TS project.. Keep in mind that this is just a friendly reminder to the user on which type of machine they are using. A simpe color and text change can switch it, but it is unnecessary because this project is no way classified. Now... after saying that.. Let me answer your other questions

    'Why use Sleep API?
    For some reason... I usually put the Sleep API in all of my projects. Once I reference my API, it's as simple as saying Sleep() and it sleeps... I find it a little easier to use and it's what I prefer. Now.. I'm not calling any sleep in this program so it can be taken out.. again.. I just had it in there as a "just-in-case"

    VB Code:
    1. 'If user is not an administrator disable the context menu
    2.         useradmin = Microsoft.VisualBasic.ApplicationServices.BuiltInRole.Administrator
    3.         userpower = Microsoft.VisualBasic.ApplicationServices.BuiltInRole.PowerUser
    4.         If My.User.IsInRole(useradmin) = True Then
    5.             ContextMenuStrip.Enabled = True
    6.         Else
    7.             ContextMenuStrip.Enabled = False
    8.         End If
    This will suffice because: The only user that should be able to change the banner IS the administrator. At no point should a typical user, power user, or any other type of user except an administrator have access to the context menu. This decission statement accurately defines this. If the user is an admin... go ahead and activate the context menu... if the user is something else besides an administrator... take the context menu away.
    PS: I forgot to take the userpower variable out of the source

    I also want to thank you for your suggestion that is now implemented... every time the position or color is changed, it saves the settings. I guess it just makes more sense

    Crap.. a mortar just hit 50 meters from my trailer.. I hate Baghdad...
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Location
    North Cackalaki
    Posts
    28

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Also... if the form is a SizableToolWindow style, you can go into the Form1.Designer.VB and change the height of form1 to something less than 0 and get an even thinner bar. When I compile, I use a height of -5 on the form1. That's why it is a sizabletoolwindow, and not a regular one.
    Phillip Dieppa
    VB.NET Newbie 2.0


    AppBar Example

  9. #9
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708

    Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!

    Ah, okay the admin thing had me wondering.
    Thanks again for the code, and thank you for serving!
    May your journey be a safe one.

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