|
Thanks! Thought it would be something small like that. Works fine now
|
|
|
|
|
the StatusBar component is a little tricky. Does your StatusBar have panels? If so you should be addressing the panel to which you want the data to appear. For example, say you had statusBar1 and statusBarPanel1 defined in your app. Use statusBarPanel1.Text = "blah blah blah".
Good luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
I am trying to supply an hDC to a dll that needs a picture drawing area. I think i have 2 choices:
1. Use Form1 itself and just specify where the dll should draw the object.
2. Use a PictureBox1.
I do not understand the structures well enough to know if i can:
a. use the windowHandle of Form1 as an hDC.
--- Does the windowHandle qualify as an hDC? If not, how can i get a suitable hDC for Form1?
b. get the hDC of pictureBox1.
--- I need the hDC in an event-handler (a Form1 keypress event) that does not have access to an e argument that allows: hdc = e.Graphics.GetHdc(); .
All suggestions are welcome.
Thank you.
|
|
|
|
|
A window handle cannot be used as a hDC (device context).
If you want to get the hDC for any control or form, use something similar to this:
Graphics g = [this/pictureBox1].CreateGraphics();
g.GetHdc();
|
|
|
|
|
You'll need to give us more information about what you want and need to do before we can help. Your description is rather vague.
What re you using to create the line graph? What database engine are you proposing to use?. What is this 24 hour time contraint? etc...
Is this perhaps for an assignment, project, or real-world application?
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
my problem is how can i tracks a server's response times and records the results of all monitoring requests into its built-in database. using Historic monitoring data and can analyzed for uptime/down time reports and trend analysis.
need help... thanks in advance.
|
|
|
|
|
Don't reinvent the wheel if you don't need to. A Google search[^] for DB performance monitoring tools which use Windows Performance Monitor data shows that several are available.
If you really need to roll your own, then you'll need to research how to interect with the Perfomance Counters (just type in performance counters into the Code Project search bar at the top of the page for several articles on how to do this).
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
i am trying to get the ip address of host on windows application
thanks
openup your heart and let the sun shine in
|
|
|
|
|
Try these search terms in The Code Project search...
ip address of host
You will find plenty of hits. One of them is bound to do what you want or at the very least point you in the right direction.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
thanks for your reply Steve , i'll learn to fish
openup your heart and let the sun shine in
|
|
|
|
|
Pretty simple if you are programming with sockets.
If TCP, then you can refer to the IPEndPoint object after establising a connection OR accepting one.
If UDP, each message is self identifying so you can extract the Host IP from the header.
If you problem is not covered by Socket Programming, then let me know. Also there are about a zillion examples of TCP and UDP client between this site and if u google the net.
Good luck
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
thanks for your reply Mike,
i found this code
String strHostName = Dns.GetHostName();
// Find host by name
IPHostEntry iphostentry = Dns.GetHostByName(strHostName);
// Grab the first IP addresses
String IPStr = "";
foreach(IPAddress ipaddress in iphostentry.AddressList)
{
IPStr = ipaddress.ToString();
}
i am trying to do a chat program(socket programming it is my homework client send message to another client through the server) my time is over tomorrow ,unfortunately i couldnt fnish but i liked very much socket programming and i will search about, is there any article about socket programming you advise
openup your heart and let the sun shine in
|
|
|
|
|
If you are referring to the local PC as host you could use WMI to retrieve the IP address.
<br />
using System.Management<br />
<br />
public ArrayList ActiveIP()<br />
{<br />
ObjectQuery oq = new ObjectQuery("Select * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=true");<br />
ManagementObjectSearcher mos = new ManagementObjectSearcher(oq);<br />
ArrayList NA = new ArrayList();<br />
<br />
foreach(ManagementObject moInfo in mos.Get())<br />
{<br />
string[] IP = (string[])moInfo["IPAddress"];<br />
NA.Add(IP.GetValue(0).ToString());<br />
}<br />
<br />
return NA;<br />
}<br />
This will return all the IP address the PC has.
Hope this helps!
I reject your reality and substitute my own!
- Adam Savage, Mythbuster
-George W Bush
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
My definition of an expert in any field is a person who knows enough about what's really going on to be scared.
- PJ Plauger
|
|
|
|
|
thanks for your reply jklucker
openup your heart and let the sun shine in
|
|
|
|
|
thanks jklucker i have resolved the problem
openup your heart and let the sun shine in
|
|
|
|
|
I have an asp page where I load image in the webpage by browsing at run time. But there is a problem. I can load from any location from the computer instead i cannot load from the location desktop. If I choose the image from the destop it gives invalid parameter error. The following is the code:
string img = Upload.PostedFile.FileName.ToString();
lblimg.Text = img;
bmp = new Bitmap(img);
Deepak Anish
Computer Programmer
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
That is because you are loading the physical file instead of using the data that was uploaded. The user account that is used to run the ASP.NET code does not have access to your personal folders, so it can't access the file on your desktop.
Also, accessing the file directly of course only works in the special case when you are browsing to the page from the same computer that is acting as web server.
---
b { font-weight: normal; }
|
|
|
|
|
But the same problem occurs when i try it from different computer.
Deepak Anish
Computer Programmer
Maxumise Fiji Ltd
Suva, Fiji
|
|
|
|
|
Check your file paths etc as has already been suggested.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
No, when you try it from a different computer, it won't work at all, as I explained.
Use the uploaded data instead of trying to access the file directly.
---
b { font-weight: normal; }
|
|
|
|
|
This is a general question which I am looking to the experts for advice. My need is to be able to read/write, primarily read from Excel files.
I am comfortable using SQL, ODBC, DataSets, etc. Looking at the C# articles it seems you have two choices:
1) For direct access, use the Excel Object Library - (which incidentally, which DLL is this anyway?)
2) For SQL like access you can use Ole DB
I have started playing with the Ole DB solution. Decent way of getting it done, reasonably fast, but I wonder about the long term viability of using this approach? I would like to be able to simply define a custom DataSet that matches the rows/columns in the spreadsheet. Then using an Adapter.Fill() command to load. I am still experimenting.
So I am thinking about going the direct access via the Excel object library but I cannot determine what exe or dll to load and then refernce. I have scanned the MS site to no avail. Any advice here is definitely appreciated.
Thanks a bunch!
Mike Luster
CTI/IVR/Telephony SME
|
|
|
|
|
You really don't need to know what the dll name is to reference the Excel object. Just right mouse on references in the Solution Explorer and click on Add Reference. Click on the COM tab and choose the Microsoft Excell 11.0 Object Library and click on select.
Add the following to your form's constructor:
<br />
ExcelObj = new Excel.Application();<br />
<br />
if (ExcelObj == null)<br />
{<br />
MessageBox.Show("ERROR: EXCEL couldn't be started!");<br />
System.Windows.Forms.Application.Exit();<br />
}<br />
<br />
ExcelObj.Visible = false;<br />
Add, ExcelObj.Quit();, to the form's dispose method so Excel will shutdown when you application shut's down. If you don't do this then you flood your system Excel's in your task manager.
Here is the code you need to open an Excel workbook and display it's worksheet.
<br />
private void DispSheets(string FileName)<br />
{<br />
theWorkbook = ExcelObj.Workbooks.Open(<br />
FileName, 0, true, 5,<br />
"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,<br />
0, true, 0, 0);<br />
<br />
foreach (Excel.Worksheet WrkSht in theWorkbook.Worksheets)<br />
{<br />
this.lstWrkSheets.Items.Add(WrkSht.Name);<br />
} <br />
}<br />
You can use the next two methods to read data from an excel spreadsheet iinto a list box.
<br />
private void btnShowData_Click(object sender, System.EventArgs e)<br />
{<br />
int iFirst = 0;<br />
int iLines = 0;<br />
this.lstXLSData.Items.Clear();<br />
<br />
Excel.Sheets sheets = theWorkbook.Worksheets;<br />
<br />
Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(this.lstWrkSheets.SelectedIndex+1);<br />
<br />
iFirst = RowStart();<br />
<br />
iLines = 25;<br />
<br />
for (int i = iFirst; i <= iLines; i++)<br />
{ <br />
Excel.Range range = worksheet.get_Range(this.cmbStartCol.Text + i.ToString(),<br />
this.cmbEndCol.Text + i.ToString());<br />
System.Array myvalues = (System.Array)range.Cells.Value2;<br />
string[] strArray = ConvertToStringArray(myvalues);<br />
this.lstXLSData.Items.Add(new ListViewItem(strArray));<br />
}<br />
}<br />
private string[] ConvertToStringArray(System.Array values)<br />
{ <br />
string[] theArray = new string[values.Length];<br />
<br />
for (int i = 1; i <= values.Length; i++)<br />
{<br />
if (values.GetValue(1, i) == null)<br />
theArray[i-1] = "";<br />
else<br />
theArray[i-1] = (string)values.GetValue(1, i).ToString();<br />
}<br />
<br />
return theArray;<br />
}<br />
I hope this information helps you!
I reject your reality and substitute my own!
- Adam Savage, Mythbuster
-George W Bush
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
My definition of an expert in any field is a person who knows enough about what's really going on to be scared.
- PJ Plauger
|
|
|
|
|
Thanks for the example code. Using the Ole DB interface is alot more abstract so I like the idea of using the Excel object model. However when I try to add the reference I do not have the Microsoft Excel 11.0 Object Lbrary. That is why I was asking about the DLL. Do I need to download a SDK to the object library?
Mike
|
|
|
|
|
What version of MS Office do you have? This code was built using MS Office 2003. The file being reference is the actual Excel.exe of your installed Office product.
I reject your reality and substitute my own!
- Adam Savage, Mythbuster
- George W Bush
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
My definition of an expert in any field is a person who knows enough about what's really going on to be scared.
- PJ Plauger
|
|
|
|
|
Slight progress, I have Office Xp aka Office 2002 (10.6713.6735) SP3 for Excel. SO.. I found the Excel 10.0 Object Library under COM components. And when I try to "new" the excel object, i.e. a Excel.Application, it only has Excel.ApplicationClass. Not exactly what I need, so I am wondering if I have to upgrade to the later version of Office (2003)?
Mike
|
|
|
|