Today, I met a puzzling problem when I was writing a program that needs to handle exceptions. Now, I suspect that the callback functions in phab don’t behave well.
The following is the example code I wrote to test above mind.
int
doTest( PtWidget_t *widget, ApInfo_t *apinfo, PtCallbackInfo_t *cbinfo )
{
try
{
throw 0;
}
catch (…)
{
dispMessageBox(“exception caught”);
}
}
I just place a button in a plain window, and then define a callbackfunction(doTest@mainfrm.cpp) in mainfrm.cpp. Finally, I add above code.
After having compiled the program, I just run it. But, I can see nothing but the window disappear quickly form the screen.
Can you help me? Any effort will be appreciated. Thanks!
Appdix 1: The definition of dispMessageBox
int
dispMessageBox(const char* msg, const char* title)
{
char const* btns[] =
{
“确定”,
“退出”
};
char font[MAX_FONT_TAG];
return PtAlert(NULL, NULL, title, NULL, msg,
PfGenerateFontName(“Simsun”, 0, 11, font),
2, btns, NULL, 1, 2, Pt_BLOCK_ALL);
}