仓酷云

标题: MSSQL教程之一个供查询用的datawindow [打印本页]

作者: 活着的死人    时间: 2015-1-16 22:40
标题: MSSQL教程之一个供查询用的datawindow
使为了数据安全,我们搭建了主从。但实时主从备份只能防止硬件问题,比如主库的硬盘损坏。但对于误操作,则无能为力。比如在主库误删一张表,或者一个update语句没有指定where条件,导致全表被更新。window
次要供以grid体例展现查询数据利用,包含以下几个功效:

1、点击列头排序(可选);

2、时分,主动用微匡助展现(可选);

3、数据库毛病时中文提醒;

包含以下工具(按按次导进便可):

1、gf_dberrormsg

globaltypegf_dberrormsgfromfunction_objectendtype

forwardprototypesglobalfunctionintegergf_dberrormsg(longsqldbcode,stringsqlerrtext,longrow,stringas_ty)endprototypes

globalfunctionintegergf_dberrormsg(longsqldbcode,stringsqlerrtext,longrow,stringas_ty);//有关数据窗口的毛病:ChooseCaseSQLDBCodeCase1400Ifas_ty="freeform"ThenMessageBox("提醒信息","请查找空项,并填进内容,才干保留!")ElseMessageBox("提醒信息","请查找第"+String(row)+"行空列,并填进内容,才干保留!")EndIfCase1Ifas_ty="freeform"ThenMessageBox("提醒信息","此项纪录已存在,不克不及反复!")ElseMessageBox("提醒信息","请查反复行第"+String(row)+"行,修正某列或删除反复行,才干保留!")EndIfCase3114MessageBox("提醒信息","没有毗连数据库,倡议从头运转使用程序!")Case-193Ifas_ty="freeform"ThenMessageBox("提醒信息","此项纪录已存在,不克不及反复!")ElseMessageBox("提醒信息","请查反复行第"+String(row)+"行,修正某列或删除反复行,才干保留!")EndIfCase-195//RequiredvalueisNULL.Ifas_ty="freeform"ThenMessageBox("提醒信息","请查找空项,并填进内容,才干保留!")ElseMessageBox("提醒信息","请查找第"+String(row)+"行空列,并填进内容,才干保留!")EndIfCase-3MessageBox("注重信息","原数据已被别的用户修正,请从头检索后再保留!")Case2601MessageBox("注重信息","主键纪录反复,不克不及保留!")Case233MessageBox("注重信息","主键纪录为空,不克不及保留!")Case1105//Sybase??MessageBox("注重信息","数据库日记满,请关照体系办理员清日记!")Case2627MessageBox("注重信息","您新增的纪录已存在,拔出失利!大概是收集抵触,请您稍后再做此项操纵。")Case-932MessageBox("注重信息","请反省收集是不是一般事情!")Case10004MessageBox("注重信息","请反省数据库是不是一般事情!")Case999MessageBox("注重信息","请反省服务器是不是一般事情!")CaseElseMessageBox("数据库提醒信息:","堕落行:"+String(row)+",堕落信息:"+SQLErrText+"SQLDBCode:"+string(SQLDBCode))EndChoose

Return1

endfunction

2、n_cst_dwsrv_gridsort

forwardglobaltypen_cst_dwsrv_gridsortfromnonvisualobjectendtypeendforward

globaltypen_cst_dwsrv_gridsortfromnonvisualobjecteventtypelongue_lbuttondown(unsignedlongflags,integerxpos,integerypos)eventtypelongue_lbuttonup(unsignedlongflags,integerxpos,integerypos)endtypeglobaln_cst_dwsrv_gridsortn_cst_dwsrv_gridsort

typeprototypesFunctionULongSetCapture(ULonghWnd)Library"USER32.DLL"FunctionBooleanReleaseCapture()Library"USER32.DLL"

endprototypes

typevariablesPrivate:DataWindowidw_requestorstringi_str_oldcolumn//前次点击排序的列名stringi_str_newcolumn//本次点击排序的列名stringi_str_arrowname//排序用的小三角标记名stringi_str_sort=A//前次排序是升序(A)仍是降序(B)stringi_str_flag=0//是不是已实行准确的鼠标按下事务(0-否,1-是)

endvariables

forwardprototypespublicfunctionintegerof_setrequestor(datawindowadw_requestor)endprototypes

eventtypelongue_lbuttondown(unsignedlongflags,integerxpos,integerypos);Stringstr_band,str_object,str_title,str_columnintli_x

