winforms closing issue, vb.net - vb.net

i have a vb.net 2.0 winforms application.
When i open another application (like calculator ) have the focus to it and try to close my application the screen freeze and i have to use ctrl + alt + del to get it to refresh.
Any idea what can affect that?

If I understand your dilemma, somewhere you're sending SENDKEYS, and if you do not have focus and you SENDKEYs the app freezes.
Why not simply add a
if Me.Focus then SendKeys

Related

WinForms ShowInTaskbar=False vs Tabbing between applications

I have a WinForms application (VB.Net), where I have set ShowInTaskbar=False for all forms except the main form. This is because all other forms are dialog windows of some sort, and I did not want them to show up separately in the task bar.
What I see now is that when no dialog is open in my application and I use Alt+Tab keys to tab between currently open applications, I don't see a tile for my application. I do see a tile when there is a dialog open. This is very counter-intuitive to me.
As I said earlier, ShowInTaskbar property is true for my main form. What else is required? Thanks for your help!
After further research, I found that my problem was being caused due to having the form border as FixedToolWindow and ShowInTaskbar=False on the dialog windows. I changed the form border to FixedDialog, and set MaximizeButton=False, MinimizeButton=False. That fixed the issue.

How to determine which form controls the keyboard input on VB.net

I'm developing a VB.net windows application and I have some issues with the keyboard input.
My application has different forms and I'm showing and hidding them with the user interaction. One of the inputs comes from the keyboard, and here is where I have a problem.
When I hide a form and show the next one, most of the times the new-shown form does not receive the keyboard input until I click somewhere on it.
I assume that the problem is that the new form I'm showing is not the "selected application" for windows until the user interacts with it by clicking on it, but I don't know how to set this "property" by code.
I tried with focus and select on the whole form (Me.select/focus) and in some form's control (me.lbl_xxx.select/focus), but I did not get any result.
Can anyone explain me how to control which application/form gets the keyboard input on windows?
Thanks
David
You can't really interact with a label so the input focus won't be set properly.
Focussing a specific textbox on your form on the other hand should just work fine.

Copy / Paste functions not working on first load

I am having an issue with the Ctrl C / Ctrl V options working in a .net Control. This .net control has many textboxes and is called via COM Interop.
Program Flow:
VB6 application creates instance of .net control with the help of Interop Control Toolkit and VBControl Extender. A new tab is created in the code jock tab manager with the .net control as the body. The first time the control is loaded Control C / Control V operations do not work at all. If you close the tab then re-open the same exact control now Control C / Control V work correctly.
If you use the right click context menu to Copy / Paste then it does work.
I have checked Code Jock forumns and didn't find anything useful.
If you add a Key_Up event and capture the Copy that works fine. But we have many .net controls that would need to be changed and doing that for every text box seems like a bad hack. And I know it works without because it works on the second load.
do you open the tab exactly the same way when you open it the second time?
when you add a key_up event it does work on the first load? where did you add the key_up, on the tab or the .net control?
what exactly do you do in the key_up event? could you post the code?
my first guess was that it had something to do with the focus not being on the .net control or tab on first load, but that it has the focus on second load somehow ...

Triggering TAB key to shift control by vb.net coding

I am opening a web site in a vb.net 2008 webbrowser control. I want when I open the 3rd page of the web site then after the page is loaded , control focus programmatic-ly by Triggering TAB keypresses automatically by my code . Please tell me the solution to shift the focus control ?
I don't know if I have understood your question right, but you could try the following,
Keep track of whether you are on the third page in your web-browser control. If you are, you can execute a JavaScript function, which changes the focus of the text-fields.
Page.ClientScript.RegisteredStartUpScript(GetTypeOf(), "function_change_tabs", script, True)

Msgbox Wait until, VB.NET

Is it possible to have a Msgbox without a button on it in a console application. I would like to have a msgbox pop up and then disappear when the task has been completed. Or could I send the msgboxresult to some form of window that would just disappear when the file has been written?
MsgBox("The users on the domain are being gathered. A prompt will appear when all information has been gathered.")
Dim userFile2 As String = savefileDialog1.FileName & ".txt"
Dim fileExists2 As Boolean = File.Exists(userFile2)
Using sw As New StreamWriter(File.Open(userFile2, FileMode.OpenOrCreate))
For Each d As DirectoryEntry In de.Children()
sw.WriteLine(d.Name)
Next
End Using
If you want to have a console app with a GUI, I'd suggest that it might be easier to just make a WinForms app. Just create a new tiny WinForms app, make the default Form small as a dialog box and make it have only one invisible Close button.
Then you can just show the Close button when it's finished.
Just remember to disable the Control box on the Form (the X up in the top right hand corner) and handle any keyboard combination that could close it.
Edit: Or if for any reason you have to have it as a Console app, then you could still write a tiny separate app that just does the GUI part that you need and have the Console app start up the GUI app, sending over the text to display.
First, a quick point. A MsgBox is a modal dialog so will halt execution until the user responds, you can't use this.
In general "console" applications should be non-graphical.
You don't want to use a console application to disiplay a window. Since .Net 4.0 is available to you may want a WPF application that can write to the console.
There is a post about outputting to the console with WPF here on SO.
You should do your work on a different thread perhaps using a System.ComponentModel.BackgroundWorker. This will allow the Window to respond to user interaction and render while your task progresses.