|
That Timer belongs to System.Timers namespace, not System.
In C# it worked as expectedly, mayb in VB, it guessed which class that you want to use, which it shouldn't, strictly speaking.
|
|
|
|
|
Hi
Try this
<code>
using System;
namespace MyNamespace
{
public class Class1
{
private Timers.Timer t;
}
}
</code>
Ahmad Shaban
|
|
|
|
|
This code produces the same issue. Timers is not found.
|
|
|
|
|
Hello,
This is a problem I faced a few months ago. Not with basic, but I came from a C++ background. Your problem is that the namespace Timers is not available to you! This sounds strange because the namespace resides in the System namespace which you imported. C# does make all classes in the imported namespace available, but not nested namespaces. You can use an alias to solve the problem, or completely import the namespace:
using Timers = System.Timers;
using System.Timers;
public class Class1
{
private System.Timers.Timer t;
}
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
-- modified at 3:32 Tuesday 21st March, 2006
|
|
|
|
|
|
|
API Help
Posted: 19 Mar 2006 07:25 PM
Hi, I use this --
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "FindWindowA")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "FindWindowExA")]
private static extern IntPtr FindWindowEx(IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
[System.Runtime.InteropServices.DllImport("user32")]
private static extern IntPtr ShowWindow(IntPtr hwnd, int nCmdShow);
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SetWindowTextA")]
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
[System.Runtime.InteropServices.DllImport("user32")]
private static extern int EnableWindow(IntPtr hWnd, bool bEnable);
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "GetWindowTextA")]
private static extern int GetWindowText(IntPtr hWnd, string lpString, int nMaxCount);
[System.Runtime.InteropServices.DllImport("user32", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
private const int WM_LBUTTONDOWN = 513;
private const int WM_LBUTTONUP = 514;
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6;
private const int SW_MAXIMIZE = 3;
private const int SW_SHOWMAXIMIZED = 3;
private const int SW_RESTORE = 9;
public void Changetext()
{
IntPtr Taskbar = FindWindow("Shell_TrayWnd", null);
IntPtr StartButton = FindWindowEx(Taskbar, IntPtr.Zero, "Button", null);
SetWindowText(StartButton, "Blah");
EnableWindow(StartButton, false);
EnableWindow(StartButton, true);
}
To change the text on the start button, and it works fine. But it can only have like 5 letters. could i use SetWindowPos to change the width of the start button, to allow for more letters? I have seen code in other langs that do this, And im pretty sire thats the method they take. If so could I see an example please .
|
|
|
|
|
Hi
I'm very interested in the code in hand here
could you send me the code please
Thanks in advance
Ahmad Shaban
|
|
|
|
|
I put it that way
using System;
using System.Runtime.InteropServices;
namespace ChangeText
{
public class MainCls
{
public MainCls() { }
[DllImport("user32", EntryPoint = "FindWindowA")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32", EntryPoint = "FindWindowExA")]
private static extern IntPtr FindWindowEx(IntPtr hWnd1, IntPtr hWnd2, string lpsz1, string lpsz2);
[DllImport("user32")]
private static extern IntPtr ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32", EntryPoint = "SetWindowTextA")]
private static extern bool SetWindowText(IntPtr hWnd, string lpString);
[DllImport("user32")]
private static extern int EnableWindow(IntPtr hWnd, bool bEnable);
[DllImport("user32", EntryPoint = "GetWindowTextA")]
private static extern int GetWindowText(IntPtr hWnd, string lpString, int nMaxCount);
[DllImport("user32", EntryPoint = "SendMessageA")]
private static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
private const int WM_LBUTTONDOWN = 513;
private const int WM_LBUTTONUP = 514;
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
private const int SW_MINIMIZE = 6;
private const int SW_MAXIMIZE = 3;
private const int SW_SHOWMAXIMIZED = 3;
private const int SW_RESTORE = 9;
public void Changetext ( string TextToSet )
{
IntPtr Taskbar = FindWindow("Shell_TrayWnd", null);
IntPtr StartButton = FindWindowEx(Taskbar, IntPtr.Zero, "Button", null);
SetWindowText(StartButton, TextToSet );
EnableWindow(StartButton, false);
EnableWindow(StartButton, true);
}
}
}
But the moment a refresh to the taskbar occur it return to its normal text "Start"
how to make it permanent
Ahmad Shaban
|
|
|
|
|
I just need to know how to change the size of it To keep it there, just set the method and call it on a timer...
|
|
|
|
|
Hi,
I am looking for a statistical random function that would allow me to supply the mean, min and max values. Something like:
Double mean = 3;
Double min = 1;
Double max = 10;
Double d = GenNext ()
Any help would be appreciated.
|
|
|
|
|
I don't know what "mean" would be ... but have you looked at the Random class?
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thanks for reply.
Sorry for the confusion but here is the definition. Mean: The average of a set of N numbers.
Yes I have, the best I could come up with is this:
double h;
double avg = 3.0, max = 10.0, min = 1.0;
Random RandomClass = new Random (10);
h = (- System.Math.Log(RandomClass.NextDouble())) * (avg - min);
But this does not help with making sure the value doesn’t go over the max.
|
|
|
|
|
CWIZO wrote: I don't know what "mean" would be ... but have you looked at the Random class?
Mean is the average ((val1 + val2 + .. valN-1 + valN)/N ) value. Random has a designed mean of (MinVal+MaxVal)/2. To do what the OP wants where the mean could be located elsewhere would need a way to define the relative distribution. For the general implementation you'd need a parameter on the line of f(x) = <some function=""> where F(x) is defined over the range min..max and has a global maxima at mean. F(x) would scale the random value given a random value R. you'd return K defined that Integral(f(k), min value,k) = R. Integral f(x) would need scaled to normalize the return. For a specfic distribution you could try hardcoding it instead of taking a function as aparameter. You could try examing (large) 3rd party math libraries, but I suspect this is something that you'll need to write yourself.
All of this is off the top of my head, and I don't know how to do the implementation.
|
|
|
|
|
I'm serializing xml data to files and need to find a way to add an xsi:schemaLocation="path\schema.xsd" atribute to the data being written.
|
|
|
|
|
[System.Xml.Serialization.XmlAttribute<br />
(Namespace="http://www.w3.org/2001/XMLSchema-instance")]<br />
public string schemaLocation = "Namespace path\\SchemaName.xsd";
I can get it in by adding this to the C# file autogenerated by the XSD tool, but this is obviously a suboptimum solution. I know for a fact that when I update the schema and rerun XSD several months later I'll forget I need to modify the file again. Is there a way I can do this from either a wrapper class or the IO class using filestreams and serializers?
|
|
|
|
|
I have some perl functions that get called through SOAP and C#. Is there a way to call these functions going from perl to C#?
** NOTE If this shows up twice, its because there was an error and I had to rename my post to post it. **
Mike - I love to program!
|
|
|
|
|
The virtual machine implementations of C# and Perl are radically different so calling methods between "byte codes" is almost impossible. You can however do a SOAP proxy like that to do interprocess communications at that level if the lower level IPC is too low.
|
|
|
|
|
Alright, I have the following perl code:
<br />
sub getComplexObj<br />
{<br />
my $_count = 12<br />
my $mike = {<br />
'Count'=> SOAP::Data->new( name => 'Count', value => $_count, type => 'xsd:int' )->attr({ 'xmlns' => $MC_XMLNS }),<br />
'test' => SOAP::Data->new( name => 'test', value => 'test string', type =>'xsd:string' )->attr({ 'xmlns'=> $MC_XMLNS })};<br />
<br />
my $foo = SOAP::Data->new(<br />
name => 'return',<br />
value =>bless{ $self ,('compObj')->attr({ 'xsi:type' => typens:'compObj' })}<br />
)->attr({ 'xmlns' => $MC_XMLNS });<br />
<br />
return $foo;<br />
}<br />
I have a WSDL file and I use that to automatically generate a C# file that uses a SOAP proxy to call this function. When I run my code, I get the following error from .NET:
"Failed to access class (CS3::SOAP::ComplexObject): syntax error at CS3/SOAP/ComplexObject.pm line 13, near \"typens:\"\nCompilation failed in require at (eval 201) line 3.\n"
When I change the $foo object to:
my $foo = SOAP::Data->name('return')->value(bless{ $self ,'compObj'})->attr({ 'xmlns' => $MC_XMLNS });
I get this error from .NET:
"Cannot assign object of type System.Xml.XmlNode[] to an object of type compObj."
Just for reference, my C# file looks like this:
<br />
[System.Web.Services.WebServiceBinding(Name="ComplexObjectPort", Namespace="http://VALIDHTTP")]<br />
[System.Diagnostics.DebuggerStepThroughAttribute()]<br />
[System.ComponentModel.DesignerCategoryAttribute("code")]<br />
public class ComplexObj : System.Web.Services.Protocols.SoapHttpClientProtocol {<br />
<br />
public ComplexObj() {<br />
this.Url = "http://VALIDHTTP/co.pcgi";<br />
}<br />
<br />
[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://VALIDHTTP#getComplexObj", RequestNamespace="http://VALIDHTTP", ResponseNamespace="http://VALIDHTTP")]<br />
[return: System.Xml.Serialization.SoapElement("return")]<br />
public compObj getComplexObj() {<br />
object[] results = this.Invoke("getComplexObj", new object[]);<br />
return ((compObj)(results[0]));<br />
}<br />
<br />
public System.IAsyncResult BegingetComplexObj(System.AsyncCallback callback, object asyncState) {<br />
return this.BeginInvoke("getComplexObj", new object[], callback, asyncState);<br />
}<br />
<br />
public compObj EndgetComplexObj(System.IAsyncResult asyncResult) {<br />
object[] results = this.EndInvoke(asyncResult);<br />
return ((compObj)(results[0]));<br />
}<br />
}<br />
<br />
[System.Xml.Serialization.SoapType(Namespace="http://VALID HTTP")]<br />
public class compObj {<br />
<br />
public int Count;<br />
<br />
public string test;<br />
}<br />
Then in a main file I have:
<br />
try<br />
{<br />
ComplexObject co = new ComplexObject();<br />
compObj comp = co.getComplexObj();<br />
}<br />
catch( Exception e )<br />
{<br />
richTextBox1.Text+=e.Message + "\n" + e.StackTrace;<br />
}<br />
My ultimate goal is simply to call a function from perl that returns a complex object. ANY help would be greatly appreciated.
Mike - I love to program!
-- modified at 16:42 Saturday 25th March, 2006
|
|
|
|
|
I am trying to create a data connection in Visual studio using the above provider. The connection tests fine but I cannot see any tables. I suspect that is due to the initial catalog setting on the connection tab.
It will not allow me to put anything else than the server name of the as/400. How do I go about putting a library name(this is the equivelant of a database schema) so that I can view the tables and use them ??
Enasromios
|
|
|
|
|
i like to know how can i view the labels in runtime and edit they propertys like in desing time
|
|
|
|
|
nameOfYourLabel.WhateverProperty
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
i dont get your reply please be mor especific
|
|
|
|
|
You access properties of a label trough it's name.
Label is just a class so if you know how to work with clasess I don't know why you would not know how to work with labels...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
now i understand you brother but its simple i have this problem and i dont know how to view a label at runtime like if it was in runtime i want that my lable be able to can be moved resize etc like in desing time
|
|
|
|
|