str_band=idw_requestor.GetBandAtPointer()//失掉以后鼠标所指工具地点的带区str_band=Left(str_band,(Pos(str_band,~t)-1))Ifstr_bandheaderThenReturn0//单击非头区,加入str_object=idw_requestor.GetObjectAtPointer()//失掉以后鼠标所指工具名str_object=Left(str_object,(Pos(str_object,~t)-1))Ifstr_object=OrIsNull(str_object)ThenReturn0//未失掉,加入IfRight(str_object,4)=_lagThen//点击的是小三角标记工具,申明前次点击过该列str_title=Left(str_object,(Len(str_object)-4))Else//头一次点击该列str_title=str_objectEndIf//失掉列工具名(默许为列名_t为列题目)str_column=Left(str_title,(Len(str_title)-2))//判别该称号是不是为列名字Ifidw_requestor.Describe(str_column+".band")=!ThenReturn0//非是列名,即列题目不是按一般纪律起名的。

//列的交代处,大概呈现调剂列宽度形态li_x=integer(idw_requestor.Describe(str_object+".X"))ifString(idw_requestor.Object.DataWindow.HorizontalScrollSplit)=0thenifxpos+integer(idw_requestor.Object.DataWindow.HorizontalScrollPosition)-li_x<=6thenreturn0endifendif

i_str_newcolumn=str_column//失掉以后单击的列idw_requestor.Modify(str_title+".border=5")//设置下凹动画效果i_str_flag=1//已启动单击事务//设置鼠标捕捉SetCapture(Handle(idw_requestor))//将鼠标的举措转移给指定的DW窗口Return0

endevent

eventtypelongue_lbuttonup(unsignedlongflags,integerxpos,integerypos);Stringstr_title,str_object,str_tmp,str_column,str_sortLonglng_posy,lng_left,lng_top,lng_right,lng_bottom

lng_posy=yposstr_object=idw_requestor.GetObjectAtPointer()ReleaseCapture()//必需先开释鼠标不然该鼠标举措将一向被数据窗口捕捉

str_title=i_str_newcolumn+_tIfi_str_flag=1Thenlng_left=Long(idw_requestor.Describe(str_title+".x"))lng_top=Long(idw_requestor.Describe(str_title+".y"))lng_right=lng_left+Long(idw_requestor.Describe(str_title+".width"))lng_bottom=lng_top+Long(idw_requestor.Describe(str_title+".height"))str_object=Left(str_object,(Pos(str_object,~t)-1))IfNot(str_object=OrIsNull(str_object))Then//失掉单击工具IfRight(str_object,4)=_lagThen//点击的是箭头工具,申明前次已点击过此列str_tmp=Left(str_object,(Len(str_object)-4))Else//头一次点击该列str_tmp=str_objectEndIfIfstr_tmp=str_titleThen//申明是在点击列上开释鼠标的//判别是不是前次点击该列,并排序Ifi_str_oldcolumn=i_str_newcolumnThen//前次点击的也是此列Ifi_str_sort=AThenstr_sort=Dstr_tmp=6Elsestr_sort=Astr_tmp=5EndIfElse//前次点击的不是此列str_sort=Astr_tmp=5EndIf//不论有无全删除箭头工具idw_requestor.Modify("destroy"+i_str_arrowname)i_str_arrowname=str_title+_lag//天生新的箭头工具名=题目名_lagstr_tmp=createtext(band=headeralignment="0"text="+str_tmp+"border="0"color="16711680"x="+String(lng_left)+"y="+String(lng_top)+"height="+String(lng_bottom-lng_top)+"width="10"name=+i_str_arrowname+visible="1"font.face="Webdings"font.height="-12"font.weight="400"font.family="1"font.pitch="2"font.charset="2"background.mode="1"background.color="553648127")idw_requestor.Modify(str_tmp)str_tmp=i_str_newcolumn++str_sortidw_requestor.SetSort(str_tmp)idw_requestor.Sort()i_str_oldcolumn=i_str_newcolumni_str_newcolumn=i_str_sort=str_sortEndIfEndIfEndIfidw_requestor.Modify(str_title+".border=6")i_str_flag=0Return0

endevent

publicfunctionintegerof_setrequestor(datawindowadw_requestor);IfIsNull(adw_requestor)orNotIsValid(adw_requestor)ThenReturn-1EndIf

idw_Requestor=adw_RequestorReturn1endfunction

onn_cst_dwsrv_gridsort.createcallsuper::createTriggerEvent(this,"constructor")endon

onn_cst_dwsrv_gridsort.destroyTriggerEvent(this,"destructor")callsuper::destroyendon

eventconstructor;//单击列题目对列举行排序endevent

3、nvo_tooltips

forwardglobaltypenvo_tooltipsfromnonvisualobjectendtypetypepointfromstructurewithinnvo_tooltipsendtypetypemsgfromstructurewithinnvo_tooltipsendtypetyperectfromstructurewithinnvo_tooltipsendtypetypetoolinfofromstructurewithinnvo_tooltipsendtypeendforward

typepointfromstructurelongxlongyendtype

typemsgfromstructurelonghwndlongmessagelongwparamlonglparamlongtimepointptendtype

typerectfromstructurelongleftlongtoplongrightlongbottomendtype

