Thanks much, I'll give that a try. Neil Lamka neil@meetingworks.com
Neil Lamka
Posts
-
Multiple UI threads in a single application -
Multiple UI threads in a single applicationI have an application that consists of a main windows form and a 2nd thread that handles communications back to a server. Based on a command stream from the server the main thread starts other windows forms that share an event/notification message structure. Since each of the newly created windows forms totally control the UI and handle messages related to the tool passed through the event system I wanted to run each on an independent UI thread instead of having all windows running off of the single main UI thread. In playing around with this I have not found any examples and have been unsuccesful at trying to figure out a structure that would do what I'm trying to accomplish. Any suggestions or pointers. Thanks Neil Lamka neil@meetingworks.com
-
Shortcut enumI would like to have a menu shortcut for Ctrl+Alt+F1 but don't find that combination in the Shortcut enum. Is there a way to create this shortcut string by ORing values or some other method that I have not found yet. Thanks Neil Lamka neil@meetingworks.com
-
Understanding ConfigurationSettingsOk, so I know I'm missing something very basic here but I am having a problem understanding how ConfigurationSettings work. I've looked at the various examples but still can't get it to work for me. I have a Windows application ... application name testapp. I've created a configuration file named testapp.exe.config and copied the file into (in this case) the bin\debug directory along with the EXE file. The config file looks like the following... copied from one of the examples: In my code I have the following statement. string appName = ConfigurationSettings.AppSettings["Application Name"]; What I get is appName = null and the config file is removed form the debug\bin directory. So, 1st, should the config file be being deleted..if so, are the actual settings stored someplace? and 2nd, what am I missing by not being able to read the value for "Application Name" give the above code and config file. Thanks for the help Neil Lamka neil@meetingworks.com
-
Setting events - beginner questionOk, Let me try again. What I'd like to be able to do is (from a class in a managed DLL) to take a method name from a file, create a menu item and set the "OnClick" event to use that method. What I have been able to figure out is how to set an onclick event handler that resides in my DLL and then to use Invoke to route the event to the desired handler within the application. I was looking for a direct way to wire the event handler to the menu item without the intermediate handling. I have the MethodInfo for the desired (real) event handler but don't see any way to use that to set the OnClick event using that information. An example would be something like &File My_Handler .... in the DLL string caption = ... get the caption from the xml string onclick = ... get the handler from the xml MethodInfo mi = ... get the MethodInfo for "My_Handler" (from onclick) //* I'm using the MagicLibrary .. which is where the MenuCommand lives MenuCommand mc = new MenuCommand( caption ); mc.Click += ??? using the MethodInfo from above. What I do have is the above but with mc.Click += new EventHandler(menu_Click); //menu_Click is my internal handler) private void menu_Click(object sender, System.EventArgs e) { MethodInfo mi = .. get the Method info for the real handler .... mi.Invoke(_callingInstance, args); .... } So..the .Net of what I'm trying to do is to use what I can find out from Reflection to wire a menu item directly to the target event handler without having to use Invoke and this event redirection. Hope this helps Neil Lamka neil@meetingworks.com
-
Confused by InvokeI am trying to play around with automating menu creation through external XML files. I've used several of the examples found in Code Project and I'm trying to bind the menu items to the MagicLibrary menu classes. I'm getting close...but I'm stumped by trying to invoke a method in the calling application from my menu helper class. What I have is the following The menu helper class is created by the main application and it reads the xml file and creates all the MagicLibrary MenuCommand items..that all seems to work fine. Within my menu helper class I have hooked into the menu click event and have the following method. The method retrieves a previously found and saved MethodInfo item that matches the actual method I want to call in the main application private void menu_Click(object sender, System.EventArgs e) { object[] args = {sender, (object)e}; MethodInfo mi = (MethodInfo)onclickList[ (string)mc.Tag+".Click" ]; if (null != mi) mi.Invoke(null, args); } The method I'm trying to invoke in the main application looks like the following public void menuNew_Click(object sender, System.EventArgs e) { //* Code to do stuff in my application based on the menu click //* event } What I get is an unhandled exception An unhandled exception of type 'System.Reflection.TargetException' occurred in mscorlib.dll Additional information: Non-static method requires a target. Which has me stumped. I'm obviously not doing something right but I don't know what I'm missing. Any help would be appreciated. Thanks Neil Lamka neil@meetingworks.com
-
Setting events - beginner questionThanks for the pointer. If I use this method then I'm assuming that in my DLL that handles reading the XML definitions for menus and all that I'd have 1) Set an "OnClick" event handler internal to my DLL and then 2) When processing the OnClick event figure out the real target menthod that should process the event and use the Invoke as you described. Is there any way to set the event handler for the menu item so as to bypass having to handle the event and route it? I'd like to get out of the way and just wire the menu directly to the desired handler. I was hoping that once I found the MethodInfo for the target method I would be able to set the menu event handler directly. Or is that what your note allows me to do and I just did not understand. Thanks Neil Neil Lamka neil@meetingworks.com
-
Setting events - beginner questionI'm trying to educate myself on C# and .Net. I decided to try and use the techniques outlined by Marc Clifton ("Using XML to generate Menus") but to use it with a different UI tool kit along with extending the menus.xsd to support imagelists. What I'm looking for is a method of taking an input name (of an imagelist or a method) passed in the xml definition or the menu and use that name to pass the actual object or method to the appropriate constructors etc. I've found that I can find the appropriate MethodInfo information using reflection and can find the FieldInfo information for an imagelist but I can't seem to figure out how to use that information to accomplish my objective. I'm using the Crownwood Magic Library menus that have a MenuCommand constructor that will take an imagelist and index value for the menu image and will take an EventHandler for an OnClick event. Is there a way to use the information retrieved form the reflection methods to set the event handler and to set the imagelist from the names passed in the xml. Thanks for the help Neil Lamka neil@meetingworks.com
-
OWNERDRAW Listbox helpI finally had a chance to try your suggestion and it did not seem to help. Any other places you would suggest I look or things I should try? The strange thing (to me at least) is that reducing the subclass procedure to simply return the default procedure reply (as my example shows) results in the same problem. Thanks Neil Neil Lamka neil@meetingworks.com
-
OWNERDRAW Listbox helpI have an application that subclasses an LBS_OWNERDRAWFIXED listbox window. When I subclass the window it seems to break the listbox so that horizontal scrolling and painting do not work correctly (perhaps other things as well that I have not gotten to yet. Assuming that it was a problem with my subclass procedure I reduced it to the following code: //* The listbox definition in the dialog resource LISTBOX ID_USERS_LISTBOX, 3, 22, 324, 185, LBS_OWNERDRAWFIXED | LBS_MULTICOLUMN | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP //* Subclass the listbox earlier in the code.... fpOldListProc = (FARPROC) SetWindowLong(hWndList, GWL_WNDPROC, (DWORD)ListProc); //* Listbox subclass procedure LRESULT APIENTRY ListProc( HWND hWnd, UINT Message, WORD wParam, LONG lParam) { return CallWindowProc((WNDPROC)fpOldListProc, hWnd, Message, wParam, lParam); } with the same result. It is worse in Win2000 than in Win/98 but basically the same kinds of problems are there. In Win2000 the items the space below the bottom row in the listbox and below and to the right of the last row of items is not repainted as well as horizontal scrolling not working correctly. I've tinkered with this for a week and I'm at a loss. Any suggestions or pointers would be greatly appreciated. Thanks Neil Neil Lamka neil@meetingworks.com