www.pudn.com > 1.rar > i2curve.cpp


#include "stdafx.h" 
#include  
 
#include "resource.h" 
#include "iaspwb.h" 
 
//function pause 
#include "func\mathutil.h" 
#include "func\FktParser.h" 
#include "func\Mathstr.h" 
 
#define INITGUID 
#include  
 
//curve set ID 
// {2DA822B8-7E88-439a-AFD2-73F06AE3CB4F} 
DEFINE_GUID(CSID_Curve,  
0x2da822b8, 0x7e88, 0x439a, 0xaf, 0xd2, 0x73, 0xf0, 0x6a, 0xe3, 0xcb, 0x4f); 
 
extern HINSTANCE g_hinstance; 
CHAR g_buf[64]; 
INT g_xstart,g_xend; 
INT g_ystart,g_yend; 
 
CI2WBCurve::CI2WBCurve(INT cid,VOID* pwb) 
{ 
m_cid=cid; 
m_csid=CSID_Curve; 
m_state=0; 
 
m_wb=(CI2WBBaseWB *)pwb; 
//use specified line style and line width 
cinfo.m_linestyle=0; 
cinfo.m_linewidth=1; 
m_wb->get_Color(&cinfo.m_color); 
m_wb->get_BKColor(&cinfo.m_bkcolor); 
m_wb->get_Font(&cinfo.m_font,WB_FONT_ALL); 
 
//curve cannot change size 
m_property=0; 
 
switch(cid) 
{ 
case 0: 
  m_type=dtCurve; 
	break; 
} 
m_name[0]='\0'; 
m_grpname[0]='\0'; 
 
//x,y default value 
m_xstart=-10; 
m_ystart=-10; 
m_xend=10; 
m_yend=10; 
} 
 
CI2WBCurve::~CI2WBCurve() 
{ 
//  m_Expression.Empty(); 
} 
 
void CI2WBCurve::OnLButtonDown(DWORD fwKeys,SHORT cx,SHORT y,HWND hwnd,INT* fend) 
{ 
} 
 
BOOL CI2WBCurve::OnLButtonUp(DWORD fwKeys,SHORT cx,SHORT y,HWND hwnd,INT* fend) 
{ 
  m_wb->m_dlgexist=1; 
  CFuncDlg*   funcdlg;   
  _g_i2hresinst=GetModuleHandle("iaspwb.dll"); 
  //initial function dialog 
  lstrcpy(g_buf,""); 
  g_xstart=m_xstart; 
  g_xend=m_xend; 
  g_ystart=m_ystart; 
  g_yend=m_yend; 
 
  funcdlg=new CFuncDlg((CI2WBBaseCtrl*)this); 
  m_wb->m_propdlg=funcdlg; 
  funcdlg->showModal(IDD_FUNCTION,hwnd); 
  if(funcdlg->m_pressok==1) 
  { 
    HDC hdc=GetDC(hwnd); 
	  switch(m_type) 
	  { 
	    case dtCurve: 
        //get x,y and expression 
        m_Expression=g_buf; 
        //m_Expression.FreeExtra(); 
        m_xstart=g_xstart; 
        m_xend=g_xend; 
        m_ystart=g_ystart; 
        m_yend=g_yend; 
        //draw curve 
        paintCurve(hdc,cx,y); 
        //set control rect 
        SetRect(&cinfo.m_rect,cx,y,cx+CURVE_WIDTH,y+CURVE_HEIGHT); 
        //finish creating control 
        *fend=1; 
        break; 
    } 
    ReleaseDC(hwnd,hdc); 
    m_wb->m_dlgexist=0; 
    m_wb->m_propdlg=NULL; 
    delete funcdlg; 
    return 0; 
  } 
  *fend=1; 
  delete funcdlg; 
  return -1; 
} 
 
void CI2WBCurve::OnMouseMove(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend) 
{ 
} 
 
void CI2WBCurve::OnRButtonDown(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend) 
{ 
} 
 
void CI2WBCurve::OnRButtonUp(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd,INT* fend) 
{ 
} 
 
