I'm updating an old ScreenSaver that I wrote in VB6 to VB.net 2010 I initially used a windows forms application that worked fine until the preview screen. Loading the application into the preview screen (or other application like notepad) using the code:
Public Sub SetForm(ByRef frm As Form, ByRef arg As String)
Dim style As Integer
Dim preview_hwnd As Integer = Integer.Parse(CType(arg, _
String))
Dim r As New RECT
GetClientRect(preview_hwnd, r)
With frm
.WindowState = FormWindowState.Normal
.FormBorderStyle = FormBorderStyle.None
.Width = r.right
.Height = r.bottom
End With
style = GetWindowLong(frm.Handle.ToInt32, GWL_STYLE)
style = style Or WS_CHILD
SetWindowLong(frm.Handle.ToInt32, GWL_STYLE, style)
SetParent(frm.Handle.ToInt32, preview_hwnd)
SetWindowLong(frm.Handle.ToInt32, GWL_HWNDPARENT, _
preview_hwnd)
SetWindowPos(frm.Handle.ToInt32, 0, r.left, 0, r.right, _
r.bottom, SWP_NOACTIVATE Or SWP_NOZORDER Or SWP_SHOWWINDOW)
End Sub
freezes the parent window and there is no input to the launched form.
Switching to a console app and using
Dim scrsvr As New frmScr
scrsvr.Preview = True
SetForm(scrsvr, args(1))
Application.Run(scrsvr)
fixed most of the problem, but the form/screensaver still doesn't accept keyboard input, either when in the preview screen or running as a full screen screensaver without running "setform". Interestingly, the configuration screen runs fine when launched from the console app.
In VB.net 2010, the only options seem to be running an app either from a form (forms application) or from the console(Console app). In VB6 we could run a forms app yet start from a Sub Main.
Any help is appreciated.