Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi there, i've problem open new window on newly Created desktop. I can start a new application there:

I do:
C++
this->hNewDesktop = CreateDesktop(sDesktop.c_str(), NULL, NULL, NULL, WRITE_DAC | READ_CONTROL | DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_SWITCHDESKTOP, NULL);

SwitchDesktop(hNewDesktop);

HWnd hWindow = CreateWindow(TEXT("test"), TEXT("test"), WS_CAPTION | WS_BORDER | WS_VISIBLE, 0, 0, WindowWidth, WindowHeight, 0, 0, this->mParent, NULL); // hInstance

---
window appears on old desktop? - anyone some ideas - I can't find some information to open a window on new desktop - only to open a application there...

? THX
Posted
Updated 29-Jun-12 6:49am
v2
Comments
enhzflep 29-Jun-12 14:52pm    
Isn't the second window being created as a child of a window on the first desktop? If so, it doesn't really surprise me that such an effort would fail.

What happens if you replace this->mParent with NULL or HWND_DESKTOP?
talim 29-Jun-12 15:41pm    
no diffrence -> see my post below. It works, but not yet for MFC Windows....

With reference to your Solution 1, my advice is: Don't do it!

I have not had to start a new desktop and open windows in it, but many years ago, I was working on an application where we wanted to create windows and "move" the handling to separate threads. We ended up changing the design.

There are reasons why you are having problems getting this working in MFC. Although the link I have posted below is from a book on VC6, I believe the points are still valid.
Using User-Interface Threads[^]

You should create a separate UI thread and create your window from there once that thread is up and running.

Soren Madsen
 
Share this answer
 
ok - Create seperate Thread an Create new window there - now it works. but now there is a Problem with MFC CWnd --> Here there are some problems Creating a window in a different thread - someone a advise?

THX
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900