|
-
Jul 23rd, 2004, 07:25 AM
#1
Thread Starter
New Member
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...
-
Jul 23rd, 2004, 11:42 AM
#2
Lively Member
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 .
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? ? ? ! ! !
-
Jul 23rd, 2004, 11:50 AM
#3
I wonder how many charact
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).
-
Jul 24th, 2004, 02:09 AM
#4
Thread Starter
New Member
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...
-
Jul 24th, 2004, 02:20 AM
#5
Thread Starter
New Member
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?
-
Jul 24th, 2004, 03:45 AM
#6
Fanatic Member
VB 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
now sample is a class, i can run it with a console coz of course it's a console. but this
VB Code:
imports system
imports system.windows.forms
public class sample
inherits form
shared sub main()
dim s as new sample()
end sub
end class
can't run it coz it's not run as an application. as well as this
VB Code:
imports system
imports system.windows.forms
public class sample
inherits button
shared sub main()
dim s as new sample()
end sub
end class
yah, it runs but does nothing at all. check this
VB Code:
imports system
imports system.windows.forms
public class sample
inherits form
shared sub main()
application.run(new sample())
end sub
end class
application class has most shared methods receiving form. so this won't compile
VB Code:
imports system
imports system.windows.forms
public class sample
inherits button
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 but
VB 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
it runs as an application what it is that running? i don't know. the app itself. just like this
VB Code:
imports system
imports system.windows.forms
public class sample
shared sub main()
application.run()
end sub
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.
-
Jul 24th, 2004, 02:52 PM
#7
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|