|
Thanks Man! You made my day a lot better.
Steve
|
|
|
|
|
Finished code:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TestManager tManager = new TestManager();
Console.WriteLine("ProcessRequest1");
tManager.Run1();
Console.WriteLine("ProcessRequest2, returned value is: " + tManager.Run2());
Console.ReadLine();
}
}
}
namespace ConsoleApplication1
{
delegate object OuterDelegate (int p);
delegate object InnerDelegate (params string[] list);
class TestManager
{
public int ProcessRequest1(OuterDelegate DoSomethingWithResults, InnerDelegate GetData, params string[] sParams)
{
int iRet = Convert.ToInt32(GetData(sParams));
iRet += 1;
return Convert.ToInt32(DoSomethingWithResults(iRet));
}
public string DoSomethingWithResults(int i)
{
i += 4;
return i.ToString();
}
public string DoNothingWithResults(int i)
{
return i.ToString();
}
public object GetData(params string[] list)
{
int iReturn;
iReturn = (Convert.ToInt32(list.GetValue(0))) + (Convert.ToInt32(list.GetValue(1)));
return iReturn;
}
public int ProcessRequest2(OuterDelegate DoNothingWithResults, InnerDelegate GetData, params string[] sParams)
{
int iRet = Convert.ToInt32(GetData(sParams));
return iRet;
}
internal void Run1()
{
string [] sArray = { "1", "2" };
Console.WriteLine("Not returning anything, results: " + ProcessRequest1(DoSomethingWithResults, GetData, sArray));
}
internal string Run2()
{
string[] sArray = { "4", "5" };
return Convert.ToString(ProcessRequest2(DoNothingWithResults, GetData, sArray));
}
}
}
|
|
|
|
|
Delegates are not used to pass parameters. You are trying to pass parameters to the delegate, ie the result of the method, and the delegate at the same time which would not be correct.
I don't think you are dumb but I think your approach is flawed.
|
|
|
|
|
|
Hi,
the params keyword tells the compiler it should collect the remaining arguments and turn them into an object array; yes, you can use params with a delegate; here is an example:
delegate void TestDelegate(params object[] list);
event TestDelegate aha;
public override void Test(int arg) {
aha+=new TestDelegate(showArgCount);
aha.Invoke(1);
aha.Invoke(1, 2, 3, 4);
}
public void showArgCount(object[] args) {
log("showArgCount: "+args.Length);
}
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:41 AM
|
|
|
|
|
Thank you for your help and I will try to have it more together on my next question. Please understand that my boss is asking me to do something very difficult and pushing me to get it done. I am under a lot of pressure and I did spend a lot of time doing research without luck. It has been a tough morning. The bottom line is that I am sorry for the question.
Steve
|
|
|
|
|
You're welcome.
And I saw nothing wrong with your question.(if I did, I would have told you!)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
hi friends am using usercontrol as drawing area to draw graphics...so now i want to apply zoom factor to usercontrol(not to image)...plzzzzzz help me..
txs in advance...
|
|
|
|
|
usercontrol zoom? Basically this will increase/decrease the size of the control?
why do you want to do that? what controls is your usercontrol containing?
you cannot apply zoom transformations on controls, at least in standard windows applications.
You may use a workaround, to apply a zoom factor to the size/location of each children controls.
Calin
modified on Thursday, February 26, 2009 11:31 AM
|
|
|
|
|
iam drawing shapes using graphics..so i want to apply zoomfactor to dt usercontrol...
|
|
|
|
|
Hi
1. How can I show and edit, Crystal report in wideness
(in C# code)
2. Is it posible to put water stamp Logo that will be in page size ?
thank's
|
|
|
|
|
E_Gold wrote: 1. How can I show and edit, Crystal report in wideness
in wideness? Really, that's the best you could do?
Maybe you should look into this[^]
|
|
|
|
|
I've never used Crystal Reports, but the terms you were looking for are:
1. Landscape
2. Watermark
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
i'll ask again
I am looking for a way to include a watermark in a report.
Does anyone have any ideas?
|
|
|
|
|
E_Gold wrote: Does anyone have any ideas?
Actually, I do have an idea[^]
I know, I'm absolutely brilliant! For my next feat I am thinking of performing brain surgery while disarming a nuclear weapon both during a skydiving free fall.
|
|
|
|
|
I need to dynamically add a flash object to a C# desktop application. Could someone give me some overview on how to do this. I have been able to add it statically but when I go to try to create it dynamically I come up with unhandled win32 exceptions. Also I need the background to be transparent and having troubles with this too.
Thanks for any help
|
|
|
|
|
Zap-Man wrote: Also I need the background to be transparent and having troubles with this too.
Your previous posting of this question already received an answer to that question.
Zap-Man wrote: I come up with unhandled win32 exceptions.
Perhaps posting the exception message along with the relevant code that creates the exception might help people have some idea what the problem is. AFAIK, the members of this site are just normal humans, without any clairvoyant powers.
|
|
|
|
|
yep your right but the response did not answer my question. and if you were to read what I posted you could see that I did post with relevant code. I'm unsure of what creates the exception. its a generic error and leads to nothing to help be debug the problem.
I was hoping that maybe someone else has done somthing like this or knows of any links that my help!
|
|
|
|
|
Zap-Man wrote: and if you were to read what I posted you could see that I did post with relevant code
Maybe in your other post (I haven't checked) but not in this one. I don't know what the hell you did or how you went about doing it. I'd listen to the other reply and heed his/her advice.
|
|
|
|
|
|
Zap-Man wrote: but the response did not answer my question.
Really?
Christian Graus wrote: A flash control is not going to draw itself transparently, ever.
That's not an answer? Whatever. Good luck.
|
|
|
|
|
how to create user and set sql authentication for an existing data base programatically using c#
|
|
|
|
|
|
Hi,
I have this function in a DLL.
long MatchPage (long hImage, long hTemplateList, long *hMatch, char *szTemplate, long iMinMark, long bRegister, long *iConfidence);
Purpose
Match a filled form image to a Template from a Template List.
Parameters
hImage
Image handle of filled form
hTemplateList
Handle of the Template List.
hMatch
Handle of a Match which can be used later by JIRegionsRecognize. The handle should be free later by JIMatchFree.
szTemplate
Template file name is returned here. File name is returned without path and without file name extension.
iMinMark
Minimal confidence for a match. Legal values are 0-100. Recommended value is 15.
bRegister
If 1, the registered image is returned in hImage if matching achieved.
iConfidence
Confidence of the Match.
Import in this way:
[DllImport("image.dll")]
public static extern long MatchPage(IntPtr hImage, IntPtr hTemplateList, out IntPtr hMatch, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szTemplate, long iMinMark, long bRegister, out IntPtr iConfidence);
...and call in this way:
rc = (int) MatchPage(hImage, hTemplateList, out hMatch, matchingTemplate, 25, 1, out iConfidence);
but the compiler says:"Access Violation" .
Someone can help me please?
TY
|
|
|
|
|
Hi,
Some of it looks good, some is less clear. It is always difficult to pinpoint what exactly is wrong; I tend to (1) keep data exchange simple and (2) add logging code on both sides, so I can see which arguments get accross correctly and which don't.
I do have 2 comments:
1.
a native long* can be passed as a managed out long or ref long, it does not need an IntPtr at all. The way your template has it, it is promising the managed world will receive an output pointer, which then natively would require long**
Chances are this is what is causing the error.
2.
I just don't know about szTemplate, I never use [MarshalAs(UnmanagedType.LPStr)] StringBuilder. I prefer a more verbose but easier to understand style as in:
[DllImport("image.dll")]
public static extern long MatchPage(..., StringBuilder szTemplate, ...);
StringBuilder sb=new StringBuilder(1000);
MatchPage(..., sb, ...);
string s=sb.ToString();
You must set an initial capacity, that is the size used to allocate the character buffer; and the safe way is to pass that Capacity to the native world so it won't overflow the buffer (similar to strncpy).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 8:42 AM
|
|
|
|