|
When I want to use a function within the DLL how do I use it?
Usually I do:
Hi();
|
|
|
|
|
It's looking like you REALLY need to pick up a book on C#. The questions you've asked in this thread are all beginning concepts in programming, let alone C#.
GENERALLY, since you've imported the namespace your class sits in (the using statement at the top of the code), you can just create an instance of your class and call its Hi method:
MyClassName myClass = new MyClassName();
myClass.Hi();
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Two things:
1st:
Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications in which my employer require the code sit in a single .cs file. They don't want seperate .dlls or any other file except for files such as pictures. I am creating this program on my own to help me with a game I play.
2nd:
I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions.
Thanks for the help.
|
|
|
|
|
ExpertComing wrote: I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions.
You're thinking of the time when these were actually called "functions". In an OOP model, they're called "methods".
There are different access levels for methods. The example I showed you is one where an instance of the host class must be created before you can call the method on that instance. Static methods don't require and instace, but you stil have to specify the class that is hosting them. You can either directly specify the host class, like MyClassName.Hi(); , or, if you change the using statement to using MYClassNameDLL.MyClassName; , you can shorten the method call to Hi(); . While it's easier to type, it leaves the source of the method a bit vague and makes your code harder to read.
ExpertComing wrote: Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications
In what language? ASP.NET is just a web page generation technology. The concepts you're refering to are still very basic, Beginning C# - Week #1, concepts. I don't see how you could possible write an ASP.NET app in C# without knowing the things you're asking about already.
I'm not here to insult you or ridicule your abilities. I'm just give you some advice based on the skill level of your question. If you are just starting out in C#, then you're best, fastest, method of learning this stuff is going to be a book. You'll get these questions answered far faster in those pages that you could in any forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well, I would always have all my code in one class, it becomes a slight mess, but it was easy. I have 3 books, I'll read them, thanks for the help, and the advice. I was used to Visual Basic 5, before .NET. You are right about the functions verse methods thing, thanks.
|
|
|
|
|
Hi All.
I'm using visual studio 2005.
1.When i minimize my application i want that the icon will appear like troy icon (near to windows clock ) and not in the main task bar.
How i do it ??
2.I need to create 2 list in my application. In those list i need to add some string`s.
I don't know what control i need to use to do it . I want to do it in some way that in each list i will grid and each string will be write in grid line.
Thanks for help.
|
|
|
|
|
Answer to Question 1:
Search CodeProject for arcticles on tray or taskbar programs
Answer to Question 2:
Depending on what kind of data you are pulling you have two options:
Set amount of date(You know there are only or a max of 100 items):
Use an array
Undefined amount of data(1-Infinite):
Use a list
Hope that helps
|
|
|
|
|
1. Showing an icon in the system tray instead of the taskbar is really quite simple:
To do this, create a new notify icon object.
NotifyIcon icon;<br />
<br />
...<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
icon = new NotifyIcon();<br />
<br />
icon.Icon = this.Icon;<br />
<br />
icon.DoubleClick += new System.EventHandler(this.notifyIcon1_DoubleClick);<br />
<br />
icon.Visible = true;<br />
<br />
}<br />
<br />
private void button1_Click(object sender, EventArgs e)<br />
{ <br />
this.Hide(); <br />
}<br />
<br />
private void notifyIcon1_DoubleClick(object sender, EventArgs e)<br />
{<br />
this.Show();<br />
}
To not show the form in the taskbar simply set the ShowInTaskbar property of the form to false, and your set!
2. I'm not sure that I fully understand what you mean but based on what you've said a listview control comes to mind.
|
|
|
|
|
This is a fairly commonly asked question. I haven't done it in .NET 2.0, however, here's what I did using .NET 1.1. I'm assuming it probably hasn't changed much.
In your form class, override the WndProc method as follows:
protected override void WndProc(ref System.Windows.Forms.Message m)
{
if(m.Msg != 0x0010)
{
base.WndProc(ref m);
}
else
{
this.Hide();
}
}
As someone else mentioned you will need to use a NotifyIcon. The trick with that, though(at least in .NET 1.1) is that you have to assign an icon to the NotifyIcon that you create in the form designer. Otherwise it won't show up in the tray when you run it.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
I have a question
I dont know if anyone here is familiar with the zedgraph API but its pretty cool.
http://zedgraph.sourceforge.net/[^]
I am having issues here tho.
I want to create a live moving chart that updates in front of your eyes every single second.
Stock Market Chart -- candlestick, bar chart, etc.
When i start my program i draw the graph but i do not populate it with data yet.
I then made a button that when it is pressed it will get the data feed and start populating the
graph chart. Here is the problem!!!!
When the data comes in my app just freezes!!! (in the background it's just constantly reading in the data not drawing or updated the chart at all)
So then i said okay let me just use a small amount of data.
When i clicked the button with a small amount of data it did absolutely nothing.
But when i minimized my application down to the windows taskbar or toolbar
(or whatever its called)
and then maximized it (brought it back up and to focus) The chart was populated and everything looked great.
I guess my question is why did i have to minimize it and then maximize it to see the results of the drawing of bars on the graph.
And why cant i see my data update and draw right in front of my eyes!!!
Thanks in advance to anyone who can help me....
|
|
|
|
|
How and when are you painting?, show your method.
Are you calling your paint method on each pass?
Are you double buffering your graphics?
Are you looping through your data first, then painting or are you painting on every loop of data?
|
|
|
|
|
I believe you need to refresh your form/chart every time you want to update the chart. You said every second. I would try a timer and the tick event, refresh your form.
jude
|
|
|
|
|
Refreshing the form was exactly what i needed to do.
Thanks alot.
|
|
|
|
|
Happy I could help!
Happy Coding!
jude
|
|
|
|
|
I have written a Windows Service application in C# that works and is controlled by a separate C# tray application. The service queues up and processes a list of files from a specified directory. I would like to be able to get the current list on a regular basis using a timer from the tray application so I can report to the user the current processing status. I know that I can override the OnCustomCommand method in my service and call that through a servicecontroller on the tray app, however, this method returns void so I can't use it to get back the list currently being processed. Does anyone know if there is a simple way I can share data between the two applications?
Thanks.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
perlmunger wrote: The service queues up and processes a list of files
If the processing occurs at sufficiently large time intervals, perhaps the service could keep its last valid status in a file known to the tray app?
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Ravi,
Thanks for the suggestion. I've thought of that and will implement it if need be, however, I was hoping to avoid any IO (disk or otherwise). Even if I could just pass a long comma-delimited string between processes it would be nice. I don't need it to pass some complex data type.
Thanks again.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
OnCustomCommand is very limited. If you want more functionality you need to use IPC ( InterProcess Communication ). I suggest you have a look at remoting.
----------------------------
Be excellent to each other
|
|
|
|
|
I really dont know networking.
Why every LinkSYs router has such IP:
192.168.1.1.
I am confused, if router has this IP, how can an packet know where to go?
I know this must be a stupid question....Dont laught at me
|
|
|
|
|
This is not a C# question...
But I will supply you with an answer : the router usualy gets the IP addres 192.168.1.1. Why this addres? Maybe because this is an easy-to-remember addres. Anyway,I know thatthe addrescan be changed.
A packet travels through the internet with the help of gateways. A gateway routes the pachet to the requested destination.
This is exactly what a router does : it has 2 port types - LAN and WAN. It routes the pachets from the lan to the wan and viceversa, it acts like a gateway at a specified addres.
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
192.168.1.1 is the first IP address in a class C private network. Read this RFC for more information about private networks: http://www.ietf.org/rfc/rfc1918.txt[^]
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
LinkSys routers have 192.168.1.1 as an ipaddress because
LinkSys assumes you will be communicating on this already configured subnet.
Subnet address --> (192.168.1) Host --> .1
Note:
The .1 in the ipaddress represents the router, 192.168.1 represents the subnet.
I wont mention the subnet Mask, this only will confuse you further, you must first understand the basics.
For example if you are at home and use DSL or Cable for internet access.
You have a modem which connects to your LinkSys router. Your router actually has 2 IP addresses
69.254.36.244 or whatever for your external (public, internet, WAN) address and 192.168.1.1 for your internal (private, LAN) address.
If your router is configured as a DHCP server (The duty of passing out ipaddresses to anyone on your private network) Then every computer connected on your LAN or private network will receive an ipaddress on the 192.168.1 subnet from your router.
So whenever you connect your computer to your linksys router you will receive an ipadress between
192.168.1.2 - 192.168.1.254 - remember 192.168.1.1 is used for your router so u cant use that one.
Hope this helps
If a router has that particular ip (192.168.1.1) then how does it no where to send packets???
Easy!!!
The packet will either have an IP address on the subnet configured by your router (192.168.1)
or some other IP address not on your private Network!!!
If the packet has an ipaddress on the 192.168.1 network (subnet) it's communicating on the LAN so it will send the packet to another computer on the subnet.
If it has a weird 68.126.88.92 ip address on the packet then it will send the packet out to the external IP address - Then your packet will be in the hands of an ISP router.
Then that router looks to see if it has the direct destination of the packet on its network if it doesnt This router also has another ip address so it sends the packet away to another router and so on and so on until it finally reaches its destination!!!
-- modified at 18:13 Friday 10th February, 2006
|
|
|
|
|
OK, i'm building an application where a user will be required to enter customer data which will later be stored in a database.
As an example, the user may have to enter the customers email address into a text box.
Now obviously, there has to be some kind of validation between the data being entered in the UI and stored in the database not only to avoid sql injection but also to check the format etc.
My question is where the validation should occur?
Should there be an emailAddress object which performs such validation?
It doesn't seem the right approach to attach all the validation to the UI.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
You didn't specify whether this was a web app or a winforms app. The answer is different depending on that. In a web application, the answer is it should be done on both the UI *and* on the server side. This is because it is possible to circumvent form controls by writing automation scripts that ignore UI validation. You should be validating on both ends--on the client side to provide quick feedback to the user without a round-trip to the server, and on the back end in case something slipped past the client validation.
If, however, you are building a winforms application, it depends on how much detail you give to your design. Good multi-tier design might have you place validation in a business rule, however, there is virtually no danger that the user will hijack the request in a winforms app which means you could validate once on the control and not have to worry about getting bad data.
Anyhow, a google search will provide you with a lot of information on how to validate user data using C#.
-Matt
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Initially, the app will be winforms based with a view to adding a web based customer portal further into the project.
My reason for asking these questions now is an attempt to avoid hard coding potential problems into the design but I also have a desire to keep this as simple as possible.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|