diff options
author | Ian C <ianc@noddybox.co.uk> | 2005-03-28 01:42:58 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2005-03-28 01:42:58 +0000 |
commit | 82f1d860690dc0a2d0210db12344f7ea5e88b6a4 (patch) | |
tree | 517481a81e64cc70b5187ce6eeb20d8fa326fa54 /src/test | |
parent | 4f54380eb1f7574bf9cc147cb8870508da09e10c (diff) |
Added ComboBox. Also improved callback filtering and made controls auto register themselves.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/dialog.h | 1 | ||||
-rw-r--r-- | src/test/dialog.rc | 8 | ||||
-rw-r--r-- | src/test/w32dtst.cpp | 59 |
3 files changed, 56 insertions, 12 deletions
diff --git a/src/test/dialog.h b/src/test/dialog.h index ac47a4e..5b08673 100644 --- a/src/test/dialog.h +++ b/src/test/dialog.h @@ -10,3 +10,4 @@ #define IDSAVEBUT 10 #define IDDIRTXT 11 #define IDDIRBUT 12 +#define IDCOMBO 13 diff --git a/src/test/dialog.rc b/src/test/dialog.rc index 27f1ea6..e96fa9f 100644 --- a/src/test/dialog.rc +++ b/src/test/dialog.rc @@ -1,9 +1,9 @@ #include <windows.h> #include "dialog.h" -TESTDLG DIALOG 10, 10, 240, 180 - STYLE WS_POPUP | WS_BORDER CAPTION - "Test Dialog" +TESTDLG DIALOG 10, 10, 240, 300 + STYLE WS_POPUP | WS_BORDER + CAPTION "Test Dialog" FONT 8,"MS Shell Dlg" { LTEXT "Text:", IDSTATIC1, 10, 10, 35, 12 @@ -17,4 +17,6 @@ TESTDLG DIALOG 10, 10, 240, 180 EDITTEXT IDSAVETXT, 10, 140, 200, 12 PUSHBUTTON "Save ...",IDSAVEBUT, 10, 155, 100, 18 + + COMBOBOX IDCOMBO, 10, 180, 100, 100, CBS_SIMPLE | CBS_SORT | WS_VSCROLL | WS_TABSTOP } diff --git a/src/test/w32dtst.cpp b/src/test/w32dtst.cpp index 5f14a6d..663c63d 100644 --- a/src/test/w32dtst.cpp +++ b/src/test/w32dtst.cpp @@ -36,16 +36,8 @@ public: , m_loadbut(this,IDLOADBUT) , m_save(this,IDSAVETXT) , m_savebut(this,IDSAVEBUT) + , m_combo(this,IDCOMBO) { - AddControl(&m_text); - AddControl(&m_check); - AddControl(&m_button); - AddControl(&m_quit); - AddControl(&m_load); - AddControl(&m_loadbut); - AddControl(&m_save); - AddControl(&m_savebut); - m_button.OnPress (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnButton)); m_quit.OnPress @@ -57,6 +49,13 @@ public: (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnLoad)); m_savebut.OnPress (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnSave)); + + m_combo.OnSelection + (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnComboSel)); + m_combo.OnDoubleClick + (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnComboDbl)); + m_combo.OnTextChanged + (this,static_cast<W32DLib::W32DLibCallback>(&Test::OnComboTxt)); } virtual ~Test() @@ -74,6 +73,16 @@ public: m_text.SetText("Hello"); m_check.SetState(W32DLib::AutoCheck::eChecked); m_quit.Enable(true); + + m_combo.Reset(); + std::cout << "addstring=" << m_combo.AddString("Entry 1") << std::endl; + std::cout << "addstring=" << m_combo.AddString("Entry 2") << std::endl; + std::cout << "addstring=" << m_combo.AddString("Entry 3") << std::endl; + + std::cout << "count=" << m_combo.Count() << std::endl; + std::cout << "HWND=" << m_combo.GetHWND() << std::endl; + + m_combo.SelectedIndex(2); } private: @@ -89,6 +98,8 @@ private: W32DLib::Text m_save; W32DLib::Button m_savebut; + W32DLib::ComboBox m_combo; + std::string m_loadpath; std::string m_savepath; @@ -108,6 +119,7 @@ private: std::cout << "check=" << m_check.GetState() << std::endl; m_static.SetText(txt.c_str()); SetText((txt+" [Title]").c_str()); + m_combo.AddString(m_combo.GetText().c_str()); return TRUE; } @@ -147,6 +159,35 @@ private: return TRUE; } + + BOOL OnComboSel(UINT msg, WPARAM wp, LPARAM lp) + { + int sel=m_combo.SelectedIndex(); + std::string str=m_combo.GetString(sel); + + std::cout << "Called OnComboSel()" << std::endl; + std::cout << "Sel:selection=" << sel << " (" << str << ")" << std::endl; + std::cout << "Sel:Window::GetText=" << m_combo.GetText(512) << std::endl; + return TRUE; + } + + BOOL OnComboDbl(UINT msg, WPARAM wp, LPARAM lp) + { + int sel=m_combo.SelectedIndex(); + std::string str=m_combo.GetString(sel); + + std::cout << "Called OnComboDbl()" << std::endl; + std::cout << "Dbl:selection=" << sel << " (" << str << ")" << std::endl; + std::cout << "Dbl:Window::GetText=" << m_combo.GetText(512) << std::endl; + return TRUE; + } + + BOOL OnComboTxt(UINT msg, WPARAM wp, LPARAM lp) + { + std::cout << "Called OnComboSel()" << std::endl; + std::cout << "Txt:Window::GetText=" << m_combo.GetText(512) << std::endl; + return TRUE; + } }; int WINAPI WinMain (HINSTANCE hInstance, |