#pragma once
|
|
#include "win32/win.hpp"
|
#include "wobject/xcontrol.hpp"
|
|
class xcombobox: public xcontrol
|
{
|
public:
|
xcombobox() :xcontrol(nullptr) {}
|
xcombobox(void* impl) :xcontrol(impl) {}
|
|
public:
|
xcombobox & operator =(const kcontrol* pcontrol)
|
{
|
this->setNativePointer((void *)pcontrol);
|
return *this;
|
}
|
public:
|
|
int GetCurSel()
|
{
|
int CB_GETCURSEL_ = 0x0147;
|
return SendMessage(GetHWND(),CB_GETCURSEL_,0,0);
|
}
|
|
int SetCurSel( int nIndex)
|
{
|
int CB_SETCURSEL_ = 0x014E;
|
return SendMessage(GetHWND(),CB_SETCURSEL_,nIndex,0);
|
}
|
|
int GetCount()
|
{
|
int CB_GETCOUNT_ = 0x0146;
|
return SendMessage(GetHWND(),CB_GETCOUNT_,0,0);
|
}
|
|
string GetLBText(int nIndex)
|
{
|
int CB_GETLBTEXT_ = 0x0148;
|
int CB_GETLBTEXTLEN_ = 0x0149;
|
int nLen = SendMessage(GetHWND(),CB_GETLBTEXTLEN_ ,nIndex,0);
|
string str = new wchar_t[nLen+1];
|
SendMessage(GetHWND(),CB_GETLBTEXT_ ,nIndex, (LPARAM)str);
|
return str;
|
}
|
|
string GetLBText()
|
{
|
int CB_GETLBTEXT_ = 0x0148;
|
int CB_GETLBTEXTLEN_ = 0x0149;
|
int nIndex = GetCurSel();
|
int nLen = SendMessage(GetHWND(),CB_GETLBTEXTLEN_ ,nIndex,0);
|
string str = new wchar_t[nLen+1];
|
SendMessage(GetHWND(),CB_GETLBTEXT_ ,nIndex, (LPARAM)str);
|
return str;
|
}
|
|
int SetItemIndex(int nIndex)
|
{
|
int CB_SETCURSEL_ = 0x014E;
|
return SendMessage(GetHWND(),CB_SETCURSEL_ ,nIndex, 0);
|
}
|
|
int AddItem(string str)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
return SendMessage(GetHWND(),CB_ADDSTRING_ ,(WPARAM)0,(LPARAM)str);
|
}
|
|
int FindString(string str)
|
{
|
int CB_FINDSTRINGEXACT_ = 0x0158;
|
return SendMessage(GetHWND(),CB_FINDSTRINGEXACT_,0,(LPARAM)str);
|
}
|
|
int DeleteItem(int nIndex)
|
{
|
int CB_DELETESTRING_ = 0x0144;
|
return SendMessage(GetHWND(),CB_DELETESTRING_,nIndex,0);
|
}
|
|
int SelectString( int nIndex,string str)
|
{
|
int CB_SELECTSTRING_ = 0x014D;
|
return SendMessage(GetHWND(),CB_SELECTSTRING_,nIndex,(LPARAM)str);
|
}
|
|
int InsertString( int nIndex,string str)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
return SendMessage(GetHWND(),CB_INSERTSTRING_,nIndex,(LPARAM)str);
|
}
|
|
int InsertString( string str)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
return SendMessage(GetHWND(),CB_INSERTSTRING_,0,(LPARAM)str);
|
}
|
|
int ResetContent()
|
{
|
int CB_RESETCONTENT_ = 0x014B;
|
return SendMessage(GetHWND(),CB_RESETCONTENT_,0,0);
|
}
|
|
int SetItemData(int nIndex, KXMLDOMElement p)
|
{
|
return SetItemData(nIndex, p.ptr());
|
}
|
|
int SetItemData(int nIndex, LPARAM p)
|
{
|
int CB_SETITEMDATA_ = 0x0151;
|
return SendMessage(GetHWND(),CB_SETITEMDATA_,nIndex,p);
|
}
|
|
int GetItemData()
|
{
|
int CB_GETITEMDATA_ = 0x0150;
|
int nIndex = GetCurSel();
|
if(nIndex < 0)
|
return -1;
|
else
|
return SendMessage(GetHWND(),CB_GETITEMDATA_,nIndex,0);
|
}
|
|
LPARAM GetItemData(int nIndex)
|
{
|
int CB_GETITEMDATA_ = 0x0150;
|
return SendMessage(GetHWND(),CB_GETITEMDATA_,nIndex,0);
|
}
|
|
int AddItem(string str, KXMLDOMElement ele)
|
{
|
return AddItem(str, ele.ptr());
|
}
|
int AddItem(string str, LPARAM p)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
int h = SendMessage(GetHWND(),CB_ADDSTRING_ ,0,(LPARAM)str);
|
SetItemData( h, p);
|
return h;
|
}
|
|
int AddItem(string str, string p)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
int h = SendMessage(GetHWND(),CB_ADDSTRING_ ,0,(LPARAM)str);
|
SetItemData( h, (LPARAM)p);
|
return h;
|
}
|
|
int InsertString(string str, KXMLDOMElement p)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
int h = SendMessage(GetHWND(), CB_INSERTSTRING_, 0, (LPARAM)str);
|
|
SetItemData(h, p);
|
return h;
|
}
|
|
int InsertString( string str, LPARAM p)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
int h = SendMessage(GetHWND(),CB_INSERTSTRING_,0,(LPARAM)str);
|
|
SetItemData( h, p);
|
return h;
|
}
|
|
|
/////
|
static int GetCurSel(HWND hWnd)
|
{
|
int CB_GETCURSEL_ = 0x0147;
|
return SendMessage(hWnd, CB_GETCURSEL_, 0, 0);
|
}
|
|
static int SetCurSel(HWND hWnd,int nIndex)
|
{
|
int CB_SETCURSEL_ = 0x014E;
|
return SendMessage(hWnd, CB_SETCURSEL_, nIndex, 0);
|
}
|
|
static int GetCount(HWND hWnd)
|
{
|
int CB_GETCOUNT_ = 0x0146;
|
return SendMessage(hWnd, CB_GETCOUNT_, 0, 0);
|
}
|
|
static string GetLBText(HWND hWnd,int nIndex)
|
{
|
int CB_GETLBTEXT_ = 0x0148;
|
int CB_GETLBTEXTLEN_ = 0x0149;
|
int nLen = SendMessage(hWnd, CB_GETLBTEXTLEN_, nIndex, 0);
|
string str = new wchar_t[nLen + 1];
|
SendMessage(hWnd, CB_GETLBTEXT_, nIndex, (LPARAM)str);
|
return str;
|
}
|
|
static string GetLBText(HWND hWnd)
|
{
|
int CB_GETLBTEXT_ = 0x0148;
|
int CB_GETLBTEXTLEN_ = 0x0149;
|
int nIndex = GetCurSel(hWnd);
|
int nLen = SendMessage(hWnd, CB_GETLBTEXTLEN_, nIndex, 0);
|
string str = new wchar_t[nLen + 1];
|
SendMessage(hWnd, CB_GETLBTEXT_, nIndex, (LPARAM)str);
|
return str;
|
}
|
|
static int SetItemIndex(HWND hWnd,int nIndex)
|
{
|
int CB_SETCURSEL_ = 0x014E;
|
return SendMessage(hWnd, CB_SETCURSEL_, nIndex, 0);
|
}
|
|
static int AddItem(HWND hWnd,string str)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
return SendMessage(hWnd, CB_ADDSTRING_, (WPARAM)0, (LPARAM)str);
|
}
|
|
static int FindString(HWND hWnd,string str)
|
{
|
int CB_FINDSTRINGEXACT_ = 0x0158;
|
return SendMessage(hWnd, CB_FINDSTRINGEXACT_, 0, (LPARAM)str);
|
}
|
|
static int DeleteItem(HWND hWnd,int nIndex)
|
{
|
int CB_DELETESTRING_ = 0x0144;
|
return SendMessage(hWnd, CB_DELETESTRING_, nIndex, 0);
|
}
|
|
static int SelectString(HWND hWnd,int nIndex, string str)
|
{
|
int CB_SELECTSTRING_ = 0x014D;
|
return SendMessage(hWnd, CB_SELECTSTRING_, nIndex, (LPARAM)str);
|
}
|
|
static int InsertString(HWND hWnd,int nIndex, string str)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
return SendMessage(hWnd, CB_INSERTSTRING_, nIndex, (LPARAM)str);
|
}
|
|
static int InsertString(HWND hWnd,string str)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
return SendMessage(hWnd, CB_INSERTSTRING_, 0, (LPARAM)str);
|
}
|
|
int ResetContent(HWND hWnd)
|
{
|
int CB_RESETCONTENT_ = 0x014B;
|
return SendMessage(hWnd, CB_RESETCONTENT_, 0, 0);
|
}
|
|
static int SetItemData(HWND hWnd,int nIndex, LPARAM p)
|
{
|
int CB_SETITEMDATA_ = 0x0151;
|
return SendMessage(hWnd, CB_SETITEMDATA_, nIndex, p);
|
}
|
|
static int GetItemData(HWND hWnd)
|
{
|
int CB_GETITEMDATA_ = 0x0150;
|
int nIndex = GetCurSel(hWnd);
|
if (nIndex < 0)
|
return -1;
|
else
|
return SendMessage(hWnd, CB_GETITEMDATA_, nIndex, 0);
|
}
|
|
static LPARAM GetItemData(HWND hWnd,int nIndex)
|
{
|
int CB_GETITEMDATA_ = 0x0150;
|
return SendMessage(hWnd, CB_GETITEMDATA_, nIndex, 0);
|
}
|
|
static int AddItem(HWND hWnd,string str, LPARAM p)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
int h = SendMessage(hWnd, CB_ADDSTRING_, 0, (LPARAM)str);
|
SetItemData(hWnd,h, p);
|
return h;
|
}
|
|
static int AddItem(HWND hWnd,string str, string p)
|
{
|
int CB_ADDSTRING_ = 0x0143;
|
int h = SendMessage(hWnd, CB_ADDSTRING_, 0, (LPARAM)str);
|
SetItemData(hWnd,h, (LPARAM)p);
|
return h;
|
}
|
|
static int InsertString(HWND hWnd,string str, LPARAM p)
|
{
|
int CB_INSERTSTRING_ = 0x014A;
|
int h = SendMessage(hWnd, CB_INSERTSTRING_, 0, (LPARAM)str);
|
|
SetItemData(hWnd,h, p);
|
return h;
|
}
|
};
|