|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
En:Welcome to the "Foxgui-announce" mailing listHi,,
I am leraning FOX, and I have one problem with this source code(I had put "onCmdMove" function), that causes one error when I quit the program. Someone could help me? #include "main_fox_app.h" #include "signal.h" // Message Map for the Main Window class FXDEFMAP(MainWindow) MainWindowMap[] = { //________Message_Type_____________ID_____________Message_Handler_______ FXMAPFUNC(SEL_SIGNAL, MainWindow::ID_QUIT, MainWindow::onCmdQuit), FXMAPFUNC(SEL_COMMAND, MainWindow::ID_QUIT, MainWindow::onCmdQuit), FXMAPFUNC(SEL_COMMAND, MainWindow::ID_MOVE, MainWindow::onCmdMove), FXMAPFUNC(SEL_COMMAND, MainWindow::ID_ABOUT, MainWindow::onCmdAbout), FXMAPFUNC(SEL_KEYPRESS, 0, MainWindow::onKeyPress), }; // Macro for the MainWindow class hierarchy implementation FXIMPLEMENT(MainWindow, FXMainWindow, MainWindowMap, ARRAYNUMBER(MainWindowMap)) // MainWindow constructor MainWindow::MainWindow(FXApp *app) : FXMainWindow(app, PROJECT_NAME, 0, 0, DECOR_ALL, 0, 0, 700, 500) // : FXMainWindow(app, PROJECT_NAME, 0, 0, DECOR_NONE , 300, 450, 800, 600) // without title bar { // Load the application icons. // FXXPMIcon *bigicon, *smallicon; // bigicon = new FXXPMIcon(getApp(), app_xpm); // smallicon = new FXXPMIcon(getApp(), app_small_xpm); // setIcon(bigicon); // setMiniIcon(smallicon); FXMenuBar *menubar; FXToolBarShell *dragshell1 = new FXToolBarShell(this, FRAME_RAISED); menubar = new FXMenuBar(this, dragshell1, FRAME_RAISED|LAYOUT_SIDE_TOP|LAYOUT_FILL_X); new FXToolBarGrip(menubar, menubar, FXMenuBar::ID_TOOLBARGRIP); FXStatusBar *statusbar; // statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER|FRAME_RAISED); statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED); filemenu = new FXMenuPane(this); new FXMenuCommand(filemenu, "&Quit\tAlt-F4\tClose this program.", 0, this, ID_QUIT); movemenu = new FXMenuPane(this); new FXMenuCommand(movemenu, "&Move\tAlt-F5\tmove the window.", 0, this, ID_MOVE); helpmenu = new FXMenuPane(this); new FXMenuCommand(helpmenu, "&About...\t\tShow information about " PROJECT_NAME ".", 0, this, ID_ABOUT); new FXMenuTitle(menubar, "&File", 0, filemenu); new FXMenuTitle(menubar, "&Move", 0, movemenu); new FXMenuTitle(menubar, "&About", 0, helpmenu); } // MainWindow destructor MainWindow::~MainWindow() { // Delete all menu panes delete filemenu; delete helpmenu; } // Create MainWindow and initialize void MainWindow::create() { FXMainWindow::create(); } // Create MainWindow and initialize long MainWindow::onCmdMove(FXObject *, FXSelector, void *) { FXMainWindow::move(35,50); return 1; } // Quit command called long MainWindow::onCmdQuit(FXObject *, FXSelector, void *) { getApp()->exit(0); return 1; } // About command called long MainWindow::onCmdAbout(FXObject *, FXSelector, void *) { FXDialogBox about(this, "About " PROJECT_NAME, DECOR_TITLE|DECOR_BORDER, 0,0,0,0, 0,0,0,0, 0,0); FXVerticalFrame *contents = new FXVerticalFrame(&about, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0, 10,10,10,10, 0,0); new FXLabel(contents, PROJECT_NAME " Version " PROJECT_VERSION ".\n\n" PROJECT_COPYWRITE "\n\n" "This software uses the FOX Toolkit Library (http://www.fox-toolkit.org).\n", 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); FXButton *button = new FXButton(contents, "OK", 0, &about, FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X, 0,0,0,0, 32,32,5,5); button->setFocus(); about.execute(PLACEMENT_OWNER); FXMainWindow::move(10,20); // posiciona a tela na coordenada coluna,linha return 1; } int main(int argc, char **argv) { FXApp app(PROJECT_NAME, PROJECT_COMPANY); app.init(argc, argv); MainWindow *w = new MainWindow(&app); app.addSignal(SIGINT, w, MainWindow::ID_QUIT); app.create(); w->show(PLACEMENT_CURSOR); w->setFocus(); return app.run(); } #ifndef MAIN_FOX_APP_H #define MAIN_FOX_APP_H #include <fx.h> #define PROJECT_NAME "Template FOX Application" #define PROJECT_VERSION "0.1" #define PROJECT_COMPANY "Foobar Corporation" #define PROJECT_COPYWRITE "Copyright © 2005, Foobar Corporation, All Rights Reserved." // The MainWindow class class MainWindow: public FXMainWindow { FXDECLARE(MainWindow) FXMenuPane *filemenu, *helpmenu, *movemenu; protected: MainWindow() {} public: MainWindow(FXApp *app); ~MainWindow(); virtual void create(); enum { ID_QUIT = FXMainWindow::ID_LAST, ID_ABOUT, ID_MOVE, ID_LAST }; long onCmdAbout (FXObject *, FXSelector, void *); long onCmdQuit (FXObject *, FXSelector, void *); long onCmdMove (FXObject *, FXSelector, void *); }; #endif // MAIN_FOX_APP_H ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Foxgui-announce mailing list Foxgui-announce@... https://lists.sourceforge.net/lists/listinfo/foxgui-announce |
|
|
Re: En:Welcome to the "Foxgui-announce" mailing listOn Tuesday 13 March 2007 19:50, Marcelo Garbato wrote:
> Hi,, > I am leraning FOX, and I have one problem with this source code(I had put "onCmdMove" function), that causes one error when I quit the program. Someone could help me? > > #include "main_fox_app.h" > #include "signal.h" > > // Message Map for the Main Window class > FXDEFMAP(MainWindow) MainWindowMap[] = { > //________Message_Type_____________ID_____________Message_Handler_______ > FXMAPFUNC(SEL_SIGNAL, MainWindow::ID_QUIT, MainWindow::onCmdQuit), > FXMAPFUNC(SEL_COMMAND, MainWindow::ID_QUIT, MainWindow::onCmdQuit), > FXMAPFUNC(SEL_COMMAND, MainWindow::ID_MOVE, MainWindow::onCmdMove), > FXMAPFUNC(SEL_COMMAND, MainWindow::ID_ABOUT, MainWindow::onCmdAbout), > FXMAPFUNC(SEL_KEYPRESS, 0, MainWindow::onKeyPress), > }; > > // Macro for the MainWindow class hierarchy implementation > FXIMPLEMENT(MainWindow, FXMainWindow, MainWindowMap, ARRAYNUMBER(MainWindowMap)) > > // MainWindow constructor > MainWindow::MainWindow(FXApp *app) > : FXMainWindow(app, PROJECT_NAME, 0, 0, DECOR_ALL, 0, 0, 700, 500) > // : FXMainWindow(app, PROJECT_NAME, 0, 0, DECOR_NONE , 300, 450, 800, 600) // without title bar > { > // Load the application icons. > // FXXPMIcon *bigicon, *smallicon; > // bigicon = new FXXPMIcon(getApp(), app_xpm); > // smallicon = new FXXPMIcon(getApp(), app_small_xpm); > // setIcon(bigicon); > // setMiniIcon(smallicon); > > FXMenuBar *menubar; > > FXToolBarShell *dragshell1 = new FXToolBarShell(this, FRAME_RAISED); > menubar = new FXMenuBar(this, dragshell1, FRAME_RAISED|LAYOUT_SIDE_TOP|LAYOUT_FILL_X); > new FXToolBarGrip(menubar, menubar, FXMenuBar::ID_TOOLBARGRIP); > > FXStatusBar *statusbar; > // statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER|FRAME_RAISED); > statusbar = new FXStatusBar(this, LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_RAISED); > > filemenu = new FXMenuPane(this); > new FXMenuCommand(filemenu, "&Quit\tAlt-F4\tClose this program.", 0, this, ID_QUIT); > > movemenu = new FXMenuPane(this); > new FXMenuCommand(movemenu, "&Move\tAlt-F5\tmove the window.", 0, this, ID_MOVE); > > helpmenu = new FXMenuPane(this); > new FXMenuCommand(helpmenu, "&About...\t\tShow information about " PROJECT_NAME ".", 0, this, ID_ABOUT); > > new FXMenuTitle(menubar, "&File", 0, filemenu); > new FXMenuTitle(menubar, "&Move", 0, movemenu); > new FXMenuTitle(menubar, "&About", 0, helpmenu); > } > > // MainWindow destructor > MainWindow::~MainWindow() > { > // Delete all menu panes > delete filemenu; > delete helpmenu; > } > > // Create MainWindow and initialize > void MainWindow::create() > { > FXMainWindow::create(); > } > > // Create MainWindow and initialize > long MainWindow::onCmdMove(FXObject *, FXSelector, void *) > { > FXMainWindow::move(35,50); > return 1; > } > > // Quit command called > long MainWindow::onCmdQuit(FXObject *, FXSelector, void *) > { > getApp()->exit(0); > return 1; > } > > // About command called > long MainWindow::onCmdAbout(FXObject *, FXSelector, void *) > { > FXDialogBox about(this, "About " PROJECT_NAME, DECOR_TITLE|DECOR_BORDER, > 0,0,0,0, 0,0,0,0, 0,0); > > FXVerticalFrame *contents = > new FXVerticalFrame(&about, LAYOUT_SIDE_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y, > 0,0,0,0, 10,10,10,10, 0,0); > new FXLabel(contents, > PROJECT_NAME " Version " PROJECT_VERSION ".\n\n" > PROJECT_COPYWRITE "\n\n" > "This software uses the FOX Toolkit Library (http://www.fox-toolkit.org).\n", > 0, JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_FILL_Y); > > FXButton *button = new FXButton(contents, "OK", 0, &about, > FXDialogBox::ID_ACCEPT, BUTTON_INITIAL|BUTTON_DEFAULT|FRAME_RAISED|FRAME_THICK|LAYOUT_CENTER_X, > 0,0,0,0, 32,32,5,5); > > button->setFocus(); > about.execute(PLACEMENT_OWNER); > FXMainWindow::move(10,20); // posiciona a tela na coordenada coluna,linha > > return 1; > } > > int main(int argc, char **argv) > { > FXApp app(PROJECT_NAME, PROJECT_COMPANY); > app.init(argc, argv); > > MainWindow *w = new MainWindow(&app); > app.addSignal(SIGINT, w, MainWindow::ID_QUIT); > app.create(); > w->show(PLACEMENT_CURSOR); > w->setFocus(); > > return app.run(); > } > > > #ifndef MAIN_FOX_APP_H > #define MAIN_FOX_APP_H > > #include <fx.h> > > #define PROJECT_NAME "Template FOX Application" > #define PROJECT_VERSION "0.1" > #define PROJECT_COMPANY "Foobar Corporation" > #define PROJECT_COPYWRITE "Copyright © 2005, Foobar Corporation, All Rights Reserved." > > // The MainWindow class > class MainWindow: public FXMainWindow > { > FXDECLARE(MainWindow) > > FXMenuPane *filemenu, *helpmenu, *movemenu; > > protected: > MainWindow() {} > > public: > MainWindow(FXApp *app); > ~MainWindow(); > > virtual void create(); > > enum > { > ID_QUIT = FXMainWindow::ID_LAST, > ID_ABOUT, > ID_MOVE, > ID_LAST > > }; > > long onCmdAbout (FXObject *, FXSelector, void *); > long onCmdQuit (FXObject *, FXSelector, void *); > long onCmdMove (FXObject *, FXSelector, void *); > }; > > > #endif // MAIN_FOX_APP_H Looks to me that you forgot to delete one of the menus. Recommendation:- install valgrind on your machine [if you're on Linux], it will save you from lots of debugging and worries. If you're on Windows, I recommend purify or boundschecker or any similar tool If you don't have these tools, keep in mind FOX may have tracing enabled when you've compiled it in debug mode. Passing -tracelevel XX on the command line of any FOX application will cause lots of logging info to be written, the higher the level XX, the more you will see [all FOX library trace info is at level 100 or higher so as to allow this tracing mechanism to be used in your own programs as well]. - Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 23:10 03/13/2007 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+ ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Foxgui-announce mailing list Foxgui-announce@... https://lists.sourceforge.net/lists/listinfo/foxgui-announce |
| Free embeddable forum powered by Nabble | Forum Help |