typetoolinfofromstructurelongcbsizelonguflagslonghwndlonguidrectrectlonghinstancestringlpsztextendtype

globaltypenvo_tooltipsfromnonvisualobjectautoinstantiateendtype

typeprototypes//ToolTips函数SubRoutineInitCommonControls()library"comctl32.dll"FunctionlongCreateWindowExA(ulongdwExStyle,stringClassName,&longWindowName,ulongdwStyle,ulongX,ulongY,ulongnWidth,&ulongnHeight,ulonghWndParent,ulonghMenu,ulonghInstance,&ulonglpParam)library"user32.dll"FunctionintegerDestroyWindow(longhWnd)library"user32.dll"FunctionintegerToolTipMsg(longhWnd,longuMsg,longwParam,&REFTOOLINFOToolInfo)library"user32.dll"AliasFor"SendMessageA"FunctionintegerRelayMsg(longhWnd,longuMsg,longwParam,&REFMSGMsg)library"user32.dll"AliasFor"SendMessageA"FunctionuLongSendMessageString(uLonghwnd,uLongMsg,uLongwParam,RefStringlpzString)Library"user32.dll"AliasFor"SendMessageA"FUNCTIONulongShowWindow(ulonghwnd,ulongnCmdShow)LIBRARY"user32.dll"//内存办理函数//FunctionlongLocalAlloc(longFlags,longBytes)library"kernel32.dll"//FunctionlongLocalFree(longMemHandle)library"kernel32.dll"//Functionlonglstrcpy(longDestination,stringSource)library"kernel32.dll"

FUNCTIONulongIsWindowVisible(ulonghwnd)LIBRARY"user32.dll"endprototypes

typevariables//公有常量Private:

//杂项常量CONSTANTstringTOOLTIPS_CLASS=tooltips_class32CONSTANTulongCW_USEDEFAULT=2147483648CONSTANTlongWM_USER=1024CONSTANTlongWS_EX_TOPMOST=8CONSTANTlongWM_SETFONT=48

//ToolTipMessagesConstantlongTTM_ADDTOOL=WM_USER+4ConstantlongTTM_DELTOOL=WM_USER+5ConstantlongTTM_NEWTOOLRECT=WM_USER+6ConstantlongTTM_RELAYEVENT=WM_USER+7ConstantlongTTM_POPUP=WM_USER+34ConstantlongTTM_UPDATE=WM_USER+29ConstantlongTTM_UPDATETIPTEXT=WM_USER+12ConstantlongTTM_TRACKACTIVATE=WM_USER+17ConstantlongTTM_TRACKPOSITION=WM_USER+18ConstantlongTTM_SETMAXTIPWIDTH=1048ConstantlongTTM_GETMAXTIPWIDTH=WM_USER+25ConstantlongTTM_SETTIPBKCOLOR=WM_USER+19ConstantlongTTM_SETTIPTEXTCOLOR=WM_USER+20ConstantlongTTM_SETTITLEA=WM_USER+32//TooltipflagsConstantintegerTTF_CENTERTIP=2ConstantintegerTTF_RTLREADING=4ConstantintegerTTF_SUBCLASS=16ConstantintegerTTF_TRACK=32ConstantintegerTTF_ABSOLUTE=128ConstantintegerTTF_TRANSPARENT=256ConstantintegerTTF_DI_SETITEM=32768ConstantintegerTTS_BALLOON=64

//TitleConstantsConstantintegerTTI_NONE=0ConstantintegerTTI_INFO=1ConstantintegerTTI_WARNING=2ConstantintegerTTI_ERROR=3//大众变量和常量Public:longhWndTT=0//TooltipcontrolwindowhandlelongToolID=1//TooltipinternalID

CONSTANTintegerSTYLE_NORMAL=0CONSTANTintegerSTYLE_BALLOONTIP=1integerTIPSTYLE



endvariables

forwardprototypespublicsubroutinesetfont(longhfont)publicsubroutinesettipposition(integerx,integery)publicsubroutinesettrack(dragobjectobject,integeruid,booleanstatus)publicsubroutineupdatetiprect(dragobjectobject,longuid,longleft,longtop,longright,longbottom)publicfunctionintegeraddtool(dragobjectobject,stringtiptext,integerflags)publicsubroutinehidetip(dragobjectcontrolobject)publicsubroutinesettiptext(dragobjectobject,longuid,stringtiptext)publicsubroutinesetmaxwidth(longal_maxwidth)publicfunctionintegerremovetool(dragobjectado_object,integerai_toolid)publicsubroutinesettiptitle(integerai_icon,stringas_title)publicsubroutinesettipbkcolor(longaul_color)publicsubroutinerelaymsg(dragobjectobject)publicfunctionbooleantipvisible()publicsubroutinerelaymsg(dragobjectobject,longwordparm,integerlongparm)endprototypes

