|
sree wrote: C# Equivalent of a C++ std::vector?
It would be List(T)[^].
sree wrote: This vector i want to pass from c# program.
I don't think you can create a vector and pass to the native function. Best method would be to use C++/CLI to wrap the native function. Write a function which takes a managed list in the C++/CLI class. Inside this function, create a std::vector with the values from list and pass to the native method. You can refer the C++/CLI project's DLL and call the methods from C# easily.
|
|
|
|
|
Thanks for your inputs.
But when i am trying to pass List<>, it giving me the fallowing exception
"Cannot marshal 'parameter #1': Generic types cannot be marshaled".can you plz tell me how to pass the list to c++.
sree
|
|
|
|
|
sree wrote: how to pass the list to c++.
By C++ do you mean C++/CLI? Can you show us the code?
|
|
|
|
|
extern "C" __declspec(dllexport) int __stdcall passVector(vector<int> &i)
{
vector<int>::iterator Iterator1 = std::max_element(i.begin(), i.end());
return *Iterator1;
}
This is my c++ function. I want to pass the vector from c# program using DllImport.
This is how i tried with Arraylist from C#
[DllImport(@"D:\sample.dll", EntryPoint = "passVector")]
public static extern int passVector(ArrayList i);
sree
|
|
|
|
|
sree wrote: I want to pass the vector from c# program using DllImport.
Well, I think you haven't got what I said so far. To reiterate, you can't pass a vector from C# using DllImport . For doing that you have to use C++/CLI to create a proxy class between your C# and C++ application. Follow the below steps.
1 - Create a C++/CLI library project. Add reference to the native DLL here
2 - Write a function that takes List(T)
3 - Iterate over the elements in this list, create a vector and push each item to it.
4 - Now call the native C++ method by passing this vector.
Since List(T) is a managed type and C++/CLI produces mixed mode assembly, you will be able to access it from C# easily. Just refer the C++/CLI dll, create a List(T) from C# project and pass to the method.
*T will the type of the object which you want to pass.
|
|
|
|
|
Hi,
Can anybody please help me to resolve below described issue?
using DirectShow i build application which show live preview and also capture video frames.
there is start/stop button available on user interface which are used for starting and stoping video frames capturing.
But when a user click on start/stop button, my preview window become totally black coloured for some time and i lost video frames during that period.
Please help me it's urgent.
Thanks & Regards,
Kunal.
|
|
|
|
|
I'd guess that whatever processing you're doing in the start/stop event is taking too long, and locking out the video capture. However, without a lot more information it's pretty hard to really know what's wrong...
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
thanks...
problem solved.
|
|
|
|
|
Nobody helps here when they face words like:
kunal.tawde wrote: Please help me it's urgent
Sorry, that is just the way it is.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Hi there,
Sir,
I want to add automatic scrolling effect of pictures in timed manner on my MDI page. The effect should be like as web base application(just we use marquee in it) that is on mouse over it should be stopped. Is it possible to add it ?
I m using C# Windows application.
Thank u .
|
|
|
|
|
Use a timer and the ontick event to manage the marquee effect (move the picture on every tick). Use the OnMouseOver event to stop the movement by disabling the timer
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i am working in a window Application and using a Gridview.In this gridview i am adding a button but can't find Button_Click Event...
Plz Dont tell me about Cell_click Event.Its Not working Properly...
Need A Help..
Thanks
|
|
|
|
|
You say you are working in a Windows application - I presume you mean a winforms application, there is no GridView in winforms.
If you are working on a webform then you will get a better response in the ASP forum.
The event I get for a DataGridView button on the other had is
private void dgData_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
ok thats DataGridView..is there any event by i can handle the button event ...
|
|
|
|
|
CellContentClick is the event by which u can handle the click events of button.
Just add buttons at design time using smart tag that u know.
In eventHandler give MassageBox.Show("Ok");
On Clicking button in datagridview u will see this msg.
|
|
|
|
|
ok thats right...but cellcontent_click event is fired when u click the header of the datagridview...then its a problem...
|
|
|
|
|
So inspect the event arguments (e) to determine who clicked it.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No. Its not. You will get the event on clicking control that u have added(like as checkbox,button,combobox etc.). Just cross check...
It works properly.
|
|
|
|
|
Please take a look at this reply to a similar question in the VB forum. RE-How-can-i-get-this-checkbox-to-work-when-it-is-selected.aspx[^]
As it is in the VB forum it is in VB.Net but you should be able to follow well enough to convert it into C#
Hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Use the "CommandName" property of the Button and set it to What ever name you want to give and the "CommandArgument" property to the unique id of that row to get the same.
You can catch the same in the RowCommand Event of the Gridview as
if (e.CommandName == "WhatEverYouNamed")
{
}
Using this you can have multiple buttons doing multiple things in one gridview.
Regards,
Kaushal Arora
Please Mark as Answer if it solved your problem.
|
|
|
|
|
I can get the WM_CREATE msg in WndProc when I click button1,but it didn't fired at the PreFilterMessage.
Follow is the source code.Thanks!
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
filter ft = new filter();
Application.AddMessageFilter(ft);
Form1 f = new Form1();
f.Show();
Application.Run();
}
}
public class filter : IMessageFilter
{
#region IMessageFilter 成员
const int WM_CREATE = 0x00001;
public bool PreFilterMessage(ref Message m)
{
<code> if (m.Msg == WM_CREATE)
{
MessageBox.Show("A");
return true;
}</code>
return false;
}
#endregion
}
public partial class Form1 : Form
{
#region Designer
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
this.button1.Location = new System.Drawing.Point(0, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(609, 265);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
#endregion
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Show();
}
const int WM_CREATE = 0x00001;
protected override void WndProc(ref Message m)
{
<code> if (m.Msg == WM_CREATE)
{ MessageBox.Show("B"); }
base.WndProc(ref m);</code>
}
}
|
|
|
|
|
Because you have already overridden it in the Form. So I guess additional message filters won't execute. Also use this[^] overload of Application.Run .
|
|
|
|
|
Thanks,
I remove the override method of WndProc from form1,but it didn't work fine.
PS: We can capture all msgs except the WM_CREATE in PreFilterMessage method.
N a v a n e e t h wrote: Also use this[^] overload of Application.Run.
I have changed
Form1 f = new Form1();<br />
f.Show();<br />
Application.Run();
to
Application.Run(new Form1());
May be I didn't clear what you mean.
|
|
|
|
|
It seems it wasn't catch by PreFilterMessage.
Is there some way to catch WM_CREATE for all forms in my application without override those WndProc in each winform?
|
|
|
|
|
I reproduced the problem you are saying. Sadly, I don't have any solution to offer.
hwswin wrote: Is there some way to catch WM_CREATE for all forms in my application without override those WndProc in each winform?
Yes. Just create a class which derives from System.Windows.Forms.Form and override the WndProc there. You can derive all your forms from this class.
|
|
|
|