// w32dlib - Win32 Control Helpers // // Copyright (C) 2005 Ian Cowburn (ianc@noddybox.demon.co.uk) // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------- // #include "w32dlib/window.h" #include "w32dlib/combobox.h" namespace W32DLib { // ------------------------------------------------------------ // ComboBox::ComboBox(Dialog *parent, int resource_id) : Control(parent,resource_id) { } // ------------------------------------------------------------ // ComboBox::~ComboBox() { } // ------------------------------------------------------------ // void ComboBox::OnSelection(Window *owner, W32DLibCallback callback) { Control::AddCallback(WM_COMMAND,CBN_SELCHANGE,owner,callback); } // ------------------------------------------------------------ // void ComboBox::OnDoubleClick(Window *owner, W32DLibCallback callback) { Control::AddCallback(WM_COMMAND,CBN_DBLCLK,owner,callback); } // ------------------------------------------------------------ // void ComboBox::OnTextChanged(Window *owner, W32DLibCallback callback) { Control::AddCallback(WM_COMMAND,CBN_EDITCHANGE,owner,callback); } // ------------------------------------------------------------ // void ComboBox::Reset() { SendMsg(CB_RESETCONTENT,0,0); } // ------------------------------------------------------------ // void ComboBox::MaxLen(int count) { SendMsg(CB_LIMITTEXT,count,0); } // ------------------------------------------------------------ // int ComboBox::Count() { return SendMsg(CB_GETCOUNT,0,0); } // ------------------------------------------------------------ // int ComboBox::AddString(const char *text) { return SendMsg(CB_ADDSTRING,0,reinterpret_cast(text)); } // ------------------------------------------------------------ // int ComboBox::AddString(const char *text, int index) { return SendMsg(CB_INSERTSTRING,index,reinterpret_cast(text)); } // ------------------------------------------------------------ // int ComboBox::RemoveString(int index) { return SendMsg(CB_DELETESTRING,index,0); } // ------------------------------------------------------------ // std::string ComboBox::GetString(int index) { std::string result; LRESULT len=SendMsg(CB_GETLBTEXTLEN,index,0); if (len!=CB_ERR) { char *text=new char[len+1]; SendMsg(CB_GETLBTEXT,index,reinterpret_cast(text)); result=text; delete[] text; } return result; } // ------------------------------------------------------------ // int ComboBox::TopRowIndex() { return SendMsg(CB_GETTOPINDEX,0,0); } // ------------------------------------------------------------ // void ComboBox::TopRowIndex(int index) { SendMsg(CB_SETTOPINDEX,index,0); } // ------------------------------------------------------------ // int ComboBox::SelectedIndex() { return SendMsg(CB_GETCURSEL,0,0); } // ------------------------------------------------------------ // void ComboBox::SelectedIndex(int index) { SendMsg(CB_SETCURSEL,index,0); } }; // namespace W32DLib // END OF FILE