Jump to content
Xtreme .Net Talk

Kirk_G

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by Kirk_G

  1. anyone?
  2. Can anyone tell me if I'm missing something obvious here or is theresome fundamental reason this can't be done? Thanks
  3. Here is an updated code snipet from a simpler example I created just to test this point public delegate childForm AsyncLoadMDIDelegate(string filename); private void openItem_Click(object sender, System.EventArgs e) { OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Title = @"Select Image Files"; openDialog.Multiselect = true; if(openDialog.ShowDialog() == DialogResult.OK) { foreach(string name in openDialog.FileNames) { //This commented out section works just fine //childForm newChild = new childForm(name); //newChild.MdiParent = this; //newChild.Show(); //Not sure why this doesn't work AsyncLoadMDIDelegate loadMDIDelegate = new AsyncLoadMDIDelegate(this.loadMDI); IAsyncResult asyncResult = loadMDIDelegate.BeginInvoke(name,new AsyncCallback(this.CallBackHandler),loadMDIDelegate); } } } public void CallBackHandler(IAsyncResult result) { AsyncLoadMDIDelegate loadMDIDelegate = (AsyncLoadMDIDelegate)result.AsyncState; childForm newChild = loadMDIDelegate.EndInvoke(result); newChild.MdiParent = this; //This is where the program doesn't work newChild.Show(); } public childForm loadMDI(string filename) { childForm newChild = new childForm(filename); return newChild; } Can anyone tell me why this doesn't asyncronously load MDI wondows. I don't get any exceptions, they just don't show up. The newChild.Show(); never runs because it never gets past the newChild.MdiParent = this; never works? Any help would be appriciated. Thanks Kirk
  4. I have a MDI application in C# that loads image data in MDI windows. The child form has a constructor with a filename parameter for the image data. If I try to open large files or files over a network it can be slow and halt the parent program. Is there a way to asyncronously load MDI windows? I have tried creating a delegate with the child forms signature, calling the delegates BeginInvoke method with a callback method that sets the child forms parent to "this" but there seems to be some fundamental problem with this idea. Everything is great up to the point where I try to set the MDIparent parameter to "this". Here is a snipet: public delegate ChildForm Async_ChildFormDelegate(string filename, bool logdata); //Now inside of ParentForm class public void LoadUnloggedData() { OpenFileDialog mydialog = new OpenFileDialog(); mydialog.Title = @"Open Un-Logged Images"; mydialog.Multiselect = true; if(mydialog.ShowDialog() == DialogResult.OK) { foreach (String name in mydialog.FileNames) { Async_ChildFormDelegate AsyncLoadOCT = new Async_ChildFormDelegate(Async_LoadData); IAsyncResult asyncResult = AsyncLoadOCT.BeginInvoke(name,true,new AsyncCallback(CallbackHandler),AsyncLoadOCT); } } } public ChildForm Async_LoadData(string filename, bool logdata) { ChildForm newOCT = new ChildForm(filename,logdata); return newOCT; } public void CallbackHandler(IAsyncResult result) { Async_ChildFormDelegate childForm = (Async_ChildFormDelegate)result.AsyncState; ChildForm newOCT = childForm.EndInvoke(result); newOCT.MdiParent = this; // Set Cursor Size newOCT.Xsize = sizeX; newOCT.Ysize = sizeY; // Display the new form. newOCT.Show(); } Everything is fine until newOCT.MdiParent = this; at which point the program jumps back up the top of the callbackhandler method, reruns the first 2 lines and leaves the method. The parent window come back up with no MDIchild loaded. Any ideas? Thanks Kirk
  5. I am trying to get a simple server/multi-client program working but have run into a security exception. The server is a console program in C# that hosts a single class. The client is a forms program that has a ListBox to contain the messages, a TextBox to input a new message, and send button. When the client program loads it obtaines a reference to the MBR class hosted by the server. It then runs a method on the class called AddUser with the following signature ArrayList users = new ArrayList(); public void AddUser(ref ListBox newLB) { users.Add(newLB); } The thought was that when a new message was sent to the server by a client, the server would go through the ArrayList of referenced ListBoxes and update each one, thereby updating the ListBoxes on all the clients. This gives an exception though. I tried a simpler case of creating a new method on the served class with the following signature: public void ChangeString(ref string msg) { msg = @"Changed by Server"; } I then added string to the client side and set it value to @"Set by Client". If I display the string's value to the console before and after using it as the argument to the ChangeString method, I can see that it does indeed change when being set by ref to the server. My question is, why is a string different from a ListBox? Is there some security setting I can change to allow this to work? Is there a better way? Thanks in advance. Kirk
  6. I think I figured it out. I just had to stop the service, then go into the registry under services and delete it. Please reply if there is a better way to do this. Thanks
  7. Next dumb question. I was able to successfully install and use the Windows Service in Win2K. Now how do I remove it. I see how to disable it but I can't make changes and recompile because I get an error saying the resources are being used by another process. Thanks
  8. Thanks, that worked great.
  9. I've got a windows service that I would like to run but can't seem to get it installed. I run the installutil program using the service as the parameter and a dialog box pops up asking for a logon name and password for the service. I have tried every user/password combo on my PC including administrator and can't get it to work. It says the install failed because of invalid password, username, etc. In the service util in win2K I see that most services use a LocalSystem logon. How do I find the password for this? Any help would be appriciated. Thanks
  10. Does anyone have a sample code in C# of how to do two way communication over the serial port? Thanks
  11. Nevermind, I found the answer. If anyone is interested I can post the code.
  12. I have written a program in C# that reads in some raw data (a 2D matrix stored in a tab delimited text file) and creates an image from it after some calculations and scaling. Currently you have to open the files through the menu which opens a OpenFileDialog window to get the filename. I would like to have my program also work by dragging a file onto the Form (which is actually a MDI parent form) and opening showing new image. From what I understand the drag and drop thing works similar to cut and paste but all I want is the filename of the file being dragged and dropped so I can open, perform my calculations, then display image. Does anybody know of a simple way to get just the filename of a file that is being dragged and dropped onto a form? Thx, Kirk
  13. That worked perfectly, thanks again for fixing my code JABE!!
  14. In my program I have custom dialog box that might or might not be open. If the dialog box is open I would like the program to update it at certain times. When I create the dialog box I make it owned by the main program. foreach(Form f in this.OwnedForms) { customDialog tempDialog = (customDialog)f; tempDialog.Zmax = blah; tempDialog.Zmin = blah; tempDialog.AutoScaleZ = blah; } this works fine for now because this dialog box is the only thing that the main program owns. My question is, how can I setup an if statement that only accepts when f is a customDialog box? I tried things like: if(f == customDialog) if(f == typeof(customDialog)) if(typeof(f) == typeof(customDialog)) but all of these caused errors. Any ideas would be appriciated. Thanks
  15. I'm not sure about the Ctrl+B but you could make it Alt+B by making the text of the button "&Button". Just place the & character in front of any letter you want as the shortcut. Hope this helps.
  16. So here is basically how the code I got working is setup: public class ChildForm : System.Windows.Forms.Form { private ParentForm tempParent; " " public ChildForm() { ... } private void ChildForm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { tempParent = (ParentForm)this.MdiParent; tempParent.sbCoords.Text = @"test"; } } In my program I have a parent form (type ParentForm) in which I have a statusBar with a panel called sbCoords. This code shows how to send text from a child (ChildForm) to the parent. The important thing to remember is that what ever you want to access in the parent has to be made public (properties, variables, statusBar panels, etc). Hope this helps some other people out there.
  17. Actually I got it working. The problem was where I placed the code. The declaration: private ParentForm tempParent; Was placed as a "global" variable for the ChildForm class and I had written the rest of the code in the constructor of ChildForm. I guess that the MDIParent of the ChildForm had not been set yet. When I moved the code to another Method that was called by a mouse click after the constructor it worked fine. Thanks for your help.
  18. I tried that too. Same result.
  19. So I have the following code inside the ChildForm: private ParentForm tempParent; tempParent = (ParentForm)this.Parent; iFilename = tempParent.Fname; iNum = tempParent.Num; Where Fname and Num are public properties in the ParentForm. When I run this it crashes and on debugging I find that it is because this.Parent and tempParent are undefined. Any ideas? Thanks, it sounds like I'm on the right track :)
  20. I have a MDI related question. How can you access public variables or public properties of the Parent form from a Child form? Its easy enough to send or retrieve info to the child from the parent, but how does the Child send or retrieve info (variables) from the Parent. I've tried using the this.MDIParent.(blah blah blah) but it doesn't show me any public variables or properties I've created in the Parent. Any help would be appriciated. Thanks
×
×
  • Create New...