Results 1 to 7 of 7

Thread: Programming Windows Application without using Windows Forms.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    3

    Programming Windows Application without using Windows Forms.

    Hi,

    Is it Possible that programming Windows Application without using Windows Forms.

    Maybe We can draw a control with GDI+ but how events and properties should it be used?

    Good Working...

  2. #2
    Lively Member TLord's Avatar
    Join Date
    Jun 2004
    Posts
    95
    yes it is possible.

    look at this example that I wrote 100% programmatically
    VB Code:
    1. Public Module AppMain
    2.     Sub Main()
    3.         Application.Run(New MainForm)
    4.     End Sub
    5. End Module
    6.  
    7. Public Class MainForm
    8.     Inherits Form
    9.     'Controls
    10.     Private WithEvents ButtonA As Button
    11.     Private WithEvents ButtonB As Button
    12.     Private WithEvents TBox As TextBox
    13.     'Instantiation
    14.     Sub New()
    15.         'Set form's properties
    16.         With Me
    17.             .FormBorderStyle = FormBorderStyle.FixedSingle
    18.             .ClientSize = New Size(200, 170)
    19.             .Text = "This form was drawn programically"
    20.             .Font = New Font("Tahoma", 10, FontStyle.Regular, GraphicsUnit.Point)
    21.         End With
    22.         'Controls
    23.         '   ButtonA
    24.         ButtonA = New Button
    25.         With ButtonA
    26.             .FlatStyle = FlatStyle.Popup
    27.             .Text = "Button A"
    28.             .Size = New Size(80, 20)
    29.             .Location = New Point(5, 5)
    30.         End With
    31.         '   ButtonB
    32.         ButtonB = New Button
    33.         With ButtonB
    34.             .FlatStyle = FlatStyle.Popup
    35.             .Text = "Button B"
    36.             .Size = New Size(80, 20)
    37.             .Location = New Point(5, 5)
    38.         End With
    39.         '   TBox
    40.         TBox = New TextBox
    41.         With TBox
    42.             .Multiline = True
    43.             .ScrollBars = ScrollBars.Both
    44.             .Text = "This is a multilined scrollable textbox"
    45.             .BackColor = Color.WhiteSmoke
    46.             .Size = New Size(165, 135)
    47.             .Location = New Point(5, 30)
    48.         End With
    49.         'Add controls
    50.         With Me.Controls
    51.             .Add(ButtonA)
    52.             .Add(ButtonB)
    53.             .Add(TBox)
    54.         End With
    55.     End Sub
    56.     'Example event handler
    57.     Sub ClickedButtonA(ByVal Sndr As Object, ByVal EvArgs As EventArgs) Handles ButtonA.Click
    58.         MessageBox.Show("You just clicked Button A!!", "Won the 99999$", MessageBoxButtons.OK)
    59.     End Sub
    60. End Class

    as you see it's very simple and easy, all you have to do is just to initialize the controls on the form's instantiation.

    Here I included also how you can play with the properties of the controls as normal after initializing them .
    Last edited by TLord; Jul 24th, 2004 at 02:45 PM.
    Do you think my life is easy?
    Do you think it's good to win?
    do you think it's nice to kill?
    Do you think learning is a must?
    Do you think computers are nothing?
    Do you think this post is stupid?
    Do ypu think we're really humen?

    DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    A 'Windows application' can be a console application, or a Forms application (or service but anyway).

    If you are asking to make an application without using Forms, then create a console project.

    TLord's example would still require a reference to the Windows.Forms library, because the code obviously inherits the Form class from it.

    If what you are asking is how to draw graphics to the screen without including the Forms library, I haven't the foggiest clue if that's possible without DirectX or calls to Win32 GDI (unmanaged).

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    3
    Thank you for answers...

    A 'Windows application' can be a console application, or a Forms application (or service but anyway).
    But, don't we program a game without including Forms by using VB.NET ?

    Good Working...

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    3
    I think that Form is a Object, namely a Class, and no different from Textbox or Button (both of them class) for Object Oriented Programming. As We can program without using Textbox or Button, we can program without using Form Control.

    I am wrong?

  6. #6
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    VB Code:
    1. imports system
    2. public class sample
    3.    shared sub x(o as object)
    4.       console.writeline(o.tostring())
    5.    end sub
    6.    shared sub main()
    7.       sample.x("hello world")
    8.    end sub
    9. end class
    now sample is a class, i can run it with a console coz of course it's a console. but this
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    inherits form
    5.    shared sub main()
    6.       dim s as new sample()
    7.    end sub
    8. end class
    can't run it coz it's not run as an application. as well as this
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    inherits button
    5.    shared sub main()
    6.       dim s as new sample()
    7.    end sub
    8. end class
    yah, it runs but does nothing at all. check this
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    inherits form
    5.    shared sub main()
    6.       application.run(new sample())
    7.    end sub
    8. end class
    application class has most shared methods receiving form. so this won't compile
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    inherits button
    5.    shared sub main()
    6.       application.run(new sample())
    7.    end sub
    8. end class
    they are all control alright but they have differences. as with coding without form, i don't know unmanaged so i can't post example. perhaps someone can do that and post it here hopefully. main is the entry point though, every code has to have one main for the program to know where to start but
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    inherits form
    5.    shared sub main()
    6.       dim f as new sample()
    7.       f.show()
    8.       application.run()
    9.    end sub
    10. end class
    it runs as an application what it is that running? i don't know. the app itself. just like this
    VB Code:
    1. imports system
    2. imports system.windows.forms
    3. public class sample
    4.    shared sub main()
    5.       application.run()
    6.    end sub
    7. end class
    buttons, textboxes are controls but form is a different thing. it's used in the application class.

    sooo... i don't know how to run button that floats. just like... i don't know how to build a house with a floating roof without a base foundation. perhaps in the near future - anti-gravity tech.

  7. #7
    Lively Member TLord's Avatar
    Join Date
    Jun 2004
    Posts
    95
    Originally posted by kadirerdogan
    Thank you for answers...



    But, don't we program a game without including Forms by using VB.NET ?

    Good Working...
    I don't use visual baisc for game programming, actually I know 6 languages else than VB.Net, and I think that when you want to program a game you should cut sides to C++ or C# because as I have readen VB.Net is ideal only for simple games like Tetris or snake-like. For now I'm learning C# for graphics-based reasons like 3D with DirectX, but I wrote very good and powerfull VB.Net programs so far.
    Do you think my life is easy?
    Do you think it's good to win?
    do you think it's nice to kill?
    Do you think learning is a must?
    Do you think computers are nothing?
    Do you think this post is stupid?
    Do ypu think we're really humen?

    DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !

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