Results 1 to 5 of 5

Thread: Create Formless Form...

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Exclamation

    I'm writing a program that will run on Windows 95 and up without an install package.
    It will run off of a floppy to collect system info and user info.
    I need command buttons, labels, and text box.
    I've created a form in a module with CreateWindowEx but can someone point me to the correct api's for
    creating the labels, buttons, and text box?
    Last edited by RobDog888; Apr 16th, 2001 at 01:07 AM.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Button -- class "BUTTON"
    Text Box -- class "EDIT"
    Label -- class "STATIC"

    Check the Platform SDK for the exact details on the extra window styles for each of these classes.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Megatron
    Guest
    Code:
    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
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Const WS_CHILD = &H40000000
    Private Const WS_VISIBLE = &H10000000
    Private Const WS_EX_CLIENTEDGE = &H200&
    Private hWndBtn As Long
    Private hWndEdit As Long
    Private hWndLabel As LongPrivate Sub Form_Load()
        
        
    ' Now add this code to the create them. Usually you
    ' would do this when the WM_CREATE message is 
    ' triggered
        hWndBtn = CreateWindowEx(0, "Button", "MyButton", WS_CHILD Or WS_VISIBLE, 32, 32, 64, 64, hwnd, 0, App.hInstance, 0)
        hWndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "MyEdit", WS_CHILD Or WS_VISIBLE, 200, 10, 100, 100, hwnd, 0, App.hInstance, 0)
        hWndBtn = CreateWindowEx(WS_EX_CLIENTEDGE, "Static", "MyLabel", WS_CHILD Or WS_VISIBLE, 10, 100, 100, 40, hwnd, 0, App.hInstance, 0)

  4. #4

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Cool

    Thanks for the code, but what else will I need to capture the button click and shell out a exe, and capture the info from the textbox?
    By the way, if there is no standard form, just the one created by the api call, is there still the Form_Load event in your code you posted?

  5. #5
    Megatron
    Guest
    Well, I assume you have your "Formless window" already made and the code as well. For this, you must also have a WindowProc function, which is specified in the lpfnWndProc variable of the WNDCLASEX structure.

    To capture the click of a button, you need to handle the WM_COMMAND message. If the handle (stored in the lParam argument) is the same as the button, then it was clicked. Here is a small example:
    Code:
    Public Function WindProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
        If wMsg = WM_COMMAND Then
            If lParam = hWnd_Btn Then MsgBox "Button was clicked!"
        End If
      
        WindProc = CallWindowProc(WndProcOld&, hwnd&, wMsg&, wParam&, lParam&)
        
    End Function

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