BOOL CI2WBCurve::OnLButtonDBLCLK(DWORD fwKeys,SHORT x,SHORT y,HWND hwnd) 
{ 
  m_wb->m_dlgexist=1; 
  //modify control properties 
  CFuncDlg* dlg; 
  I2Rect r1; 
  _g_i2hresinst=GetModuleHandle("iaspwb.dll"); 
  //initial function dialog 
  lstrcpy(g_buf,m_Expression); 
  g_xstart=m_xstart; 
  g_xend=m_xend; 
  g_ystart=m_ystart; 
  g_yend=m_yend; 
  dlg=new CFuncDlg(this); 
  m_wb->m_propdlg=dlg; 
  dlg->showModal(IDD_FUNCTION,hwnd); 
  if(dlg->m_pressok==1) 
  { 
    //get x,y and expression 
    m_Expression=g_buf; 
    m_xstart=g_xstart; 
    m_xend=g_xend; 
    m_ystart=g_ystart; 
    m_yend=g_yend; 
    getControlRect(r1); 
    InvalidateRect(hwnd,&r1,TRUE); 
    m_wb->m_dlgexist=0; 
    delete dlg; 
    return 0; 
  } 
  delete dlg; 
  return -1; 
} 
 
VOID CI2WBCurve::moveTo(INT xoffset,INT yoffset) 
{ 
  //move control 
	cinfo.m_rect.left+=xoffset; 
	cinfo.m_rect.top+=yoffset; 
	cinfo.m_rect.right+=xoffset; 
	cinfo.m_rect.bottom+=yoffset; 
} 
 
VOID CI2WBCurve::OnInplaceEditorNeedText(LPWB32FONT pfont,LPSTR* ptext) 
{ 
} 
 
VOID CI2WBCurve::OnInplaceEditorReturnText(POINT pos,LPSTR text) 
{ 
} 
 
BOOL CI2WBCurve::OnDragFile(LPSTR filename,POINT p,CHAR* ptr,HWND hwnd) 
{ 
  return TRUE; 
} 
 
VOID CI2WBCurve::OnChangeData(RECT& rect) 
{ 
} 
 
VOID CI2WBCurve::set_Font(WB32FONT* pfont,INT mask) 
{ 
} 
 
VOID CI2WBCurve::getControlRect(I2Rect& Value) 
{ 
Value=cinfo.m_rect; 
} 
 
VOID CI2WBCurve::paintControl(HDC hdc) 
{ 
switch(m_type) 
{ 
  case dtCurve: 
    paintCurve(hdc,cinfo.m_rect.left,cinfo.m_rect.top); 
    break; 
} 
} 
 
VOID CI2WBCurve::writeToStream(I2MemoryFileStream *stm,BOOL fdata) 
{ 
//set WB32CONTROLDATA struct 
WB32CONTROLDATA wcd; 
wcd.cid=m_cid; 
wcd.csid=m_csid; 
lstrcpy(wcd.idname,m_name); 
lstrcpy(wcd.idgrpname,m_grpname); 
getControlRect(wcd.rect); 
if(fdata) 
{ 
  switch(m_type) 
  { 
    case dtCurve: 
      wcd.len=m_Expression.GetLength()+1+sizeof(WB32CONTROLATTRIB)+4*sizeof(INT); 
	    break; 
    default: 
      throw new I2BaseException(I2E_NOTSUPPORT); 
      break; 
  } 
} 
//write WB32CONTROLDATA struct 
stm->writeFile((CHAR*)&wcd,sizeof(WB32CONTROLDATA)); 
if(fdata) 
{ 
stm->writeFile((CHAR*)&cinfo,sizeof(WB32CONTROLATTRIB)); 
switch(m_type) 
{ 
case dtCurve: 
  stm->writeFile((CHAR*)&m_xstart,sizeof(INT)); 
  stm->writeFile((CHAR*)&m_xend,sizeof(INT)); 
  stm->writeFile((CHAR*)&m_ystart,sizeof(INT)); 
  stm->writeFile((CHAR*)&m_yend,sizeof(INT)); 
	stm->writeFile((CHAR*)m_Expression.GetBuffer(256),m_Expression.GetLength()+1); 
	break; 
 
default: 
  throw new I2BaseException(I2E_NOTSUPPORT); 
  break; 
}//end switch 
}//end if(fdata) 
} 
 
