home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <owl\applicat.h>
- #include <owl\button.h>
- #include <owl\framewin.h>
- #include <owl\listbox.h>
- #include <owl\static.h>
- #include <owl\window.h>
- #include <owl\window.rh>
-
- #include "xferlist.h"
-
- class TMyWindow : public TWindow
- {
- public:
- TMyWindow(TWindow *parent = 0);
- virtual ~TMyWindow();
-
- protected:
- virtual void SetupWindow();
-
- void CbToDst();
- void CbToSrc();
- void CmExit();
-
- private:
- TListBox *src, *dst;
-
- void MoveSels(TListBox *src, TListBox *dst);
-
- DECLARE_RESPONSE_TABLE(TMyWindow);
- };
- DEFINE_RESPONSE_TABLE1(TMyWindow, TWindow)
- EV_COMMAND(CM_EXIT, CmExit),
- EV_BN_CLICKED(IDB_TODST, CbToDst),
- EV_BN_CLICKED(IDB_TOSRC, CbToSrc),
- END_RESPONSE_TABLE;
-
- TMyWindow::TMyWindow(TWindow *parent)
- {
- Init(parent, 0, 0);
-
- int wbtn = 80,
- hbtn = 30,
- wlist = 150,
- hlist = 250,
- wspace = 30,
- hspace = 50,
- x0 = 30,
- y0 = 50;
- int x = x0, y = y0;
-
- new TStatic(this, -1, "Source", x, y, wlist, hbtn);
- y += hbtn;
- if (NULL != (src = new TListBox(this, IDL_SRC, x, y, wlist, hlist)))
- src->Attr.Style |= LBS_MULTIPLESEL;
-
- x += wlist + wspace;
- y += hspace;
- new TButton(this, IDB_TODST, "-->", x, y, wbtn, hbtn);
- y += hbtn + hspace;
- new TButton(this, IDB_TOSRC, "<--", x, y, wbtn, hbtn);
-
- x += wbtn + wspace;
- y = y0;
- new TStatic(this, -1, "Destination", x, y, wlist, hbtn);
- y += hbtn;
- if (NULL != (dst = new TListBox(this, IDL_DST, x, y, wlist, hlist)))
- dst->Attr.Style |= LBS_MULTIPLESEL;
- }
-
- TMyWindow::~TMyWindow()
- {
- }
-
- void TMyWindow::SetupWindow()
- {
- static char *names[] =
- { "Keith", "Bruce", "Kevin", "Bridget", "Kate",
- "Kay", "Roger", "Marie", "Kathleen", "Liz",
- "Ingrid", "Craig", "George", "Janet", "Gary",
- "Helen", "Candace",
- NULL };
-
- TWindow::SetupWindow();
-
- if (src)
- for (int ix = 0; names[ix]; ++ix)
- src->AddString(names[ix]);
- }
-
- void TMyWindow::MoveSels(TListBox *src, TListBox *dst)
- {
- if (src && dst)
- {
- int *sels, numsels = src->GetSelCount();
- if ((numsels > 0) && (NULL != (sels = new int[numsels])))
- {
- int ix;
-
- src->GetSelIndexes(sels, numsels);
- for (ix = 0; ix < numsels; ++ix)
- {
- char *str;
- int size = src->GetStringLen(sels[ix]) + 1;
- if ((size > 1) && (NULL != (str = new char[size])))
- {
- src->GetString(str, sels[ix]);
- dst->AddString(str);
- delete str;
- }
- }
- for (ix = numsels - 1; ix >= 0; --ix)
- src->DeleteString(sels[ix]);
-
- delete sels;
- }
- }
- }
-
- void TMyWindow::CbToDst()
- {
- MoveSels(src, dst);
- }
-
- void TMyWindow::CbToSrc()
- {
- MoveSels(dst, src);
- }
-
- void TMyWindow::CmExit()
- {
- SendMessage(WM_CLOSE);
- }
-
- class TXferApp : public TApplication
- {
- public:
- TXferApp() : TApplication()
- { nCmdShow = SW_SHOWMAXIMIZED; }
-
- void InitMainWindow()
- {
- SetMainWindow(new TFrameWindow( 0,
- "Multiple Selection List Tester",
- new TMyWindow ));
- GetMainWindow()->AssignMenu("EXITMENU");
- }
- };
-
- int OwlMain(int, char *[])
- {
- return TXferApp().Run();
- }
-