publicsubroutinesetfont(longhfont);//此函数用于设置ToolTips窗口的字体,代码以下:

Send(hWndTT,WM_SETFONT,hFont,1)

endsubroutine

publicsubroutinesettipposition(integerx,integery);//此函数用于设置ToolTips的地位,代码以下:

Send(hWndTT,TTM_TRACKPOSITION,0,Long(X,Y))

endsubroutine

publicsubroutinesettrack(dragobjectobject,integeruid,booleanstatus);//此函数用于激活或作废ToolTips窗口设置新文本,代码以下://参数Status为True时激活,为False时作废

TOOLINFOToolInfo

ToolInfo.cbSize=40ToolInfo.hWnd=Handle(Object)ToolInfo.uID=uID

IfStatusThenToolTipMsg(hWndTT,TTM_TRACKACTIVATE,1,ToolInfo)ElseToolTipMsg(hWndTT,TTM_TRACKACTIVATE,0,ToolInfo)EndIf

endsubroutine

publicsubroutineupdatetiprect(dragobjectobject,longuid,longleft,longtop,longright,longbottom);//此函数用于更新ToolTips的矩形框,代码以下:

TOOLINFOTOOLINFO

TOOLINFO.hWnd=Handle(Object)TOOLINFO.uID=uID

TOOLINFO.Rect.Left=LeftTOOLINFO.Rect.Top=TopTOOLINFO.Rect.Right=RightTOOLINFO.Rect.Bottom=Bottom

ToolTipMsg(hWndTT,TTM_NEWTOOLRECT,0,TOOLINFO)

endsubroutine

publicfunctionintegeraddtool(dragobjectobject,stringtiptext,integerflags);//此函数用于注册要显现ToolTips的把持,代码以下:IfhWndTT<=0ThenIfTIPSTYLE=STYLE_BALLOONTIPThenhWndTT=CreateWindowExA(WS_EX_TOPMOST,TOOLTIPS_CLASS,0,TTF_CENTERTIP+TTS_BALLOON,&CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,&0,0,Handle(GetApplication()),0)ElsehWndTT=CreateWindowExA(WS_EX_TOPMOST,TOOLTIPS_CLASS,0,TTF_CENTERTIP,&CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,&0,0,Handle(GetApplication()),0)EndIfEndIf

TOOLINFOTOOLINFO

TOOLINFO.cbSize=40TOOLINFO.uFlags=FlagsTOOLINFO.hWnd=Handle(Object)TOOLINFO.hInstance=0TOOLINFO.uID=ToolIDToolID++TOOLINFO.lpszText=tiptext//LStrCpy(ToolInfo.lpszText,Left(tiptext,80))

TOOLINFO.Rect.Left=0TOOLINFO.Rect.Top=0TOOLINFO.Rect.Right=UnitsToPixels(Object.Width,XUnitsToPixels!)TOOLINFO.Rect.Bottom=UnitsToPixels(Object.Height,YUnitsToPixels!)

IfToolTipMsg(hWndTT,TTM_ADDTOOL,0,TOOLINFO)=0Then//MessageBox("毛病","不克不及注册控件!",StopSign!,Ok!)//LocalFree(ToolInfo.lpszText)//开释分派的内存Return(-1)EndIf

//LocalFree(ToolInfo.lpszText)//开释分派的内存Return(ToolID-1)

endfunction

publicsubroutinehidetip(dragobjectcontrolobject);MSGMSGMSG.hWnd=Handle(ControlObject)MSG.Message=513//WM_LBUTTONDOWNMSG.WParam=Message.WordParmMSG.Lparam=Message.LongParm

RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

endsubroutine

publicsubroutinesettiptext(dragobjectobject,longuid,stringtiptext);//此函数用于为ToolTips窗口设置新文本,代码以下:

TOOLINFOToolInfo

ToolInfo.hWnd=Handle(Object)ToolInfo.uID=uIDToolInfo.lpszText=TipText

ToolTipMsg(hWndTT,TTM_UPDATETIPTEXT,0,ToolInfo)

endsubroutine

publicsubroutinesetmaxwidth(longal_maxwidth);/*****************************************************************************

Function:of_setmaxwidth

Description:Setsthemaximumtooltipwidth.Ifthetextislongeritwillsplittedovermorethanoneline.

Returns:(none)

Arguments:Longal_MaxWidth

Use:Calltosetthemaximumwidth.

-------------------------------------------------------------------------------

Auteur:AartOnkenhout

RevisionHistory--------------------DateVersion15-05-20001.0Initialversion

******************************************************************************/

Send(hWndTT,TTM_SETMAXTIPWIDTH,0,UnitsToPixels(al_MaxWidth,xUnitsToPixels!))

Returnendsubroutine

