Subj : Re: want to execute code as soon as application is run To : borland.public.cpp.borlandcpp From : Simon Hearn Date : Wed Jul 20 2005 03:06 am Thanks for this, I'll give it a go and get back to you soon. Simon "Ed Mulroy" wrote: >As I remember it, the SetupWindow function runs when the WM_CREATE message >is received, during the CreateWindow call. That is before the window is >completely constructed so before it is displayed. > >Programs that need to do something immediately following the end of the >window creation often do it by performing a PostMessage to the same window >as the last item in WM_CREATE. That makes it the last item in the >SetupWindow function. > >The message used depends upon the application. Many don't use a timer so >just post a WM_TIMER message and let the code respond to it. Others call >RegisterWindowMessage and use that value for the message. Still others use >something like WM_USER+100 for the message. > >. Ed > > >> Simon Hearn wrote in message >> news:42dd3fc2$1@newsgroups.borland.com... >> >> I'm trying to execute a piece of code that displays a dialog >> box with two buttons, on of which is cancel - exits the >> program. I need this code to execute as soon as the application >> in run and the window is displayed. >> >> At the moment the code is in the SetupWindow() function, >> which works ok. But it's actually run before the window is fully >> created. So when I hit cancel, the application quits, but I get >> an error (an exception from the TXWindow function) saying >> the window was not created properly (because I destroyed it >> before it was fully created). >> >> So, I either need to stop this error message appearing thus >> achieving a quiet exit. Or I need to place the code after the >> window is fully created. >> >> I don't know how to do either of these so can anyone help >> me out? > > .