Results 1 to 3 of 3

Thread: Help creating an unmanaged Button!

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    Help creating an unmanaged Button!

    I need to subclass a openFileDialog control, get its hwnd(already did it), subclass it(will make it later) and then create buttons and the code.

    Any help creating a button in a form(for now)?
    I already managed to do this(C# Code):
    Code:
    [DllImport("User32.Dll", CharSet=CharSet.Auto)]
    public static extern void CreateWindowEx(int ExStyle, string className, string title, uint WSstyle, int x, int y, int width, int height, IntPtr parent, int menu, int instance, object extraParam);
    
    private void MyFunc() {
    IntPtr HINSTANCE = Microsoft.VisualBasic.Compatibility.VB6.Support.GetHInstance();
    
    CreateWindowEx(0, "BUTTON", "LOLS", 0x40000000, 0, 0, 100, 100, this.Handle, 0, HINSTANCE.ToInt32(), 0);
    }
    It isn't giving any error but it also doesnt show anything in my form.. any idea in what i'm doing wrong?
    \m/\m/

  2. #2

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    nevermind, i just forgot about the ShowWindow()
    \m/\m/

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ex .

    VB Code:
    1. Const WS_EX_STATICEDGE = &H20000
    2. Const WS_EX_TRANSPARENT = &H20&
    3. Const WS_CHILD = &H40000000
    4. Const CW_USEDEFAULT = &H80000000
    5. Const SW_NORMAL = 1
    6. Private Type CREATESTRUCT
    7.     lpCreateParams As Long
    8.     hInstance As Long
    9.     hMenu As Long
    10.     hWndParent As Long
    11.     cy As Long
    12.     cx As Long
    13.     y As Long
    14.     x As Long
    15.     style As Long
    16.     lpszName As String
    17.     lpszClass As String
    18.     ExStyle As Long
    19. End Type
    20. Private 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 Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
    21. Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    22. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    23. Dim mWnd As Long
    24. Private Sub Form_Load()
    25.     'KPD-Team 1999
    26.     'URL: [url]http://www.allapi.net/[/url]
    27.     'E-Mail: [email][email protected][/email]
    28.     Dim CS As CREATESTRUCT
    29.     'Create a new label
    30.     mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC", "Hello World !", WS_CHILD, 0, 0, 300, 50, Me.hwnd, 0, App.hInstance, CS)
    31.     Me.Caption = mWnd
    32.     'Show our label
    33.     ShowWindow mWnd, SW_NORMAL
    34. End Sub
    35. Private Sub Form_Unload(Cancel As Integer)
    36.     'destroy our label
    37.     DestroyWindow mWnd
    38. 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
  •  



Click Here to Expand Forum to Full Width