473,789 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Non interactive "form"?

Hi all,

Is there a "standard" way to structure a small windows form such that it can
run non-interactively with an appropriate command line switch?

E.g, if I run the form normally I get the form's UI, but if I run it with /q
(or whatever), it runs non-interactively (perhaps logging to the event log).
I did try parsing the command line in Main(), but of course Main is static
and it's not possible therefore to use some field or method elsewhere in the
form based on what happens in Main(). I also tried parsing the command line
in the form's constructor but I noticed that once the code has got this far,
the form appears even if I skip InitializeCompo nent().

I guess that there's a standard way to do this?

TIA
Mark
Nov 15 '05 #1
2 1777
Mark <ma**@ReMoVeThI sBiTmossywell.c om> wrote:
Is there a "standard" way to structure a small windows form such that it can
run non-interactively with an appropriate command line switch?

E.g, if I run the form normally I get the form's UI, but if I run it with /q
(or whatever), it runs non-interactively (perhaps logging to the event log).
I did try parsing the command line in Main(), but of course Main is static
and it's not possible therefore to use some field or method elsewhere in the
form based on what happens in Main(). I also tried parsing the command line
in the form's constructor but I noticed that once the code has got this far,
the form appears even if I skip InitializeCompo nent().

I guess that there's a standard way to do this?

Keep all your business logic (or whatever) separate from your GUI code.
If you get an appropriate command line, run the code non-interactively,
otherwise start up the GUI which controls the business logic. Sort of:

Main method
/ \
/ \
GUI Non-GUI
\ /
\ /
Core logic

That suggests (to me, at least) that your form shouldn't be the class
containing the Main method - it might even be a separate class on its
own, solely for startup purposes.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
[snip]


Keep all your business logic (or whatever) separate from your GUI code.
If you get an appropriate command line, run the code non-interactively,
otherwise start up the GUI which controls the business logic. Sort of:

Main method
/ \
/ \
GUI Non-GUI
\ /
\ /
Core logic

That suggests (to me, at least) that your form shouldn't be the class
containing the Main method - it might even be a separate class on its
own, solely for startup purposes.


Ah! Yes, this makes sense. In fact the non-gui code _is_ the core logic, so
what I have is:

Main method
/ \
Gui |
| |
\ /
Core logic

So, as you say, I've simply created a separate class for each of the three
sections above and it works a treat. Thanks very much for your help.

Mark
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17770
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? Thanks, John
3
4227
by: Hodad | last post by:
I would like to adapt, as much as possible, the appearance and color red of the font in this button: <P><CENTER><BUTTON VALUE="SUBMIT"><A HREF="http://www.familytreedna.com/surname_join.asp?code=Q17978" STYLE="TEXT-DECORATION: NONE;"> <FONT COLOR="RED" FACE="COPPERPLATE GOTHIC BOLD">Right Here</FONT></A></BUTTON></CENTER></P>
3
2708
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their "name" property (which sources from "name" HTML attribue). The problem is, that if the form contains form control named "name", it overwrites the form name property. In fact, I'm quite surprised that it's so easy to spoil any of the form object...
11
4178
by: Pete Wilson | last post by:
Hi folks -- The page at http://www.pwilson.net/submit-demo.html will not validate. The validator at http://validator.w3.org tells me I can't have an input inside a form. Would some kind soul please tell me what I'm doing wrong?
9
21496
by: Dan | last post by:
I am trying to use Request.Form("__EVENTTARGET") to get the name of the control that caused a post back. It keeps returning "". I am not really sure why, this happens for all of my controls that invoke are invoking a post back. I've never used this type of method before, but I need to get the name of the control doing the postback in the Form Load event, and cannot wait until the event of the target control that runs due to the...
1
5232
by: kbarrios | last post by:
Hi, I am working with VBScript and I put a "window.open" inside a "form action post" due that I am handing a "checkbox" on it, but the "window.open" doesn't work: <FORM ACTION="baz_add_action.asp" METHOD="post"> ...here go the Window.open script <INPUT NAME="add<%=p_prod_id%>" TYPE="checkbox" value="ON">
6
2434
by: KiwiGenie | last post by:
Hi..I am trying to make a search form. I am fairly new to access and could well be looking at it completely wrong. I have an unbound form with textboxes in the header for entering different search criteria. I have a subform for displaying the results, which is bound to Query4. SQL for Query4 (taken from sql view in query): SELECT tblRecipes.RecipeName, tblRecipes.FoodCategory, Sum(Query3.IngredCost) AS SumOfIngredCost, Query3.RecipeID FROM...
38
3314
by: Sanders Kaufman | last post by:
I'm converting my table-based layouts to css-positioned divs - but the ONLY reason I'm doing it is because it's *considered* a best practice. I don't really see where anything goes hinky when tables are used - but I'm doing it anyway because the HTML and CSS specs says to reserve tables for tabular data. So as I convert my login widgit to a css thing, I'm saying to myself - hey, this form is most certainly "tabular data" - even if it...
3
1921
by: eBob.com | last post by:
How does a "sub-form", i.e. one invoked by another form, determine anything about the form which brought it into existence, i.e., I suppose, instantiated it? I wanted to so something like this ... MsgBox("called by " & Owner.Name) .... but that throws a null reference exception. Parent.Name and ParentForm.Name also throw null reference exceptions. Form1.Name works - but that's not very flexible.
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3700
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.