|
it's written thats its only supported in windows 2003..
how do you do this in XP ?
|
|
|
|
|
Ooops, I've used the wrong link for the right class .
The class is, in fact, Win32_LogicalDisk and not Win32_Volume.
Win32_LogicalDisk should work on all systems.
Here's the correct link: Win32_LogicalDisk[^]
mav
|
|
|
|
|
Hi,
Suppose i have a list of all active applications in my system and every
application is a window using GetWindow() from the API. I can get their handles, the tittle af the applications, get the All children of any window of this application.I mean.. if this window is open, I'd get the handel of Address bare(because we can regard it children), and access to the content that is " www.msn.com ".
Now i want to Know how i can to do all this task by classes in C#
your help is greatly appreciated
|
|
|
|
|
So, you want to get the the handle to a window and all it's chrildren?
If so, there is a really good example on www.pinvoke.net, look up FindWindow and then FindWindowEx.
/\ |_ E X E GG
|
|
|
|
|
I'm working on a simple app for sending text messages through SMS.ac, but I need to know how to do a HTTP POST request, or more specifically, how to add the data to the request. It's encoding type is "multipart/form-data" all I need to add (I think) is the phone number and the message. Check it out at http://sms.ac/
So what would I need to do to get the correct data in the request?
|
|
|
|
|
Look into the Method property of the WebRequest class.
Somehting like this WebRequest.Method="POST";
/\ |_ E X E GG
|
|
|
|
|
I've made this code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://sms.ac/login.asp");<br />
request.Method = "POST";<br />
Stream reqStream = request.GetRequestStream();<br />
<br />
byte[] buffer = Chars2Bytes(("loginuserid=<removed>&loginpassword=<removed>").ToCharArray());<br />
reqStream.Write(buffer, buffer.Length, 0);<br />
<br />
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
But it keeps getting timeout when I get the response...the page exists, and if the data is wrong it sohuld return something since it's running on a .NET server so any errors would still get returned wouldn't they?
Tell me if I'm doing anything stupid
|
|
|
|
|
|
|
Hi there,
I am developing a C# application in which I would like to generate buttons/textboxes or whatever controls dynamically at runtime,The number of the controls to be generated will be determined in runtime..Do anyone have any idea can I do this..How can I generate them and then further access them to manipulate them???
Pleaaaaaaaaaaaaaaaaaaaaaaase HEEEEEEEEEEEEEEEEEEEEEEEEEEELP
Best Regards,
E.A.
|
|
|
|
|
I created the below code in VB.NET a while back. It will create as many textboxes as specified in 'mintLenCode' I used the "VB.Net to C# Converstion" program from www.vbconversions.com to do a quick port to C# (getting a lazy). Mind you I'm a newbie, so take it as it is. There might be a better way.
private void CreateTextBoxes ()
{
//Declare variables for textbox properties
System.Drawing.Font Font = new System.Drawing.Font("Comic Sans MS", (float) (26.25), System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
int counter = 0;
int locationX = 16;
//Size array based on length of mlng_CODE
TxtBox = new TextBox[mintLenCode + 1];
//Create TextBoxes and set properties
do
{
counter = counter + 1;
TxtBox[counter] = new TextBox();
TxtBox[counter].Anchor = AnchorStyles.None;
TxtBox[counter].Font = Font;
TxtBox[counter].Location = new System.Drawing.Point(locationX, 152);
TxtBox[counter].MaxLength = 1;
TxtBox[counter].Size = new System.Drawing.Size(36, 56);
TxtBox[counter].TabIndex = counter;
TxtBox[counter].TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
TxtBox[counter].Name = System.Convert.ToString(counter);
locationX = locationX + TxtBox[counter].Width;
TxtBox[counter].KeyUp += new System.Windows.Forms.KeyEventHandler (txtbox_KeyUp);
this.Controls.Add(TxtBox[counter]);
} while (!(counter == mintLenCode));
}
www.lovethosetrains.com
|
|
|
|
|
Hi there,
Thanks alot for your help..But the problem now is that ,when I create buttons whose location are outside the form size, I can see them..what would be the solution to that???
I don't want to resize the windows form as its size can exceed my monitor size,but I would rather prefer a scroll bar..
Any Idea how can I solve that??
Best Regards,
E.A.
|
|
|
|
|
Hi,
I've a datagrid connected to one table from postgres database. I'm using ODBC. Also, table has only 3 columns, out of which I'm using only 2 columns, and I'mve added these columns to datagrid manually.
Now, when I try to edit ot even try to add new row after postback it doesnt seem to work! The form doesnt do anything.
There is another form where I'm creating and populating (basically handling everything at runtime) and there the same piece of code is working just fine!
Here is the code of the form that is not working...
<--CODE-ASPX-START-->
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 38px; POSITION: absolute; TOP: 17px" runat="server" autogeneratecolumns="False" bordercolor="Silver" borderwidth="1px">
<columns>
<asp:buttoncolumn text="Add" buttontype="PushButton" headertext="New" commandname="AddNewRow">
<asp:editcommandcolumn buttontype="PushButton" updatetext="Update" headertext="Change" canceltext="Cancel" edittext="Edit">
<asp:boundcolumn datafield="url_name" headertext="Url Name">
<asp:boundcolumn datafield="url_comments" headertext="Comments">
<asp:linkbutton id="LinkButton2" style="Z-INDEX: 106; LEFT: 208px; POSITION: absolute; TOP: 312px" runat="server" forecolor="Black" font-names="Verdana" font-size="10pt">Make Changes
<asp:linkbutton id="LinkButton1" runat="server" style="Z-INDEX: 107; LEFT: 100px; POSITION: absolute; TOP: 311px" forecolor="Black" font-names="Verdana" font-size="10pt">Add New
<--CODE-ASPX-END-->
<--CODE-ASPX.CS-START-->
private void Page_Load(object sender, System.EventArgs e)
{
string connectionStr = "DRIVER={PostgreSQL}; SERVER=localhost;UID=xxx;PASSWORD=xxx;Trusted_connection=false;DATABASE=marketing;";
string str = "select pk_url,url_name,url_comments FROM urls;";
connection = new OdbcConnection(connectionStr);
connection.Open();
selectCommand = new OdbcCommand(str,connection);
adapter = new OdbcDataAdapter(selectCommand);
ds = new DataSet();
adapter.Fill(ds,"urls");
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "urls";
DataGrid1.DataBind();
connection.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.LinkButton2.Click += new System.EventHandler(this.LinkButton2_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
Response.Write("Am I Editing!!!");
Response.Write(" e.item.itemindex: "+e.Item.ItemIndex);
DataGrid1.EditItemIndex = e.Item.ItemIndex;
DataGrid1.DataBind();
}
private void AddNewRow()
{
DataRow dr = ds.Tables[0].NewRow();
int loc = ds.Tables["urls"].Rows.Count;
ds.Tables["urls"].Rows.InsertAt(dr,loc);
ds.AcceptChanges();
DataGrid1.DataBind();
DataGrid1.EditItemIndex = loc;
}
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.DataGrid1.SelectedItem.Attributes["onmouseover"] = "this.style.cursor='hand'";
this.DataGrid1.SelectedItem.Attributes.Remove("onmouseout");
if(this.DataGrid1.EditItemIndex >= 0)
{
this.DataGrid1.EditItemIndex = -1;
this.DataGrid1.DataBind();
}
}
private void LinkButton2_Click(object sender, System.EventArgs e)
{
this.DataGrid1.EditItemIndex = this.DataGrid1.SelectedIndex;
this.DataGrid1.DataBind();
}
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) | (e.Item.ItemType == ListItemType.AlternatingItem) | (e.Item.ItemType == ListItemType.SelectedItem))
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor = 'thistle';this.style.cursor='hand'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor = 'gray'");
e.Item.Attributes.Add("onclick",GetPostBackEventReference(e.Item));
e.Item.Attributes.Add("onclick","javascript:__doPostBack(\'" + "DataGrid1:" + "_ctl" + (e.Item.ItemIndex+2) + ":_ctl0\',\' \')");
}
}
}
}
<--CODE-ASPX.CD-END-->
One more thing, as you can see I've tried adding buttonColumns in datagrid as well as withought those. But nothing seem to work!
Any, as in any suggestion is apprecitated
thanks
shatru2k
|
|
|
|
|
im also playing with postgres odbc, but not working. have you found where is the problem??
|
|
|
|
|
Hi all,
I want to check the availability of some terminals whose ip I know previously or in other words are they online or not. I send them some test message and they should in return send the affirmative answer if they are online.I assume a server is running at each end which responds to the test message.I can do it between 2 terminals in udp(dont want to use tcp for this). But how to send the message to 4 different terminals. Because in this case I cant use the single socket that i used in case of 2 terminals.I am new to networking. So dont have much idea.Should I use multithreading or something like making multiple sockets but then the question comes how many .If I am wrong somewhere please let me know.
with thanks.....
|
|
|
|
|
Hi!
Why not just ping them? You can either call ping with Process.Start() or search for a C# implementation of ping. I think I remember seeing one here on CP.
mav
|
|
|
|
|
I would like to implement a Timer control to display text in a Panels() implementation in a StatusBar control. I would like to display the text for the time like (X Hours, X Minutes, X Seconds) from the moment that the application begins to run.
To develop the application, create a form, add a status bar, click on status bar, go to properties window, click on panels(), click on Add, add a panel, name the panel statusBarPanelTime, leave it as sunken, clear the Text property for the statusBarPanelTime control, go back to properties of the main form, change ShowPanels to true, Add a Timer control to the main form components tray, name the Timer control timerStatusBar, set its interval to 1000 and set the timer to enabled = true, put a timerStatusBar.start() event in the onLoad event for the form, double click the timerStatusBar object and in the _Tick event handler write statusBarPanelTimer.Text = ?
Now, here is the question, there is not any timerStatusBar.Text property to assign to the statusBarPanelTimer.Text property. There is also not an .Elapsed() method to implement. I looked at the articles available, and have found some Console code that only implements "Hello World". How would I assign the time elapsed since the application is opened to run and place it in the statusBarPanelTimer? Also, I would like to control the placement of the statusBarPanelTimer in the statusBar, perhaps positioning it to the right hand side in the statusBar, even placing it at a specific exact location in the statusBar. Request assistance.
|
|
|
|
|
your question confuses me.
/\ |_ E X E GG
|
|
|
|
|
Alex Eggie:
I am interested in adding a panel to the status bar that simply displays text starting from the time that the application begins. The text originally displays (0 Hours, 0 Minutes, 0 Seconds) and then increments each second in the format (X Hours, X Minutes, X Seconds) using a Timer control. However, I am not certain how to assign the current value for the timerStatusBar (timer control) to the statusBarPanelTimer control (panel in status bar) text property. I also need to be able to parse out the time from the Timer control in terms of hours, minutes and seconds, but I am uncertain where to even get the current value of the Timer control.
statusBarPanelTimer.Text = ?(timerStatusBar.Text does not exist)
Also, I would like to position the panel in the status bar either aligned to the right or to even position the status bar panel at a SPECIFIC location in the status bar. Would appreciate assistance.
Cordially,
New_Phoenix
|
|
|
|
|
So, you just want to display the time (hours, minutes, seconds) in a status bar?
Um, just add to your timer.tick method, statusBar.PanelWhatever.Text=DateTime.Now.toShortTimeString;
is that what you want??? I still don't understand exactly.
/\ |_ E X E GG
|
|
|
|
|
I think I got it...
When you application starts you need to remember the start time. So in your main form declare a variable like:
<br />
private DateTime startTime = DateTime.Now;<br />
Now in your Timer.Tick eventhandler do the following:
<br />
TimeSpan ts = DateTime.Now - startTime;<br />
string text = ts.Hours + " Hours, " + ts.Minutes + " Minutes, " + ts.Seconds + " Seconds";<br />
statusBarPanelTimer.Text = text;<br />
Regarding the other question: Have a look at the propertiesof the status bar panel. There is something like Alignment which you can use to align it to the right. A specific location can only be made by having all AutoSize properties of the statusbar panels to the left to false and assigning fix widths to them.
|
|
|
|
|
Robert Rohde:
Thanks, it worked great! Much appreciated!
Cordially,
New_Phoenix
|
|
|
|
|
Hi,
I'm fairly new to c# and I can't seem to access another object from another class when it is public, how can I do this? This is a much simplified version of the code:
public class Entry<br />
{<br />
public M2 ds1 = new M2();<br />
[STAThread]<br />
static void Main()<br />
{<br />
M1 test = new M1("hi");<br />
}<br />
}<br />
public class M1<br />
{<br />
public M1(string data)<br />
{<br />
ds1.Add(data);
}<br />
}<br />
public class M2<br />
{<br />
ArrayList data1 = new ArrayList();<br />
public M2()<br />
{<br />
}<br />
public void AddData(string data)<br />
{<br />
data1.Add(data);<br />
}<br />
}
|
|
|
|
|
Your problem hasnt much to do with C#. You should read some basic book about object oriented programming.
You cannot directly access ds1 of class Entry. For this you either need to declare the field static (which means there is only one value for the whole class and not for each instance) or access the field from an instance of the Entry class.
|
|
|
|
|
I need programmatic control device volume, location of that is :
control panel->sounds and audio device properties->device volume.
Or in the bottom right angle(volume icon).
Can i do this with .NET library? If no how do this with using WinAPI and С#?
|
|
|
|
|