photoshop的工具条好像不是子窗体。只不过它采用了一些方法,使其看起来是一起的(类似子窗体)

解决方案 »

  1.   

    就是做SDI的界面效果,怎么弄?
      

  2.   

    很多所谓自许为高手的人都解决不了这个问题,所以,只有我这个菜鸟出马了::::::VERSION 5.00
    Begin VB.Form frmMain 
       Caption         =   "Floating Toolbar Demo"
       ClientHeight    =   2535
       ClientLeft      =   1125
       ClientTop       =   3345
       ClientWidth     =   3165
       ForeColor       =   &H80000008&
       LinkTopic       =   "Form1"
       PaletteMode     =   1  'UseZOrder
       ScaleHeight     =   2535
       ScaleWidth      =   3165
       Begin VB.PictureBox Picture1 
          BackColor       =   &H80000005&
          Height          =   1935
          Left            =   120
          ScaleHeight     =   1875
          ScaleWidth      =   2115
          TabIndex        =   0
          Top             =   120
          Width           =   2175
       End
       Begin VB.Menu mnuFile 
          Caption         =   "&File"
          Begin VB.Menu mnuFileExit 
             Caption         =   "E&xit"
          End
       End
       Begin VB.Menu mnuView 
          Caption         =   "&View"
          Begin VB.Menu mnuViewToolbar 
             Caption         =   "&Toolbar"
          End
       End
    End
    Attribute VB_Name = "frmMain"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = FalseOption ExplicitPrivate Sub Form_Load()
        Width = Screen.Width * 0.9
        Height = Screen.Height * 0.9
        Move (Screen.Width - Width) / 2, (Screen.Height - Height) / 2
        
        g_xToolbarPos = 1000: g_yToolbarPos = 2000
        Call mnuViewToolbar_Click
        
    End Sub
    Private Sub Form_Resize()
        Picture1.Move 0, 0, ScaleWidth, ScaleHeight
    End SubPrivate Sub Form_Unload(Cancel As Integer)
        If g_bToolbarVisible Then
            frmToolbar.UnloadToolbar
        End If
    End SubPrivate Sub mnuFileExit_Click()
        Unload Me
    End SubPrivate Sub mnuView_Click()
       
        If g_bToolbarVisible Then
            mnuViewToolbar.Checked = True
        Else
            mnuViewToolbar.Checked = False
        End If
    End SubPrivate Sub mnuViewToolbar_Click()
        
        If Not g_bToolbarVisible Then
            frmToolbar.LoadToolbar Me
        Else
            frmToolbar.UnloadToolbar
        End If
    End SubVERSION 5.00
    Begin VB.Form frmToolbar 
       BorderStyle     =   4  'Fixed ToolWindow
       Caption         =   "Tools"
       ClientHeight    =   2535
       ClientLeft      =   1155
       ClientTop       =   1770
       ClientWidth     =   6300
       ForeColor       =   &H00000000&
       KeyPreview      =   -1  'True
       LinkTopic       =   "Form2"
       MaxButton       =   0   'False
       MinButton       =   0   'False
       PaletteMode     =   1  'UseZOrder
       ScaleHeight     =   2535
       ScaleWidth      =   6300
       ShowInTaskbar   =   0   'False
    End
    Attribute VB_Name = "frmToolbar"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = FalseOption Explicit'Set values for imgButtons bitmap
    Private Const IMAGE_COLS = 15
    Private Const IMAGE_ROWS = 2
    Private Const STATE_UNSELECTED = 0
    Private Const STATE_SELECTED = 1Private m_ImageWidth As Long
    Private m_ImageHeight As Long
    Private m_xSpacer As Long
    Private m_ySpacer As Long'Indicates which tool is currently selected
    Private m_nCurrTool As Integer
    'Tracks parent form
    Private m_frmParent As Form'Windows API declarations
    Private Declare Function SetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
    Private Const SWW_HPARENT = -8
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Const HWND_TOPMOST = -1Private Const SWP_NOMOVE = 2
    Private Const SWP_NOSIZE = 1
    Private Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    Public Sub LoadToolbar(frm As Form)
      
        Set m_frmParent = frm
       
        Show     SetWindowWord hwnd, SWW_HPARENT, m_frmParent.hwnd
         
         SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS
         
         Me.Width = 1000
         Me.Height = 5000
         
    End Sub
    Public Sub UnloadToolbar()
        
        Unload Me
    End SubPrivate Sub Form_Load()
        Dim nWidth As Long, nHeight As Long    
        Width = nWidth + (Width - ScaleWidth)
        Height = nHeight + (Height - ScaleHeight)
        
        Left = g_xToolbarPos: Top = g_yToolbarPos
       
        g_bToolbarVisible = True
        
    End SubPrivate Sub Form_Unload(Cancel As Integer)
       
        g_xToolbarPos = Left: g_yToolbarPos = Top
        
        g_bToolbarVisible = False
        
        m_frmParent.SetFocus
        
    End Sub
    Module::Option ExplicitPublic g_xToolbarPos As Integer
    Public g_yToolbarPos As IntegerPublic g_bToolbarVisible As Boolean
      

  3.   

    用setparent代替SetWindowWord 是不是会更好一点
    SetWindowWord 是在16位的windows下的
    32为应该用setwindowlong
    对于setwindowlong 在msdn中有以下叙述
    You must not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window. Instead, use the SetParent function. 
      

  4.   

    win98下照样可用setwindowword,而且效果一样。
    不过在win2000中用不了,可能真的得用setparent了
      

  5.   

    wjying(葡萄) (2002-1-21 23:41:22) 
    setparent 就会出不去了!!!!!!!!!!!!!
      

  6.   

    代码作了伪装!
    什么意思?
    难道SetWindowWord 和setparent有区别?
    那要是在nt下怎么办,SetWindowWord 不能用了阿
      

  7.   

    to Bardo(巴顿)
    能具体说明一下吗