🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11254

Re: Problems using "SwitchDesktop"

#11254
From: Ted Byers
Date: Fri, 20 Feb 2004 21:15
65 lines
3485 bytes
>
> Make sure you are associating the correct desktop with the calling thread,
> and that you are not creating the form until after you have switched
> desktops.
>
OK.  Here is my new WinMain:

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  try
  {
    HDESK defaultDesktop, tempDesktop;
    defaultDesktop = GetThreadDesktop(GetCurrentThreadId());
    tempDesktop = CreateDesktop("GetItRightChild",
                                NULL,
                                NULL,
                                0,
                                DESKTOP_CREATEWINDOW |
DESKTOP_SWITCHDESKTOP,
                                NULL);
    BOOL rv = SetThreadDesktop(tempDesktop);
    rv = SwitchDesktop(tempDesktop);
     Application->Initialize();
     Application->CreateForm(__classid(TMainForm), &MainForm);
     Application->Run();
    rv = SwitchDesktop(defaultDesktop);
    rv = SetThreadDesktop(defaultDesktop);
    rv = CloseDesktop(tempDesktop);
  }
  catch (Exception &exception)
  {
     Application->ShowException(&exception);
  }
  return 0;
}

Alas, the behaviour with this is identical to my first attempt.  The desktop
is created and we switch to it, but my main form does not appear on it.  But
when I close, I see my form displayed on the original desktop.

Of the flags I can use:

DESKTOP_CREATEMENU Required to create a menu on the desktop.
DESKTOP_CREATEWINDOW Required to create a window on the desktop.
DESKTOP_ENUMERATE Required for the desktop to be enumerated.
DESKTOP_HOOKCONTROL Required to establish any of the window hooks.
DESKTOP_JOURNALPLAYBACK Required to perform journal playback on the desktop.
DESKTOP_JOURNALRECORD Required to perform journal recording on the desktop.
DESKTOP_READOBJECTS Required to read objects on the desktop.
DESKTOP_SWITCHDESKTOP Required to activate the desktop using the
SwitchDesktop function.
DESKTOP_WRITEOBJECTS Required to write objects on the desktop.

I know I need DESKTOP_CREATEWINDOW and DESKTOP_SWITCHDESKTOP, and that I
don't need DESKTOP_CREATEMENU, and probably not DESKTOP_ENUMERATE (but I am
not certain).  Would failure to use one of the other flags cause my problem,
or is there some other function I should be calling as well?  Or is there
something I ought to be setting in the default TApplication object?  Or, do
I have to go so far as to create a separate program that handles creating
and switching to the new desktop and then spawns my program as a child
process?

Thanks,

Ted
Technical Details
Message-ID: <403677f3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <403642b4$1@newsgroups.borland.com> <40366663$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,90c150c625365b29
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-20 13:41:09 PST
From: "Ted Byers" <r.ted.byers@sympatico.ca>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <403642b4$1@newsgroups.borland.com> <40366663$1@newsgroups.borland.com>
Subject: Re: Problems using "SwitchDesktop"
Date: Fri, 20 Feb 2004 16:15:27 -0500
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 65.95.240.180
Message-ID: <403677f3@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1077311475 65.95.240.180 (20 Feb 2004 13:11:15 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail