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...
Printable View
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...
yes it is possible.
look at this example that I wrote 100% programmatically
VB Code:
Public Module AppMain Sub Main() Application.Run(New MainForm) End Sub End Module Public Class MainForm Inherits Form 'Controls Private WithEvents ButtonA As Button Private WithEvents ButtonB As Button Private WithEvents TBox As TextBox 'Instantiation Sub New() 'Set form's properties With Me .FormBorderStyle = FormBorderStyle.FixedSingle .ClientSize = New Size(200, 170) .Text = "This form was drawn programically" .Font = New Font("Tahoma", 10, FontStyle.Regular, GraphicsUnit.Point) End With 'Controls ' ButtonA ButtonA = New Button With ButtonA .FlatStyle = FlatStyle.Popup .Text = "Button A" .Size = New Size(80, 20) .Location = New Point(5, 5) End With ' ButtonB ButtonB = New Button With ButtonB .FlatStyle = FlatStyle.Popup .Text = "Button B" .Size = New Size(80, 20) .Location = New Point(5, 5) End With ' TBox TBox = New TextBox With TBox .Multiline = True .ScrollBars = ScrollBars.Both .Text = "This is a multilined scrollable textbox" .BackColor = Color.WhiteSmoke .Size = New Size(165, 135) .Location = New Point(5, 30) End With 'Add controls With Me.Controls .Add(ButtonA) .Add(ButtonB) .Add(TBox) End With End Sub 'Example event handler Sub ClickedButtonA(ByVal Sndr As Object, ByVal EvArgs As EventArgs) Handles ButtonA.Click MessageBox.Show("You just clicked Button A!!", "Won the 99999$", MessageBoxButtons.OK) End Sub 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 :thumb: .
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).
Thank you for answers...
But, don't we program a game without including Forms by using VB.NET ?Quote:
A 'Windows application' can be a console application, or a Forms application (or service but anyway).
Good Working...
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?
now sample is a class, i can run it with a console coz of course it's a console. but thisVB Code:
imports system public class sample shared sub x(o as object) console.writeline(o.tostring()) end sub shared sub main() sample.x("hello world") end sub end class
can't run it coz it's not run as an application. as well as thisVB Code:
imports system imports system.windows.forms public class sample inherits form shared sub main() dim s as new sample() end sub end class
yah, it runs but does nothing at all. check thisVB Code:
imports system imports system.windows.forms public class sample inherits button shared sub main() dim s as new sample() end sub end class
application class has most shared methods receiving form. so this won't compileVB Code:
imports system imports system.windows.forms public class sample inherits form shared sub main() application.run(new sample()) end sub 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 butVB Code:
imports system imports system.windows.forms public class sample inherits button shared sub main() application.run(new sample()) end sub end class
it runs as an application what it is that running? i don't know. the app itself. just like thisVB Code:
imports system imports system.windows.forms public class sample inherits form shared sub main() dim f as new sample() f.show() application.run() end sub end class
buttons, textboxes are controls but form is a different thing. it's used in the application class.VB Code:
imports system imports system.windows.forms public class sample shared sub main() application.run() end sub end 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.
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.Quote:
Originally posted by kadirerdogan
Thank you for answers...
But, don't we program a game without including Forms by using VB.NET ?
Good Working...