publicfunctionintegerremovetool(dragobjectado_object,integerai_toolid);/*****************************************************************************

Function:of_removetool

Description:Unregistersacontrolwithinthetooltipcontrol

Returns:(none)

Arguments:DragObjectado_ObjectObjecttounregisterwithinthetooltipcontrolIntegerai_ToolIdToolId(returnedbyof_AddTool)

Use:

-------------------------------------------------------------------------------

Auteur:AartOnkenhout

RevisionHistory--------------------DateVersion29-06-20011.0Initialversion

******************************************************************************/

TOOLINFOTOOLINFOIntegerli_Width,li_Height

TOOLINFO.cbSize=40TOOLINFO.uFlags=16//FlagsTOOLINFO.hWnd=Handle(ado_Object)TOOLINFO.hInstance=0//NotusedTOOLINFO.uID=ai_ToolID

ToolTipMsg(hWndTT,TTM_DELTOOL,0,TOOLINFO)

Return1

endfunction

publicsubroutinesettiptitle(integerai_icon,stringas_title);/*****************************************************************************

Function:of_settiptitle

Description:Setsthetitleofthetooltip

Returns:(none)

Arguments:Integerai_IconValues:TTI_NONE=0TTI_INFO=1TTI_WARNING=2TTI_ERROR=3Stringas_Title

Use:Callwiththedesiredtitleandicon.

-------------------------------------------------------------------------------

Auteur:AartOnkenhout

RevisionHistory--------------------DateVersion10-05-20011.0Initialversion

******************************************************************************/

SendMessageString(hWndTT,TTM_SETTITLEA,ai_Icon,as_Title)endsubroutine

publicsubroutinesettipbkcolor(longaul_color);/*****************************************************************************

Function:of_settipbkcolor

Description:Setsthebackgroundcolorofthetooltip-window

Returns:(none)

Arguments:uLongaul_Color

Use:Callwiththedesiredcolor

-------------------------------------------------------------------------------

Auteur:AartOnkenhout

RevisionHistory--------------------DateVersion10-05-20011.0Initialversion

******************************************************************************/

Send(hWndTT,TTM_SETTIPBKCOLOR,aul_color,0)endsubroutine

publicsubroutinerelaymsg(dragobjectobject);//此函数用于向显现ToolTips窗口发送把持动静,代码以下:MSGMSG

MSG.hWnd=Handle(Object)//WM_MOUSEMOVEMSG.Message=512MSG.WParam=Message.WordParmMSG.LParam=Message.LongParm

RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

endsubroutine

publicfunctionbooleantipvisible();IfIsWindowVisible(HwndTT)>0ThenReturnTrue

ReturnFalse

endfunction

publicsubroutinerelaymsg(dragobjectobject,longwordparm,integerlongparm);//此函数用于向显现ToolTips窗口发送把持动静,代码以下:MSGMSG

MSG.hWnd=Handle(Object)//WM_MOUSEMOVEMSG.Message=512MSG.WParam=WordParmMSG.LParam=LongParm

RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

endsubroutine

onnvo_tooltips.createcallsuper::createTriggerEvent(this,"constructor")endon

onnvo_tooltips.destroyTriggerEvent(this,"destructor")callsuper::destroyendon

eventconstructor;//布局point用于传送坐标//布局msg用于传送动静//布局rect用于传送矩形框的地位//布局toolinfo用于传送与tooltips相干的动静

//用法///////////////////////////////////////////////////////////////界说实例变量://nca_ToolTipsinvo_ToolTip

//windowopen事务://注册要显现ToolTips的把持//invo_tooltip.AddTool(sle_userid,"请输出登任命户名",0)//invo_tooltip.AddTool(sle_password,"请输出登录口令",0)//必要提醒的控件,在自界说ue_mousemove事务(pbm_mousemove)://invo_tooltip.RelayMsg(This)//////////////////////////////////////////////////////////////////

InitCommonControls()

endevent

eventdestructor;ifhWndTT>0thenDestroyWindow(hWndTT)endevent

4、n_cst_dwsrv_autohint

forwardglobaltypen_cst_dwsrv_autohintfromnonvisualobjectendtypetypelogfontfromstructurewithinn_cst_dwsrv_autohintendtypetypetextsizefromstructurewithinn_cst_dwsrv_autohintendtypeendforward

typelogfontfromstructurelonglfHeightlonglfWidthlonglfEscapementlonglfOrientationlonglfWeightcharacterlfItaliccharacterlfUnderlinecharacterlfStrikeOutcharacterlfCharSetcharacterlfOutPrecisioncharacterlfClipPrecisioncharacterlfQualitycharacterlfPitchAndFamilystringlfFaceNameendtype

typetextsizefromstructurelongl_cxlongl_cyendtype

globaltypen_cst_dwsrv_autohintfromnonvisualobjecteventtypelongue_mousemove(unsignedlongflags,integerxpos,integerypos)eventtypelongresize(unsignedlongsizetype,integernewwidth,integernewheight)endtypeglobaln_cst_dwsrv_autohintn_cst_dwsrv_autohint

