473,558 Members | 2,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help-document view architecture in c#

Is this a good idea? From a brief dabble with MFC years ago, I
understand that this is a worthy goal.
Therefore I'm trying to remove most of the guts of an app from the main
form code to another class. This class starts the program with
Application.Run (new frmMain()) within its static void Main() method.

However, ..... how can I get frmMain to update the data held within
this data class? Pass events back to it? Contain a refernce to the
class and access its properties? I'd like to be able to send frmMain a
reference to the class when I isntantiate it within Application.Run (new
frmMain()) but becuase void main is declared statically, this isn't an
option.

Feeling a little lost now...!

Nov 29 '05 #1
6 2748
Greg,

Why isn't it an option? To me, it would seem like you just create a
constructor for your form which would take an instance of the data class.
You can create an instance of the data class before you call
Application.Run , and then do this:

Application.Run (new frmMain(dataCla ss));

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Greg" <gr************ *@yahoo.co.uk> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Is this a good idea? From a brief dabble with MFC years ago, I
understand that this is a worthy goal.
Therefore I'm trying to remove most of the guts of an app from the main
form code to another class. This class starts the program with
Application.Run (new frmMain()) within its static void Main() method.

However, ..... how can I get frmMain to update the data held within
this data class? Pass events back to it? Contain a refernce to the
class and access its properties? I'd like to be able to send frmMain a
reference to the class when I isntantiate it within Application.Run (new
frmMain()) but becuase void main is declared statically, this isn't an
option.

Feeling a little lost now...!

Nov 29 '05 #2
Thanks Nicolas
I'm pretty chuffed that you think it is an option - at least I'm not
barking up the wrong tree.

The problem is that I cant get the class ("clsApplicatio nData") to send
an instance of itself. the this keyword doesn't work since void main()
is static.

Nov 29 '05 #3
Greg,

Um, so why not just create it, like so?

// Create the instance of the application data:
clsApplicationD ata appData = new clsApplicationD ata();

// Run the program.
Application.Run (new frmMain(appData ));

Of course, this doesn't help if you want to have a universal instance.
In which case, you should expose a singleton of the app data, and then you
could do this:

// Get the singleton instance.
clsApplicationD ata appData = new clsApplicationD ata.Instance;

// Run the program.
Application.Run (new frmMain(appData ));

Or, you could just access the instance directly in your form.

I don't see what the problem is.

Also, you might want to re-consider your naming of the classes/forms.
The suggested public naming conventions indicate you should not prefix class
names with an indicator of the type (cls, frm).

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Greg" <gr************ *@yahoo.co.uk> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Thanks Nicolas
I'm pretty chuffed that you think it is an option - at least I'm not
barking up the wrong tree.

The problem is that I cant get the class ("clsApplicatio nData") to send
an instance of itself. the this keyword doesn't work since void main()
is static.

Nov 29 '05 #4
Thanks Nick.
Thanks also for the advice on naming conventions - I've just migrated
from VB so I haven't found my feet yet. For the purpose of this thread
though, I'll stick with what I've already used, to save confusion.

The issue is that it is an instance of clsApplicationD ata that
kickstarts the program. Therefore for your suggestion to work, this
would need to create a new instance of itself. That doesn't make sense,
does it? Maybe my form class should start the application and create an
instance of clsApplicationD ata. That would definitely solve the
problem, though it doesn't seem best practice to me - surely
clsAppplication Data should be running the whole show, not being created
by a class that is GUI related.

Nov 29 '05 #5
Greg,

If you have a Main method on clsAppplication Data, then in that Main
method, no instance is created.

I prefer the approach taken by the template for the windows forms
application in VS.NET 2005. Basically, there is a class in your project,
"Program" which has the entry point "Main", which creates the instance of
your form class (which is separate) and then calls the static Run method on
the Application class, passing the instance. It allows you easily place
whatever other code you need for startup somewhere that is separate from
your UI code (or any other code, for that matter).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Greg" <gr************ *@yahoo.co.uk> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Thanks Nick.
Thanks also for the advice on naming conventions - I've just migrated
from VB so I haven't found my feet yet. For the purpose of this thread
though, I'll stick with what I've already used, to save confusion.

The issue is that it is an instance of clsApplicationD ata that
kickstarts the program. Therefore for your suggestion to work, this
would need to create a new instance of itself. That doesn't make sense,
does it? Maybe my form class should start the application and create an
instance of clsApplicationD ata. That would definitely solve the
problem, though it doesn't seem best practice to me - surely
clsAppplication Data should be running the whole show, not being created
by a class that is GUI related.

Nov 29 '05 #6
Excellent. That appears to have worked.
within the Program class:
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^

static void Main()
{
Application.Run (new frmMain(new clsApplicationD ata()));
}
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^
I'll see how it behaves tomorrow, but from the logic it would appear
that frmMain will know all about clsApplicationD ata, which is what I've
been striving for!

Thanks a lot Nicholas, I really appreciate your help.

Greg.

Nov 29 '05 #7

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

Similar topics

21
6501
by: Dave | last post by:
After following Microsofts admonition to reformat my system before doing a final compilation of my app I got many warnings/errors upon compiling an rtf file created in word. I used the Help Workshop program: hcw.exe that's included with Visual Basic. This exact same file compiled perfectly with no notes, warnings or errors prior to...
9
4388
by: Tom | last post by:
A question for gui application programmers. . . I 've got some GUI programs, written in Python/wxPython, and I've got a help button and a help menu item. Also, I've got a compiled file made with the microsoft HTML workshop utility, lets call it c:\path\help.chm. My question is how do you launch it from the GUI? What logic do I put behind...
4
3333
by: Sarir Khamsi | last post by:
Is there a way to get help the way you get it from the Python interpreter (eg, 'help(dir)' gives help on the 'dir' command) in the module cmd.Cmd? I know how to add commands and help text to cmd.Cmd but I would also like to get the man-page-like help for classes and functions. Does anyone know how to do that? Thanks. Sarir
6
4312
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing result in any way. Who can help me, I thank you very very much. list.cpp(main program)...
3
3333
by: Colin J. Williams | last post by:
Python advertises some basic service: C:\Python24>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> With numarray, help gives unhelpful responses:
7
5349
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available from clicking on many of the available topics (mostly methods but some properties are also unavailable). This same problem occurs with many, if not...
5
3253
by: Steve | last post by:
I have written a help file (chm) for a DLL and referenced it using Help.ShowHelp My expectation is that a developer using my DLL would be able to access this help file during his development time using "F1" help within the VB IDE. Is this expectation achievable In trying to test my help file in the IDE, I have a solution with 2 projects:...
8
3209
by: Mark | last post by:
I have loaded Visual Studio .net on my home computer and my laptop, but my home computer has an abbreviated help screen not 2% of the help on my laptop. All the settings look the same on both including search the internet for help, but the help is worthless. Any ideas?
10
3341
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably the worst I ever seen. I almost cannot find anything I need, including things I
1
6115
by: trunxnirvana007 | last post by:
'UPGRADE_WARNING: Array has a new behavior. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"' 'UPGRADE_WARNING: Couldn't resolve default property of object Label. Click for more:...
0
7629
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7549
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8061
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...
1
7593
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...
0
6183
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...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2045
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
1
1164
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.