[RESOLVED] Transparent black overlay?
So what I'm looking for help with is on how to create this transparency like black overlay I could use on forms.
This is the best way to describe it, but it would be similar to when Win7 needs administration permissions. When the dialog pops up, the screen dims down almost as if they overlapped the screen with a transparent black layer of some sort. This is easily accomplish able by creating a black form and having its opacity set to half and starting it maximized-which I'm already doing. The problem with this though is I need to do this within a form, so using a panel or anything is out of the questions since transparency really grabs the background image and not the actual controls underneath. Plus I feel if adding a form to another forms controls depletes it's ability to use it's opacity property.
The form I need this in is my cash register. It is full screen but if my menu auto hides it still resizes. It has two parts, the order(panel to the left) and the payments(panel to the right). As you could imagine I want the payments portion blacked out until the order is capable of accepting payments(the payment due is greater than 0). Or I'm thinking it fallows the mouse, you mouse over the payments and the orders panel blacks out, and vice verse.
Plus I have tried googling this but no one seems to have the answer on other forums.. Everyone gets confused and the thread ends short with no solution. Apparently though experts-exchange has the answer, but wants me to pay... so no. Wish their site would stop showing up in my google results.
But did have an idea of what I could do. My best guess was I could take a snap shot of just the panel I want to black out. Set it as the background image for that panel THEN use my overlay panel(back color sent to black) overlapping the appropriate section with it's transparency set to half.. But still I'm not sure how to take a snap shot of just a particular.control..
Thanks in advanced! :)
Re: Transparent black overlay?
Re: Transparent black overlay?
Quote:
Originally Posted by
MattP
Good example, but still wouldn't be right for me. This is the most common way I've seen this done. Where they take a second form and place it over top the other and place it just right. Unfortunately there are many reason why I cannot do this or rather shouldn't do this. Mainly my application takes up the whole screen, the main form stays in the back and all other forms are set to top most to stay atop the main form. When having multiple forms set to top most still allows those forms to overlap each other as they normal would when given focus. Plus to have a form resize I would have to accommodated that as well.
I'm looking for something a little more simple to handle, something that would be similar to drawing under a paint event when indicated a certain panel needs to be blacked out.
Thanks though :)
Re: Transparent black overlay?
Have you looked at the form Owner property? It controls the Z order of forms in your program. An Owned form stays in front of the Owner and no other window can come between them. They minimize, maximize and close together. Ownership applies to forms displayed by the Show method (not ShowDialog or MDI). A given form can own multiple Owned forms., and you can organize a whole bunch of forms in tree fashion using the owner relationship. Besides the Owner property, there is the form's OwnedForms collection, the AddOwnedForm and RemoveOwnedForm methods, and the Owner argument to Form.Show.
BB
Re: Transparent black overlay?
Quote:
Originally Posted by
boops boops
Have you looked at the form Owner property? It controls the Z order of forms in your program. An Owned form stays in front of the Owner and no other window can come between them. They minimize, maximize and close together. Ownership applies to forms displayed by the Show method (not ShowDialog or MDI). A given form can own multiple Owned forms., and you can organize a whole bunch of forms in tree fashion using the owner relationship. Besides the Owner property, there is the form's OwnedForms collection, the AddOwnedForm and RemoveOwnedForm methods, and the Owner argument to Form.Show.
BB
hmmm honestly I haven't heard a lick about this until now. I'll h ave to do some experimenting because it sounds like it would allow me to remove my temporary fix. Which was to have my main form NOT set to top most, and all other set to top most. This gave the behavior of having the main screen remain behind all other included forms. While the forms themselves behaved normally with one another. This was a real tough situations I was trying to recreate, but with a few tricks up my sleeve I got it to work, but never intending to keep it permanently.
Regardless I kind of want to stay away from using another form to do this overlay. I'd really like it to be a panel that I could simply add to another panel. I still think taking a snap shot of the one panel I'm trying to cover(controls and all) and setting that image to said panels background. This would allow the panel I'm overlaying it with to grab the background image and apply it's transparency correctly. Giving it the experience of an overlay, even though what your seeing is the background image and not the controls.
Anyone know how to take a snap shot of a control, in my case a panel. Which would also capture the controls that may be contained within that panel?
Re: Transparent black overlay?
Quote:
Originally Posted by
boops boops
Have you looked at the form Owner property? It controls the Z order of forms in your program. An Owned form stays in front of the Owner and no other window can come between them. They minimize, maximize and close together. Ownership applies to forms displayed by the Show method (not ShowDialog or MDI). A given form can own multiple Owned forms., and you can organize a whole bunch of forms in tree fashion using the owner relationship. Besides the Owner property, there is the form's OwnedForms collection, the AddOwnedForm and RemoveOwnedForm methods, and the Owner argument to Form.Show.
BB
hmmm honestly I haven't heard a lick about this until now. I'll h ave to do some experimenting because it sounds like it would allow me to remove my temporary fix. Which was to have my main form NOT set to top most, and all other set to top most. This gave the behavior of having the main screen remain behind all other included forms. While the forms themselves behaved normally with one another. This was a real tough situations I was trying to recreate, but with a few tricks up my sleeve I got it to work, but never intending to keep it permanently.
Regardless I kind of want to stay away from using another form to do this overlay though :(. I'd really like it to be a panel that I could simply add to another panel. I still think taking a snap shot of the one panel I'm trying to cover(controls and all) and setting that image to said panels background. This would allow the panel I'm overlaying it with to grab the background image and apply it's transparency correctly. Giving it the appearance of an overlay, even though what your seeing is the background image and not the controls.
Anyone know how to take a snap shot of a control, in my case a panel. Which would also capture the controls that may be contained within that panel?
Re: Transparent black overlay?
Quote:
Originally Posted by
DavesChillaxin
Anyone know how to take a snap shot of a control, in my case a panel. Which would also capture the controls that may be contained within that panel?
Control.DrawToBitmap:wave:.
BB
Re: Transparent black overlay?
Quote:
Originally Posted by
boops boops
Control.DrawToBitmap:wave:.
BB
Seems simple enough, thanks!
I'll update here later to announce if it worked or not.
1 Attachment(s)
Re: Transparent black overlay?
So if anyone is interested still, I got it to work. Pretty well too. :)
If anyones truly interested then I'll throw together a quick project. But for now I'm going to attach a snap shot of what it looks like.
Note this is without a secondary form, but rather just a panel you add to the parent form your going to overlay completely or partially.