I was wondering if there is an easy way of creating a PopUp Dialog Box in a QNX Project using PhAB.
What I need is a PopUp Dialog to appear on screen when a certain event or alarm is raised in my program.
I figure I can build the whole thing from code and dynamically generate the dialog box, but I was wondering if there is an option in PhAB for this kind of action.
Sure… sorta. The dialog itself can be generated in PhAB. The event itself is a little trickier, but basically drop a timer on your base window and check for the event in the timer’s activate callback. When the event happens call ApCreateModule(). In PhAB, make sure you create a link (Project → Internal Links) to define the location & setup function.
To summarize:
In PhAB, create dialog and it’s internal link, and create a timer on the base window.
In code, watch for the event in the timer callback and call ApCreateModule().
I’ve modified your solution a little. Instead of having a timer cicle every x seconds, I’ve setup signal handlers that receive signals when a pop-up is required. Signal hanlders work great, but I’m crashing when I call ApCreateModule (ABM_Stuff, NULL, NULL). It sucks because the debugger doesn’t seem to be able to step through the signal handler.
Ah well, can’t have all I want I guess. I’ll keep on working on this signal stuff, but if I start running around in circles, I may just use a timer afterall!
Ok, step two… I want the popup box to beep when it appears. Should be simple, yes?
I basically added printf("\a"); before I call ApCreateModule(), but no sound… So I figure I did something wrong, and when I close the application I hear a beep.
So I try different things, moving the printf around, adding another, adding text after \a… nothing seems to get the system to beep until I shut down the app.
Well, turns out the /a works fine, as long as a terminal window is open. If I close the terminal window I’ve started the app in, I no longer hear beeps.
So now I figure I might want to play a wave file instead of just a simple beep, and was wondering if anyone knew if there is an easy way to do so?
It’s not printf that is the problem, but rather the behavior of stdout.
A friendly snipe at Mario: Do you think you will hear the beep faster if you send the “\a\n” via puts rather than printf, .
In that case you don’t need the putc() because fclose will flush it for you.
Hey Mitch, lol! I jumped on the occasion to mention puts, because I recently wrote some benchmark program to evaluate performance of printf, sprintf, puts and their C++ counter part cout, strstream stringstream.
I was amazed to see that puts was almost 10 times faster then printf. That’s understandable because puts doesn’t have to parse the string to look for format (%…).
I was also surprised to see that cout was also faster the printf ( almost as fast a puts ) and for the same reason; no parsing. It however makes the code bigger, each value use in the cout expression results in a call.
strstream, stringstream also proved much faster then sprintf even if they perform memory allocation.