?? babygrid.cpp
字號:
k=strlen(tbuffer);
c=0;
for(j=13;j<k;j++)
{
buffer[c]=tbuffer[j];
c++;
}
buffer[c]=0x00;
strcpy((char*)lParam,buffer);
}
else
{
strcpy((char*)lParam,"");
}
break;
case BGM_CLEARGRID:
SendMessage(BGHS[SelfIndex].hlist1,LB_RESETCONTENT,0,0);
BGHS[SelfIndex].rows = 0;
BGHS[SelfIndex].cursorrow = 1;
BGHS[SelfIndex].homerow = 1;
BGHS[SelfIndex].homecol = 1;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,TRUE);
}
break;
case BGM_DELETECELL:
LPBGcell=(_BGCELL*)wParam;
if(OutOfRange(LPBGcell))
{
wParam=MAKEWPARAM((UINT)GetMenu(hWnd),BGN_OUTOFRANGE);
lParam = 0;
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
ReturnValue = -1;
break;
}
wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col);
//see if that cell is already loaded
FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer);
if(FindResult != LB_ERR)
{
//it was found, delete it
SendMessage(BGHS[SelfIndex].hlist1,LB_DELETESTRING,FindResult,0);
NotifyEndEdit(hWnd,SelfIndex);
}
break;
case BGM_SETGRIDDIM:
if((wParam>=0)&&(wParam<=MAX_ROWS))
{
BGHS[SelfIndex].rows = wParam;
}
else
{
if(wParam<0)
{
BGHS[SelfIndex].rows = 0;
}
else
{
BGHS[SelfIndex].rows = MAX_ROWS;
}
}
if((lParam>0)&&(lParam<=MAX_COLS))
{
BGHS[SelfIndex].cols = lParam;
}
else
{
if(lParam <= 0)
{
BGHS[SelfIndex].cols = 1;
}
else
{
BGHS[SelfIndex].cols = MAX_COLS;
}
}
{RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,TRUE);
}
GetVisibleColumns(hWnd,SelfIndex);
break;
case BGM_SETCOLWIDTH:
if((wParam <= MAX_COLS)&&(wParam >= 0) && (lParam >= 0))
{
RECT rect;
BGHS[SelfIndex].columnwidths[wParam] = lParam;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
GetVisibleColumns(hWnd,SelfIndex);
}
break;
case BGM_SETHEADERROWHEIGHT:
if(wParam >= 0)
{
RECT rect;
BGHS[SelfIndex].headerrowheight = wParam;
SizeGrid(hWnd,SelfIndex);
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_GETROW:
ReturnValue = BGHS[SelfIndex].cursorrow;
break;
case BGM_GETCOL:
ReturnValue = BGHS[SelfIndex].cursorcol;
break;
case BGM_GETTYPE:
LPBGcell=(_BGCELL*)wParam;
if(OutOfRange(LPBGcell))
{
wParam=MAKEWPARAM((UINT)GetMenu(hWnd),BGN_OUTOFRANGE);
lParam = 0;
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
ReturnValue = -1;
break;
}
wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col);
//see if that cell is already loaded
FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer);
if(FindResult != LB_ERR)
{
//it was found, get it
SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,FindResult,(LPARAM)buffer);
switch (buffer[11])
{
case 'A':ReturnValue=1;break;
case 'N':ReturnValue=2;break;
case 'T':ReturnValue=3;break;
case 'F':ReturnValue=4;break;
case 'G':ReturnValue=5;break;
default: ReturnValue =1;break;
}
}
break;
case BGM_GETPROTECTION:
LPBGcell=(_BGCELL*)wParam;
if(OutOfRange(LPBGcell))
{
wParam=MAKEWPARAM((UINT)GetMenu(hWnd),BGN_OUTOFRANGE);
lParam = 0;
SendMessage(GetParent(hWnd),WM_COMMAND,wParam,lParam);
ReturnValue = -1;
break;
}
wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col);
//see if that cell is already loaded
ReturnValue = 0;
FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer);
if(FindResult != LB_ERR)
{
//it was found, get it
SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,FindResult,(LPARAM)buffer);
switch (buffer[10])
{
case 'U':ReturnValue=0;break;
case 'P':ReturnValue=1;break;
default: ReturnValue =0;break;
}
}
break;
case BGM_SETROWHEIGHT:
if(wParam <1){wParam=1;}
BGHS[SelfIndex].rowheight = wParam;
SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SizeGrid(hWnd,SelfIndex);
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETTITLEHEIGHT:
if(wParam<0){wParam =0;}
BGHS[SelfIndex].titleheight = wParam;
SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol);
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETGRIDLINECOLOR:
DrawCursor(hWnd,SelfIndex);
BGHS[SelfIndex].gridlinecolor = (COLORREF)wParam;
DrawCursor(hWnd,SelfIndex);
RefreshGrid(hWnd);
break;
case BGM_SETCURSORCOLOR:
DrawCursor(hWnd,SelfIndex);
BGHS[SelfIndex].cursorcolor = (COLORREF)wParam;
DrawCursor(hWnd,SelfIndex);
RefreshGrid(hWnd);
break;
case BGM_SETHILIGHTTEXTCOLOR:
BGHS[SelfIndex].highlighttextcolor = (COLORREF)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETHILIGHTCOLOR:
BGHS[SelfIndex].highlightcolor = (COLORREF)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETPROTECTCOLOR:
BGHS[SelfIndex].protectcolor = (COLORREF)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETUNPROTECTCOLOR:
BGHS[SelfIndex].unprotectcolor = (COLORREF)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETELLIPSIS:
BGHS[SelfIndex].ELLIPSIS = (BOOL)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETTITLEFONT:
BGHS[SelfIndex].htitlefont = (HFONT)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETHEADINGFONT:
BGHS[SelfIndex].hcolumnheadingfont = (HFONT)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETROWSNUMBERED:
BGHS[SelfIndex].ROWSNUMBERED = (BOOL)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case BGM_SETCOLSNUMBERED:
BGHS[SelfIndex].COLUMNSNUMBERED = (BOOL)wParam;
{
RECT rect;
GetClientRect(hWnd,&rect);
InvalidateRect(hWnd,&rect,FALSE);
}
break;
case WM_ENABLE:
if(wParam == FALSE)
{
BGHS[SelfIndex].textcolor = RGB(120,120,120);
}
else
{
BGHS[SelfIndex].textcolor = RGB(0,0,0);
}
case WM_MOUSEMOVE:
int x,y,r,c,t,z;
x=LOWORD(lParam);
y=HIWORD(lParam);
r=GetRowOfMouse(SelfIndex,y);
c=GetColOfMouse(SelfIndex,x);
t=GetColOfMouse(SelfIndex,x+10);
z=GetColOfMouse(SelfIndex,x-10);
if(BGHS[SelfIndex].COLUMNSIZING)
{
int dx,nx,cr;
dx=x-BGHS[SelfIndex].columntoresizeinitx;
nx=BGHS[SelfIndex].columntoresizeinitsize + dx;
if(nx<=0){nx=0;}
cr=BGHS[SelfIndex].columntoresize;
SendMessage(hWnd,BGM_SETCOLWIDTH,cr,nx);
}
if((r==0)&&(c>=-1)&&((t!=c)||(z!=c))&&(!BGHS[SelfIndex].COLUMNSIZING))
{
if((BGHS[SelfIndex].cursortype != 2)&&(BGHS[SelfIndex].ALLOWCOLUMNRESIZING))
{
BGHS[SelfIndex].cursortype = 2;
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
}
}
else
{
if((BGHS[SelfIndex].cursortype != 1)&&(!BGHS[SelfIndex].COLUMNSIZING))
{
BGHS[SelfIndex].cursortype = 1;
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
}
break;
case WM_LBUTTONUP:
if(BGHS[SelfIndex].COLUMNSIZING)
{
BGHS[SelfIndex].COLUMNSIZING = FALSE;
SetCursor(LoadCursor(NULL, IDC_ARROW));
BGHS[SelfIndex].cursortype = 1;
BGHS[SelfIndex].SHOWINTEGRALROWS=BGHS[SelfIndex].REMEMBERINTEGRALROWS;
SizeGrid(hWnd,SelfIndex);
}
break;
case WM_RBUTTONUP :
case WM_LBUTTONDBLCLK :
case WM_LBUTTONDOWN:
{
int x,y,r,c;
//check for column sizing
if(BGHS[SelfIndex].cursortype == 2)
{
int c,x,t,z;
//start column sizing
if(!BGHS[SelfIndex].COLUMNSIZING)
{
BGHS[SelfIndex].REMEMBERINTEGRALROWS = BGHS[SelfIndex].SHOWINTEGRALROWS;
}
BGHS[SelfIndex].COLUMNSIZING = TRUE;
BGHS[SelfIndex].SHOWINTEGRALROWS = FALSE;
x=LOWORD(lParam);
BGHS[SelfIndex].columntoresizeinitx=x;
t=GetColOfMouse(SelfIndex,x+10);
z=GetColOfMouse(SelfIndex,x-10);
c=GetColOfMouse(SelfIndex,x);
if(t!=c)
{
//resizing column c
BGHS[SelfIndex].columntoresize = c;
}
if(z!=c)
{
//resizing hidden column to the left of cursor
if(c==-1)
{
c=SendMessage(hWnd,BGM_GETCOLS,0,0);
}
else
{
c-=1;
}
BGHS[SelfIndex].columntoresize = c;
}
BGHS[SelfIndex].columntoresizeinitsize = BGHS[SelfIndex].columnwidths[c];
}
if(BGHS[SelfIndex].EDITING)
{
CloseEdit(hWnd,SelfIndex);
}
else
{
SetFocus(hWnd);
}
BOOL NRC,NCC;
NRC=FALSE;
NCC=FALSE;
if(GetFocus()==hWnd)
{
x=LOWORD(lParam);
y=HIWORD(lParam);
r=GetRowOfMouse(SelfIndex,y);
c=GetColOfMouse(SelfIndex,x);
DrawCursor(hWnd,SelfIndex);
if((r>0)&&(c>0))
{
if(r != BGHS[SelfIndex].cursorrow)
{
BGHS[SelfIndex].cursorrow = r;
NRC=TRUE;
}
else
{
BGHS[SelfIndex].cursorrow = r;
}
if(c != BGHS[SelfIndex].cursorcol)
{
BGHS[SelfIndex].cursorcol = c;
NCC=TRUE;
}
else
{
BGHS[SelfIndex].cursorcol = c;
}
}
if(NRC){NotifyRowChanged(hWnd,SelfIndex);}
if(NCC){NotifyColChanged(hWnd,SelfIndex);}
DrawCursor(hWnd,SelfIndex);
SetCurren
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -