#include "winplus.h"

#define LARGE_BUFFER_SIZE       4096
static char large_buffer[LARGE_BUFFER_SIZE];
  
CWindowedControl::CWindowedControl(HWND Handle)
{
  this->Handle=Handle;
  iControl=-1;
}

CWindowedControl::CWindowedControl(HWND hDialog,int iControl)
{
  this->iControl=iControl;
  Handle=::GetDlgItem(hDialog,iControl);
}

void CWindowedControl::Init(HWND hDialog,int iControl)
{
  this->iControl=iControl;
  Handle=::GetDlgItem(hDialog,iControl);
}

LRESULT CWindowedControl::Perform(UINT Msg,WPARAM wParam,LPARAM lParam)
{
  return ::SendMessage(Handle,Msg,wParam,lParam);
}

char *CWindowedControl::GetText()
{
  /*int chars=*/Perform(WM_GETTEXT,LARGE_BUFFER_SIZE,(LPARAM)large_buffer);
  return large_buffer;
}

void CWindowedControl::SetText(char *szStr)
{
  Perform(WM_SETTEXT,0,(LPARAM)szStr);
}

void CWindowedControl::Move(int l,int t,int w,int h)
{
  ::MoveWindow(Handle,l,t,w,h,1);
}

int CButton::IsChecked()
{
  return Perform(BM_GETCHECK,0,0);
}

void CButton::Check(int Checked)
{
  Perform(BM_SETCHECK,Checked ? BST_CHECKED : BST_UNCHECKED,0);
};

