RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
vb.net判定窗口置顶,vb窗体置顶

VB窗口置顶。。。。。

API函数SetWindowPos

高港ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!

'这个函数能为窗口指定一个新位置和状态。它也可改变窗口在内部窗口列表中的位置。该函数与DeferWindowPos函数相似,只是它的作用是立即表现出来的(在vb里使用:针对vb窗体,如它们在win32下屏蔽或最小化,则需重设最顶部状态。如有必要,请用一个子类处理模块来重设最顶部状态)

Public

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

Long

'hwnd

-----------

Long,欲定位的窗口

'hWndInsertAfter

-

Long,窗口句柄。在窗口列表中,窗口hwnd会置于这个窗口句柄的后面。也可能选用下述值之一:

Public

Const

HWND_BOTTOM

=

1

'将窗口置于窗口列表底部

Public

Const

HWND_TOP

=

'将窗口置于Z序列的顶部;Z序列代表在分级结构中,窗口针对一个给定级别的窗口显示的顺序

Public

Const

HWND_TOPMOST

=

-1

'将窗口置于列表顶部,并位于任何最顶部窗口的前面

Public

Const

HWND_NOTOPMOST

=

-2

'将窗口置于列表顶部,并位于任何最顶部窗口的后面

'x

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

Long,窗口新的x坐标。如hwnd是一个子窗口,则x用父窗口的客户区坐标表示

'y

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

Long,窗口新的y坐标。如hwnd是一个子窗口,则y用父窗口的客户区坐标表示

'cx

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

Long,指定新的窗口宽度

'cy

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

Long,指定新的窗口高度

'wFlags

---------

Long,包含了旗标的一个整数

Public

Const

SWP_FRAMECHANGED

=

H20

'强迫一条WM_NCCALCSIZE消息进入窗口,即使窗口的大小没有改变

Public

Const

SWP_DRAWFRAME

=

SWP_FRAMECHANGED

'围绕窗口画一个框

Public

Const

SWP_HIDEWINDOW

=

H80

'隐藏窗口

Public

Const

SWP_NOACTIVATE

=

H10

'不激活窗口

Public

Const

SWP_NOMOVE

=

H2

'保持当前位置

(x和y设定将被忽略)

Public

Const

SWP_NOREDRAW

=

H8

'窗口不自动重画

Public

Const

SWP_NOSIZE

=

H1

'保持当前大小

(cx和cy会被忽略)

Public

Const

SWP_NOZORDER

=

H4

'保持窗口在列表的当前位置

(hWndInsertAfter将被忽略)

Public

Const

SWP_SHOWWINDOW

=

H40

'显示窗口

'用法示例

SetWindowPos

Form1.hwnd,

HWND_TOPMOST,

0,

0,

0,

0,

SWP_NOMOVE

Or

SWP_NOSIZE

VB.NET如何让弹出的窗体显示在所有的窗体的最前面(包括其他程序打开的窗体)

你可以这样做,设置窗体的TopMost 属性为真!

Me.TopMost = True

Form.TopMost 属性

获取或设置一个值,指示该窗体是否应显示为最顶层窗体。

急:vb.net设计的软件中,如何让主窗口置顶?

用SetWindowPos,参数TOP_MOST

就是直接设置窗口的TOPMOST属性也行啊,把默认的false改成true,自己在窗口的属性列表里找找吧

VB中怎么写。将窗口置顶的代码

用SetWindowPos函数,通用部分声明: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 Long

Private Const a = -1

Private Const b = H1

Private Const c = H2窗体部分:

Private Sub Form_Load()

SetWindowPos Me.hwnd, a, 0, 0, 0, 0, b Or c

End Sub这个是在窗体加载的时候置顶,SetWindowPos Me.hwnd, a, 0, 0, 0, 0, b Or c 是窗体置顶的实现代码如果你要按下按钮就实现指定可以把它添加到command1_click事件中即可

VB 窗口置顶

你说的是保持在最前面吧!你再说明白点!

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)

Private Sub Form_Load()

Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)

'其它代码

End Sub

将下面的代码复制到记事本中,并将其保持为Form1.frm

VERSION 5.00

Begin VB.Form Form1

BorderStyle = 0 'None

ClientHeight = 4695

ClientLeft = 0

ClientTop = 0

ClientWidth = 6975

LinkTopic = "Form1"

ScaleHeight = 4695

ScaleWidth = 6975

ShowInTaskbar = 0 'False

StartUpPosition = 3 '窗口缺省

Begin VB.Shape Shape3

BackColor = H000080FF

BackStyle = 1 'Opaque

BorderStyle = 0 'Transparent

Height = 855

Left = 3480

Shape = 3 'Circle

Top = 960

Width = 975

End

Begin VB.Shape Shape2

BackColor = H000080FF

BackStyle = 1 'Opaque

BorderStyle = 0 'Transparent

Height = 855

Left = 1560

Shape = 3 'Circle

Top = 960

Width = 975

End

Begin VB.Shape Shape1

BackColor = H000080FF

BackStyle = 1 'Opaque

BorderStyle = 0 'Transparent

Height = 1095

Left = 1920

Shape = 2 'Oval

Top = 1320

Width = 2055

End

End

Attribute VB_Name = "Form1"

Attribute VB_GlobalNameSpace = False

Attribute VB_Creatable = False

Attribute VB_PredeclaredId = True

Attribute VB_Exposed = False

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)

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Dim mouse_x As Single

Dim mouse_y As Single

Private Sub Form_Load()

Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)

Me.BackColor = HFF0000

Dim rtn As Long

BorderStyler = 0

rtn = GetWindowLong(hwnd, -20)

rtn = rtn Or H80000

SetWindowLong hwnd, -20, rtn

SetLayeredWindowAttributes hwnd, HFF0000, 0, H1

End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

mouse_x = 0

mouse_y = 0

If Button = 1 Then

mouse_x = X

mouse_y = Y

End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 Then

Form1.Left = Form1.Left + (X - mouse_x)

Form1.Top = Form1.Top + (Y - mouse_y)

End If

End Sub


本文题目:vb.net判定窗口置顶,vb窗体置顶
文章地址:http://lswzjz.com/article/dsijhoi.html