#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, 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, int 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, 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, int 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;
|
}
|
};
|