JBTALKS.CC

标题: [VB]有没有方法可以吧MDICLIENT的SCROLLBAR关掉? [打印本页]

作者: goodhermit95    时间: 2009-11-7 09:39 PM
标题: [VB]有没有方法可以吧MDICLIENT的SCROLLBAR关掉?
如题,我不要吧scrollbar藏起来罢了,我要form不会飞出范围
GOOGLE找了一大堆不是看不懂就是不是我要的
作者: goodday    时间: 2009-11-7 09:58 PM
有难度 , 没做过
帮你找找
作者: TSHsoft    时间: 2009-11-7 10:35 PM
例如?有什么软件是这样的吗?可以发个截图看看吗?
作者: goodhermit95    时间: 2009-11-8 10:11 AM
标题: 回复 #3 TSHsoft 的帖子
我是要form不会跑出去就在那个范围而已

如果只是要藏起来就很简单
dim c as control
for each c in me.controls
if typeof c is mdiclient then
c.dock = none
c.location = new point(-2,-2) '把3d border 藏起来不然很怪
c.height += 10
c.width += 10
'如果有其它东西如menustrip或statusstrip就要改变
end if
next
作者: TSHsoft    时间: 2009-11-8 10:33 AM
正常是mdiclient移动超过mdiparent范围的时候,mdiparent就自动会有scrollbar出现,所以你不要让scrollbar出现也不要让mdiclient超过mdiparent的范围咯~ 是吗?

不好意思,我很少用vb2008。呵呵!em0013
作者: goodday    时间: 2009-11-8 12:58 PM
就是咯

你找到什么link paste 上来
我去看看
我的 语言能力 还复杂的 因该可以消化吧
作者: goodhermit95    时间: 2009-11-8 01:58 PM

  1. Public Class Form1

  2.     Dim mdiClient As MdiClient = Nothing
  3.     Dim SB_BOTH As Integer = 3

  4.     <DllImport("user32.dll")> _
  5.     Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
  6.     End Function

  7.     Protected Overrides Sub WndProc(ByRef m As Message)
  8.         If mdiClient IsNot Nothing Then
  9.             ShowScrollBar(mdiClient.Handle, SB_BOTH, 0)
  10.         End If

  11.         MyBase.WndProc(m)
  12.     End Sub

  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

  14.         For Each c As Control In Me.Controls
  15.             If TypeOf c Is MdiClient Then
  16.                 mdiClient = c
  17.             End If
  18.         Next

  19.         Dim fm As Form = New Form2
  20.         fm.MdiParent = Me
  21.         fm.Show()

  22.     End Sub
  23. End Class
复制代码

  1. <DllImport("user32.dll")> _
  2.     Private Shared Function ShowScrollBar(ByVal hWnd As IntPtr, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
  3.     End Function

  4.     Protected Overrides Sub WndProc(ByRef m As Message)
  5.         If mdiClient IsNot Nothing Then
  6.             ShowScrollBar(mdiClient.Handle, SB_BOTH, 0)
  7.         End If

  8.         MyBase.WndProc(m)
复制代码

  1. private const int SB_BOTH = 3;

  2. private const int WM_NCCALCSIZE = 0x83;

  3. [System.Runtime.InteropServices.DllImport("user32.dll")]

  4. private static extern int ShowScrollBar(IntPtr hWnd, int wBar, int bShow);

  5. protected override void WndProc(ref Message m)
  6. {

  7. if (mdiClient != null)
  8. {

  9. ShowScrollBar(mdiClient.Handle, SB_BOTH, 0);
  10. }

  11. base.WndProc(ref m);
  12. }

  13. MdiClient mdiClient = null;

  14. private void FormMain_Load(object sender, EventArgs e)
  15. {
  16. foreach (Control c in this.Controls)
  17. {
  18. if (c is MdiClient)
  19. {
  20. mdiClient = c as MdiClient;
  21. }
  22. }
  23. }
复制代码

作者: goodday    时间: 2009-11-8 08:01 PM
http://www.codeproject.com/KB/cs ... .aspx?display=Print

你要的

作者: goodhermit95    时间: 2009-11-9 09:36 AM
标题: 回复 #8 goodday 的帖子
简单了,直接加一个参考就可以了
然后用ILMERGE就搞定




欢迎光临 JBTALKS.CC (https://jbtalks.my/) Powered by Discuz! X2.5