typeprototypesFUNCTIONulongGetDC(ulonghwnd)LIBRARY"user32.dll"FUNCTIONulongReleaseDC(ulonghwnd,ulonghdc)LIBRARY"user32.dll"FUNCTIONulongSelectObject(ulonghdc,ulonghObject)LIBRARY"gdi32.dll"FUNCTIONulongDeleteObject(ulonghObject)LIBRARY"gdi32.dll"FUNCTIONulongCreateFontIndirect(refLOGFONTlpLogFont)LIBRARY"gdi32.dll"ALIASFOR"CreateFontIndirectA"FUNCTIONulongGetTextExtentExPoint(ulonghdc,refstringlpszStr,ulongcchString,ulongnMaxExtent,refulonglpnFit,refulongalpDx,reftextSIZElpSize)LIBRARY"gdi32.dll"ALIASFOR"GetTextExtentExPointA"FUNCTIONulongGetTextExtentPoint32(ulonghdc,refstringlpsz,ulongcbString,reftextSIZElpSize)LIBRARY"gdi32.dll"ALIASFOR"GetTextExtentPoint32A"FunctionlongMulDiv(longnNumber,longnNumerator,longnDenominator)Library"KERNEL32.DLL"FUNCTIONulongGetDeviceCaps(ulonghdc,ulongnIndex)LIBRARY"gdi32.dll"

endprototypes

typevariablesPrivate:DataWindowidw_requestornvo_tooltipsToolTipStringis_prior_dwo

endvariables

forwardprototypespublicfunctionlongof_gettextwidth(stringas_colname,stringas_text)publicsubroutineof_replacestring(refstringas_src,stringas_oldstr,stringas_newstr)publicfunctionintegerof_setrequestor(datawindowadw_requestor)endprototypes

eventtypelongue_mousemove(unsignedlongflags,integerxpos,integerypos);Stringls_dwo,ls_col,ls_textLongll_rowIntli_posls_dwo=idw_requestor.GetObjectAtPointer()

Ifis_prior_dwo=ls_dwoThenReturn0Elseis_prior_dwo=ls_dwoEndIf

IfTooltip.tipvisible()orflags0ThenTooltip.hidetip(idw_requestor)endif

li_pos=Pos(ls_dwo,"~t")Ifli_pos<=0ThenReturn0

ls_col=Left(ls_dwo,li_pos-1)ll_row=Long(Mid(ls_dwo,li_pos+1))

Ifidw_requestor.Describe(ls_col+".Type")"column"ThenReturn0//不是列工具

Longll_width,ll_needWidth,ll_xStringls_editStyll_width=Long(idw_requestor.Describe(ls_col+".Width"))ll_x=Long(idw_requestor.Describe(ls_col+".x"))ls_editSty=idw_requestor.Describe(ls_col+".Edit.Style")

Ifls_editSty="editmask"Then//有掩码Intli_colNumStringls_maskli_colNum=Integer(idw_requestor.Describe(ls_col+".ID"))ls_mask=idw_requestor.Describe(ls_col+".EditMask.Mask")IfLeft(idw_requestor.Describe(ls_col+".Coltype"),4)="char"Then//字符型掩码//字符能够转化为数字(间接用string(s,"##")得不到)of_replaceString(ls_mask,"#","@")ls_text=String(idw_requestor.Object.Data[ll_row,li_colNum],ls_mask)Else//别的范例掩码////messagebox("",ls_mask)ls_text=String(idw_requestor.Object.Data[ll_row,li_colNum],ls_mask)EndIfElse//以后行列值(便于dddw,ddlb失掉显现值)ls_text=idw_requestor.Describe("Evaluate(LookUpDisplay("+ls_col+"),"+String(ll_row)+")")EndIf



//必要宽度ll_needWidth=of_getTextWidth(ls_col,ls_text)

Ifls_editSty="checkbox"Orls_editSty="radiobuttons"Then//这两品种型必要加个分外值ll_needWidth+=86EndIf

//列的宽度不敷大概位于显现的最右列,只能显现一部分Ifll_width<ll_needWidthOr&ll_x+ll_width>=idw_requestor.Width+Long(idw_requestor.Object.DataWindow.HorizontalScrollPosition)Then//修正TipTooltip.SetTipText(idw_requestor,Tooltip.ToolID-1,ls_text)Tooltip.relaymsg(idw_requestor)Return0EndIf

Return0

endevent

eventtypelongresize(unsignedlongsizetype,integernewwidth,integernewheight);Ifsizetype1ThenTooltip.updatetiprect(idw_requestor,Tooltip.ToolID-1,0,0,&UnitsToPixels(idw_requestor.Width,XUnitsToPixels!),UnitsToPixels(idw_requestor.Height,YUnitsToPixels!))EndIf

