C# .net Sow Form on new Desktop.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RAJSPY
    New Member
    • Jan 2008
    • 18

    C# .net Sow Form on new Desktop.

    Hi all,

    I want to show my windows form on a new desktop.

    I kow you can start a new desktop with the [DllImport("user 32.dll")] commando.
    But I can't get the form on it. Has anyone got some code of this.

    Thanx
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    If you're using the resource from CodeProject such as this one then I'd imagine that you'd have to start a new process to the new desktop with a path to the .exe of the form. Here's a section from CodeProject.

    Originally posted by CodeProject
    The CreateProcess function in kernel32.dll takes a parameter of type STARTUPINFO, which has a parameter ("lpDesktop" ) which allows you to specify the desktop the process is to be created in. As a result, I chose to import this function, instead of using the .NET frameworks Process class, meaning reduced functionality when creating process, but I hope to resolve this in the next release. Now the code, this example shows the two ways of creating a process.

    // instance method

    Code:
    Desktop desktop = Desktop.OpenDesktop("myDesktop");
    Process p = desktop.CreateProcess("calc.exe");
     
    // static method
    
    Process p = Desktop.CreateProcess("calc.exe", "myDesktop");
    So, where " calc.exe" is, in the .CreateProcess parameter, replace it with the applications path that starts up the form. But you will need to be using this resource from CodeProject in order for it to work properly. Does this help?

    joedeene

    Comment

    • RAJSPY
      New Member
      • Jan 2008
      • 18

      #3
      Yeah that is one of the solutions but i figured that out already. I want to make a new desktop and run some code on it. The way you supose is in 2 steps.
      I want to bring this toghether in 1 step. 1 program 1 exe.

      Comment

      • dhpatel82
        New Member
        • Nov 2011
        • 1

        #4
        Show a form in new Desktop

        Originally posted by RAJSPY
        Yeah that is one of the solutions but i figured that out already. I want to make a new desktop and run some code on it. The way you supose is in 2 steps.
        I want to bring this toghether in 1 step. 1 program 1 exe.
        Hi Rajspy,

        Did you get any solution? I also have same kind of requiremen. so could you please help me ?

        Thanks

        Dhaval Patel

        Comment

        Working...