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

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

  
Appendix A: QFormMDI  
Documentation component by D.Glodt (c)2000-2003 Appendix A: QFormMDI

QFormMDI Component

     QFormEx is identical as a QForm component with functionality  MDI.
     The standard components of rapidq having a handle control (Qpanel,  QRichEdit, QScrollBox...) can be associated the windows child MDI,
     they must be no visible and their parent property must be the object  itself at the time of their declaration.
     The components can be declared as variables array or to be of  different type for each window child MDI.

QFormMDI Property

Field Type R/W Default




ChildCaption STRING R/W
Text of title bar of  active child window
ChildHandle LONG R
Handle of  active child window
ChildLeft SHORT R/W
Left position of  active child window
ChildTop SHORT R/W
Top position of  active child window
ChildWidth SHORT R/W
Width of  active child window
ChildHeight SHORT R/W
Height of  active child window
ChildMax INTEGER R/W 1024
Maximum  child window
ChildCount INTEGER R
Child window number
ChildIcon LONG R/W
 Icon handle for child window
ChildState INTEGER R/W
State of active child window,could be wsNormal,wsMinimized,wsMaximized wsNormal
MDIMenu LONG R/W
 Sub menu handle to insert the child window name
ComponentIndex INTEGER R
Index of associated component to the active child window
ChildResult INTEGER R/W False
Result of the action of closing of a child window, the value  is has true during closing and can be put at false at the time of a  OnChildClose event to cancel closing if the application requires a  safeguard

QFormMDI Methods

Method Type Description Params




AddChild SUB(handle&,Title$,index&,left%,
top%,width%,height%,DefaultSize&)
Add a child window , handle& is the handle component 
associated the child  window , Title$ is the text of the title bar of 
the child window , index& is the number of the associated component, 
DefaultSize& indicates if one uses dimensions by default.
8
CloseChild SUB Close the active child window 0
CloseAllChild SUB Close all the child window 0
CascadeChild SUB Resize all the child window on cascade 0
SetHorzChild SUB Resize all the child window on horizontal 0
SetVertChild SUB Resize all the child window on vertical 0
IconArrangeChild SUB Arrange all the child window on icon 0
MinimizeAllChild SUB Minimize all the child window 0
MaximizeAllChild SUB Maximize all the child window 0
RestoreChild SUB Restore the child window
ActiveNextChild SUB Activate the next child window 0
ActivePreviousChild SUB Activate the previous child window 0
GetChild FUNCTION(Title$)& Return the index of child window corresponding to the title Title$  1
ChildExist FUNCTION(Title$)& Return the existence of a child window by his title  1
ActiveChild SUB(Index&) Activate the child window identified by index&  1
FreeChild FUNCTION(handle&)& Return the state associated from a component to a child window, return True if 
the component identified by handle& is not associated to a child window 
1
SetDeskBar SUB The application will be in the task bar during its  reduction  0

QFormMDI Events

Event Type Occurs when... Params




OnChildClose (handleChild&,index&,titleChild$) Closing child window, the parameter index& is the index of  the associated component  3
OnChildActive (handleChild&,index&,titleChild$) Activation child window 3
OnChildResize (handleChild&,index&,titleChild$) Resize  child window 3

QFormMDI Example1

$TYPECHECK ON

$include "rapidq.inc"
$include "object\QformMDI.inc"

DECLARE SUB mnuNew_Click
DECLARE SUB mnuOpen_Click
DECLARE SUB mnuClose_Click
DECLARE SUB mnuCloseAll_Click
DECLARE SUB mnuNext_Click
DECLARE SUB mnuPrevious_Click
DECLARE SUB mnuCascade_Click
DECLARE SUB mnuTileHorz_Click
DECLARE SUB mnuTileVert_Click
DECLARE SUB mnuArrange_Click
DECLARE SUB mnuMinAll_Click
DECLARE SUB mnuMaxAll_Click
DECLARE SUB mnuRestAll_Click
DECLARE SUB mnuCut_Click
DECLARE SUB mnuCopy_Click
DECLARE SUB mnuPaste_Click
DECLARE SUB mnuSelectAll_Click
DECLARE SUB show
DECLARE SUB close
DECLARE SUB KeyDown(Key as word,Shift as integer)
DECLARE SUB infos(handleChild as long,index as integer,titleChild as string)
DECLARE SUB CloseMDI(handleChild as long,index as integer,titleChild as string)

