# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1672195618 0 # Node ID 0cde119fc94519236bcd5e20c12b7ec8863e34cf # Parent 8af64b6d75a9a53d8cf90bedcae99794e8deac99 C++: Fix initialization and #define reused strings. diff -r 8af64b6d75a9 -r 0cde119fc945 dwtestoo.cpp --- a/dwtestoo.cpp Wed Dec 28 01:00:12 2022 +0000 +++ b/dwtestoo.cpp Wed Dec 28 02:46:58 2022 +0000 @@ -28,6 +28,9 @@ #define SHAPES_DIRECT 1 #define DRAW_FILE 2 +#define APP_TITLE "Dynamic Windows C++" +#define APP_EXIT "Are you sure you want to exit?" + class DWTest : public DW::Window { private: @@ -140,12 +143,12 @@ DW::Menu *menu = new DW::Menu(); DW::MenuItem *menuitem = menu->AppendItem("~Quit"); menuitem->ConnectClicked([this] () -> int - { - if(this->app->MessageBox("dwtestoo", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?") != 0) { - this->app->MainQuit(); - } - return TRUE; - }); + { + if(this->app->MessageBox(APP_TITLE, DW_MB_YESNO | DW_MB_QUESTION, APP_EXIT) != 0) { + this->app->MainQuit(); + } + return TRUE; + }); // Add the "File" menu to the menubar... menubar->AppendItem("~File", menu); @@ -186,12 +189,13 @@ DWEnv env; this->app->GetEnvironment(&env); - this->app->MessageBox("About dwindows", DW_MB_OK | DW_MB_INFORMATION, "dwindows test\n\nOS: %s %s %s Version: %d.%d.%d.%d\n\nHTML: %s\n\ndwindows Version: %d.%d.%d\n\nScreen: %dx%d %dbpp", - env.osName, env.buildDate, env.buildTime, - env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild, - env.htmlEngine, - env.DWMajorVersion, env.DWMinorVersion, env.DWSubVersion, - this->app->GetScreenWidth(), this->app->GetScreenHeight(), this->app->GetColorDepth()); + this->app->MessageBox("About dwindows", DW_MB_OK | DW_MB_INFORMATION, + "dwindows test\n\nOS: %s %s %s Version: %d.%d.%d.%d\n\nHTML: %s\n\ndwindows Version: %d.%d.%d\n\nScreen: %dx%d %dbpp", + env.osName, env.buildDate, env.buildTime, + env.MajorVersion, env.MinorVersion, env.MajorBuild, env.MinorBuild, + env.htmlEngine, + env.DWMajorVersion, env.DWMinorVersion, env.DWSubVersion, + this->app->GetScreenWidth(), this->app->GetScreenHeight(), this->app->GetColorDepth()); return FALSE; }); // Add the "Help" menu to the menubar... @@ -350,7 +354,7 @@ cancelbutton->ConnectClicked([this] () -> int { - if(this->app->MessageBox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?") != 0) { + if(this->app->MessageBox(APP_TITLE, DW_MB_YESNO | DW_MB_QUESTION, APP_EXIT) != 0) { this->app->MainQuit(); } return TRUE; @@ -373,7 +377,7 @@ } public: // Constructor creates the application - DWTest(const char *title) { + DWTest(const char *title): DW::Window(title) { char fileiconpath[1025] = "file"; char foldericonpath[1025] = "folder"; @@ -483,7 +487,7 @@ HICN fileicon,foldericon; int OnDelete() override { - if(app->MessageBox("dwtest", DW_MB_YESNO | DW_MB_QUESTION, "Are you sure you want to exit?") != 0) { + if(app->MessageBox(APP_TITLE, DW_MB_YESNO | DW_MB_QUESTION, APP_EXIT) != 0) { app->MainQuit(); } return TRUE;