• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 一個供查詢用的datawindow

    發表于:2007-05-25來源:作者:點擊數: 標簽:datawindow用的主要查詢一個
    主要供以grid方式展示查詢數據使用, 包括以下幾個功能: 1、點擊列頭排序(可選); 2、 時候,自動用微幫助展示(可選); 3、數據庫錯誤時中文提示; 包括以下對象(按順序導入即可): 1、 gf_dberrormsg global type gf_dberrormsg from function_objec

          主要供以grid方式展示查詢數據使用, 包括以下幾個功能:

    1、點擊列頭排序(可選);

    2、 時候,自動用微幫助展示(可選);

    3、數據庫錯誤時中文提示;

          包括以下對象(按順序導入即可):

    1、gf_dberrormsg

    global type gf_dberrormsg from function_object
    end type

    forward prototypes
    global function integer gf_dberrormsg (long sqldbcode, string sqlerrtext, long row, string as_ty)
    end prototypes

    global function integer gf_dberrormsg (long sqldbcode, string sqlerrtext, long row, string as_ty);//有關數據窗口的錯誤:
    Choose Case SQLDBCode
     Case 1400
      If as_ty = "freeform" Then
       MessageBox("提示信息" , "請查找空項,并填入內容,才能保存!")
      Else
       MessageBox("提示信息","請查找第"+String(row)+"行空列,并填入內容,才能保存!")
      End If
     Case   1
      If as_ty = "freeform" Then
       MessageBox("提示信息" , "此項記錄已經存在,不能重復!")
      Else
       MessageBox("提示信息","請查重復行第"+String(row)+"行,修改某列或刪除重復行,才能保存!")
      End If
     Case 3114
      MessageBox("提示信息","沒有連接數據庫,建議重新運行應用程序!")
     Case -193
      If as_ty = "freeform" Then
       MessageBox("提示信息" , "此項記錄已經存在,不能重復!")
      Else
       MessageBox("提示信息","請查重復行第"+String(row)+"行,修改某列或刪除重復行,才能保存!")
      End If
     Case -195 // Required value is NULL.
      If as_ty = "freeform" Then
       MessageBox("提示信息" , "請查找空項,并填入內容,才能保存!")
      Else
       MessageBox("提示信息","請查找第"+String(row)+"行空列,并填入內容,才能保存!")
      End If
     Case -3
      MessageBox("注意信息","原數據已被其它用戶修改,請重新檢索后再保存!")
     Case 2601
      MessageBox("注意信息","主鍵記錄重復,不能保存!")
     Case 233
      MessageBox("注意信息","主鍵記錄為空,不能保存!")
     Case 1105 //Sybase??
      MessageBox("注意信息","數據庫日志滿,請通知系統管理員清日志!")
     Case 2627
      MessageBox("注意信息","您新增的記錄已存在,插入失敗! 也許是網絡沖突,請您稍后再做此項操作。")
     Case -932
      MessageBox("注意信息","請檢查網絡是否正常工作!")
     Case 10004
      MessageBox("注意信息","請檢查數據庫是否正常工作!")
     Case 999
      MessageBox("注意信息","請檢查服務器是否正常工作!")
     Case Else
      MessageBox("數據庫提示信息:","出錯行:" + String(row) + ", 出錯信息:" + SQLErrText+"SQLDBCode:"+string(SQLDBCode))
    End Choose

    Return 1

    end function

    2、n_cst_dwsrv_gridsort

    forward
    global type n_cst_dwsrv_gridsort from nonvisualobject
    end type
    end forward

    global type n_cst_dwsrv_gridsort from nonvisualobject
    event type long ue_lbuttondown ( unsignedlong flags,  integer xpos,  integer ypos )
    event type long ue_lbuttonup ( unsignedlong flags,  integer xpos,  integer ypos )
    end type
    global n_cst_dwsrv_gridsort n_cst_dwsrv_gridsort

    type prototypes
    Function ULong SetCapture(ULong hWnd) Library "USER32.DLL"
    Function Boolean ReleaseCapture() Library "USER32.DLL"

    end prototypes

    type variables
    Private:
     DataWindow idw_requestor
     string i_str_oldcolumn //上次點擊排序的列名
     string i_str_newcolumn //本次點擊排序的列名
     string i_str_arrowname //排序用的小三角符號名
     string i_str_sort='A' //上次排序是升序(A)還是降序(B)
     string i_str_flag='0' //是否已執行正確的鼠標按下事件(0-否,1-是)

    end variables

    forward prototypes
    public function integer of_setrequestor (datawindow adw_requestor)
    end prototypes

    event type long ue_lbuttondown(unsignedlong flags, integer xpos, integer ypos);String str_band,str_object,str_title,str_column
    int li_x

    str_band = idw_requestor.GetBandAtPointer() //得到當前鼠標所指對象所在的帶區
    str_band = Left(str_band,(Pos(str_band,'~t') - 1))
    If str_band <> 'header' Then Return 0 //單擊非頭區,退出
    str_object = idw_requestor.GetObjectAtPointer() //得到當前鼠標所指對象名
    str_object = Left(str_object,(Pos(str_object,'~t') - 1))
    If str_object = '' Or IsNull(str_object) Then Return 0 //未得到,退出
    If Right(str_object,4) = '_lag' Then //點擊的是小三角符號對象,說明上次點擊過該列
     str_title = Left(str_object,(Len(str_object) - 4))
    Else //頭一次點擊該列
     str_title = str_object
    End If
    //得到列對象名(默認為列名_t為列標題)
    str_column = Left(str_title,(Len(str_title) - 2))
    //判斷該名稱是否為列名字
    If idw_requestor.Describe(str_column+".band") = '!' Then Return 0//非是列名,即列標題不是按正常規律起名的。

    //列的交接處,可能出現調整列寬度狀態
    li_x=integer(idw_requestor.Describe(str_object+".X"))
    if String(idw_requestor.Object.DataWindow.HorizontalScrollSplit)='0' then
     if xpos+integer(idw_requestor.Object.DataWindow.HorizontalScrollPosition)- li_x<=6 then
      return 0
     end if
    end if

    i_str_newcolumn = str_column //得到當前單擊的列
    idw_requestor.Modify(str_title+".border='5'") //設置下凹動畫效果
    i_str_flag = '1' //已啟動單擊事件
    //設置鼠標捕獲
    SetCapture(Handle(idw_requestor)) //將鼠標的動作轉移給指定的DW窗口
    Return 0

    end event

    event type long ue_lbuttonup(unsignedlong flags, integer xpos, integer ypos);String str_title,str_object,str_tmp,str_column,str_sort
    Long lng_posy,lng_left,lng_top,lng_right,lng_bottom

    lng_posy = ypos
    str_object = idw_requestor.GetObjectAtPointer()
    ReleaseCapture() //必須先釋放鼠標否則該鼠標動作將一直被數據窗口捕獲

    str_title = i_str_newcolumn+'_t'
    If i_str_flag = '1' Then
     lng_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))
     If Not (str_object = '' Or IsNull(str_object)) Then //得到單擊對象
      If Right(str_object,4) = '_lag' Then //點擊的是箭頭對象,說明上次已點擊過此列
       str_tmp = Left(str_object,(Len(str_object) - 4))
      Else //頭一次點擊該列
       str_tmp = str_object
      End If
      If str_tmp = str_title Then //說明是在點擊列上釋放鼠標的
       //判斷是否上次點擊該列,并排序
       If i_str_oldcolumn = i_str_newcolumn Then  //上次點擊的也是此列
        If i_str_sort = 'A' Then
         str_sort = 'D'
         str_tmp = '6'
        Else
         str_sort = 'A'
         str_tmp = '5'
        End If
       Else //上次點擊的不是此列
        str_sort = 'A'
        str_tmp = '5'
       End If
       //不管有沒有全刪除箭頭對象
       idw_requestor.Modify("destroy "+i_str_arrowname)
       i_str_arrowname = str_title+'_lag' //生成新的箭頭對象名=標題名_lag
       str_tmp = 'create text(band=header alignment="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_sort
       idw_requestor.SetSort(str_tmp)
       idw_requestor.Sort()
       i_str_oldcolumn = i_str_newcolumn
       i_str_newcolumn = ''
       i_str_sort = str_sort
      End If
     End If
    End If
    idw_requestor.Modify(str_title+".border='6'")
    i_str_flag = '0'
    Return 0

    end event

    public function integer of_setrequestor (datawindow adw_requestor);If IsNull(adw_requestor) or Not IsValid(adw_requestor) Then
     Return -1
    End If

    idw_Requestor = adw_Requestor
    Return 1
    end function

    on n_cst_dwsrv_gridsort.create
    call super::create
    TriggerEvent( this, "constructor" )
    end on

    on n_cst_dwsrv_gridsort.destroy
    TriggerEvent( this, "destructor" )
    call super::destroy
    end on

    event constructor;//單擊列標題對列進行排序
    end event

    3、nvo_tooltips

    forward
    global type nvo_tooltips from nonvisualobject
    end type
    type point from structure within nvo_tooltips
    end type
    type msg from structure within nvo_tooltips
    end type
    type rect from structure within nvo_tooltips
    end type
    type toolinfo from structure within nvo_tooltips
    end type
    end forward

    type point from structure
     long  x
     long  y
    end type

    type msg from structure
     long  hwnd
     long  message
     long  wparam
     long  lparam
     long  time
     point  pt
    end type

    type rect from structure
     long  left
     long  top
     long  right
     long  bottom
    end type

    type toolinfo from structure
     long  cbsize
     long  uflags
     long  hwnd
     long  uid
     rect  rect
     long  hinstance
     string  lpsztext
    end type

    global type nvo_tooltips from nonvisualobject autoinstantiate
    end type

    type prototypes
    // ToolTips函數
    SubRoutine InitCommonControls() library "comctl32.dll"
    Function long CreateWindowExA(ulong dwExStyle, string ClassName, &
         long WindowName, ulong dwStyle, ulong X, ulong Y, ulong nWidth, &
         ulong nHeight, ulong hWndParent, ulong hMenu, ulong hInstance, &
         ulong lpParam) library "user32.dll"
    Function integer DestroyWindow(long hWnd) library "user32.dll"
    Function integer ToolTipMsg(long hWnd, long uMsg, long wParam, &
         REF TOOLINFO ToolInfo) library "user32.dll" Alias For "SendMessageA"
    Function integer RelayMsg(long hWnd, long uMsg, long wParam, &
         REF MSG Msg) library "user32.dll" Alias For "SendMessageA"
    Function uLong SendMessageString( uLong hwnd, uLong Msg, uLong wParam, Ref String lpzString ) Library "user32.dll" Alias For "SendMessageA"
    FUNCTION ulong ShowWindow(ulong hwnd,ulong nCmdShow) LIBRARY "user32.dll"
    //內存管理函數
    //Function long LocalAlloc(long Flags, long Bytes) library "kernel32.dll"
    //Function long LocalFree(long MemHandle) library "kernel32.dll"
    //Function long lstrcpy(long Destination, string Source) library "kernel32.dll"

    FUNCTION ulong IsWindowVisible(ulong hwnd) LIBRARY "user32.dll"
    end prototypes

    type variables
    //私有常量
    Private:

    //雜項常量
    CONSTANT string TOOLTIPS_CLASS = 'tooltips_class32'
    CONSTANT ulong CW_USEDEFAULT = 2147483648
    CONSTANT long WM_USER = 1024
    CONSTANT long WS_EX_TOPMOST = 8
    CONSTANT long WM_SETFONT = 48

    // ToolTip Messages
    Constant long TTM_ADDTOOL   = WM_USER + 4
    Constant long TTM_DELTOOL = WM_USER + 5
    Constant long TTM_NEWTOOLRECT = WM_USER + 6
    Constant long TTM_RELAYEVENT   = WM_USER + 7
    Constant long TTM_POPUP =WM_USER + 34
    Constant long TTM_UPDATE= WM_USER + 29
    Constant long TTM_UPDATETIPTEXT = WM_USER + 12
    Constant long TTM_TRACKACTIVATE = WM_USER + 17
    Constant long TTM_TRACKPOSITION = WM_USER + 18
    Constant long TTM_SETMAXTIPWIDTH = 1048
    Constant long TTM_GETMAXTIPWIDTH = WM_USER + 25
    Constant long TTM_SETTIPBKCOLOR = WM_USER + 19
    Constant long TTM_SETTIPTEXTCOLOR = WM_USER + 20
    Constant long TTM_SETTITLEA = WM_USER + 32
    // Tooltip flags
    Constant integer TTF_CENTERTIP   = 2
    Constant integer TTF_RTLREADING = 4
    Constant integer TTF_SUBCLASS  = 16
    Constant integer TTF_TRACK  = 32
    Constant integer TTF_ABSOLUTE  = 128
    Constant integer TTF_TRANSPARENT = 256
    Constant integer TTF_DI_SETITEM  = 32768
    Constant integer TTS_BALLOON = 64

    // Title Constants
    Constant integer TTI_NONE = 0
    Constant integer TTI_INFO = 1
    Constant integer TTI_WARNING = 2
    Constant integer TTI_ERROR = 3
    //公共變量和常量
    Public:
    long hWndTT=0 // Tooltip control window handle
    long ToolID = 1 // Tooltip internal ID

    CONSTANT integer STYLE_NORMAL = 0
    CONSTANT integer STYLE_BALLOONTIP = 1
    integer TIPSTYLE


    end variables

    forward prototypes
    public subroutine setfont (long hfont)
    public subroutine settipposition (integer x, integer y)
    public subroutine settrack (dragobject object, integer uid, boolean status)
    public subroutine updatetiprect (dragobject object, long uid, long left, long top, long right, long bottom)
    public function integer addtool (dragobject object, string tiptext, integer flags)
    public subroutine hidetip (dragobject controlobject)
    public subroutine settiptext (dragobject object, long uid, string tiptext)
    public subroutine setmaxwidth (long al_maxwidth)
    public function integer removetool (dragobject ado_object, integer ai_toolid)
    public subroutine settiptitle (integer ai_icon, string as_title)
    public subroutine settipbkcolor (long aul_color)
    public subroutine relaymsg (dragobject object)
    public function boolean tipvisible ()
    public subroutine relaymsg (dragobject object, long wordparm, integer longparm)
    end prototypes

    public subroutine setfont (long hfont);//此函數用于設置ToolTips窗口的字體,代碼如下:

    Send(hWndTT,WM_SETFONT,hFont,1)


    end subroutine

    public subroutine settipposition (integer x, integer y);//此函數用于設置ToolTips的位置,代碼如下:

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

    end subroutine

    public subroutine settrack (dragobject object, integer uid, boolean status);//此函數用于激活或取消ToolTips窗口設置新文本,代碼如下:
    //參數Status為True時激活,為False時取消

    TOOLINFO ToolInfo

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

    If Status Then
     ToolTipMsg(hWndTT,TTM_TRACKACTIVATE,1,ToolInfo)
    Else
     ToolTipMsg(hWndTT,TTM_TRACKACTIVATE,0,ToolInfo)
    End If

    end subroutine

    public subroutine updatetiprect (dragobject object, long uid, long left, long top, long right, long bottom);//此函數用于更新ToolTips的矩形框,代碼如下:

    TOOLINFO TOOLINFO

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

    TOOLINFO.Rect.Left  = Left
    TOOLINFO.Rect.Top   = Top
    TOOLINFO.Rect.Right  = Right
    TOOLINFO.Rect.Bottom  = Bottom

    ToolTipMsg(hWndTT,TTM_NEWTOOLRECT,0,TOOLINFO)


    end subroutine

    public function integer addtool (dragobject object, string tiptext, integer flags);//此函數用于注冊要顯示ToolTips的控制,代碼如下:
    If hWndTT <= 0 Then
     If  TIPSTYLE = STYLE_BALLOONTIP Then
      hWndTT = CreateWindowExA(WS_EX_TOPMOST,TOOLTIPS_CLASS,0, TTF_CENTERTIP+ TTS_BALLOON, &
       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,  &
       0, 0, Handle(GetApplication()),0)
     Else
      hWndTT = CreateWindowExA(WS_EX_TOPMOST, TOOLTIPS_CLASS,0,TTF_CENTERTIP, &
       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,  &
       0, 0, Handle(GetApplication()),0)
     End If
    End If

    TOOLINFO TOOLINFO

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

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

    If ToolTipMsg(hWndTT,TTM_ADDTOOL, 0, TOOLINFO) = 0 Then
     // MessageBox("錯誤","不能注冊控件!",StopSign!,Ok!)
     //   LocalFree(ToolInfo.lpszText) //釋放分配的內存
     Return(-1)
    End If

    //LocalFree(ToolInfo.lpszText) //釋放分配的內存
    Return(ToolID - 1)


    end function

    public subroutine hidetip (dragobject controlobject);MSG MSG
    MSG.hWnd = Handle(ControlObject)
    MSG.Message  = 513 // WM_LBUTTONDOWN
    MSG.WParam = Message.WordParm
    MSG.Lparam = Message.LongParm

    RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

    end subroutine

    public subroutine settiptext (dragobject object, long uid, string tiptext);//此函數用于為ToolTips窗口設置新文本,代碼如下:

    TOOLINFO ToolInfo

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

    ToolTipMsg(hWndTT,TTM_UPDATETIPTEXT,0,ToolInfo)

    end subroutine

    public subroutine setmaxwidth (long al_maxwidth);/*****************************************************************************

     Function:  of_setmaxwidth

     Description: Sets the maximum tooltip width. If the text is longer it will
          splitted over more than one line.

     Returns:   (none)

     Arguments:  Long   al_MaxWidth

     Use:    Call to set the maximum width.

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

     Auteur: Aart Onkenhout

     Revision History
     --------------------
     Date   Version
     15-05-2000 1.0  Initial version

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

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

    Return
    end subroutine

    public function integer removetool (dragobject ado_object, integer ai_toolid);/*****************************************************************************

     Function:  of_removetool

     Description: Unregisters a control within the tooltip control

     Returns:   (none)

     Arguments:  DragObject  ado_Object Object to unregister within the tooltip control
          Integer   ai_ToolId Tool Id (returned by of_AddTool)

     Use:    

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

     Auteur: Aart Onkenhout

     Revision History
     --------------------
     Date   Version
     29-06-2001 1.0  Initial version

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

    TOOLINFO TOOLINFO
    Integer li_Width, li_Height

    TOOLINFO.cbSize   = 40
    TOOLINFO.uFlags   = 16 //Flags
    TOOLINFO.hWnd   = Handle( ado_Object )
    TOOLINFO.hInstance = 0 // Not used
    TOOLINFO.uID   = ai_ToolID

    ToolTipMsg( hWndTT, TTM_DELTOOL, 0, TOOLINFO )

    Return 1


    end function

    public subroutine settiptitle (integer ai_icon, string as_title);/*****************************************************************************

     Function:  of_settiptitle

     Description: Sets the title of the tooltip

     Returns:   (none)

     Arguments:  Integer  ai_Icon
          Values:  TTI_NONE = 0
              TTI_INFO = 1
              TTI_WARNING = 2
              TTI_ERROR = 3
          String  as_Title

     Use:    Call with the desired title and icon.

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

     Auteur: Aart Onkenhout

     Revision History
     --------------------
     Date   Version
     10-05-2001 1.0  Initial version

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

    SendMessageString( hWndTT, TTM_SETTITLEA, ai_Icon, as_Title )
    end subroutine

    public subroutine settipbkcolor (long aul_color);/*****************************************************************************

     Function:  of_settipbkcolor

     Description: Sets the backgroundcolor of the tooltip-window

     Returns:   (none)

     Arguments:  uLong  aul_Color 

     Use:    Call with the desired color

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

     Auteur: Aart Onkenhout

     Revision History
     --------------------
     Date   Version
     10-05-2001 1.0  Initial version

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

    Send( hWndTT, TTM_SETTIPBKCOLOR,aul_color, 0 )
    end subroutine

    public subroutine relaymsg (dragobject object);//此函數用于向顯示ToolTips窗口發送控制消息,代碼如下:
    MSG MSG

    MSG.hWnd   = Handle(Object) // WM_MOUSEMOVE
    MSG.Message  = 512
    MSG.WParam   = Message.WordParm
    MSG.LParam   = Message.LongParm

    RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

    end subroutine

    public function boolean tipvisible ();If IsWindowVisible(HwndTT) > 0 Then Return True

    Return False

    end function

    public subroutine relaymsg (dragobject object, long wordparm, integer longparm);//此函數用于向顯示ToolTips窗口發送控制消息,代碼如下:
    MSG MSG

    MSG.hWnd   = Handle(Object) // WM_MOUSEMOVE
    MSG.Message  = 512
    MSG.WParam   = WordParm
    MSG.LParam   = LongParm

    RelayMsg(hWndTT,TTM_RELAYEVENT,0,MSG)

    end subroutine

    on nvo_tooltips.create
    call super::create
    TriggerEvent( this, "constructor" )
    end on

    on nvo_tooltips.destroy
    TriggerEvent( this, "destructor" )
    call super::destroy
    end on

    event constructor;//結構point用于傳送坐標
    //結構msg用于傳送消息
    //結構rect用于傳送矩形框的位置
    //結構toolinfo用于傳送與tooltips相關的消息

    //用法/////////////////////////////////////////////////////////////
    //定義實例變量:
    //nca_ToolTips invo_ToolTip

    //window open事件:
    //注冊要顯示ToolTips的控制
    //invo_tooltip.AddTool(sle_userid,"請輸入登錄用戶名",0)
    //invo_tooltip.AddTool(sle_password,"請輸入登錄口令",0)
    //需要提示的控件,在自定義ue_mousemove事件(pbm_mousemove):
    //invo_tooltip.RelayMsg(This)
    //////////////////////////////////////////////////////////////////

    InitCommonControls()

    end event

    event destructor;if hWndTT>0 then DestroyWindow(hWndTT)
    end event

    4、n_cst_dwsrv_autohint

    forward
    global type n_cst_dwsrv_autohint from nonvisualobject
    end type
    type logfont from structure within n_cst_dwsrv_autohint
    end type
    type textsize from structure within n_cst_dwsrv_autohint
    end type
    end forward

    type logfont from structure
     long  lfHeight
     long  lfWidth
     long  lfEscapement
     long  lfOrientation
     long  lfWeight
     character  lfItalic
     character  lfUnderline
     character  lfStrikeOut
     character  lfCharSet
     character  lfOutPrecision
     character  lfClipPrecision
     character  lfQuality
     character  lfPitchAndFamily
     string  lfFaceName
    end type

    type textsize from structure
     long  l_cx
     long  l_cy
    end type

    global type n_cst_dwsrv_autohint from nonvisualobject
    event type long ue_mousemove ( unsignedlong flags,  integer xpos,  integer ypos )
    event type long resize ( unsignedlong sizetype,  integer newwidth,  integer newheight )
    end type
    global n_cst_dwsrv_autohint n_cst_dwsrv_autohint

    type prototypes
    FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
    FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"
    FUNCTION ulong SelectObject(ulong hdc,ulong hObject) LIBRARY "gdi32.dll"
    FUNCTION ulong DeleteObject(ulong hObject) LIBRARY "gdi32.dll"
    FUNCTION ulong CreateFontIndirect(ref LOGFONT lpLogFont) LIBRARY "gdi32.dll" ALIAS FOR "CreateFontIndirectA"
    FUNCTION ulong GetTextExtentExPoint(ulong hdc,ref string lpszStr,ulong clearcase/" target="_blank" >cchString,ulong nMaxExtent,ref ulong lpnFit,ref ulong alpDx,ref textSIZE lpSize) LIBRARY "gdi32.dll" ALIAS FOR "GetTextExtentExPointA"
    FUNCTION ulong GetTextExtentPoint32(ulong hdc,ref string lpsz,ulong cbString,ref textSIZE lpSize) LIBRARY "gdi32.dll" ALIAS FOR "GetTextExtentPoint32A"
    Function long MulDiv (long nNumber, long nNumerator, long nDenominator) Library  "KERNEL32.DLL"
    FUNCTION ulong GetDeviceCaps(ulong hdc,ulong nIndex) LIBRARY "gdi32.dll"

    end prototypes

    type variables
    Private:
     DataWindow idw_requestor
     nvo_tooltips ToolTip
     String is_prior_dwo

    end variables

    forward prototypes
    public function long of_gettextwidth (string as_colname, string as_text)
    public subroutine of_replacestring (ref string as_src, string as_oldstr, string as_newstr)
    public function integer of_setrequestor (datawindow adw_requestor)
    end prototypes

    event type long ue_mousemove(unsignedlong flags, integer xpos, integer ypos);String ls_dwo,ls_col,ls_text
    Long ll_row
    Int li_pos
    ls_dwo = idw_requestor.GetObjectAtPointer()

    If is_prior_dwo = ls_dwo Then
     Return 0
    Else
     is_prior_dwo = ls_dwo
    End If

    If Tooltip.tipvisible() or flags <> 0 Then
     Tooltip.hidetip(idw_requestor)
    end if

    li_pos = Pos(ls_dwo, "~t")
    If li_pos <= 0 Then Return 0


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


    If idw_requestor.Describe(ls_col+".Type") <> "column" Then  Return 0 //不是列對象


    Long ll_width,ll_needWidth,ll_x
    String ls_editSty
    ll_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")

    If ls_editSty = "editmask" Then //有掩碼
     Int li_colNum
     String ls_mask
     li_colNum = Integer(idw_requestor.Describe(ls_col+".ID"))
     ls_mask = idw_requestor.Describe(ls_col+".EditMask.Mask")
     If Left(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)
     End If
    Else
     //當前行列值(便于dddw,ddlb得到顯示值)
     ls_text = idw_requestor.Describe("Evaluate('LookUpDisplay("+ls_col+")',"+String(ll_row)+")")
    End If

    //需要寬度
    ll_needWidth = of_getTextWidth(ls_col,ls_text)

    If ls_editSty = "checkbox" Or ls_editSty = "radiobuttons" Then
     //這兩種類型需要加個額外值
     ll_needWidth+= 86
    End If

    //列的寬度不夠 或者 位于顯示的最右列,只能顯示一部分
    If ll_width < ll_needWidth Or &
     ll_x+ll_width >= idw_requestor.Width +Long(idw_requestor.Object.DataWindow.HorizontalScrollPosition) Then
     //修改Tip
     Tooltip.SetTipText( idw_requestor, Tooltip.ToolID - 1,ls_text)
     Tooltip.relaymsg(idw_requestor)
     Return 0
    End If

    Return 0


    end event

    event type long resize(unsignedlong sizetype, integer newwidth, integer newheight);If sizetype <> 1 Then
     Tooltip.updatetiprect(idw_requestor,Tooltip.ToolID - 1 ,0,0,&
      UnitsToPixels(idw_requestor.Width, XUnitsToPixels!),UnitsToPixels(idw_requestor.Height, YUnitsToPixels!) )
    End If

    Return 0


    end event

    public function long of_gettextwidth (string as_colname, string as_text);//根據列名和文本,得到文本的顯示寬度
    //得到字體相關信息
    Int li_charset
    li_charset = Integer(idw_requestor.Describe(as_colName+".Font.CharSet"))
    Int li_Escapement
    li_Escapement = Integer(idw_requestor.Describe(as_colName+".Font.Escapement"))
    String ls_Face
    ls_Face = idw_requestor.Describe(as_colName+".Font.Face")
    Int li_Family
    li_Family = Integer(idw_requestor.Describe(as_colName+".Font.Family"))
    Int li_height
    li_height = Integer(idw_requestor.Describe(as_colName+".Font.Height"))
    Int li_Italic
    li_Italic = Integer(idw_requestor.Describe(as_colName+".Font.Italic"))
    Int li_Pitch
    li_Pitch = Integer(idw_requestor.Describe(as_colName+".Font.Pitch"))
    Int li_Strikethrough
    li_Strikethrough = Integer(idw_requestor.Describe(as_colName+".Font.Strikethrough"))
    Int li_Underline
    li_Underline = Integer(idw_requestor.Describe(as_colName+".Font.Underline"))
    Int li_Weight
    li_Weight = Integer(idw_requestor.Describe(as_colName+".Font.Weight"))
    Int li_Width
    li_Width = Integer(idw_requestor.Describe(as_colName+".Font.Width"))


    Long ll_newFont,ll_oldFont,ll_hdc
    LOGFONT    lst_Font

    lst_Font.lfWeight = li_Weight
    lst_Font.lfWidth = li_Width
    If li_Italic = 1 Then
     lst_Font.lfItalic = Char(255)
    Else
     lst_Font.lfItalic = Char(0)
    End If
    If li_Underline = 1 Then
     lst_Font.lfUnderline = Char(1)
    Else
     lst_Font.lfUnderline = Char(0)
    End If
    If li_Strikethrough = 1 Then
     lst_Font.lfStrikeOut = Char(1)
    Else
     lst_Font.lfStrikeOut = Char(0)
    End If
    //DEFAULT_CHARSET
    lst_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)/72
    lst_Font.lfHeight = - muldiv(Abs(li_height),getdevicecaps(ll_hdc,90),72)
    //用指定的屬性創建邏輯字體
    ll_newFont = CreateFontIndirect(lst_Font)
    //選入
    ll_oldFont = SelectObject(ll_hdc,ll_newFont)

    TextSize lstr_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單位)
    Return  PixelsToUnits(lstr_Size.l_cx,XPixelsToUnits!)


    end function

    public subroutine of_replacestring (ref string as_src, string as_oldstr, string as_newstr);Int start_pos = 0
    // Find the first occurrence of old_str.
    start_pos = Pos(as_src, as_oldstr)

    // Only enter the loop if you find old_str.
    Do While start_pos > 0
     // Replace old_str with new_str.
     as_src = Replace(as_src, start_pos, &
      Len(as_oldstr), as_newstr)
     // Find the next occurrence of old_str.
     start_pos = Pos(as_src, as_oldstr, &
      start_pos+Len(as_newstr))
     
    Loop


    end subroutine

    public function integer of_setrequestor (datawindow adw_requestor);If IsNull(adw_requestor) Or Not IsValid(adw_requestor) Then
     Return -1
    End If

    idw_Requestor = adw_requestor

    toolTip.addtool(adw_requestor,"",0)
    Return 1

    end function

    on n_cst_dwsrv_autohint.create
    call super::create
    TriggerEvent( this, "constructor" )
    end on

    on n_cst_dwsrv_autohint.destroy
    TriggerEvent( this, "destructor" )
    call super::destroy
    end on

    5、uo_dw_query

    forward
    global type uo_dw_query from datawindow
    end type
    end forward

    global type uo_dw_query from datawindow
    integer width = 1797
    integer height = 712
    integer taborder = 1
    boolean hscrollbar = true
    boolean vscrollbar = true
    boolean livescroll = true
    borderstyle borderstyle = stylelowered!
    event mousemove pbm_mousemove
    event ue_mouseup pbm_lbuttonup
    event ue_lbuttondown pbm_lbuttondown
    event ue_mousemove pbm_mousemove
    end type
    global uo_dw_query uo_dw_query

    type prototypes
    Function ulong SetCapture(ulong hWnd) Library "USER32.DLL"
    Function BOOLEAN ReleaseCapture() Library "USER32.DLL"
    FUNCTION ulong GetCapture() LIBRARY "user32.dll"

    end prototypes

    type variables
    Public:
     Boolean SortAfterClickOnHeader = True
     Boolean AutoHint = False
    Private:
     n_cst_dwsrv_gridSort inv_gridSort
     n_cst_dwsrv_autoHint inv_antohint
    end variables

    event ue_mouseup;If SortAfterClickOnHeader And IsValid(inv_gridSort) Then
     inv_gridSort.Event ue_lbuttonup(flags,xpos,ypos)
    End If

    end event

    event ue_lbuttondown;If SortAfterClickOnHeader And IsValid(inv_gridSort) Then
     inv_gridSort.Event ue_lbuttondown(flags,xpos,ypos)
    End If

    end event

    event ue_mousemove;If AutoHint And IsValid(inv_antohint) Then
     inv_antohint.Event ue_MouseMove(flags,xpos,ypos)
    End If
    end event

    on uo_dw_query.create
    end on

    on uo_dw_query.destroy
    end on

    event constructor;SetTransObject(sqlca)

    If SortAfterClickOnHeader Then
     inv_gridSort = Create n_cst_dwsrv_gridSort
     inv_gridSort.of_SetRequestor(This)
    End If
    If AutoHint Then
     inv_antohint = Create n_cst_dwsrv_autoHint
     inv_antohint.of_SetRequestor(This)
    End If

    end event

    event rowfocuschanged;//

    end event

    event clicked;if row<>0 then
     this.setRow(row)
    end if
    end event

    event dberror;if SQLDBCode = -1 then
     int li_rtn
     //重新連接成功,則返回
     li_rtn = SetTranSobject(sqlca)
     if li_rtn = 1 then return 1
    end if

    //display different message according the datawindow is freeform or not
    If This.Object.datawindow.processing = "0" Then
     gf_dberrormsg(SQLDBCode,SQLErrText,row , "freeform")
    Else
     gf_dberrormsg(SQLDBCode , SQLErrText , row , "")
    End If
    sqlca.SQLCode = -1
    Return 1

    end event

    event destructor;If IsValid(inv_gridSort) Then
     Destroy inv_gridSort
    End If

    If IsValid(inv_antohint) Then
     Destroy inv_antohint
    End If

    end event

    event itemerror;string ls_column , ls_message

    if trim(data) = "" then
     return 3
    end if
    ls_column = dwo.name
    ls_message = this.describe(ls_column + ".validationmsg")
    if trim(ls_message) <> "?" then
     messagebox("提示信息" , ls_message)
       return 3
    else
     messagebox("提示信息" , "該項數據不合法!")
     return 3
    end if

    /*
     各返回值意義:
     0-拒絕此數值,顯示錯誤消息
     1-拒絕此數值,但不顯示錯誤消息
     2-接受此數值。
     3-拒絕此數值,但允許改變焦點,用原值來代替新值
    */
    end event


    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>