|
I am using Asyncallback in .net CF development in a button_click event. There is no problem when I complie and deploy the program, but as I click the button to start the event, error occured. The message is 'An unhandled exception of type 'System.NotSupportedException' occurred in System.Windows.Forms.dll', and it stopped at 'application.run(new form())' I used the begininvoke to start the callback, and endinvoke to get the result. I used ppc 2003 emulator, and vs2005. Thanks for your help.
Here comes part of my code:
private delegate int CalcDelegate(int input1, int input2, ref string strResult);
CalcDelegate mDeleg;
private void button1_Click(object sender, System.EventArgs e)
{
mDeleg = new CalcDelegate(Calc);
int input1 = Convert.ToInt16(textBox1.Text);
int input2 = Convert.ToInt16(textBox2.Text);
string strResult = null; // dummy parameter
AsyncCallback cb = new AsyncCallback(CalcCallback);
IAsyncResult ar = mDeleg.BeginInvoke(input1, input2, ref strResult, cb, null);
Thread.Sleep(1000);
}
private void CalcCallback(IAsyncResult ar)
{
string result=null;
int output = mDeleg.EndInvoke(ref result, ar);
textBox3.Text = output.ToString();
}
|
|
|
|
|
This is not the first time I've seen this, either...
I create a RichTextBox, and I catch some keydown events. I want to catch CTRL-I, CTRL-B, and CTRL-U for changing selected text (italic, bold, and underline). It works fine with CTRL-B and CTRL-U, but when I hit CTRL-I, the richtextbox inserts tabs in there, too. For example (if you were to open the RTF files in Notepad), this line:
... bla bla bla ...
turns into:
... \i\tab bla bla bla \i0\tab ...
instead of:
... \i bla bla bla \i0 ...
And, if I do it right, it seems to replace the selected text with an italicized tab.
Any ideas?
-Daniel
-- modified at 14:25 Monday 8th May, 2006
|
|
|
|
|
I believe you want to catch the KeyDown or KeyPress event (not sure which one). One of these events lets you tell the event handler that you have processed the key and this prevents the underlying UI control from seeing it.
|
|
|
|
|
I currently am catching the KeyDown event. I'll see if setting the KeyEventArgs e.Handled to true helps at all...
-Daniel
|
|
|
|
|
Nope, no change. It still inserts a tab character. I thought it might have something to do with setting the rtfbox's AcceptsTab to true, but it does it whether it's true or false.
-Daniel
|
|
|
|
|
Well, I figured out a work-around, in case someone else gets as annoyed as I did at how the RichTextBox inserted tabs when it shouldn't.
I put in a global bool ("handled").
I have a KeyDown handler, and a KeyPress handler.
In the KeyDown, it sets "handled" to false, and checks for all the CTRL-[x] key strokes (where 'x' represents any other key on the keyboard).
If CTRL-I is pressed, "handled" is set to true.
Then, in the KeyPress handler, e.Handled is set to "handled" (meaningless for all the other CTRL-[x] keystrokes).
Basically, I had to tell the RichTextBox to ignore CTRL-I. I don't know why. I don't see a difference between CTRL-I and CTRL-[x], as far as the underlying control is concerned; and I don't see why CTRL-I is so special that the RichTextBox would trigger a tab-insertion on it and no other.
Oh well. It's fixed now. Thanks anyway!
-Daniel
|
|
|
|
|
You could also have overridden IsInputKey for RichTextBox and filtered out TAB characters.
Incidentally, the difference in Ctrl+I and Ctrl+{x} is that Ctrl+I is also the ASCII representation of tab (CHR 9). (You can open Notepad and press Ctrl+I in the text area; it tabs over just like you had pressed the Tab key.)
--
I've killed again, haven't I?
|
|
|
|
|
Wow, thanks, Office Lineman! I had looked into the IsInputKey, and I probably would have taken that route if I knew CTRL-I's relationship with the tab character.
By the way, I didn't know that (about CTRL-I being the keystroke for tab). That might make typing a tab character into web form text boxes a little easier!...
-Daniel
CodeProject rocks.
|
|
|
|
|
Hi..
I want to use the CmdLoadFromResource() method of ths speech SDK 5.1 to make the xml file that includes the Grammar embeded but i dont know how to use this method in C#.
This code shows how i used this method:
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long LoadLibrary(string lpLibFileName);
private void button2_Click(object sender, System.EventArgs e)
{
this.objRecoContext = new SpSharedRecoContext();
this.objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);
this.objRecoContext.State=SpeechRecoContextState.SRCS_Enabled;
grammar = objRecoContext.CreateGrammar(0);
int hModule=Convert.ToInt32(LoadLibrary("ReviewWinApp.dll"));
int langID=409;
grammar.CmdLoadFromResource(hModule,"tryRecog.xml","CFGGRAMMAR",langID,SpeechLoadOption.SLODynamic);
grammar.State=SpeechGrammarState.SGSEnabled;
grammar.CmdSetRuleIdState(1,SpeechRuleState.SGDSActive);
}
When i click this button i got the error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ReviewWinApp.exe
Additional information: The specified resource type cannot be found in the image file.
I am not good in COM programming.Could any one give me a C# code sample for using this method?
|
|
|
|
|
When the main window of a .NET Windows Forms app is partially occluded by other windows, clicking one of the app's exposed menu items correctly activates the form but doesn't display the menu.
I know this is in keeping with MS' new UI guidelines (as seen in Office 2003 apps), but I'd like my app to behave like an older style MFC app. I recall seeing an article/note that explained how to do this but don't seem to be able to find it. A pointer would be much appreciated.
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Hi everybody!
I have DataGridView whose sourse I set to a datatable with 4 columns
containing data. I then remove two columns, create a DataGridViewComboBoxColumn and DataGridViewCheckBoxColumn and insert this into the same location as the columns that were removed. I want to set as the selected value in the combo box of every cell in the DataGridView a specific value. I have done it, but once the debugger leaves the file with the code that executes this functionality, the values that were set in the combo box and check box are lost.
I don't know whether the problem is because I removed and then added these columns. At the end of the Load() method I have this line: dataGridView.AutoGenerateColumns = false; if I don't use it, the column that I removed appears again. Any idea about why the value of the DataGridComboBoxColumn is changed to null automatically and how to solve it?
Other thing is that if I change the values of the combo box in the datagridview and later I want to save them, when I get the values are not the ones I chose, but the values that I set at the beginning as the datasource of the datagridview.
This is part of the code I’m using:
private void FrmTestCases_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Path", typeof(string)));
dt.Columns.Add(new DataColumn("Category", typeof(string)));
dt.Columns.Add(new DataColumn("Include", typeof(string)));
dt.Columns.Add(new DataColumn("Description", typeof(string)));
dataGridView.DataSource = dt;
dataGridView.Columns.Remove("Category");
dataGridView.Columns.Remove("Include");
DataGridViewComboBoxColumn cb = new DataGridViewComboBoxColumn();
DataGridViewCheckBoxColumn kb = new DataGridViewCheckBoxColumn();
cb = CreateComboBoxColumn("Category", "Category");
kb = CreateCheckBoxColumn("Include", "Include");
dataGridView.Columns.Insert(1, cb);
dataGridView.Columns.Insert(2, kb);
}
// ---------
private void OnFormClosing(object sender, FormClosingEventArgs e)
{
DataRowView testCase = (DataRowView)dataGridView.Rows[0].DataBoundItem;
String fileStream = testCase["Include"] + "," + testCase["Category"];
}
I've been working on it for days but NO LUCK !! Can you please give me a hand?!
Elvia
|
|
|
|
|
Hi, I was wondering how to make the unvisible btnClose visible when btnOpen is Clicked, then hide btnOpen when btnClose is Clicked, so it is kind of like a loop. Feel free to email me
|
|
|
|
|
btnClose.Show();
btnOpen.Hide();
etc.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
void btnOpen_Click(object sender, System.EventArgs e)
{
btnOpen.Visible = false;
btnClose.Visible = true;
}
void btnClose_Click(object sender, System.EventArgs e)
{
btnOpen.Visible = true;
btnClose.Visible = false;
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
www.troschuetz.de
|
|
|
|
|
I have solution with almost 100 projects. I have one startup project. Everytime if there is any changes in one of the projects i am pressing F5 to build all the projects, which is taking about 30-40 mins. And i don't have provision to uncheck the Build check box in configuration manager of solution, its locked.
Is there any way i can test and debug just the changes made. I tried Attach to process. From bin folder i executed the exe of startup project and try to attach one of the changed projects from solution (which is other than start-up), sometimes it is attaching and sometimes not. Even if it attaches i am unable to debug the changes made.
I am using Framework 1.1
Any help, Very urgent
Thanks
Santosh
|
|
|
|
|
First off, you can try to enable the Incremental Build feature of studio to prevent those long build times. I am assuming you're using VS 2003: go into your Project Properties->Configuration Properties->Adavanced and enable (set to true) the Incremental Build (you can read more about this feature in on-line help).
Attach to process works, provided the EXE and the code are insynch with one another; in other words, if you make too many changes to the the code, and attempt to attach to that running process, despite the fact that you have break-point set, it maynot allow that breakpoint to execute.
If you just want to rebuild out one of the sub-projects, you can right-click on that project in solution explorer, and click Rebuild; it should only rebuild that project and anything the changes made will effect ...
Good-luck!
:..::. Douglas H. Troy ::..
Bad Astronomy |Development Blogging|Viksoe.dk's Site
|
|
|
|
|
Is there a way to clear the history of a webbrowser? I have a winform that uses a webbrowser, but when I go from one process to another I'd like its history to be cleared so that the back button goes no further than the current process's first page.
|
|
|
|
|
FoxholeWilly wrote: back button goes no further than the current process's first page
The back button history is persistent across processes? Can someone confirm this? It sure doesn't work that way in IE or Firefox browser desktop instances.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
You assume too much with the word "process." I am using it in its generic form. I have a webbrowser, a user pushes a button, and it displays some content, then does something completely different, then pushes a button, and other content is displayed in the webbrowser. I would like to clear the navigation history so that when the user pushes "back" he does not go beyond the initial page from the second time the webbrowser was used.
|
|
|
|
|
FoxholeWilly wrote: You assume too much with the word "process."
Yeah sorry about that.
I got your original reply by email. I can understand how you thought that.
I have used WebBrowser in applications where I create new instances of it during the lifetime of the application (process). I thought you were meaning that and the history was still present across the different instances. I was interested since it would effect the behavior of my applications.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
Sorry about the original reply, it was one of those stupid and impulsive messages that one regrets the moment the "Post" key is pushed.
I figured I would have to just dispose and recreate the webbrowser control each time, but was hoping there was a simple yet illusive command that would clear the history, something like WebBrowser.ClearHistory() (hint, hint, Microsoft)
|
|
|
|
|
in your html page put the following
history.forward
this vil work good
regards
kalyan
|
|
|
|
|
I'm trying to get javascript to work from within a js file which is embedded into a custom control. I am able to get embedded style sheets and images in the same control to work fine. I have used reflector to verify that the .js file is there and has the correct path. I have tried three methods of referencing the js file in my OnPreRender method. I have used RegisterClientScriptInclude in conjunction with GetWebResourceUrl. I have used RegisterClientScriptResource. I have tried just setting up a LiteralControl with the script reference and adding it to the header, using GetWebResourceUrl to get the URL. In all these cases, the script tag is rendered on the page with a url that looks like this:
<script src="/control_test/WebResource.axd?d=kN16ZCatkm1MQ5JqEow-rFnxOlL1FcRrnlZIuw4pdq5WQtMe1QPxJ5N0g5Bj_QiVljlpuyQ3oGq1EsHpF2JdEw2&t=632826839637949892" type="text/javascript"></script>
but when I try to call a function from the file, I get an 'object expected' error. If I put http://localhost plus the url listed in the script tag into my browser, it returns a file called WebResource.axd which has the contents of the javascript file. It seems like if that is happening, then the browser should have access to the file. Could this be some type of mime type problem? I have the mime type in my AssemblyInfo.cs as text/javascript.
Jason
|
|
|
|
|
Nevermind. The javascript is actually loading, it's some other problem.
|
|
|
|
|
Hi, i wanna allocate memory for some data but i dont know how.
With C it loks like
struct MyStruct
{
int number;
string Name;
struct *Next;
}
But i dont know how do that in C#
so could some one help me.
??
thx
|
|
|
|
|