So, I've been experimenting with child windows in WPF, using SetParent, and trying to set up some transparency on the child window. It looks like I've got a bit of a catch-22.
If I set the child's WindowStyle = None, as it seems is required for transparency, I cannot move/resize the child correctly. If I don't set the WindowStyle, I can't get transparency.
Does anyone have any ideas on either how to move/resize the child window correctly, when it's WindowStyle = None, or to get transparency without WindowStyle = None?
The parent window and child window are in separate processes. I am running on Windows 7. I am happy to use WinApi calls, language is in C#.
I should note that the user should not be able to reposition or resize the child window directly. The child window gets resized when the parent window is resized, so that the size of the child is alwasy relative to the size of the parent window.And, because the parent and child window are in separate processes, I am using SetWindowPos to resize the child window.
The example
https://github.com/Hexum064/TransparentChild
Related
I have a main WPF window. (henceforth, parent window). In this parent window I have a button. When button is clicked I open a custom messagebox window (henceforth, child window) in a position within parent window. When opening child window I pass as an argument the parent window, and another argument to indicate the child window where I want to locate it. Then within child window, according these parameters passed as arguments, I do some calculations based on the Top and Left coordinates of the parent Window.
I have seen that when parent window is maximized, then its Top and Left coordinates are not being updated, they are the same, I mean they keep unchanged keeping last values before parent window is maximized. Why?
As a result of this, when doing some calculations using Parent.Top and Parent.Left from child window, it is making my logic failing.
How can I obtain correct Parent.Top, Parent.Left and others like Parent.Height and Parent.Width from child window logic?
I use Visual Studio 2008 and NET 3.5 SP1.
Does anyone at all know how to get C# GUI programs to automatically open maximized and fit correctly in whatever screen resolution is on the computer?when I run and maximize the application the tablepage(Control) is not maximize and as well as other controls.please help me with details...
Use the WindowState property: https://msdn.microsoft.com/en-us/library/system.windows.forms.form.windowstate(v=vs.110).aspx
Set the property to Maximized before you show the form.
If you want your controls to resize with the window, use the Anchor and Dock properties in the Forms Designer.
Use Anchor to have a control's edge be a fixed distance from a given edge, and use the Dock property to have a control fill an area.
When I set the main window's visibility to hidden, No icon is shown in taskbar, so I have no control over the window to show it again. I want for the application's icon to be visible even when I hide the window, and to show the window when I click it's button in the taskbar. (something like minimize behavior)
How can I achieve that using WPF and .Net 4.0 in C#?
Edit: I mean the icon in taskbar (usually in the left and middle of the horizontal taskbar) not the notifyicon in system tray.
So, based on "comments" section, what you are looking to do is minimize or hide a window but still show some windows or dialogues that the window opens. First if you want to keep your window in the task bar, you should minimize with:
this.WindowState = WindowState.Minimized
That can be called from anywhere within the form. As you mentioned, though, this will close hide any dialogues that have this window set as the parent. The key, then is to not use this window as the parent. Lets say your dialogues inherit from form. You want to use:
newWindow.Show();
I am guessing that you are calling "ShowDialog", which ties the window state to the parent window state. Try this out and hopefully it will help!
Edit
One more note: the same is actually true of MessageBoxes, but the way to control the parent form is with the first parameter of the MessageBox.Show() call. If you pass in a form as the first parameter, that will be the parent, otherwise the parent will not be set.
I am working with wpf c#, I set the visibility of the child window to hidden on closing. But when I minimized the parent window, or clicked on the parent window from taskbar, there comes a shadow like window of the hidden child window.How can I avoid this.
Try to use Visibility.Collapsed instead of Visibility.Hidden
I have created a window in C# by win api. And made it as child to another window. This parent window is an external program and I don't know its source code.
When i move my window inside parent window some parent's elements draw itself on my window.
For, better understanding i've made some screens.
This is before I move my window. My window is gray.
And this one is after moving my window over the "SeatOpen" button.
I have no idea how parent window can draw on my window.
So, why this is happening and how to fix?
The parent window is not drawing on your window... you are failing to draw on your window yourself -- your window is not responding to WM_PAINT messages for some reason so whatever garbage was on the screen remains there.
Try to redraw your window when location is changed and it is over Seat Open button.