I am implementing an application, and when you start this application, you have a main screen maximized over the whole screen, but also a popup appears. I want that as long as my pop up isn't closed, the user can't do anything in the main screen behind this popup (like when you have an error message or something)? It is probably some property but can't find it out. Someone who can help me out please? I am working in WPF and C#.
Popups are not not meant for this sort of thing i think. You can just use a normal Window and ShowDialog to get a modal popup. If you don't want the frame and everything you can style it respectively by setting AllowsTransparency to true and WindowStyle to None.
Related
i got a problem with a wpf application. I got a checkbox to set the window always on top, but when i activate the checkbox and set TopMost = true not only my window gets in front, also the taskbar.
My problem is, my application should stay in front of another fullscreen application. This means, only the window should be in focus, not the taskbar.
I found a solution with hiding the taskbar completely as soon i active TopMost... but this is not a satisfying solution, because the taskbar is also hidden, when I use my tool without the fullscreen application.
Summary:
- setting the application window always on top with my checkbox
- with my fullscreen application running, there should be no focus on the taskbar
- when running without the fullscreen application, the taskbar should be shown without focus.
I hope somebody can help me and thanks for your attention.
best regards,
Simon
I'm not sure if it works, but you can try this: disable the Taskbar-Icon for your TopMost-App.
Another workaround would be to let the taskbar always slide out of view (its a taskbar setting)
I have a CefSharp browser added as a control to a WinForms panel. This is fine on first load - the browser works as expected.
This application is regularly minimized to the taskbar, which is done by calling hide() and show() on the form. This works fine for the form, and worked fine with an embedded Internet Explorer browser (the default WebBrowser control)
However, when I hide/show the form, the CefSharp browser doesn't seem to be re-drawn along with the Form. Right clicking where the browser should be shows the Form's context menu, rather than the browser's context menu, which suggests to me the browser is not attached to that form, rather than the webpage within the browser is being incorrectly drawn.
I initially assumed that it was being invalidated and needed to be redrawn, and have tried a variety of Show, Invalidate, Refresh, Update method calls on the Form, the Panel, and the Browser itself. I've also tried clearing the panel controls and adding the browser again... none of these things seem to work.
When debugging, the browser object is present, has the same URL and parent, is still showing "fill" as the dock mode, has sensible looking height/width sizes etc, so it doesn't look as though it's been detached in some way from the parent etc, it's just not being re-drawn when the form is shown again
Is there a "correct" method for hiding and showing a form containing a CefSharp browser, or some other way of forcing the browser to redraw, that I'm missing?
So here's my own solution, found with some help from Çöđěxěŕ in the comments (who also points out that using Show() and Hide() is not the correct way to show/hide a form at all, instead use WindowState)
In my case, the problem arose from use of Form.ShowInTaskbar
When setting Form.ShowInTaskbar to False (eg don't show the icon for my app when I've just minimized it to the taskbar tray), the browser control seems to get confused about which form is the parent, which appears to be related to the Form.Handle changing.
My solution was to set ShowInTaskBar as false on application load (so the application is never in the taskbar) or not to set it to false on minimize (so it is always in the taskbar when minimized to the system tray). Neither of these are an ideal solution, but they work with the caveat that you have to have the app always hidden, or never hidden.
Presumably it would be possible to re-assign the parent properly on maximize
Use
this.WindowState = FormWindowState.Maximized;
Please see the scrrenshot
How to implement, using WPF, notifications mechanism similar to what eg. Chrome has?
By which I mean: custom content pop-up, displaying especially when my main application window is minimized.
Things I have tried out so far:
WPF Popup class with StaysOpen property set to true. Seems okay, except that it disappears when I minimize the main window.
Custom template window: well, it's a window, so it appears as another application window in the taskbar, which I'd like to avoid.
I am trying to get the image of a window. All I have is its window handle. One possible solution is given here. The problem is that it only works when the window is completely visible. In case the window is partially visible, or hidden behind another window, the CopyFromScreen() method does not give the required result.
I am looking for a solution other than to make the window visible by making it the topmost window and then returning back to is position. The reason being, I have to capture the image frequently and for multiple windows. This will make the the screen to flicker continuously.
I want to send keys to a show dialogue form from another inactive form.See the picture
Form a is showing dialogue.Behind is another form which has a customized keyboard and numpad.
I simply send keys against these button clicks.
How is it possible that I can send keys from keyboard to show dialogue form.
What you're asking is essentially impossible. Once you understand how modal dialogs work (forms that are shown using the ShowDialog method are modal), you will understand why. A modal dialog is used when you want to force the user to interact only with that dialog. It prevents them from interacting with any other windows in your application by disabling those windows. They become impervious to mouse clicks, don't receive keyboard input, and can't receive the focus. Windows beeps at you and flashes the title bar of the modal dialog when you try, it's non-subtle way of shaking its head and saying "no, no, no".
So what's going on here is that when you show your "Deposits" form as a modal dialog using the ShowDialog method, all of the other windows in your application are disabled. In your particular case, that means the window that contains your on-screen keyboard is disabled, too, and can't receive mouse click events. That's why nothing is happening when you try to click on its "keys" (buttons).
The easiest workaround (as I suggested in a comment) is to show your "Deposits" form as a non-modal dialog using the Show method instead. Unlike a modal dialog, this will not disable other windows in your application, allowing the user to interact with all of them at once. Clicking on another window will set focus to that window and allow it to process input events. But you say this isn't workable for you, because you want the "Deposits" form to disable every control on your main window, but not your on-screen keyboard.
Of course, I lied at the beginning when I said it was "impossible". What I meant is that is that it's very tricky, and will require you to work around the standard Windows interactivity model. A couple of ideas
on how you might go about doing that spring to mind:
You could use the On-Screen Keyboard utility that is included with all recent versions of Windows. Microsoft already provides a program for this purpose. You don't have to build and maintain your own, it already includes all the necessary logic to prevent it from stealing the focus when the user clicks on one of its "keys", and since it isn't part of your program, it won't be disabled when you show forms as modal using the ShowDialog method. To check it out, go to Start -> Run and type osk.
For example, in Windows 7 it looks something like this:
If you insist on using your own, custom-designed on-screen keyboard, you will have to show it as a child window of your modal dialog. That is, your application starts with its main form, per usual. Then, when you show the "Deposits" form as a modal dialog using the ShowDialog method, the main form gets disabled. From the "Deposits" form, you can then show the on-screen keyboard form using the non-modal Show method. The main form is still disabled, because it's showing a modal dialog (the "Deposits" form). But the "Deposits" form is not disabled, because it's showing a non-modal dialog (your on-screen keyboard).