|
Hi,
COM offers component architecture inside and outside .NET (you can use COM from VB6 ).
COM needs extra code and care, installation, registration, has appartment issues, ...
as I always use .NET on PC, I avoid COM.
|
|
|
|
|
Thanks for the reply, I guess the only usage of COM/COM+ nowdays is to use managed code .NET from unmanaged code (VB6 for example)
Would microsoft leave this architecture in the future?
Regards,
|
|
|
|
|
IMO they seldom leave something, they may shift their focus...
|
|
|
|
|
Hi
I'm just wondering could anyone give me some pointers on where I could find how to share data between two different processes in c# at first but I might make a c++ version after when I get more experience in it. I have found two articles here on codeproject but I'm finding them a little hard to understand
article 1
article 2
If you could help it would be great
|
|
|
|
|
Hi ppl
Pls help me with a cell change problem.
I have a sourcegrid with 4 column ans 4 rows.
I can Insert data to every cell but the problem is I dont wanna use mouse or Tab to change cell. I want to use Enter key to change cell.
That mease I will insert data to a cell and press Enter key and coursor will go to next cell.
Can anyone have face this problem....
please help me
Thanks
|
|
|
|
|
SourceGrid - Open Source C# Grid Control[^]
I presume that^ is the source grid you're on about.
Something like this should work
void grid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (grid1.FocusCell.Row == grid1.RowsCount-1)
{
if (grid1.FocusCell.Column == grid1.Columns.Count - 1)
{
grid1[1,0].Focus(); selects the first cell
}
else grid1[1, grid1.FocusCell.Column + 1].Focus();selects the first cell in the next
}
else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();
}
}
|
|
|
|
|
many many thanks.
I have tried it but some error I cant understand...
void grid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (grid1.FocusCell.Row == grid1.RowsCount-1)
//to check if you have reached the last cell in the column
{
if (grid1.FocusCell.Column == grid1.Columns.Count - 1)//checks if you have reached the
//last row in the last column
{
grid1[1,0].Focus(); //selects the first cell
}
else grid1[1, grid1.FocusCell.Column + 1].Focus();//selects the first cell in the next
//column
}
else grid1[grid1.FocusCell.Row + 1, grid1.FocusCell.Column].Focus();//selects the next cell
}
}
The Bold text "grid1.focuscell.row and grid1.focuscell.colume does not have any defination."
Cant you fix it pls
Thanks
modified on Tuesday, April 14, 2009 10:18 PM
|
|
|
|
|
put your source grid name ("grid1" change it to your grid name") there my friend.
I think you better use the key up event, that can easly handle enter or arrow keys.
|
|
|
|
|
Sorry that was my fault
You must be using version 4;
try this way:
void grid1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
int row = grid1.Selection.ActivePosition.Row;
textBox1.Text = row.ToString();
int column = grid1.Selection.ActivePosition.Column;
if (grid1.Selection.ActivePosition.Row == grid1.RowsCount - 1)
{
if (column == grid1.Columns.Count - 1)
{
grid1.Selection.Focus(new SourceGrid.Position(1, 0), true);
}
else grid1.Selection.Focus(new SourceGrid.Position(1, grid1.Selection.ActivePosition.Column + 1), true);
}
else
grid1.Selection.MoveActiveCell(1, 0);
}
}
|
|
|
|
|
Sorry I was out of town.I have tried it but
It didnt work. Dont know why.
Do I need to use any event handler code to the .Designer.CS page?
Like this.grid1.keypress += new .....
pls make it clear.
Thanks again
modified on Saturday, April 18, 2009 11:24 AM
|
|
|
|
|
Hi
I have 2 Windows Service Question
1.Is WS can work in background ? Is it posible to do some job evry 2 minutes ? (if yes, can I get some help ?)
2.How can I install WS in simple way ? (not with Installutil.exe .......)
3.How to run .exe file through WS
i'll do this:
System.Diagnostics.Process G = new Process();
G.StartInfo.FileName = @"d:\demo.exe";
G.Start();
thank's in advance
|
|
|
|
|
1. Yes, absolutely. Use the System.Threading.Timer class. Read the documentation for the choices that are offered to you.
2. Installutil.exe is the best way. You may try to use a setup project instead, but I never tried it.
3. This seems to be correct to me.
E_Gold wrote: I have 2 Windows Service Question
You should learn how to count, that was 3 questions.
|
|
|
|
|
1) Yes. Avoid the Timer class and write a threaded timer.
2) You can't not use installutil.exe...
3) Use the Process class.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I use a System.Timers.Timer
|
|
|
|
|
You get more control with a thread, and the timer events are the lowest priority events in Windows. This means that on a busy system, your app might not even *see* the event. Personally, I take no chances with that kind of stuff.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Well then it depends on usage; the Timer does what I need it to.
|
|
|
|
|
This[^] article looks like a viable alternative
I are troll
|
|
|
|
|
1) Yes, but are you sure you don't want a Windows Scheduled Task?
2) Kinda sorta, as the article pointed out by Eddy suggests. That's how I do it.
3) Yes, but are you sure you don't want a Windows Scheduled Task?
|
|
|
|
|
Hi all,
I'm having a problem using DllImport in C# to call a C++ function.
C++ Header File:
DLLEXPORT int drawMarkupOnLine (int jobId, int lineNumber, short* line, int drawMode);
C++ Source File:
DLLEXPORT int drawMarkupOnLine (int jobId, int lineNumber, short* line, int drawMode)
{
...
}
==========================================
C# Source File:
[DllImport("vdrdll.dll", EntryPoint = @"?drawMarkupOnLine@@YAHHHPAFH@Z")]
unsafe static extern int drawMarkupOnLine(int jobId, int lineNumber, short* line, int drawMode);
...
short* scan0 = (short*)bmd.Scan0;
short* nextScanLine = scan0;
drawMarkupOnLine (0, i, nextScanLine, lca[i]);
==========================================
When I try to call the function, I get an EntryPointNotFoundException, with message, "Unable to find an entry point named '?drawMarkupOnLine@@YAHHHPAFH@Z' in DLL 'vdrdll.dll'."
I've tried various permutations of IntPtr, string pointers, and void pointers for the third parameter (which I'm assuming is causing the problem), but nothing seems to work. (Other functions with only int parameters work just fine.) Can someone suggest a reliable way to get this to link?
Thanks,
Alan
|
|
|
|
|
Hi Alan,
in C# one does not need unsafe nor short*, instead ref short would do.
since native C++ is mangling names, I suggest you try DllImport("vdrdll.dll", EntryPoint="...", ExactSpelling=true) , since maybe the marshaling is adding an A or W because of the pointer.
|
|
|
|
|
Thanks for the suggestion Luc, but I'm still getting the same result. It even happens when I use a simple local variable for the 3rd parameter.
|
|
|
|
|
It gets stranger: The problem still shows up even with all int parameters.
|
|
|
|
|
OK, I suggest you use DUMPBIN or some other tool to verify the symbols exported by your DLL file.
BTW: you are not getting confused (or confusing your tools) by having several copies of the DLL in different places, other folders, GAC, ...?
FWIW: I tend to use C, not C++, for native code, avoiding all name mangling. Never had such problems.
|
|
|
|
|
Thanks Luc. I got the symbol from the VdrDll.exp file (exports library file), which seems to work for the other exported functions.
I tried renaming the generated DLL, and got the expected missing module error message.
Yes, C would be simpler, but I'm trying to leverage a massive existing code base already in C++.
|
|
|
|
|
Hi Alan,
I did some experiments using VS2008 Express for both C++ and C# and all went well, here is the relevant code:
#define NATIVECPPEXPERIMENT_API __declspec(dllexport)
NATIVECPPEXPERIMENT_API int fint1(int arg1) {
return arg1*arg1;
}
NATIVECPPEXPERIMENT_API int fint4(int arg1,int arg2, short* arg3, int arg4) {
*arg3=(short)(arg1*arg2);
return arg1*arg4;
}
namespace ConsoleApplication1 {
class Program {
static void log(string s) {Console.WriteLine(s);}
static void Main(string[] args) {
int res1=cppfint1(12);
log("res1="+res1);
short shrt=14;
int res4=cppfint4(12,13,ref shrt, 15);
log("res4="+res4);
log("shrt="+shrt);
Console.ReadLine();
}
[DllImport("nativeCppExperiment.dll", EntryPoint="?fint1@@YAHH@Z")]
static extern int cppfint1(int arg1);
[DllImport("nativeCppExperiment.dll", EntryPoint="?fint4@@YAHHHPAFH@Z")]
static extern int cppfint4(int agr1, int arg2, ref short arg3, int arg4);
}
}
So either you are overlooking something, or your system is ill. I suggest you try closing and reopening Studio, and consider rebooting.
|
|
|
|