Hi all.
I'm here with a new trouble, as you can see on the title.
I apologize for posting on VB general discussion, i haven't found a better place, feel free to move this topic wheter this is not the appropriate section.
Anyway, i'm trying to create a button control with CreateWindowEx function
from user32.dll in order to avoid the .Net method (form1.controls.add.button ..).
This is my code:
the variable button has 0 as value, so i guess i've written something wrong in CreateWindowEx, or i haven't decleared it correctly.
May you help me? Thanks in advance
I'm here with a new trouble, as you can see on the title.
I apologize for posting on VB general discussion, i haven't found a better place, feel free to move this topic wheter this is not the appropriate section.
Anyway, i'm trying to create a button control with CreateWindowEx function
from user32.dll in order to avoid the .Net method (form1.controls.add.button ..).
This is my code:
VB.NET:
Public Class Form1
Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" ( _
ByVal dwExStyle As Long, _
ByVal lpClassName As String, _
ByVal lpWindowName As String, _
ByVal dwStyle As Long, _
ByVal x As Integer, _
ByVal y As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hWndParent As IntPtr, _
ByVal hMenu As Long, _
ByVal hInstance As Long, _
ByVal lpParam As Long _
) As IntPtr
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
Const BS_PUSHBUTTON = &H1&
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim hWnd As IntPtr = Me.Handle
Dim button As IntPtr
button = CreateWindowEx(0, "Button", "testo", WS_VISIBLE Or WS_CHILD Or BS_PUSHBUTTON, 0, 0, 60, 30, hWnd, 0, System.Runtime.InteropServices.Marshal.GetHINSTANCE(GetType(Form1).Module), 0)
End Sub
End Class
the variable button has 0 as value, so i guess i've written something wrong in CreateWindowEx, or i haven't decleared it correctly.
May you help me? Thanks in advance