dim j as integer
dim flag as integer
dim UntitledCount as integer
const VK_F6=117

CREATE Form AS QFormMDI
  Caption = "MDI Parent"
  Center
  Width=Screen.Width/2*1.5
  Height=Screen.Height/2*1.5
  CREATE mnuMain AS QMAINMENU
    CREATE mnuFile AS QMENUITEM
      Caption="&File"
      CREATE mnuNew AS QMENUITEM
        Caption="&New"
        OnClick=mnuNew_Click
      END CREATE
      CREATE mnuOpen AS QMENUITEM
        Caption="&Open"
        OnClick=mnuOpen_Click
      END CREATE
      CREATE mnuClose AS QMENUITEM
        Caption="&Close"
        OnClick=mnuClose_Click
      END CREATE
      CREATE mnuCloseAll AS QMENUITEM
        Caption="Close &All"
        OnClick=mnuCloseAll_Click
      END CREATE
      CREATE mnuNext AS QMENUITEM
        Caption="Next"
        OnClick=mnuNext_Click
      END CREATE
      CREATE mnuPrevious AS QMENUITEM
        Caption="Previous"
        OnClick=mnuPrevious_Click
      END CREATE
    END CREATE
    CREATE mnuEdit as QMENUITEM
      Caption="&Edit"
      CREATE mnuCut as QMENUITEM
        Caption="&Cut"
        ShortCut="CTRL+X"
        OnClick=mnuCut_Click
      END CREATE
      CREATE mnuCopy as QMENUITEM
        Caption="&Copy"
        ShortCut="CTRL+C"
        OnClick=mnuCopy_Click
      END CREATE
      CREATE mnuPaste as QMENUITEM
        Caption="&Paste"
        ShortCut="CTRL+V"
        OnClick=mnuPaste_Click
      END CREATE
      CREATE Sep2 as QMENUITEM
        Caption="-"
      END CREATE
      CREATE mnuSelectAll as QMENUITEM
        Caption="&Select all"
        ShortCut="CTRL+A"
        OnClick=mnuSelectAll_Click
      END CREATE
    END CREATE
    CREATE mnuWindows AS QMENUITEM
      Caption="&Windows"
      CREATE mnuCascade AS QMENUITEM
        Caption="&Cascade"
        OnClick=mnuCascade_Click
      END CREATE
      CREATE mnuTileHorz AS QMENUITEM
        Caption="Tile &Horizontally"
        OnClick=mnuTileHorz_Click
      END CREATE
      CREATE mnuTileVert AS QMENUITEM
        Caption="Tile &Vertically"
        OnClick=mnuTileVert_Click
      END CREATE
      CREATE mnuArrange AS QMENUITEM
        Caption="&Arrange Icons"
        OnClick=mnuArrange_Click
      END CREATE
      CREATE mnuMinAll AS QMENUITEM
        Caption="&Minimize All"
        OnClick=mnuMinAll_Click
      END CREATE
      CREATE mnuMaxAll AS QMENUITEM
        Caption="Ma&ximixe All"
        OnClick=mnuMaxAll_Click
      END CREATE
      CREATE mnuRestAll AS QMENUITEM
        Caption="&Restore All"
        OnClick=mnuRestAll_Click
      END CREATE
    END CREATE
  END CREATE
  CREATE Stat AS QSTATUSBAR
  END CREATE
  KeyPreview=true
  MdiMenu=mnuWindows.handle
  ChildMax=20
  OnChildClose=CloseMDI
  OnChildActive=infos
  OnClose=Close
  OnPaint=Show
  OnKeyDown=KeyDown
