|
Hi,
I am trying to raise the events of an unmanaged ActivX control in C# Class library. My code is as follows
Inside the class I have declared a static object of the OCX
public static CtConectorXClass ctiConnecter = new CtConectorXClass();
In the constructor,
ctiConnecter.OnACSCloseStreamConf += new ICtConectorXEvents_OnACSCloseStreamConfEventHandler(ctiConnecter_OnACSCloseStreamConf);<br />
And the event handler that I need is
private void ctiConnecter_OnACSCloseStreamConf(object sender, CtConectorXControl.ICtConectorXEvents_OnACSCloseStreamConfEvent e) { }<br />
The event class is ICtConectorXEvents_OnACSCloseStreamConfEvent. But in class library project, I am not getting this class in the CtConectorXControl namespace.
In a windows project it creates an AxCtConectorXControl namespace when we add a reference and I am getting all the event classes in that namespace.
Can anybody tell me where is the problem?
Thanks
Sree
|
|
|
|
|
Hi all,
I have three byte arrays, and I want to add all of them together and make a single one. Can you tell me what's the best way to do this.
Thanks
I appreciate your help all the time...
CodingLover
|
|
|
|
|
byte[] a = new byte[2] {1, 2};
byte[] b = new byte[2] {3, 4};
byte[] c = new byte[2] {5, 6};
List<byte> d = new List<byte>();
d.AddRange(a);
d.AddRange(b);
d.AddRange(c);
byte[] newArray = d.ToArray();
|
|
|
|
|
Create a new array large enough to hold the data from the three arrays, and use the Array.Copy method to copy the data into it.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Yes, I work on it. But the question is, that way is safe. I mean may be three arrays can be large. And also in copy a bit can be shift.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
CodingLover wrote: But the question is, that way is safe. I mean may be three arrays can be large.
If you don't have enough memory for the original arrays and the combined array, you could instead make a class that contains the arrays and can be used as a single array. Someting like:
public class ArrayCombiner<T> {
private List<T[]> _arrays = new List<T[]>();
private int _length = 0;
public void Add(T[] array) {
_arrays.Add(array);
_length += array.Length;
}
public int Length { get { return _length; } }
public T this[int index] {
get {
if (index < 0 || index >= _length) {
throw new IndexOutOfRangeException();
}
int array = 0;
while (index > _arrays[array].Length) {
index -= _arrays[array].Length;
array++;
}
return _arrays[array][index];
}
}
}
CodingLover wrote: And also in copy a bit can be shift.
What?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I am attempting to call the "ChangeDisplaySettings" function from the Win32 API which is supposed to update the display settings on the computer. It takes in a DEVMODE structure (also defined via the API) as an argument. The function is defined as:
public static extern int ChangeDisplaySettings(ref DEVMODE lpDevMode, int dwFlags);
Apparently, in C# you cannot pass the value "null" in the place of a DEVMODE because it is a nonnullable value. I am attempting to call "ChangeDisplaySettings(null, 0);" which is supposed to update the display settings strictly based on what the registry has but i get errors telling me it cannot convert "null" to a "ref DEVMODE". Does anyone know how i can either call the function in the way that i would like to in order to update the display based on the registry, or perform this same function in a different manner? Help is appreciated!!!!
THANKS!!!
-JDub
|
|
|
|
|
you can you script " " full null value
|
|
|
|
|
What do you mean by "script "" full null value"? If you dont mind, could you please provide a short example of what you mean or what i should be putting as the argument
|
|
|
|
|
Maybe something like this...
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(ref DevMode devMode, int flags);
[DllImport("user32.dll")]
public static extern int ChangeDisplaySettings(IntPtr devMode, int flags);
...
ChangeDisplaySettings(IntPtr.Zero, 0);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That Worked Perfectly! I never thought about overloading the function. Thank you so much!
|
|
|
|
|
Thank you! excellent tip, that's work perfectly.
|
|
|
|
|
Just a quick overview,
I have controls which have a property of Type Type. The property grid doesn't by default support editing of it. So I have to inherit from UITypeEditor.
What my program currently does is display a form with all the types in the assembly my UITypeEditor is in and all the assemblies it references. This is not quite ideal because it should be the assembly the Form (or other control) that is being designed is in and all of it's references.
Any ideas?
Thanks in advance,
Chris
|
|
|
|
|
hi all,
i am using window.open() in C# aspx.cs the code works fine in ie6,mozilla but in ie7 and ie8 new window opens but it closes within 1 second.
here is my code.
Page.RegisterStartupScript("pop1", "window.open('" + url + "','mywindow');");
Is there any coding problem or browser ,please give some ideas regarding this.
Thanks
hivshi
|
|
|
|
|
Did you not see the ASP.NET forum ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
That code doesn't open the page in a new window, it opens the page in the window named "mywindow". It's only if there is no window with that name that a new window is opened. If you want to open a new window, you should use the target "_blank" instead of "mywindow".
There is nothing in the window.open method that could case the window to close after a second. There has to be something in the code in the page that you open that does that.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi,
can anyone tell me how to handle the columns size of the datagridview.
i know the propriety but sometimes i d´ont know the lenght of the strings!!! so i get a big or small sized columns
is there something i can enable?
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
The AutoSizeMode property is probably what you're looking for.
Eslam Afifi
|
|
|
|
|
While AutoSize does a reasonable job I find manually sizing the column during development the most satisfactory. I have a function where I pass a CSV string of sizes after the grid is loaded and that sets the column widths, including hiding 0 width columns which I always have as column 0 holds the ID for the row .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Create a C# Windows Application. Replace the non-designer class code in the Form with mine below.
The code simply creates 10 Panels on the form, each with one button on it. I assign each button's parent panel to the button's "Tag" property. I assign one common click event handler to all the buttons. In the click event handler, I simply cast the button's "Tag" to a Panel, then do a Form.Controls.Remove() to remove the Panel from the Form's "Controls" collection.
I also create a "debug" window so that I can see when the button click event handler fires.
Run the application and start hitting the spacebar. Exactly as you would expect, as you "click" each button by hitting the spacebar, the respective panel is removed. But keep hitting the spacebar after no more panels are visible. The click event KEEPS ON FIRING. I can understand that the panel can still be alive (and not have been garbage collected) and still have the button in its' "Controls" collection. But how does the spacebar keypress get from the form (which is in focus and has Controls.Count = 0) to the panel (and on to the button) that is no longer in its "Controls" collection???
public partial class Form1 : Form
{
private Form debugForm;
private TextBox debugTextBox;
public Form1()
{
InitializeComponent();
}
void b_Click(object sender, EventArgs e)
{
Button b = (Button)sender;
Panel p = (Panel)(b.Tag);
this.Controls.Remove(p);
debugTextBox.Text += "Click event fired for " + b.Name + " : this.Controls.Count = " +
this.Controls.Count.ToString() + "\r\n";
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
debugForm.Close();
}
catch { }
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
Panel p = new Panel();
p.Left = 0;
p.Top = i * 35;
p.Width = 300;
p.Height = 30;
Button b = new Button();
b.Left = 0;
b.Top = 0;
b.Width = 300;
b.Height = 30;
b.Name = b.Text = "Button" + i.ToString();
b.Click += new EventHandler(b_Click);
b.Tag = p;
p.Controls.Add(b);
this.Controls.Add(p);
}
Rectangle rScreen = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
this.Left = 0;
this.Width = rScreen.Width / 2;
this.Top = 0;
this.Height = rScreen.Height;
debugForm = new Form();
debugForm.StartPosition = FormStartPosition.Manual;
debugForm.Left = this.Right + 1;
debugForm.Width = this.Width;
debugForm.Top = this.Top;
debugForm.Height = this.Height;
debugTextBox = new TextBox();
debugTextBox.Multiline = true;
debugTextBox.Dock = DockStyle.Fill;
debugTextBox.ScrollBars = ScrollBars.Both;
debugForm.Controls.Add(debugTextBox);
debugForm.Show();
}
}
|
|
|
|
|
I was working on my project and all my tool strip items, label, combo box ect..disappeared. I can still reference the objects in my code, but I cannot see the items even in Visual Studio.
Thanks!
|
|
|
|
|
Hi,
My question is basicly the title. What are the differences in C# between those two? If I implement a Vector3 class (X, Y and Z, all float member). Why would I use struct instead of class? How do I choose? The sintax is pretty much the same... (as I see)
Thanks,
Dirso
|
|
|
|
|
|
Is google broken where you live ? Did someone steal all your reference books ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Calm down! You don't have to be that rude. Sorry if my question has offended you in anyway - it was not my intention. The previous guy has already sent me to google.
I already undertood what you (both) meant and I'll be more carefull next time before posting a question.
Thanks,
Dirso
|
|
|
|