|
As mav pointed out, you will need to use reflection. Here is a quick example to get you going:
MethodInfo mi = typeof(Form).GetMethod("Close",
BindingFlags.Instance | BindingFlags.Public);
if(mi != null)
mi.Invoke(this, null);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Why do I get this error???
currency.cpp(72) : fatal error C1004: unexpected end of file found
/* Currency equivalence to the Dollar*/
#include <stdio.h>
float Australian_Dollar; //Australian Dollar
float Euro; //Euro Dollar
float British_Pound; //British_Pound Dollar
float Japanese_Yen; //Japanese_Yen Dollar
float Swiss_Franc; //Swiss_Franc Dollar
/* Dollar conversion */
int main(void)
{
/* 13 */
int menunum; /*Defines the menunum as an integer for the scanf */
int final1;
float count;
{
while (final1 != 0)
printf (" Select a currency by entering a the number beside the currency. \n\n");
printf(" Enter q to quit.\n\n");
printf (" 1. Australian Dollar \n");
printf (" 2. Euro \n");
printf (" 3. British Pound \n");
printf (" 4. Japanese Yen \n");
printf (" 5. Swiss Franc \n"); /* 28 */
scanf("%f", &menunum); /* 30 Users enters the number on the menu bar */
if (menunum == 1){
printf("%f\n", Australian_Dollar);
} /* Australian_Dollar */
else if (menunum == 2) {
printf("%f\n", Euro);
}
else if (menunum == 3) {
printf("%f\n", British_Pound);
} /* 41 British_Pound */
else if (menunum == 4) {
printf("%f\n", Japanese_Yen);
} /* Japanese_Yen */
else if (menunum == 5) {
printf("%f\n", Swiss_Franc);
} /* 51 Swiss_Franc */
else {
printf("Choose another or quit.\n");
}
Australian_Dollar = 1.43; // 50 Define Australian dollar
Euro = 0.83; // Define Euro currency
British_Pound = 0.55; // Define British Pound
Japanese_Yen = 110.9; // Define Janpanese Yen
Swiss_Franc = 1.28; // Define Swiss Franc
scanf("%f", &final1); /* 30 Users enters the number on the menu bar */
return 0;
}
|
|
|
|
|
1.) Why do you ask a CPP question in the C# forum?
2.) Why don't you give a file to include at the very start of your code?
Mav
|
|
|
|
|
|
I have problem in crystal report,exception text below:
************** Exception Text **************
System.IO.FileLoadException: The located assembly's manifest definition with name 'CrystalDecisions.Shared' does not match the assembly reference.
File name: "CrystalDecisions.Shared"
at CRTest.Viewer..ctor(String reportFilePath, String param1)
at CRTest.ParamForm.okBt_Click(Object sender, EventArgs e) in d:\myprogram\reporttest\crtest\paramform.cs:line 92
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
=== Pre-bind state information ===
LOG: DisplayName = CrystalDecisions.Shared, Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
(Fully-specified)
LOG: Appbase = C:\Program Files\FE-Creation\CRTest\
LOG: Initial PrivatePath = NULL
Calling assembly : CrystalDecisions.CrystalReports.Engine, Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304.
===
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from C:\WINNT\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: CrystalDecisions.Shared, Version=9.1.5000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304
LOG: Attempting download of new URL file:///C:/Program Files/FE-Creation/CRTest/CrystalDecisions.Shared.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
////////////
Please tell me about solve this problem.
Thanks.
สวัสดีครับ
|
|
|
|
|
It looks like your app referenced a version of Crystal Reports (9.1.5000.0) and the version of Crystal Reports that's installed on the machine your running your app is different. You must have the same version of the .DLL's on the target machine as what you developed your app against.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I create a object which inherits from TextBox class,I hope no contextMenu display when click mouse right button in the new object. How to cancel the event or cancel the contextMenu !
|
|
|
|
|
Create a new ContextMenu without any items and assign it as the ContextMenu for your TextBox like this.
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
ContextMenu cm = new ContextMenu();<br />
myTextBox1.ContextMenu = cm;<br />
}
|
|
|
|
|
Actually it would be better to do this within the class, that way you don't have to worry about it if you want to do use it again somewhere else.
public class TextBoxEx : TextBox
{
ContextMenu cm = null;
public TextBoxEx()
{
cm = new ContextMenu();
base.ContextMenu = cm;
}
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Anyone know how to get the Full Path of a process in the Process List
i Tried getting it's start info and .WorkingDirectory but it was all blank.
Sample:
Process[] xi= Process.GetProcessesByName(proc);
ListViewItem fo = applist.Items.Add(xi[0].ProcessName.ToString());
string dir = xi[0].StartInfo.WorkingDirectory.ToString() + xi[0].ProcessName.ToString() + ".exe";
|
|
|
|
|
Is there anyway to programmatically limit an application to one cpu?
I have a third party tool that dies on multiprocessor computers but it works great on one processor.
Any ideas?
|
|
|
|
|
Is your application multithreaded? It could be that your code is not actually thread-safe, but you haven't actually tested it enough on uniprocessor machines to see it fail.
|
|
|
|
|
On Task Manager you can use "Set Affinity..." menu to limit it to only one CPU.
There are API calls to control processor affinity.
Yes, even I am blogging now!
|
|
|
|
|
There's a Win32 API function SetProcessAffinityMask
Maybe that can help
"It was when I found out I could make mistakes that I knew I was on to something."
-Ornette Coleman
"Philosophy is a study that lets us be unhappy more intelligently."
-Anon.
|
|
|
|
|
Sweet, thanks for the quick replys.
Arun
My application that uses the third party tool is not multithreaded.
Daniel
Yeah, I saw that in the task manager, that's what led me to believing that the multi cpu was the problem because when I did set the affinity to just one cpu it works great.
parths
Sweet, I'll have to try that out and see if I can limit it using that call.
UPDATE:
I tried that SetProcessAffinityMask method and it worked like a charm. I added what I did to the www.pinvoke.net/[^] collection. Love that site. Thanks for you help.
|
|
|
|
|
I'm in a somewhat sticky situation.
I'm developing an Explorer Bar (for IE). In my implementation, I used a few singletons for very important (core) classes which are, by design, singleton. I guess I didn't want to have to manage parent-child relations for conceivably every object I worked with, but it seems like that was a bad decision. This worked okay until I realized that new windows in IE (such as created by Ctrl-N or File->New Window) are running in the same process, and since the singleton pattern I'm using does so with a static accessor (get) property, this system fails as I believe the two instances of the Explorer Bar are running in the same AppDomain because they're running in two different threads of the same IE process. So basically, instead of having separate singletons per thread group, then end up sharing the same singleton, which is bad for Windows Forms objects.
The kinda tricky thing is that my Explorer Bar is multi-threaded, so I can't just implement my singleton accessor using a hashtable keyed on the thread ID. If there were a way to access a thread group ID, or some sort of way to figure out which thread ID or IE window owns that particular CLR instance, that would be helpful.
So any suggestions, managed or unmanaged, would be helpful. Maybe I simply need to rearchitect everything, even though now really isn't the best time for that. I'd rather be able to add a few lines into my singleton accessor (Singleton.Instance) instead.
Thanks!
Arun
|
|
|
|
|
Hello
I have an object. This object contains an enum value, but I do not know which type the value is. I can find out by asking GetType.
The problem is that the object can contain different kinds of enums. All these enums inherit from int, and I want to know the value of this int.
How do I get the value of an object, when I know that the object contains an enum value of type GetType?
Programically(pseudo code), it can be written like:
intGetIntFromEnum(Type type, string enumString)
{
object enumObject = Enum.Parse(type, enumString);
return (int)enumObject; // Here it fails..., even though the enumobject's type is inheriting from int
}
Gooky
|
|
|
|
|
That should work! I use very similar code in a custom XML serializer/deserializer I wrote. This also works:
<br />
MessageBox.Show(((int)Enum.Parse(typeof(AnchorStyles), "Left")).ToString());<br />
It displays "4". Maybe enumObject is returning null , perhaps because the enumString is incorrect?
|
|
|
|
|
Hehe..
Playing a little around....
System.Convert.ToInt32(enumObject) works perfect. Thanks anyway
Gooky
|
|
|
|
|
Hi,
Someone responded to my post before, about how to keep the scroll bar at the bottom of a text field... I didn't understand the code ONE bit, and I am used to vb, with the simple Text1.SelText(Text1) type deal... is there a similar method within c#? i scanned MSN docs to find nothing -_- please help!!!!
|
|
|
|
|
How about the following:
string str = "Nick Parker";
text1.Test = str;
string search = "Nick";
int index = str.IndexOf(search, 0, 0);
if(index != -1)
{
text1.Select(index, search.Length);
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
A new version of wx.NET was recently released. wx.NET provides .NET bindings for wxWidgets, a powerful cross-platform GUI toolkit. wx.NET/wx.Widgets uses the native UI framework on each supported platform: Windows, Linux, and Mac OS X.
The new 0.5 version has many improvements over previous releases. A quick summary of changes:
- Dozens of new classes.
- Full support for Mac OS X.
- New event system: Activated, Closing, MouseEnter, etc. events.
- Easier to use binary downloads for Windows, Linux, and Mac OS X.
- An new build system to make compiling easier along with a user manual to step you through the process.
- 6 new samples and an easy to use sample launcher.
- A new tool to generate C# or VB.NET code from XRC or wxGlade WXG UI layout files. Supports editing of the resulting code and
modifications to the UI similar to the VS.NET System.Windows.Forms designer. - CLS compliant (no more uints).
- Numerous bug fixes.
Key contributors to this release:
- Alexander Olk
- Bryan Bulten
- Mike Muegel
Wx.NET is completely open source and free. More information is available at:
http://wxnet.sf.net/
We have recently started a fundraising campaign to support the work of Alexander Olk on the project. Please see the following for details:
http://wxnet.sf.net/donate.html
Even a little bit will help accelerate development. I've jump started the fund by donating US$150.
Best Regards,
-Mike Muegel on behalf of the wx.NET Development Team
|
|
|
|
|
Mike, due to the large number of threads within the C# forum, you may consider writing an article about using wx.NET and posting it here on CP, otherwise this thread will soon become lost. Good luck.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I'm using Late binding to control powerpoint. I now am at the point where
it does what I want it to do, but I need some eventhandling to know what it's doing.
All the samples I see that deal with events use early binding
(http://support.microsoft.com/default.aspx?scid=kb;en-us;308825)
and this type of function:
<br />
oPPT = new PowerPoint.ApplicationClass();<br />
UCOMIConnectionPointContainer oConnPointContainer = (UCOMIConnectionPointContainer) oPPT;<br />
Since I'm using LateBinding, i Use:
<br />
Object oPPT;<br />
Type objClassType;<br />
objClassType = Type.GetTypeFromProgID("Powerpoint.Application");<br />
oPPT = Activator.CreateInstance(objClassType);<br />
Now when trying to do the same thing with UCOMIConnectionPointContainer it returns NULL because it's just an 'object' due to late binding - How do i fix this?
How can I hook up events when using late binding? Is this even possible?
Thanks
|
|
|
|
|
I have a datagrid that all of its columns are BoolColumnStyle and its DataSource is a table with no relations. I relate this DG with a counter, when I mark true or false in each DataGridCell the counter adds or subtracts (respectively) a certain number. Also I relate a TreeView with this DataGrid that the previous counter works separately for each TreeNode under the TopNode in this DataGrid. I used the following code to make my datagrid to respond to one click :
private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hti = this.dataGrid1.HitTest(e.X, e.Y);
try
{
if( hti.Type = = DataGrid.HitTestType.Cell )
{
int r = (int)hti.Row;
int c = (int)hti.Column;
DataRow dr = table.Rows[r];
DataColumn dc = table.Columns[c];
this.dataGrid1[r,c] = !(bool) this.dataGrid1[r,c];
}
}
catch(Exception ex )
{
MessageBox.Show(ex.ToString());
}
} I have the following problems :
1. The following message appears. I do not know what is the ListManeger or in other words, I do not understand what is the problem.
The ListManeger’s position must be equal to the rowNum.
Parameter name: rowNum Do you want to correct the value? 2. The DataGrid responds to clicks even when there is no any TreeNodes are selected although I make a ckeck if (TreeView.TreeNode IsSelected). I want the DataGrid to respond to clicks only when any TreeNode under the TopNode is selected.
3. when the selected TreeNode is changed, I empty the DataGrid by the following code, but the last cell that I add a value to it remains checked :
for(int i=0 ; i<table.Rows.Count ; i++)
{
DataRow dr = table.Rows[i];
for(int j=0 ; j<table.Columns.Count; j++)
{
dr[j] = false;
}
} The problems 1 and 3 disturb my counter.
Please if there is a solution.
Thank you
|
|
|
|