Click here to Skip to main content
15,908,455 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Save Variable Values to a file and start another application when unhandled error occurs Pin
Eddy Vluggen2-Dec-09 4:11
professionalEddy Vluggen2-Dec-09 4:11 
GeneralRe: Save Variable Values to a file and start another application when unhandled error occurs Pin
Mehdi Ghiasi2-Dec-09 4:38
Mehdi Ghiasi2-Dec-09 4:38 
GeneralRe: Save Variable Values to a file and start another application when unhandled error occurs Pin
Eddy Vluggen2-Dec-09 5:27
professionalEddy Vluggen2-Dec-09 5:27 
QuestionHow to create a form that is modal to the desktop? Pin
dileep20091-Dec-09 1:27
dileep20091-Dec-09 1:27 
AnswerRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak1-Dec-09 4:37
mveDave Kreskowiak1-Dec-09 4:37 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20091-Dec-09 4:42
dileep20091-Dec-09 4:42 
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak1-Dec-09 4:56
mveDave Kreskowiak1-Dec-09 4:56 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20091-Dec-09 5:23
dileep20091-Dec-09 5:23 
Dave,

Appreciate your help...

i am able to create a new desktop and show a msgbox onto it, however i am unable to show a form in the new desktop, the form is displayed in the original desktop.

below is the code i am using ...
(this is working wonderfully....)

<DllImport("user32.dll")> _
    Private Shared Function CreateDesktop(ByVal lpszDesktop As String, ByVal lpszDevice As IntPtr, ByVal pDevmode As IntPtr, ByVal dwFlags As Integer, ByVal dwDesiredAccess As Integer, ByVal lpsa As IntPtr) As IntPtr
    End Function
    <DllImport("user32.dll")> _
Public Shared Function SetThreadDesktop(ByVal hDesktop As IntPtr) As Boolean
    End Function
    <DllImport("user32.dll")> _
    Public Shared Function GetThreadDesktop(ByVal dwThreadId As Integer) As IntPtr
    End Function
    <DllImport("kernel32.dll")> _
    Public Shared Function GetCurrentThreadId() As Integer
    End Function
    <DllImport("user32.dll")> _
    Public Shared Function SwitchDesktop(ByVal hDesktop As IntPtr) As Boolean
    End Function
    'desktop
    Public Const DESKTOP_CREATEWINDOW As Integer = &H2
    Public Const DESKTOP_ENUMERATE As Integer = &H40
    Public Const DESKTOP_WRITEOBJECTS As Integer = &H80
    Public Const DESKTOP_SWITCHDESKTOP As Integer = &H100
    Public Const DESKTOP_CREATEMENU As Integer = &H4
    Public Const DESKTOP_HOOKCONTROL As Integer = &H8
    Public Const DESKTOP_READOBJECTS As Integer = &H1
    Public Const DESKTOP_JOURNALRECORD As Integer = &H10
    Public Const DESKTOP_JOURNALPLAYBACK As Integer = &H20
    Public Const AccessRights As Integer = DESKTOP_CREATEWINDOW Or DESKTOP_SWITCHDESKTOP
    Public Const MB_SERVICE_NOTIFICATION As UInteger = &H200000
    Private Sub CreateNewDesktop()
        'Get the current desktop
        Dim _hOrigDesktop As IntPtr = GetThreadDesktop(GetCurrentThreadId())
        'create our desktop
        Dim _hNewDesktop As IntPtr = CreateDesktop("MyDesktop", IntPtr.Zero, IntPtr.Zero, 0, AccessRights, IntPtr.Zero)
        ' set the thread desktop
        SetThreadDesktop(_hNewDesktop)
        SwitchDesktop(_hNewDesktop)
        'MessageBox.Show("test", "test", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification)
        Form2.showdialog() 'this is not shown in the new desktop 
        SwitchDesktop(_hOrigDesktop)
        SetThreadDesktop(_hOrigDesktop)
    End Sub


is there something i am missing out...Also is there a way to get all the processes in the original desktop to the new desktop just to imitate the original one..
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak1-Dec-09 5:36
mveDave Kreskowiak1-Dec-09 5:36 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20091-Dec-09 21:51
dileep20091-Dec-09 21:51 
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak2-Dec-09 0:55
mveDave Kreskowiak2-Dec-09 0:55 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20092-Dec-09 1:04
dileep20092-Dec-09 1:04 
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak2-Dec-09 1:19
mveDave Kreskowiak2-Dec-09 1:19 
GeneralRe: How to create a form that is modal to the desktop? Pin
Eddy Vluggen1-Dec-09 7:23
professionalEddy Vluggen1-Dec-09 7:23 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20091-Dec-09 21:44
dileep20091-Dec-09 21:44 
GeneralRe: How to create a form that is modal to the desktop? Pin
Eddy Vluggen2-Dec-09 0:48
professionalEddy Vluggen2-Dec-09 0:48 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20092-Dec-09 1:10
dileep20092-Dec-09 1:10 
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak2-Dec-09 1:20
mveDave Kreskowiak2-Dec-09 1:20 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20092-Dec-09 3:33
dileep20092-Dec-09 3:33 
GeneralRe: How to create a form that is modal to the desktop? Pin
Eddy Vluggen2-Dec-09 4:19
professionalEddy Vluggen2-Dec-09 4:19 
GeneralRe: How to create a form that is modal to the desktop? Pin
Dave Kreskowiak2-Dec-09 4:31
mveDave Kreskowiak2-Dec-09 4:31 
GeneralRe: How to create a form that is modal to the desktop? Pin
Eddy Vluggen2-Dec-09 2:07
professionalEddy Vluggen2-Dec-09 2:07 
GeneralRe: How to create a form that is modal to the desktop? Pin
dileep20092-Dec-09 3:32
dileep20092-Dec-09 3:32 
GeneralRe: How to create a form that is modal to the desktop? Pin
Eddy Vluggen2-Dec-09 4:07
professionalEddy Vluggen2-Dec-09 4:07 
QuestionWorking with AsyncOperations Pin
Jeroen De Dauw30-Nov-09 8:04
Jeroen De Dauw30-Nov-09 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.