Return0

endevent

publicfunctionlongof_gettextwidth(stringas_colname,stringas_text);//依据列名和文本,失掉文本的显现宽度//失掉字体相干信息Intli_charsetli_charset=Integer(idw_requestor.Describe(as_colName+".Font.CharSet"))Intli_Escapementli_Escapement=Integer(idw_requestor.Describe(as_colName+".Font.Escapement"))Stringls_Facels_Face=idw_requestor.Describe(as_colName+".Font.Face")Intli_Familyli_Family=Integer(idw_requestor.Describe(as_colName+".Font.Family"))Intli_heightli_height=Integer(idw_requestor.Describe(as_colName+".Font.Height"))Intli_Italicli_Italic=Integer(idw_requestor.Describe(as_colName+".Font.Italic"))Intli_Pitchli_Pitch=Integer(idw_requestor.Describe(as_colName+".Font.Pitch"))Intli_Strikethroughli_Strikethrough=Integer(idw_requestor.Describe(as_colName+".Font.Strikethrough"))Intli_Underlineli_Underline=Integer(idw_requestor.Describe(as_colName+".Font.Underline"))Intli_Weightli_Weight=Integer(idw_requestor.Describe(as_colName+".Font.Weight"))Intli_Widthli_Width=Integer(idw_requestor.Describe(as_colName+".Font.Width"))

Longll_newFont,ll_oldFont,ll_hdcLOGFONTlst_Font

lst_Font.lfWeight=li_Weightlst_Font.lfWidth=li_WidthIfli_Italic=1Thenlst_Font.lfItalic=Char(255)Elselst_Font.lfItalic=Char(0)EndIfIfli_Underline=1Thenlst_Font.lfUnderline=Char(1)Elselst_Font.lfUnderline=Char(0)EndIfIfli_Strikethrough=1Thenlst_Font.lfStrikeOut=Char(1)Elselst_Font.lfStrikeOut=Char(0)EndIf//DEFAULT_CHARSETlst_Font.lfCharSet=Char(li_charset)lst_Font.lfOutPrecision=Char(0)lst_Font.lfClipPrecision=Char(0)lst_Font.lfQuality=Char(0)lst_Font.lfPitchAndFamily=Char(0)lst_Font.lfFaceName=ls_Face

ll_hdc=getdc(Handle(idw_requestor))//以点为巨细单元的字体变化成设备所必要的得当的逻辑巨细//LOGPIXELSY=90//muldiv:abs(li_Height)*getdevicecaps(ll_hdc,90)/72lst_Font.lfHeight=-muldiv(Abs(li_height),getdevicecaps(ll_hdc,90),72)//用指定的属性创立逻辑字体ll_newFont=CreateFontIndirect(lst_Font)//选进ll_oldFont=SelectObject(ll_hdc,ll_newFont)

TextSizelstr_Size//判别字串的巨细GetTextExtentpoint32(ll_hdc,as_text,Len(as_text),lstr_Size)//恢复SelectObject(ll_hdc,ll_oldFont)//开释资本DeleteObject(ll_newFont)ReleaseDC(Handle(idw_requestor),ll_hdc)

//前往宽度(unit单元)ReturnPixelsToUnits(lstr_Size.l_cx,XPixelsToUnits!)

endfunction

publicsubroutineof_replacestring(refstringas_src,stringas_oldstr,stringas_newstr);Intstart_pos=0//Findthefirstoccurrenceofold_str.start_pos=Pos(as_src,as_oldstr)

//Onlyentertheloopifyoufindold_str.DoWhilestart_pos>0//Replaceold_strwithnew_str.as_src=Replace(as_src,start_pos,&Len(as_oldstr),as_newstr)//Findthenextoccurrenceofold_str.start_pos=Pos(as_src,as_oldstr,&start_pos+Len(as_newstr))Loop

endsubroutine

publicfunctionintegerof_setrequestor(datawindowadw_requestor);IfIsNull(adw_requestor)OrNotIsValid(adw_requestor)ThenReturn-1EndIf

idw_Requestor=adw_requestor

toolTip.addtool(adw_requestor,"",0)Return1

endfunction

onn_cst_dwsrv_autohint.createcallsuper::createTriggerEvent(this,"constructor")endon

onn_cst_dwsrv_autohint.destroyTriggerEvent(this,"destructor")callsuper::destroyendon

5、uo_dw_query

forwardglobaltypeuo_dw_queryfromdatawindowendtypeendforward

globaltypeuo_dw_queryfromdatawindowintegerwidth=1797integerheight=712integertaborder=1booleanhscrollbar=truebooleanvscrollbar=truebooleanlivescroll=trueborderstyleborderstyle=stylelowered!eventmousemovepbm_mousemoveeventue_mouseuppbm_lbuttonupeventue_lbuttondownpbm_lbuttondowneventue_mousemovepbm_mousemoveendtypeglobaluo_dw_queryuo_dw_query

