Form behaviour in windows compact framework - c#

I am altering an existing windows compact framework application and i did most of the part and i noticed the different behavior of the form.
Consider i am Opening my application, "ApplicationForm" is the main form and on clicking Next button in ApplicationForm another form say "NextForm" will open.I am using below code to open the NextForm.
NextForm obj = new NextForm();
obj.Showdialog();
Now NextForm screen is in open and at this time if I open FileExplorer in device,FileExplorer will open.Now if i Open my installed application from device from Start menu,the application opens with the last open Form say NextForm.It will show NextForm in screen but from here if i click Back button in NextForm it is taking me to FileExplorer.Actually it should take me to ApplicationForm and it works fine when FileExplorer is not opened.
1.I need to navigate to ApplicationForm if i click Back button in NextForm even if FileExplorer is opened in the above scenario.
2.Is it possible to set like this,even the application is opened and the user is in any say NextForm form,when user click application from Start menu it should open the ApplicationForm(which is the Main form) and all other form(NextForm) should close automatically.
Is it possible to solve this issue.

Related

Winforms ShowDialog(this) blocks the switching windows of other applications to the foreground

When I open any dialog in my Winforms application then Windows 10 behaves oddly in these ways:
ALT-TAB no longer displays the list of windows
I cannot switch to hidden applications using taskbar icons - if I select a taskbar icon of a window that is not currently visible (even if it is not hidden by the winforms app) the icon just flashes and then stays highlighted, but is not brought to the foreground. I can use other applications that are visible. As soon as I close the dialog form the other I can use the windows of other applications correctly
If I switch to the application window that is behind the winforms application by clicking on it, I cannot go back to the winforms app either by ALT-TAB or by clicking on the taskbar icon. I can get back to it by minimizing the other application
I'm opening the dialogs with
dialogFormName.ShowDialog(this);
TopMost is set false on all forms and is not set in the code.
I've read about 50 related articles and the only problems seem to be either TopMost is set or ShowDialog is not called with the parent form. I'm not a regular Winforms developer so I'm probably doing something stupid. This is driving me crazy, so I'd really appreciate any help!
Edit: The same issues occur with MessageBox.Show(this, "test"). The issue does not occur with a newly created app just with a single button calling MessageBox.Show(this, "test"). The problem application uses EntityFramework but no other packages and the problem existed before I added EF.
After trying different scenarios I eventually found the issue. In my case I was calling ShowDialog() after a user clicks an item on a ContextMenu. The blocking of ALT-TAB was caused by the following code that attached the ContextMenu to the ListView that the menu was contextually for:
lstList.ContextMenu = myContextMenu;
As soon as I removed that association, the ShowDialog no longer blocked ALT-TAB.
Form.ShowDialog() blocks the parent form until it's closed.
Use Show() to display the form separately without blocking its parent.

VS2012 C# - vshost32 has stopped working

I have a windows form application which is basically a PDF viewer. I used the Adobe PDF Viewer COM component for this project.
The program works but I'm having an issue when I click the close button on the top right of the form after I open a pdf file. When I click the close button, VS does not exit the 'run'-mode and I have to manually click the 'stop' button on VS. And when I press the stop button, a window pops saying "vshost32 has stopped working".
However, this does not happen when I run the application and close it without opening a pdf file.
Any idea why this happens?
You may have manually release the COM object by using Marshal. See this link: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx
The vshost32.exe is related to designer-simulation tasks in window forms, so try creating a new project then improt your classes from the old one.

Change the Opening Window in Visual Studio

I am making an application, but silly me I made the main application in the Main Window, but I need to make an opening screen with a start button which opens the main application, any help?

WPF Application not opening when clicking on the Desktop Icon

I am developing a Wpf application. On installing my application, shortcut icons are created in the desktop and the program menu.
When i click the desktop icon for the time, my application opens. Now i minimize my application in the tray/task bar. On clicking my desktop icon, my application is not maximized. It still minimized in the tray/task bar. For ex, you can take a look at Skype, adobe reader etc..
Requirement - where ever the application icon is present in the PC such as desktop or program menu or etc., my application should be maximized when the user clicks the shortcut icon.
A desktop link will open a new application every time you click on it. If you want your application to open only once and change position/size of the original one once you start a new one, you will have to do this yourself:
Once you application starts, check if another version is already running.
Send your running application a message.
End itself.
If there was no other application started, run normally and liste for the message.
On arrival of the message, check if minized and if so, maximize (or change size/position to whatever you need).
Try to implement it and if you have a very specific problem with any of the steps, come to SO and ask a very specific question about it :)

windows mobile releasing resources when application is closed (.net 3.5 cf)

I have a basic .net 3.5 cf application with 4+ forms. I am using a window handler class that I created to make sure that certain forms only have one instance open at a time where as other (Product Details for example) can be opened as many times as the user wants. My problem lies in the fact that when the user closes all the forms (By clicking the "x" on the form rather than the "exit" button in the menu) that the application does not release the database connection. In addition to this if the user closes all the forms and then opens the app up again their previous search results are shown rather than a new form. How can I make sure to release all resources when the user closes all the forms??
The (X) button is a minimize button, not a Close button. You need to eitehr change the MinimizeButton on the Forms to false - which changes the (X) to an (ok) - or add logic to handle cases where all Forms get minimized.
Be aware that on Windows Mobile that clicking the 'X' is more like minimizing a window than closing it. It definitely won't exit the application, and may actually literally perform a minimize rather than a close on the form (I can't remember for sure)
So when they're "opening up the app again", it's likely it's just re-showing the same form.

Categories