Guidance
指路人
g.yi.org
software / rapidq / Examples / QObject / Object / QFormMDI.inc

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'=======================================================
' Type Objet
' Classe QFormMDI Version 1.0
'=======================================================
     $IFNDEF TRUE
      $DEFINE True 1
     $ENDIF

     $IFNDEF FALSE
      $DEFINE False 0
     $ENDIF

     $IFNDEF boolean
      $DEFINE boolean INTEGER
     $ENDIF

     TYPE MDI_CLASS
      cbSize AS LONG
      style AS LONG
      lpfnWndProc AS LONG
      cbClsExtra AS LONG
      cbWndExtra AS LONG
      hInstance AS LONG
      hIcon AS LONG
      hCursor AS LONG
      hbrBackground AS LONG
      lpszMenuName AS LONG
      lpszClassName AS LONG
      hIconSm AS LONG
     END TYPE

     DECLARE FUNCTION MDI_RegisterClass LIB "User32" ALIAS "RegisterClassExA" (pcWndClassEx AS MDI_CLASS) AS LONG
     DECLARE FUNCTION MDI_EnumChild LIB "User32" ALIAS "EnumChildWindows" (hWndParent AS LONG,lpEnumFunc AS LONG,lParam AS LONG) AS LONG
     DECLARE FUNCTION MDI_CreateWindow LIB "User32" ALIAS "CreateWindowExA" (dwExStyle AS LONG,lpClassName AS STRING,lpWindowName AS STRING,dwStyle AS LONG,x AS LONG,y AS LONG,nWidth AS LONG,nHeight AS LONG,hWndParent AS LONG,hMenu AS LONG,hInstance AS LONG,lpParam AS LONG) AS LONG
     DECLARE FUNCTION MDI_DefChildProc LIB "User32" ALIAS "DefMDIChildProcA" (hWnd AS LONG,uMsg AS LONG,wParam AS LONG,lParam AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetClassName LIB "User32" ALIAS "GetClassNameA" (hwnd AS LONG,ByRef lpClassName AS STRING,nMaxCount AS LONG) AS LONG
     DECLARE FUNCTION MDI_SetProp LIB "User32" ALIAS "SetPropA" (hwnd AS LONG,lpString AS STRING,hData AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetProp LIB "User32"  ALIAS "GetPropA" (hwnd AS LONG,lpString AS STRING) AS LONG
     DECLARE FUNCTION MDI_GetClientRect LIB "User32" ALIAS "GetClientRect" (hwnd AS LONG,lpRect AS QRECT) AS LONG
     DECLARE FUNCTION MDI_MoveWindow LIB "User32" ALIAS "MoveWindow" (hwnd AS LONG,x AS LONG,y AS LONG,nWidth AS LONG,nHeight AS LONG,bRepaint AS LONG) AS LONG
     DECLARE FUNCTION MDI_SetLong LIB "User32" ALIAS "SetWindowLongA" (hwnd AS LONG,nIndex AS LONG,dwNewLong AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetText LIB "User32" ALIAS "GetWindowTextA" (hwnd AS LONG,ByRef lpString AS STRING,cch AS LONG) AS LONG
     DECLARE FUNCTION MDI_SetText LIB "user32" ALIAS "SetWindowTextA" (hWnd AS LONG,lpString AS STRING) AS LONG
     DECLARE FUNCTION MDI_SetFocus LIB "User32" ALIAS "SetFocus" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION MDI_SetParent LIB "user32" ALIAS "SetParent" (hWndChild AS LONG,hWndNewParent AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetParent LIB "user32" ALIAS "GetParent" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetRect LIB "user32" ALIAS "GetWindowRect" (hwnd AS LONG, lpRect AS QRECT) AS LONG
     DECLARE FUNCTION MDI_isIconic LIB "user32" ALIAS "IsIconic" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION MDI_isZoomed LIB "user32" ALIAS "IsZoomed" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION MDI_GetTextLenght LIB "user32" ALIAS "GetWindowTextLengthA" (hwnd AS LONG) AS LONG
     DECLARE FUNCTION MDI_SendMessage LIB "user32" ALIAS "SendMessageA" (hwnd AS LONG, wMsg AS LONG, wParam AS LONG, lParam AS LONG) AS LONG
     DECLARE FUNCTION MDI_SetClassLong LIB "user32" ALIAS "SetClassLongA" (hwnd AS LONG,nIndex AS LONG,dwNewLong AS LONG) AS LONG
     DECLARE FUNCTION MDI_ShowWindow LIB "user32" ALIAS "ShowWindow" (hwnd AS LONG,nCmdShow AS LONG) AS LONG


'styles
     CONST MDI_EX_MDICHILD=&H40
     CONST MDI_CHILD=&H40000000
     CONST MDI_VISIBLE=&H10000000
     CONST MDI_OVERLAPPED=&H0
     CONST MDI_CAPTION=&HC00000
     CONST MDI_SYSMENU=&H80000
     CONST MDI_THICKFRAME=&H40000
     CONST MDI_MINIMIZEBOX=&H20000
     CONST MDI_MAXIMIZEBOX=&H10000
     CONST MDI_OVERLAPPEDWINDOW=(MDI_OVERLAPPED OR MDI_CAPTION OR MDI_SYSMENU OR MDI_THICKFRAME OR MDI_MINIMIZEBOX OR MDI_MAXIMIZEBOX)

'messages
     CONST MDI_MOVE = &H3
     CONST MDI_CLOSE=&H10
     CONST MDI_CREATE=&H1
     CONST MDI_DESTROY=&H2
     CONST MDI_SIZE=&H5
     CONST MDI_SYSCOMMAND=&H112
     CONST MDI_MDIDESTROY=&H221
     CONST MDI_MDIRESTORE=&H223
     CONST MDI_MDIMAXIMIZE=&H225
     CONST MDI_MDITILE=&H226
     CONST MDI_MDICASCADE=&H227
     CONST MDI_MDIICONARRANGE=&H228
     CONST MDI_MDIACTIVATE=&H222
     CONST MDI_MDISETMENU=&H230
     CONST MDI_MDINEXT=&H224
     CONST MDI_MDIGETACTIVE = &H229
     CONST MDI_CHILDACTIVATE = &H22
     CONST MDI_TILE_VERTICAL=&H0
     CONST MDI_TILE_HORIZONTAL=&H1

     CONST MDI_HWND_DESKTOP=0
     CONST MDI_USEDEFAULT=&H80000000
     CONST MDI_MINIMIZE=&HF020
     CONST MDI_MAXIMIZE = &HF030
     CONST MDI_HWNDPARENT=-8
     CONST MDI_HICON=-14
     CONST MDI_COLOR_WINDOW=5
     CONST MDI_COLOR_BACKGROUND=1
     CONST MDI_COLOR_WINDOWFRAME=6
     CONST MDI_COLOR_APPWORKSPACE=12
     CONST MDI_COLOR_HIGHLIGHT=13

'Events
     DECLARE SUB OnChildClose_eventTemplate(handleChild AS LONG,index AS INTEGER,titleChild AS STRING)
     DECLARE SUB OnChildActive_eventTemplate(handleChild AS LONG,index AS INTEGER,titleChild AS STRING)
     DECLARE SUB OnChildResize_eventTemplate(handleChild AS LONG,index AS INTEGER,titleChild AS STRING)


     TYPE QFormMDI EXTENDS QFORM
Private:
      hClient AS LONG
      hChild(1024) AS LONG
      hComponent AS LONG
      ClassName AS STRING
      ChildClass AS MDI_CLASS
      Rect AS QRECT
      style AS LONG
Public:
      ChildCaption AS STRING PROPERTY SET SetChildCaption
      ChildHandle AS LONG PROPERTY SET SetChildHandle
      ComponentIndex AS INTEGER PROPERTY SET SetComponentIndex
      ChildTop AS SHORT PROPERTY SET SetChildTop
      ChildLeft AS SHORT PROPERTY SET SetChildLeft
      ChildWidth AS SHORT PROPERTY SET SetChildWidth
      ChildHeight AS SHORT PROPERTY SET SetChildHeight
      MdiMenu AS LONG PROPERTY SET SetMdiMenu
      ChildMax AS INTEGER PROPERTY SET SetChildMax
      ChildCount AS INTEGER PROPERTY SET SetChildCount
      ChildState AS INTEGER PROPERTY SET SetChildState
      ChildIcon AS LONG PROPERTY SET SetChildIcon
      ChildResult AS INTEGER
      OnChildClose AS EVENT(OnChildClose_eventTemplate)
      OnChildActive AS EVENT(OnChildActive_eventTemplate)
      OnChildResize AS EVENT(OnChildResize_eventTemplate)

Private:

  '========================================================
  ' Fonction callback recherche handle fenetre client MDI
  '========================================================
      FUNCTION EnumClient(hWnd AS LONG,lParam AS LONG) AS LONG
       DIM Buffer AS STRING

       Buffer=SPACE$(255)
       MDI_GetClassName(hWnd,Buffer,255)
       IF INSTR(UCASE$(Buffer),"MDICLIENT") THEN QFormMDI.hClient=hWnd
       Result=True
      END FUNCTION

  '========================================================
  ' Fonction callback recherche handle fenetre fille MDI
  '========================================================
      FUNCTION EnumChild(hWnd AS LONG,lParam AS LONG) AS LONG
       DIM Buffer AS STRING

       Buffer=SPACE$(255)
       MDI_GetClassName(hWnd,Buffer,255)
       IF INSTR(UCASE$(Buffer),"MDICHILD") THEN
        IF QFormMDI.ChildCount>0 THEN
         IF hwnd<>QFormMDI.hChild(QFormMDI.ChildCount-1) THEN
          QFormMDI.hChild(QFormMDI.ChildCount)=hWnd
          QFormMDI.ChildCount++
         END IF
        ELSE
         QFormMDI.hChild(QFormMDI.ChildCount)=hWnd
         QFormMDI.ChildCount++
        END IF
       END IF
       Result=true
      END FUNCTION

  '========================================================
  ' Procedure adaptation dimentions fenetre fille MDI
  '========================================================
      SUB GetSizeChild(hwnd AS LONG)
       DIM Rc AS QRECT
       DIM Rw AS QRECT
       DIM borderX AS SHORT
       DIM borderY AS SHORT
       DIM top AS SHORT
       DIM left AS SHORT

       MDI_GetClientRect(QFormMDI.hClient,Rc)
       MDI_GetRect(QFormMDI.hClient,Rw)
       top=Rw.top
       left=Rw.left
       borderX=((Rw.Right-Rw.Left)-Rc.Right)/2
       borderY=((Rw.Bottom-Rw.Top)-Rc.Bottom)/2
       MDI_GetRect(hWnd,Rw)
       QFormMDI.ChildLeft=Rw.Left-(left+borderX)
       QFormMDI.ChildTop=Rw.Top-(top+borderY)
       QFormMDI.ChildWidth=Rw.Right-Rw.Left
       QFormMDI.ChildHeight=Rw.Bottom-Rw.Top
      END SUB

  '========================================================
  ' Fonction retourne etat fenetre fille MDI
  '========================================================
      FUNCTION GetState(hwnd AS LONG) AS SHORT
       IF MDI_isIconic(hwnd) THEN
        result=1
       ELSEIF MDI_isZoomed(hwnd) THEN
        result=2
       ELSE
        result=0
       END IF
      END FUNCTION

  '========================================================
  ' Fonction retourne le texte caption d'une fenetre MDI
  '========================================================
      FUNCTION GetTextChild(hwnd AS LONG) AS STRING
       DIM size AS INTEGER
       DIM buffer AS STRING

       size=MDI_GetTextLenght(hwnd)
       buffer=SPACE$(size)+CHR$(0)
       size=MDI_GetText(hwnd,buffer,LEN(buffer))
       result=LEFT$(buffer,size)
      END FUNCTION

public:
  '========================================================
  ' Procedure de fenetre enfant MDI
  '========================================================
      FUNCTION ChildProc(hWnd AS LONG,uMsg AS LONG,wParam AS LONG,lParam AS LONG) AS LONG
       SELECT CASE uMsg
       CASE MDI_CREATE
        MDI_SetParent(QFormMDI.hComponent,hWnd)
        MDI_ShowWindow(QFormMDI.hComponent,true)
        MDI_SetProp(hWnd,"EditHandle",QFormMDI.hComponent)
        MDI_SetProp(hWnd,"EditIndex",QFormMDI.ComponentIndex)
        QFormMDI.ChildCount++
        IF QFormMDI.MdiMenu>0 THEN SendMessage(QFormMDI.hClient,MDI_MDISETMENU,0,QFormMDI.MdiMenu)
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       CASE MDI_SIZE
        QFormMDI.hComponent=MDI_GetProp(hWnd,"EditHandle")
        QFormMDI.ComponentIndex=MDI_GetProp(hWnd,"EditIndex")
        QFormMDI.ChildCaption=QFormMDI.GetTextChild(hwnd)
        MDI_GetClientRect(hWnd,QFormMDI.Rect)
        MDI_MoveWindow(QFormMDI.hComponent,0,0,QFormMDI.Rect.Right,QFormMDI.Rect.Bottom,True)
        QFormMDI.GetSizeChild(hwnd)
        IF QFormMDI.OnChildResize<>0 THEN CALLFUNC(QFormMDI.OnChildResize,hwnd,QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       CASE MDI_MDIACTIVATE
        QFormMDI.ChildHandle=hWnd
        QFormMDI.ChildCaption=QFormMDI.GetTextChild(hwnd)
        QFormMDI.GetSizeChild(hwnd)
        MDI_SetFocus(MDI_GetProp(lParam,"EditHandle"))
        QFormMDI.ComponentIndex=MDI_GetProp(hWnd,"EditIndex")
        QFormMDI.ChildState=QFormMDI.GetState(hwnd)
        IF QFormMDI.OnChildActive<>0 THEN CALLFUNC(QFormMDI.OnChildActive,hwnd,QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       CASE MDI_CLOSE
        QFormMDI.ChildResult=True
        QFormMDI.ChildCaption=QFormMDI.GetTextChild(hwnd)
        QFormMDI.ComponentIndex=MDI_GetProp(hWnd,"EditIndex")
        IF QFormMDI.OnChildClose<>0 THEN CALLFUNC(QFormMDI.OnChildClose,hwnd,QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
        IF QFormMDI.ChildResult>0 THEN
         Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
        ELSE
         Result=False
        END IF
       CASE MDI_DESTROY
        QFormMDI.hComponent=MDI_GetProp(hWnd,"EditHandle")
        MDI_MoveWindow(QFormMDI.hComponent,0,0,0,0,0)
        MDI_ShowWindow(QFormMDI.hComponent,false)
        MDI_SetParent(QFormMDI.hComponent,QFormMDI.handle)
        QFormMDI.ChildCount--
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       CASE MDI_MOVE
        QFormMDI.GetSizeChild(hwnd)
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       CASE ELSE
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildState=QFormMDI.GetState(hwnd)
        END IF
        Result=MDI_DefChildProc(hWnd,uMsg,wParam,lParam)
       END SELECT
      END FUNCTION

Public:

  '========================================================
  ' Proprieté nombre max fenetre fille MDI
  '========================================================
      PROPERTY SET SetChildMax(number AS INTEGER)
       IF number<=1024 THEN QFormMDI.ChildMax=number
      END PROPERTY

  '========================================================
  ' Proprieté icon fenetre fille MDI
  '========================================================
      PROPERTY SET SetChildIcon(handle AS LONG)
       IF QFormMDI.ChildCount>0 THEN
        MDI_SetClassLong(QFormMDI.ChildHandle,MDI_HICON,handle)
       ELSE
        QFormMDI.ChildClass.hIcon=handle
        QFormMDI.ChildClass.hIconSm=handle
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté caption fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildCaption(CAPTION AS STRING)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCaption=CAPTION
        MDI_SetText(QFormMDI.ChildHandle,QFormMDI.ChildCaption)
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté handle fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildHandle(handle AS LONG)
    'lecture uniquement
      END PROPERTY

  '========================================================
  ' Proprieté index composant fenetre fille MDI active
  '========================================================
      PROPERTY SET SetComponentIndex(index AS INTEGER)
    'lecture uniquement
      END PROPERTY

  '========================================================
  ' Proprieté top fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildTop(top AS SHORT)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildTop=top
        MDI_MoveWindow(QFormMDI.ChildHandle,QFormMDI.ChildLeft,QFormMDI.ChildTop,QFormMDI.ChildWidth,QFormMDI.ChildHeight,True)
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté left fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildLeft(left AS SHORT)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildLeft=left
        MDI_MoveWindow(QFormMDI.ChildHandle,QFormMDI.ChildLeft,QFormMDI.ChildTop,QFormMDI.ChildWidth,QFormMDI.ChildHeight,True)
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté width fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildWidth(width AS SHORT)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildWidth=width
        MDI_MoveWindow(QFormMDI.ChildHandle,QFormMDI.ChildLeft,QFormMDI.ChildTop,QFormMDI.ChildWidth,QFormMDI.ChildHeight,True)
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté height fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildHeight(height AS SHORT)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildHeight=height
        MDI_MoveWindow(QFormMDI.ChildHandle,QFormMDI.ChildLeft,QFormMDI.ChildTop,QFormMDI.ChildWidth,QFormMDI.ChildHeight,True)
       END IF
      END PROPERTY

  '========================================================
  ' Proprieté handle menu fenetre fille MDI
  '========================================================
      PROPERTY SET SetMdiMenu(MenuHandle AS LONG)
       IF MenuHandle>0 THEN QFormMDI.MdiMenu=MenuHandle
      END PROPERTY

  '========================================================
  ' Proprieté nombre fenetre fille MDI
  '========================================================
      PROPERTY SET SetChildCount(index AS INTEGER)
    'lecture uniquement
      END PROPERTY

  '========================================================
  ' Proprieté etat fenetre fille MDI active
  '========================================================
      PROPERTY SET SetChildState(state AS INTEGER)
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildState=state
        IF state=1 THEN
         SendMessage(QFormMDI.ChildHandle,MDI_SYSCOMMAND,MDI_MINIMIZE,0)
        ELSEIF state=2 THEN
         SendMessage(QFormMDI.hClient,MDI_MDIMAXIMIZE,QFormMDI.ChildHandle,0)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        ELSE
         SendMessage(QFormMDI.hClient,MDI_MDIRESTORE,QFormMDI.ChildHandle,0)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END PROPERTY

  '========================================================
  ' Méthode addition d'une fenetre fille MDI
  '========================================================
      SUB AddChild(handle AS LONG,Title AS STRING,index AS INTEGER,Left AS SHORT,Top AS SHORT,Width AS SHORT,Height AS SHORT,DefaultSize AS boolean)
    'init client MDI
       IF QFormMDI.hClient=0 THEN
        QFormMDI.ChildClass.cbSize=SIZEOF(QFormMDI.ChildClass)
        QFormMDI.ChildClass.lpfnWndProc=CODEPTR(QFormMDI.ChildProc)
        QFormMDI.ChildClass.hbrBackground=MDI_COLOR_WINDOWFRAME
        QFormMDI.ChildClass.lpszClassName=VARPTR(QFormMDI.ClassName)
      'QFormMDI.ChildClass.hinstance=application.hinstance
        MDI_RegisterClass(QFormMDI.ChildClass)
        MDI_EnumChild(QFormMDI.Handle,CODEPTR(QFormMDI.EnumClient),0)
       END IF
       IF QFormMDI.ChildCount<QFormMDI.ChildMax AND handle<>0 THEN
        QFormMDI.hComponent=handle
        QFormMDI.ComponentIndex=index
        QFormMDI.style=MDI_CHILD OR MDI_VISIBLE OR MDI_OVERLAPPEDWINDOW
        IF DefaultSize=True THEN
        'QFormMDI.hChild(QFormMDI.ChildCount)=MDI_CreateWindow(MDI_EX_MDICHILD,QFormMDI.ClassName,Title,QFormMDI.style,MDI_USEDEFAULT,MDI_USEDEFAULT,MDI_USEDEFAULT,MDI_USEDEFAULT,QFormMDI.hClient,0,application.hinstance,0)
         QFormMDI.hChild(QFormMDI.ChildCount)=MDI_CreateWindow(MDI_EX_MDICHILD,QFormMDI.ClassName,Title,QFormMDI.style,MDI_USEDEFAULT,MDI_USEDEFAULT,MDI_USEDEFAULT,MDI_USEDEFAULT,QFormMDI.hClient,0,0,0)
        ELSE
        'QFormMDI.hChild(QFormMDI.ChildCount)=MDI_CreateWindow(MDI_EX_MDICHILD,QFormMDI.ClassName,Title,QFormMDI.style,Left,Top,Width,Height,QFormMDI.hClient,0,application.hinstance,0)
         QFormMDI.hChild(QFormMDI.ChildCount)=MDI_CreateWindow(MDI_EX_MDICHILD,QFormMDI.ClassName,Title,QFormMDI.style,Left,Top,Width,Height,QFormMDI.hClient,0,0,0)
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode fermeture fenetre fille MDI active
  '========================================================
      SUB CloseChild
       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildResult=True
        QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
        QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
        QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
        IF QFormMDI.OnChildClose<>0 THEN CALLFUNC(QFormMDI.OnChildClose,QFormMDI.CHildHandle,QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
        IF QFormMDI.ChildResult>0 THEN
         SendMessage(QFormMDI.hClient,MDI_MDIDESTROY,QFormMDI.ChildHandle,0)
        END IF
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
         QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
         QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
         QFormMDI.ChildState=QFormMDI.GetState(QFormMDI.ChildHandle)
         QFormMDI.GetSizeChild(QFormMDI.ChildHandle)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode fermeture fenetres fille MDI
  '========================================================
      SUB CloseAllChild
       DIM i AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        IF QFormMDI.ChildCount>1 THEN
         FOR i=0 TO QFormMDI.ChildCount-1
          QFormMDI.ChildResult=True
          QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.hChild(i),"EditIndex")
          QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.hChild(i))
          IF QFormMDI.OnChildClose<>0 THEN CALLFUNC(QFormMDI.OnChildClose,QFormMDI.hChild(i),QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
          IF QFormMDI.ChildResult>0 THEN
           SendMessage(QFormMDI.hClient,MDI_MDIDESTROY,QFormMDI.hChild(i),0)
          END IF
         NEXT i
        ELSE
         IF QFormMDI.ChildCount>0 THEN
          QFormMDI.ChildResult=True
          QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.hChild(0),"EditIndex")
          QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.hChild(0))
          IF QFormMDI.OnChildClose<>0 THEN CALLFUNC(QFormMDI.OnChildClose,QFormMDI.hChild(0),QFormMDI.ComponentIndex,QFormMDI.ChildCaption)
          IF QFormMDI.ChildResult>0 THEN
           SendMessage(QFormMDI.hClient,MDI_MDIDESTROY,QFormMDI.hChild(0),0)
          END IF
         END IF
        END IF
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
         QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
         QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
         QFormMDI.ChildState=QFormMDI.GetState(QFormMDI.ChildHandle)
         QFormMDI.GetSizeChild(QFormMDI.ChildHandle)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode mise en cascade des fenetres fille MDI
  '========================================================
      SUB CascadeChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDICASCADE,0,0)
       END IF
      END SUB

  '========================================================
  ' Méthode mise en horizontale fenetres fille MDI
  '========================================================
      SUB SetHorzChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDITILE,MDI_TILE_HORIZONTAL,0)
       END IF
      END SUB

  '========================================================
  ' Méthode mise en verticale fenetres fille MDI
  '========================================================
      SUB SetVertChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDITILE,MDI_TILE_VERTICAL,0)
       END IF
      END SUB

  '========================================================
  ' Méthode arrangement des fenetres fille MDI en icone
  '========================================================
      SUB IconArrangeChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDIICONARRANGE,0,0)
       END IF
      END SUB

  '========================================================
  ' Méthode reduit en icone les fenetres fille MDI
  '========================================================
      SUB MinimizeAllChild
       DIM i AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        FOR i=0 TO QFormMDI.ChildCount-1
         SendMessage(QFormMDI.hChild(i),MDI_SYSCOMMAND,MDI_MINIMIZE,0)
        NEXT i
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
         QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
         QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
         QFormMDI.ChildState=QFormMDI.GetState(QFormMDI.ChildHandle)
         QFormMDI.GetSizeChild(QFormMDI.ChildHandle)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode met en taille maxi les fenetres fille MDI
  '========================================================
      SUB MaximizeAllChild
       DIM i AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        FOR i=0 TO QFormMDI.ChildCount-1
         SendMessage(QFormMDI.hClient,MDI_MDIMAXIMIZE,QFormMDI.hChild(i),0)
        NEXT i
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
         QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
         QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
         QFormMDI.ChildState=QFormMDI.GetState(QFormMDI.ChildHandle)
         QFormMDI.GetSizeChild(QFormMDI.ChildHandle)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode restauration taille des fenetres fille MDI
  '========================================================
      SUB RestoreChild
       DIM i AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        FOR i=0 TO QFormMDI.ChildCount-1
         SendMessage(QFormMDI.hClient,MDI_MDIRESTORE,QFormMDI.hChild(i),0)
        NEXT i
        IF QFormMDI.ChildCount>0 THEN
         QFormMDI.ChildHandle=MDI_SendMessage(QFormMDI.hClient,MDI_MDIGETACTIVE,0,0)
         QFormMDI.ComponentIndex=MDI_GetProp(QFormMDI.ChildHandle,"EditIndex")
         QFormMDI.ChildCaption=QFormMDI.GetTextChild(QFormMDI.ChildHandle)
         QFormMDI.ChildState=QFormMDI.GetState(QFormMDI.ChildHandle)
         QFormMDI.GetSizeChild(QFormMDI.ChildHandle)
         MDI_SetFocus(MDI_GetProp(QFormMDI.ChildHandle,"EditHandle"))
        END IF
       END IF
      END SUB

  '========================================================
  ' Méthode active la fenetre fille MDI suivante
  '========================================================
      SUB ActiveNextChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDINEXT,QFormMDI.ChildHandle,False)
       END IF
      END SUB

  '========================================================
  ' Méthode active la fenetre fille MDI précedente
  '========================================================
      SUB ActivePreviousChild
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDINEXT,QFormMDI.ChildHandle,True)
       END IF
      END SUB

  '========================================================
  ' Méthode retourne index titre fenetre fille MDI
  '========================================================
      FUNCTION GetChild(title AS STRING) AS INTEGER
       DIM i AS INTEGER
       DIM index AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        index=0
        FOR i=0 TO QFormMDI.ChildCount-1
         IF title=QFormMDI.GetTextChild(QFormMDI.hChild(i)) THEN index=i
        NEXT i
        result=index
       ELSE
        result=0
       END IF
      END FUNCTION

  '========================================================
  ' Méthode retourne l'existence titre fenetre fille MDI
  '========================================================
      FUNCTION ChildExist(title AS STRING) AS boolean
       DIM i AS INTEGER
       DIM exist AS INTEGER

       IF QFormMDI.ChildCount>0 THEN
        QFormMDI.ChildCount=0
        MDI_EnumChild(QFormMDI.hClient,CODEPTR(QFormMDI.EnumChild),0)
        exist=False
        FOR i=0 TO QFormMDI.ChildCount-1
         IF title=QFormMDI.GetTextChild(QFormMDI.hChild(i)) THEN exist=True
        NEXT i
        result=exist
       ELSE
        result=False
       END IF
      END FUNCTION


  '========================================================
  ' Méthode active la fenetre fille MDI par index
  '========================================================
      SUB ActiveChild(index AS INTEGER)
       IF QFormMDI.ChildCount>0 THEN
        SendMessage(QFormMDI.hClient,MDI_MDIACTIVATE,QFormMDI.hChild(index),0)
       END IF
      END SUB

  '========================================================
  ' Méthode retourne etat associé MDI d'un composant
  '========================================================
      FUNCTION FreeChild(handle AS LONG) AS boolean
       IF MDI_GetParent(handle)=QFormMDI.handle THEN
        result=True
       ELSE
        result=False
       END IF
      END FUNCTION

  '=============================================================================
  ' méthode application dans barre outil bureau lors de la reduction fenetre
  '=============================================================================
      SUB SetDeskBar
       MDI_SetLong(QFormMDI.handle,MDI_HWNDPARENT,MDI_HWND_DESKTOP)
       MDI_SetLong(application.handle,MDI_HWNDPARENT,QFormMDI.handle)
      END SUB

      CONSTRUCTOR
       FormStyle=2
       COLOR=-2147483636
       ChildMax=1024
       ClassName="MDIChild"
       hClient=0
       ChildCount=0
      END CONSTRUCTOR
     END TYPE
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Sat 2023-2-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-04-27 22:25:02