-
January 19th, 2008, 04:07 AM
#1
CreateWindowEx DestroyWindow
CreateWindowEx creates an overlapped, pop-up, or child window with an extended style.
DestroyWindow destroys the specified window. The function sends WM_DESTROY and WM_NCDESTROY messages to the window to deactivate it and remove the keyboard focus from it. The function also destroys the window’s menu, flushes the thread message queue, destroys timers, removes clipboard ownership, and breaks the clipboard viewer chain (if the window is at the top of the viewer chain).
Code:
Const WS_EX_TRANSPARENT As Int32 = 32
Const WS_EX_TOOLWINDOW As Int32 = 128
Const WS_EX_CONTEXTHELP As Int32 = 1024
Const WS_EX_STATICEDGE As Int32 = 131072
Const WS_EX_APPWINDOW As Int32 = 262144
Const WS_SYSMENU As Int32 = 524288
Const WS_BORDER As Int32 = 8388608
Const WS_CHILD As Int32 = 1073741824
Const WS_POPUPWINDOW As Int32 = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Const WS_POPUP As Int32 = -2147483648
Const CW_USEDEFAULT As Int32 = -2147483648
Const SW_NORMAL As Int32 = 1
Private Structure CREATESTRUCT
Public lpCreateParams, hInstance, hMenu, hWndParent, cy, cx, y, x, style As Int32, lpszName, lpszClass As String, ExStyle As Int32
End Structure
Private Declare Function apiCreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Int32, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Int32, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal hWndParent As Int32, ByVal hMenu As Int32, ByVal hInstance As Int32, ByRef lpParam As CREATESTRUCT) As Int32
Private Declare Function apiDestroyWindow Lib "user32" Alias "DestroyWindow" (ByVal hWnd As Int32) As Int32
Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hWnd As Int32, ByVal nCmdShow As Int32) As Int32
Private hWnd As Int32
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CS As New CREATESTRUCT
hWnd = apiCreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC", "New Window name", WS_CHILD, 10, 10, 200, 200, Me.Handle.ToInt32, 0, VB6.GetHInstance.ToInt32, CS) 'Create a new label
MessageBox.Show("Handle created: " & hWnd)
apiShowWindow(hWnd, SW_NORMAL) 'Show label
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
apiDestroyWindow(hWnd) 'Destroy label
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|