[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:
Protected Overrides ReadOnly Property CreateParams() As System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
cp.Style = &HC00000 ' WS_CAPTION
cp.Style = &H800000 ' WS_BORDER
cp.ExStyle = &H80& Or &H8& ' WS_EX_TOOLWINDOW | WS_EX_TOPMOST
'Me.Opacity = 0.75
Return cp
End Get
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. :sick:
Is there a work around to get the opacity to show up on the form?
By the way,
VB Code:
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.
Re: [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!
Is anyone out there with experience of Appbars? :cry:
1 Attachment(s)
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:
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:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = uCallBack Then
Select Case IntPtr.Size 'm.WParam.ToInt32()
Case CInt(ABNotify.ABN_POSCHANGED)
ABSetPos()
'The Case Else did the trick... this made the bar mount and stay in position.
Case Else
ABSetPos()
End Select
End If
MyBase.WndProc(m)
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.
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
1 Attachment(s)
Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!
:thumb:
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!
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:
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:
If My.User.IsInRole(useradmin) = True Then
ContextMenuStrip.Enabled = True
ElseIf My.User.IsInRole(userpower) = True Then
ContextMenuStrip.Enabled = False
Else
MessageBox.Show("Unknown user")
End If
Well done!
Thanks, I learned a few things!
Re: [RESOLVED] [2005] AppBar question. Anyone with WS_EX_TOOLWINDOW experience is welcomed!!
Quote:
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 :)
Quote:
'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:
'If user is not an administrator disable the context menu
useradmin = Microsoft.VisualBasic.ApplicationServices.BuiltInRole.Administrator
userpower = Microsoft.VisualBasic.ApplicationServices.BuiltInRole.PowerUser
If My.User.IsInRole(useradmin) = True Then
ContextMenuStrip.Enabled = True
Else
ContextMenuStrip.Enabled = False
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 :p
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... :(
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. :)
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.