VOID CI2WBCurve::readFromStream(I2MemoryFileStream *stm,INT len,const I2Rect& r) 
{ 
VOID *p; 
if(len) 
{ 
  stm->readFile((CHAR*)&cinfo,sizeof(WB32CONTROLATTRIB)); 
  p=GlobalAlloc(GPTR,len-sizeof(WB32CONTROLATTRIB)); 
  stm->readFile((CHAR*)p,len-sizeof(WB32CONTROLATTRIB)); 
} 
 
switch(m_type) 
{ 
case dtCurve: 
  { 
  m_xstart=*(INT*)p; 
  m_xend=*((INT*)p+1); 
  m_ystart=*((INT*)p+2); 
  m_yend=*((INT*)p+3); 
  m_Expression=(CHAR*)p+sizeof(INT)*4; 
  break; 
  } 
default: 
  throw new I2BaseException(I2E_NOTSUPPORT); 
  break; 
} 
if(len) 
	GlobalFree(p); 
} 
 
VOID CI2WBCurve::OnAttribChange(INT type,INT mask,BOOL flocal) 
{ 
if(flocal) 
{ 
//  if(type == WBAT_LINEWIDTH) 
//	  m_wb->get_LineWidth(&cinfo.m_linewidth); 
//  if(type == WBAT_LINESTYLE) 
//	  m_wb->get_LineStyle(&cinfo.m_linestyle); 
  if(type == WBAT_COLOR) 
    m_wb->get_Color(&cinfo.m_color); 
  if(type == WBAT_BKCOLOR) 
	  m_wb->get_BKColor(&cinfo.m_bkcolor); 
 
//  if(type == WBAT_FONT) 
//	  m_wb->get_Font(&cinfo.m_font,mask); 
} 
} 
 
VOID CI2WBCurve::paintCurve(HDC hdc,INT cx,INT cy) 
{ 
if(!m_Expression.GetLength()) 
  return; 
HPEN holdpen,hpen; 
hpen=CreatePen(0,1,cinfo.m_color); 
holdpen=(HPEN)SelectObject(hdc,hpen); 
HFONT hfont=m_wb->createWBFont(&cinfo.m_font); 
HFONT holdfont=(HFONT)SelectObject(hdc,hfont); 
RECT r; 
CHAR buf[16]; 
SetTextColor(hdc,cinfo.m_color); 
int oldmode=SetBkMode(hdc,TRANSPARENT); 
 
SHORT px,py; 
SHORT xr,yr; 
SHORT xstep,ystep; 
xstep=(CURVE_WIDTH-2*CURVE_MARGIN)/(m_xend-m_xstart); 
ystep=(CURVE_HEIGHT-2*CURVE_MARGIN)/(m_yend-m_ystart); 
if(m_xstart<=0 && m_xend>=0) 
  xr=CURVE_MARGIN-m_xstart*xstep; 
else if(m_xstart>=0 && m_xend>=0) 
  xr=CURVE_MARGIN; 
else  
  xr=CURVE_WIDTH-CURVE_MARGIN; 
 
if(m_ystart<=0 && m_yend>=0) 
  yr=CURVE_HEIGHT-CURVE_MARGIN+m_ystart*ystep; 
else if(m_ystart>=0 && m_yend>=0) 
  yr=CURVE_HEIGHT-CURVE_MARGIN; 
else  
  yr=CURVE_MARGIN; 
 
px=cx; 
py=cy+yr; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+CURVE_WIDTH,cy+yr); 
 
px=cx+xr; 
py=cy; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+xr,cy+CURVE_HEIGHT); 
 
//x-arrow 
px=cx+CURVE_WIDTH-3; 
py=cy+yr-2; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+CURVE_WIDTH,cy+yr); 
 
px=cx+CURVE_WIDTH-3; 
py=cy+yr+2; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+CURVE_WIDTH,cy+yr); 
 