typeprototypesFunctionulongSetCapture(ulonghWnd)Library"USER32.DLL"FunctionBOOLEANReleaseCapture()Library"USER32.DLL"FUNCTIONulongGetCapture()LIBRARY"user32.dll"

endprototypes

typevariablesPublic:BooleanSortAfterClickOnHeader=TrueBooleanAutoHint=FalsePrivate:n_cst_dwsrv_gridSortinv_gridSortn_cst_dwsrv_autoHintinv_antohintendvariables

eventue_mouseup;IfSortAfterClickOnHeaderAndIsValid(inv_gridSort)Theninv_gridSort.Eventue_lbuttonup(flags,xpos,ypos)EndIf

endevent

eventue_lbuttondown;IfSortAfterClickOnHeaderAndIsValid(inv_gridSort)Theninv_gridSort.Eventue_lbuttondown(flags,xpos,ypos)EndIf

endevent

eventue_mousemove;IfAutoHintAndIsValid(inv_antohint)Theninv_antohint.Eventue_MouseMove(flags,xpos,ypos)EndIfendevent

onuo_dw_query.createendon

onuo_dw_query.destroyendon

eventconstructor;SetTransObject(sqlca)

IfSortAfterClickOnHeaderTheninv_gridSort=Createn_cst_dwsrv_gridSortinv_gridSort.of_SetRequestor(This)EndIfIfAutoHintTheninv_antohint=Createn_cst_dwsrv_autoHintinv_antohint.of_SetRequestor(This)EndIf

endevent

eventrowfocuschanged;//

endevent

eventclicked;ifrow0thenthis.setRow(row)endifendevent

eventdberror;ifSQLDBCode=-1thenintli_rtn//从头毗连乐成,则前往li_rtn=SetTranSobject(sqlca)ifli_rtn=1thenreturn1endif



//displaydifferentmessageaccordingthedatawindowisfreeformornotIfThis.Object.datawindow.processing="0"Thengf_dberrormsg(SQLDBCode,SQLErrText,row,"freeform")Elsegf_dberrormsg(SQLDBCode,SQLErrText,row,"")EndIfsqlca.SQLCode=-1Return1

endevent

eventdestructor;IfIsValid(inv_gridSort)ThenDestroyinv_gridSortEndIf

IfIsValid(inv_antohint)ThenDestroyinv_antohintEndIf

endevent

eventitemerror;stringls_column,ls_message

iftrim(data)=""thenreturn3endifls_column=dwo.namels_message=this.describe(ls_column+".validationmsg")iftrim(ls_message)"?"thenmessagebox("提醒信息",ls_message)return3elsemessagebox("提醒信息","该项数据分歧法!")return3endif

/*各前往值意义:0-回绝此数值,显现毛病动静1-回绝此数值,但不显现毛病动静2-承受此数值。3-回绝此数值,但同意改动核心,用原值来取代新值*/endevent


从理论上讲,完全可以为数据表里的每个字段分别建一个索引,但MySQL把同一个数据表里的索引总数限制为16个。
作者: 只想知道    时间: 2015-1-18 20:40
发几份SQL课件,以飨阅者
作者: 乐观    时间: 2015-1-23 13:06
SQL语言是学习所有数据库产品的基础,无论你是做数据库管理还是做数据库开发都是这样。不过具体学习的侧重点要看你将来做哪一块,如果是做数据库管理(DBA),侧重点应该放在SQLServer的系统管理上.
作者: 仓酷云    时间: 2015-1-31 16:03
如果,某一版本可以提供强大的并发响应,但是没有Oracle的相应版本稳定,或者价格较贵,那么,它就是不适合的。
作者: 小女巫    时间: 2015-2-6 20:31
而SQLServer如果能像Oracle一样可以为登陆分配如:5%的cpu,10%的内存。就可以解决这个漏洞。
作者: 山那边是海    时间: 2015-2-18 14:56
groupby子句可以将查询结果分组,并返回行的汇总信息Oracle按照groupby子句中指定的表达式的值分组查询结果。
作者: 小妖女    时间: 2015-3-6 08:18
很多书籍啊,不过个人认为看书太慢,还不如自己学。多做实际的东西,就会遇到很多问题,网上搜下解决问题。不断重复这个过程,在配合sql的F1功能。
作者: 若天明    时间: 2015-3-12 22:41
一个百万级别的基本信息表A,一个百万级别的详细记录表B,A中有个身份证id,B中也有身份id;先要找出A中在B的详细记录。
作者: 透明    时间: 2015-3-20 04:44
我是新手,正在学习数据库和操作系统,深感理论的泛广,唯有一步一步来,但是又感觉时间不够,收集了很多资料却总是没能认真的看完,希望有一个讨论板块,大家共同解决,共同分享,共同努力




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2