END CREATE

' Components for MDI
dim edit(20) as qrichedit
dim handleControl as long
for j=0 to 20
  edit(j).parent=form
  edit(j).visible=false 'must be no visible
  edit(j).ScrollBars=3
  edit(j).WordWrap=false
next j

Form.SetDeskBar
Form.ShowModal

'Find free component for MDI
Function GetCtl() as integer
  dim find as integer
  dim h as integer

  find=0
  for j=0 to 20
    if form.FreeChild(edit(j).handle) and find=0 then
      h=j
      find=1
    end if
  next j
  result=h
End Function

SUB mnuNew_Click
  dim index as integer

  if form.ChildCount<form.ChildMax then
    index=GetCtl()
    form.AddChild(edit(index).handle,"Untitled "+STR$(UntitledCount+1),index,0,0,0,0,true)
    UntitledCount++
  end if
END SUB

SUB mnuOpen_Click
  dim index as integer
  DIM OD AS QOPENDIALOG

  OD.Filter="Text file(*.txt)|*.txt"
  if form.ChildCount<form.ChildMax then
    IF OD.Execute THEN
      IF form.ChildExist(OD.FileName) THEN
        form.ActiveChild(form.GetChild(OD.FileName))
        EXIT SUB
      END IF
      index=GetCtl()
      edit(index).loadfromfile(OD.FileName)
      edit(index).modified=false
      form.AddChild(edit(index).handle,OD.FileName,index,0,0,0,0,True)
      UntitledCount++
    END IF
  end if
END SUB

SUB CloseMDI(handleChild as long,index as integer,titleChild as string)
  dim msgButton as integer

  if edit(index).modified then
    msgButton=MessageBox("Fermer fenetre?",titleChild,36)
    if msgButton=6 then
      edit(index).modified=false
      edit(index).clear
      form.ChildResult=true
    else
      form.ChildResult=false
    end if
  else
    edit(index).clear
  end if
END SUB

SUB mnuClose_Click
  form.CloseChild
  if form.ChildCount=0 then stat.simpleText=""
END SUB

SUB mnuCloseAll_Click
  form.CloseAllChild
  if form.ChildCount=0 then stat.simpleText=""
END SUB

SUB mnuNext_Click
  form.ActiveNextChild
END SUB

SUB mnuPrevious_Click
  form.ActivePreviousChild
END SUB

SUB mnuCascade_Click
  form.CascadeChild
END SUB

SUB mnuTileHorz_Click
  form.SetHorzChild
END SUB

SUB mnuTileVert_Click
  form.SetVertChild
END SUB

SUB mnuArrange_Click
  form.IconArrangeChild
END SUB

SUB mnuMinAll_Click
  form.MinimizeAllChild
END SUB

SUB mnuMaxAll_Click
  form.MaximizeAllChild
END SUB

SUB mnuRestAll_Click
  form.RestoreChild
END SUB

SUB mnuCut_Click
  if form.ChildCount>0 then
    edit(form.componentIndex).CutToClipBoard
  end if
END SUB

SUB mnuCopy_Click
  if form.ChildCount>0 then
    edit(form.componentIndex).CopyToClipBoard
  end if
END SUB

SUB mnuPaste_Click
  if form.ChildCount>0 then
    edit(form.componentIndex).PasteFromClipBoard
  end if
END SUB

SUB mnuSelectAll_Click
  if form.ChildCount>0 then
    edit(form.componentIndex).SelectAll
  end if
END SUB

SUB infos(handleChild as long,index as integer,titleChild as string)
  stat.simpleText=titleChild
End Sub

SUB show
  dim index as integer

  if flag=false then
    if form.ChildCount<form.ChildMax then
      index=GetCtl()
      form.AddChild(edit(index).handle,"Untitled "+STR$(UntitledCount+1),index,0,0,0,0,true)
      UntitledCount++
    end if
    flag=true
  end if
END SUB

Sub Close
  form.CloseAllChild
  if form.ChildCount>0 then form.modalResult=false