SetRect(&r,px-10,py-20,0,0); 
DrawText(hdc,"x",-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,"x",-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
 
//y-arrow 
px=cx+xr-2; 
py=cy+3; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+xr,cy); 
 
px=cx+xr+2; 
py=cy+3; 
MoveToEx(hdc,px,py,NULL); 
LineTo(hdc,cx+xr,cy); 
 
SetRect(&r,px+10,py,0,0); 
DrawText(hdc,"y",-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,"y",-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
 
//x 
INT j; 
py=cy+yr; 
if(m_xend-m_xstart>50) 
{ 
  for(j=0;j<=m_xend-m_xstart;j=j+5) 
  { 
    px=cx+CURVE_MARGIN+xstep*j; 
    MoveToEx(hdc,px,py,NULL); 
    LineTo(hdc,px,py-3); 
  } 
} 
else 
{ 
  for(j=0;j<=m_xend-m_xstart;j++) 
  { 
    px=cx+CURVE_MARGIN+xstep*j; 
    MoveToEx(hdc,px,py,NULL); 
    LineTo(hdc,px,py-3); 
  } 
} 
SetRect(&r,cx+CURVE_MARGIN,py,0,0); 
itoa(m_xstart,buf,10); 
DrawText(hdc,buf,-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,buf,-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
SetRect(&r,cx+CURVE_MARGIN+xstep*(j-1),py,0,0); 
itoa(m_xend,buf,10); 
DrawText(hdc,buf,-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,buf,-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
 
//y 
px=cx+xr; 
if(m_yend-m_ystart>50) 
{ 
  for(j=0;j<=m_yend-m_ystart;j=j+5) 
  { 
    py=cy+CURVE_HEIGHT-CURVE_MARGIN-ystep*j; 
    MoveToEx(hdc,px,py,NULL); 
    LineTo(hdc,px+3,py); 
  } 
} 
else 
{ 
  for(j=0;j<=m_yend-m_ystart;j++) 
  { 
    py=cy+CURVE_HEIGHT-CURVE_MARGIN-ystep*j; 
    MoveToEx(hdc,px,py,NULL); 
    LineTo(hdc,px+3,py); 
  } 
} 
SetRect(&r,px-20,cy+CURVE_HEIGHT-CURVE_MARGIN-10,0,0); 
itoa(m_ystart,buf,10); 
DrawText(hdc,buf,-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,buf,-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
SetRect(&r,px-20,cy+CURVE_HEIGHT-CURVE_MARGIN-ystep*j,0,0); 
itoa(m_yend,buf,10); 
DrawText(hdc,buf,-1,&r,DT_CALCRECT|DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
DrawText(hdc,buf,-1,&r,DT_EDITCONTROL|DT_NOPREFIX|DT_EXPANDTABS); 
 
SetBkMode(hdc,oldmode); 
SelectObject(hdc,holdfont); 
DeleteObject(hfont); 
 
INT x,value; 
BOOL fset=0; 
CFunction* fkt = CFunction::Parse(m_Expression); 
long double result; 
if (fkt) 
{ 
  for(x=m_xstart;x<=m_xend;x++) 
  { 
    result = fkt->Execute(x); 
    value=(INT)result*ystep; 
    if(value <= yr && value >= -CURVE_HEIGHT+CURVE_MARGIN+yr) 
    { 
      if(!fset) 
      { 
        px=cx+xr+x*xstep; 
        py=cy+yr-(INT)value; 
        MoveToEx(hdc,px,py,NULL); 
        fset=1; 
      } 
      else 
        LineTo(hdc,cx+xr+x*xstep,cy+yr-value); 
    } 
/*    else  
    { 
      if(x<0) 
      { 
        x=x+1; 
        result=(fkt->Execute(x))*m_ystep; 
        if(result<100+5 && result>-100-5) 
        { 
          if(result<0) 
          { 
            if(!fset) 
            { 
              px=cx+100+5+(x-1)*m_xstep; 
              py=cy+200+5; 
              MoveToEx(hdc,px,py,NULL); 
              fset=1; 
            } 
           // else 
           //  LineTo(hdc,cx+100+5+(x-1)*m_xstep,cy+200+5); 
          } 
          else 
          { 
            if(!fset) 
            { 
              px=cx+100+5+(x-1)*m_xstep; 
              py=cy+5; 
              MoveToEx(hdc,px,py,NULL); 
              fset=1; 
            } 
           // else 
           //   LineTo(hdc,cx+100+5+(x-1)*m_xstep,cy+5); 
          } 
        } 
        x=x-1; 
      } 
      else 
      { 
        x=x-1; 
        result = (fkt->Execute(x))*m_ystep; 
        if(result<100+5 && result>-100-5) 
        { 
          if(result<0) 
          { 
            if(!fset) 
            { 
              px=cx+100+5+(x+1)*m_xstep; 
              py=cy+200+5; 
              MoveToEx(hdc,px,py,NULL); 
              fset=1; 
            } 
          //  else 
          //    LineTo(hdc,cx+100+5+(x+1)*m_xstep,cy+200+5); 
          } 
          else 
          { 
            if(!fset) 
            { 
              px=cx+100+5+(x+1)*m_xstep; 
              py=cy+5; 
              MoveToEx(hdc,px,py,NULL); 
              fset=1; 
            } 
         //   else 
         //     LineTo(hdc,cx+100+5+(x+1)*m_xstep,cy+5); 
          } 
        } 
        x=x+1;         
      } 
    }      */ 
  } 
} 
 
SelectObject(hdc,holdpen); 
DeleteObject(hpen); 
} 
 
 
extern HINSTANCE g_hinstance; 
 
CI2WBCurveSet::CI2WBCurveSet() 
{ 
 
} 
 
CI2WBCurveSet::~CI2WBCurveSet() 
{ 
 
} 
 
VOID CI2WBCurveSet::enumControlInfo(I2List& m_infolist) 
{ 
if(!g_hinstance) 
  g_hinstance=GetModuleHandle("iaspwb.dll"); 
WB32CONTROLINFO wbci; 
wbci.cid=Draw_Pen; 
wbci.hicon=LoadIcon(g_hinstance,MAKEINTRESOURCE(IDI_C_CURVE)); 
wbci.hcursor=LoadCursor(g_hinstance,MAKEINTRESOURCE(IDC_C_PEN)); 
LoadString(g_hinstance,IDS_NAME_PEN,wbci.name,MAX_CONTROLNAME); 
LoadString(g_hinstance,IDS_DESC_PEN,wbci.description,MAX_CONTROLNAME); 
wbci.type=0; 
m_infolist.append(wbci); 
 
m_infopos=0; 
} 
 
VOID CI2WBCurveSet::createControl(INT cid,VOID* pwb,VOID** ppawc,HWND hwnd) 
{ 
if(!pwb||!ppawc) 
   throw new I2BaseException(I2E_INVALIDPARAMETER); 
*ppawc=(VOID*)new CI2WBCurve(cid,pwb); 
 
if(!*ppawc) 
   throw new I2BaseException(I2E_OUTOFMEMORY); 
} 
 
 
VOID CI2WBCurveSet::getControlSetID(GUID* Value) 
{ 
*Value=CSID_Curve; 
} 
 
VOID CI2WBCurveSet::getControlCursor(INT cid,HCURSOR* pcur) 
{ 
switch(cid) 
{ 
case 0: 
   *pcur=LoadCursor(g_hinstance,MAKEINTRESOURCE(IDC_C_CTRL)); 
   break; 
 
default: 
   throw new I2BaseException(I2E_INVALIDPARAMETER); 
   break; 
} 
} 
 
CFuncDlg::CFuncDlg(CI2WBBaseCtrl* pawc) 
{ 
  m_pawc=pawc; 
  m_pressok=0; 
} 
 
void CFuncDlg::onInitliaze(const I2Dialog& dlg) 
{ 
  char buf[10],buf1[32]; 
  INT  color; 
  itoa(m_pawc->cinfo.m_linestyle,buf,10); 
  itemMessage(IDC_P_LINESTYLE,WM_SETTEXT,0, (LPARAM)buf); 
  itoa(m_pawc->cinfo.m_linewidth,buf,10); 
  itemMessage(IDC_P_LINEWIDTH,WM_SETTEXT,0, (LPARAM)buf); 
  color=GetRValue(m_pawc->cinfo.m_color);    
  itoa(color,buf,10); 
  lstrcpy(buf1,buf); 
  lstrcat(buf1," "); 
  color=GetGValue(m_pawc->cinfo.m_color); 
  itoa(color,buf,10); 
  lstrcat(buf1,buf); 
  lstrcat(buf1," "); 
  color=GetBValue(m_pawc->cinfo.m_color); 
  itoa(color,buf,10); 
  lstrcat(buf1,buf); 
  itemMessage(IDC_P_COLOR,WM_SETTEXT,0, (LPARAM)buf1); 
  color=GetRValue(m_pawc->cinfo.m_bkcolor); 
  itoa(color,buf,10); 
  lstrcpy(buf1,buf); 
  lstrcat(buf1," "); 
  color=GetGValue(m_pawc->cinfo.m_bkcolor); 
  itoa(color,buf,10); 
  lstrcat(buf1,buf); 
  lstrcat(buf1," "); 
  color=GetBValue(m_pawc->cinfo.m_bkcolor); 
  itoa(color,buf,10); 
  lstrcat(buf1,buf); 
  itemMessage(IDC_P_BCOLOR,WM_SETTEXT,0, (LPARAM)buf1); 
  itemMessage(IDC_P_FONT,WM_SETTEXT,0, (LPARAM)m_pawc->cinfo.m_font.name); 
  itoa(m_pawc->cinfo.m_font.size,buf,10); 
  itemMessage(IDC_P_FONTSIZE,WM_SETTEXT,0, (LPARAM)buf); 
 
  itemMessage(IDC_FUNCTION,WM_SETTEXT,0, (LPARAM)g_buf); 
  itoa(g_xstart,buf,10); 
  itemMessage(IDC_XSTART,WM_SETTEXT,0, (LPARAM)buf); 
  itoa(g_xend,buf,10); 
  itemMessage(IDC_XEND,WM_SETTEXT,0, (LPARAM)buf); 
  itoa(g_ystart,buf,10); 
  itemMessage(IDC_YSTART,WM_SETTEXT,0, (LPARAM)buf); 
  itoa(g_yend,buf,10); 
  itemMessage(IDC_YEND,WM_SETTEXT,0, (LPARAM)buf); 
} 
 
void CFuncDlg::onCommand(const I2Dialog& dlg,WORD wID,WORD wNotifyCode) 
{ 
  char buf[16]; 
  memset(buf,0,16); 
  if(wID==IDCANCEL) 
  { 
    g_xstart=-10; 
    g_ystart=-10; 
    g_xend=10; 
    g_yend=10; 
    destroy(); 
  } 
  else if(wID==IDOK) 
  { 
    m_pressok=1; 
    itemMessage(IDC_FUNCTION,WM_GETTEXT,255, (LPARAM)g_buf); 
    itemMessage(IDC_XSTART,WM_GETTEXT,16, (LPARAM)buf); 
    g_xstart=atoi(buf); 
    itemMessage(IDC_XEND,WM_GETTEXT,16, (LPARAM)buf); 
    g_xend=atoi(buf); 
    itemMessage(IDC_YSTART,WM_GETTEXT,16, (LPARAM)buf); 
    g_ystart=atoi(buf); 
    itemMessage(IDC_YEND,WM_GETTEXT,16, (LPARAM)buf); 
    g_yend=atoi(buf); 
 
    if(lstrlen(g_buf)) 
      if((g_xend-g_xstart)>=0 && (g_yend-g_ystart)>=0 
        && g_xend-g_xstart<=200 && g_yend-g_ystart<=200 ) 
          destroy(); 
      else 
        MessageBox(NULL,"参数无效","信息",MB_OK); 
    else  
      MessageBox(NULL,"表达式不能为空","信息",MB_OK); 
  } 
}