“Suresh Kumar” <skavula@nordson.com> wrote in message
news:cea5lj$1k4$1@inn.qnx.com…
On Base Window I created Button, in this button Activate callback
function, I written code like this:
ApCreateModule (ABM_NewWindow, NULL, NULL)
sleep(2);
By this iam able crate NewWindow, but this NewWindow apperaing
after
2 seconds dalay.
Does the window have a frame? I would expect the frame to show up before
the sleep(), but the window’s contents after.
What is happenning is that ApCreateModule() creates and realizes the widgets
and then returns. The widgets haven’t drawn anything at this point –
they’re just marked as “damaged”, which will cause them to draw as soon as
the global “hold count” goes to zero (take a look at PtHold() in the docs).
The Photon library increments the hold count before invoking any callback
and decrements it after the callback returns – this way, all the widgets
that a callback modifies or creates draw just once, right after the callback
returns, even if the callback modifies a widget several times. (Think about
a callback that changes a widget’s background colour, then size, then font,
then text colour, and finally the text. If each of those changes caused the
widget to draw its new state to the screen right away, it would look pretty
bad.)
If you need to force a damaged widget to draw regardless of the hold count,
call PtFlush(). But it’s somewhat heavy-handed – it causes all the
damaged widgets in your application to draw.
(In case you wondered: the reason the window frame doesn’t pay attention to
your hold count is because it’s the window manager, not your application,
that draws it.)
But I want display first NewWindow and then 2 seconds delay. For
this what should i do, and what are the flags i need to select?
Calling PtFlush() before the sleep() should make the window draw right away;
but in general, using sleep() in a single-threaded Photon application is not
a good idea. During those two seconds, the application will do literally
nothing – it won’t react to user input, it won’t redraw itself if you drag
a window in front of it or switch consoles, and so on. It’s better to set
up a timer widget and do whatever you wanted to do after the delay in the
timer’s callback. If you don’t want the person to click on any buttons
during the two seconds, block the window (using the Pt_BLOCKED flag) – this
way it will ignore any user input but will redraw when necessary.