End Sub

Sub KeyDown(key as word,shift as integer)
  'next child with Ctrl+F6
  if shift=CtrlDown and key=VK_F6 then form.ActiveNextChild
end sub
 

QFormMDI Example2

$TYPECHECK ON
$OPTION ICON "photo.ico"
$include "rapidq.inc"
$Include "Object\QFormMDI.inc"
$Include "Object\QICON.inc"

DECLARE SUB mnuNew_Click
DECLARE SUB mnuOpen_Click
DECLARE SUB mnuClose_Click
DECLARE SUB mnuCloseAll_Click
DECLARE SUB mnuNext_Click
DECLARE SUB mnuPrevious_Click
DECLARE SUB mnuCascade_Click
DECLARE SUB mnuTileHorz_Click
DECLARE SUB mnuTileVert_Click
DECLARE SUB mnuArrange_Click
DECLARE SUB mnuMinAll_Click
DECLARE SUB mnuMaxAll_Click
DECLARE SUB mnuRestAll_Click
DECLARE SUB show
DECLARE SUB close
DECLARE SUB KeyDown(Key as word,Shift as integer)
DECLARE SUB infos(handleChild as long,index as integer,titleChild as string)
DECLARE SUB CloseMDI(handleChild as long,index as integer,titleChild as string)

dim j as integer
dim flag as integer
dim UntitledCount as integer
const VK_F6=117
dim icon as Qicon
    icon.associated=true
    icon.filename=command$(0)

CREATE Form AS QFormMDI
  Caption="MDI Parent"
  Center
  Width=Screen.Width/2*1.5
  Height=Screen.Height/2*1.5
  ChildIcon=icon.handle
  CREATE panel as QPANEL
    align=1
    height=35
    bevelOuter=0
    CREATE bt1 as QBUTTON
      top=5
      left=5
      width=25
      Hint="Prévious"
      ShowHint=true
      caption="<<"
      OnClick=mnuPrevious_Click
    END CREATE
    CREATE bt2 as QBUTTON
      top=5
      left=35
      width=25
      Hint="Next"
      ShowHint=true
      caption=">>"
      OnClick=mnuNext_Click
    END CREATE
  END CREATE
  CREATE mnuMain AS QMAINMENU
    CREATE mnuFile AS QMENUITEM
      Caption="&File"
      CREATE mnuNew AS QMENUITEM
        Caption="&New"
        OnClick=mnuNew_Click
      END CREATE
      CREATE mnuOpen AS QMENUITEM
        Caption="&Open"
        OnClick=mnuOpen_Click
      END CREATE
      CREATE mnuClose AS QMENUITEM
        Caption="&Close"
        OnClick=mnuClose_Click
      END CREATE
      CREATE mnuCloseAll AS QMENUITEM
        Caption="Close &All"
        OnClick=mnuCloseAll_Click
      END CREATE
      CREATE mnuNext AS QMENUITEM
        Caption="Next"
        OnClick=mnuNext_Click
      END CREATE
      CREATE mnuPrevious AS QMENUITEM
        Caption="Previous"
        OnClick=mnuPrevious_Click
      END CREATE
    END CREATE
    CREATE mnuWindows AS QMENUITEM
      Caption="&Windows"
      CREATE mnuCascade AS QMENUITEM
        Caption="&Cascade"
        OnClick=mnuCascade_Click
      END CREATE
      CREATE mnuTileHorz AS QMENUITEM
        Caption="Tile &Horizontally"
        OnClick=mnuTileHorz_Click
      END CREATE
      CREATE mnuTileVert AS QMENUITEM
        Caption="Tile &Vertically"
        OnClick=mnuTileVert_Click
      END CREATE
      CREATE mnuArrange AS QMENUITEM
        Caption="&Arrange Icons"
        OnClick=mnuArrange_Click
      END CREATE
      CREATE mnuMinAll AS QMENUITEM
        Caption="&Minimize All"
        OnClick=mnuMinAll_Click
      END CREATE
      CREATE mnuMaxAll AS QMENUITEM
        Caption="Ma&ximixe All"
        OnClick=mnuMaxAll_Click
      END CREATE
      CREATE mnuRestAll AS QMENUITEM
        Caption="&Restore All"
        OnClick=mnuRestAll_Click
      END CREATE
    END CREATE
  END CREATE
  CREATE Stat AS QSTATUSBAR
  END CREATE
  KeyPreview=true
  MdiMenu=mnuWindows.handle
  ChildMax=20
  OnChildClose=CloseMDI
  OnChildActive=infos
  OnClose=Close
  OnKeyDown=KeyDown
