tmwoods
tmwoods

Reputation: 2413

Can I use javascript to make the equivalent of Windows Form Applications?

I have used Visual Studio to make Windows forms applications using C# and VB but I would like to start learning another language, preferably javascript. Can I do this? I just downloaded Visual Studio 2012 Professional and the only option I can find is to make Windows 8 Apps.

Sorry if this is an obvious question with an obvious answer but I can't seem to find the answer anywhere. Also I'm interested if my line of thought (trying to use javascript to make windows desktop applications) is a dumb one so please chime in if it is.

Thanks!

I should point out I will be developing a UI that cannot be run from a browser necessarily; that is technicians will be using it in the field, far away from wifi.

Upvotes: 1

Views: 3931

Answers (5)

gilly3
gilly3

Reputation: 91497

Yes, you can write an HTML Application, which is web app that runs locally and with the same rights as any compiled application. These have been around since at least Windows 95 and are still supported in Windows 8.

To create an HTML Application, save your HTML file with an HTA extension. It will run just like any other web app, but without the security restrictions. For example, you will have access to the file system. Instead of running in a browser, it has its own window and icon, both of which are customizable via the <hta:application> tag:

<hta:application id="MyApp"
    icon="MyApp.ico"
    border="none"
    windowstate="maximize" />

Make sure to include an X-UA-Compatible meta tag, lest your code be run in IE7 mode:

<meta http-equiv="X-UA-Compatible" content="IE=9" />

For deployment, create an installer using your favorite method, or just zip up all files needed, and have users unzip to any directory on their computer and create shortcuts on the desktop or in the start menu as needed.

All the information you need to get started is in the documentation at MSDN.

JScript.Net is another option. This implementation (and extension) of JavaScript, allows you to actually write Windows Forms applications with JavaScript. Sadly, there's no IDE support that I know of. The last (and maybe only) version of Visual Studio to support JScript.Net was Visual Studio 2005. You would have to write the code without the help of an IDE and use the command line compiler.

Upvotes: 1

elclanrs
elclanrs

Reputation: 94101

This is the web world, you're not restricted to Windows forms, all you need is HTML, CSS, JavaScript and an embedded browser, like chromiumembedded (has .NET bindings) or App.js for Node which I think uses CEF as well.

There also many frameworks that provide UI elements, like jQuery UI, Extjs and many more.

Upvotes: 0

Fritz45
Fritz45

Reputation: 782

You can build JavaScript applications that "look like" a Windows application using Visual Studio. But you should realize that this application will almost certainly be a Web-Application that will have to be hosted on a server and will run in a Browser.

So my advice if you want to learn is to look into Web-applications using Visual Studio first to understand how the application is structured. Javascrip apps can be debugged and written in Visual Studio and if they are well designed they can look and feel just like a Windows application, but with many advantages, mainly that users do not need to install it on their computers.

Upvotes: 0

lzcd
lzcd

Reputation: 1353

Windows 8 supports desktop applications written in Javascript. Previous versions of Windows don't... at least not inherently.

I'd suggest, given that this is an introduction to Javascript... and that Windows 8 desktop apps work in a similar fashion to web pages, that you focus in on constructing regular web pages that contain Javascript.

This can be achieved by creating a plain old HTML file (with any editor ... including Visual Studio) and loading it up into a web browser.

Once you're across how Javascript works in a regular web settings, it should be easier to tackle everything from Windows 8 apps through to ChromiumEmbedded apps.

Upvotes: 3

dwerner
dwerner

Reputation: 6602

It's not dumb - JavaScript lends itself well to GUI programming. It's not WinForms, but there are bindings of node.js to QT, for example. https://github.com/arturadib/node-qt

Upvotes: 1

Related Questions