END CREATE

'components for MDI
dim edit(20) as qpanel
dim img(20) as qimage
for j=0 to 20
  edit(j).parent=form
  edit(j).visible=false 'must be no visible
  edit(j).bevelOuter=0
  edit(j).color=&hffffff
  img(j).AutoSize=1
  img(j).Parent=edit(j)
next j

Form.SetDeskBar
Form.ShowModal

'Find free component for MDI
Function GetCtl() as integer
  dim find as integer
  dim h as integer

  find=0
  for j=0 to 20
    if form.FreeChild(edit(j).handle) and find=0 then
      h=j
      find=1
    end if
  next j
  result=h
End Function

SUB mnuNew_Click
  dim index as integer

  if form.ChildCount<form.ChildMax then
    index=GetCtl()
    form.AddChild(edit(index).handle,"Untitled "+STR$(UntitledCount+1),index,0,0,0,0,true)
    UntitledCount++
  end if
END SUB

SUB mnuOpen_Click
  dim index as integer
  DIM OD AS QOPENDIALOG

  OD.caption="Load image"
  OD.Filter="Bitmap file(*.bmp)|*.bmp"
  if form.ChildCount<form.ChildMax then
    IF OD.Execute THEN
      IF form.ChildExist(OD.FileName) THEN
        form.ActiveChild(form.GetChild(OD.FileName))
        EXIT SUB
      END IF
      index=GetCtl()
      img(index).bmp=OD.FileName
      form.AddChild(edit(index).handle,OD.FileName,index,0,0,img(index).width+8,img(index).height+27,False)
      UntitledCount++
    END IF
  end if
END SUB

SUB CloseMDI(handleChild as long,index as integer,titleChild as string)
  img(index).handle=0
END SUB

SUB mnuClose_Click
  form.CloseChild
  if form.ChildCount=0 then stat.simpleText=""
END SUB

SUB mnuCloseAll_Click
  form.CloseAllChild
  if form.ChildCount=0 then stat.simpleText=""
END SUB

SUB mnuNext_Click
  form.ActiveNextChild
END SUB

SUB mnuPrevious_Click
  form.ActivePreviousChild
END SUB

SUB mnuCascade_Click
  form.CascadeChild
END SUB

SUB mnuTileHorz_Click
  form.SetHorzChild
END SUB

SUB mnuTileVert_Click
  form.SetVertChild
END SUB

SUB mnuArrange_Click
  form.IconArrangeChild
END SUB

SUB mnuMinAll_Click
  form.MinimizeAllChild
END SUB

SUB mnuMaxAll_Click
  form.MaximizeAllChild
END SUB

SUB mnuRestAll_Click
  form.RestoreChild
END SUB

SUB infos(handleChild as long,index as integer,titleChild as string)
  stat.simpleText=titleChild
End Sub

Sub Close
  form.CloseAllChild
  if form.ChildCount>0 then form.modalResult=false
  if form.ChildCount=0 then icon.filename=""
End Sub

Sub KeyDown(key as word,shift as integer)
  'next child with Ctrl+F6
  if shift=CtrlDown and key=VK_F6 then form.ActiveNextChild
end sub
 
 
 

掌柜推荐
 
 
¥860.00 ·
 
 
¥900.00 ·
 
 
¥810.00 ·
 
 
¥317.00 ·
 
 
¥1,370.00 ·
 
 
¥660.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-02-10 20:18:20