Search Results

Search found 2806 results on 113 pages for 'winforms'.

Page 17/113 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • WinForms: How to determine if window is no longer active (no child window has focus)?

    - by Marek
    My application uses multiple windows I want to hide one specific window in case the application loses focus (when the Active Window is not the application window) source I am handling the Deactivate event of my main form. private void MainForm_Deactivate(object sender, EventArgs e) { Console.WriteLine("deactivate"); if (GetActiveWindow() == this.Handle) { Console.WriteLine("isactive=true"); } else { Console.WriteLine("isactive=false"); } } [DllImport("user32.dll")] static extern IntPtr GetActiveWindow(); The output is always deactivate isactive=true I have observed the same behavior if a new window within my application receives focus and also if I click into a different application. I would expect GetActiveWindow to return the handle of the new active window when called from the Deactivate handler. Instead it always returns the handle of my application window. How is this possible? Is the Deactivate event handled "too soon"? (while the main form is still active?). How can I detect that my application has lost focus (my application window is not the active window) and another application gained it without running GetActiveWindow on a timer?

    Read the article

  • How do I drag and drop a folder in Winforms?

    - by Tuntuni
    I would like to know how to drag & drop the folder and get its name. I already know how to do it with a file, but I'm not really sure how to modify it to be able to drag folders as well. Here's the code of the event that is triggered when a file is dropped. private void checkedListBox_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { //I'm only interested in the first file, even if there were multiple files //dropped string fileName = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; } } Thanks, Tuntuni.

    Read the article

  • Winforms - How to allow user to increase font size of listview with hidden controls?

    - by John M
    I am creating an winform application that will run on a tablet PC. One form for this app will have a listview control. I would like to allow the user to change the font size based on preference (ie did they remember their glasses today). A few ways that I can think of would be a numeric-up-down or +/- button controls. Both of these ways require screen real estate that is very limited. Is there a control or technique that would allow font size changes with a hidden-when-not-used control?

    Read the article

  • How do I launch a winforms form from a DLL correctly?

    - by rodent31337
    There's another question similar to mine, but I wanted to gather some specifics: I want to create a DLL that is called from unmanaged code. When the unmanaged functions are called in the DLL, I want to collect information and show it in a kind of form. What I'd like to do is, when DllMain() is called, and the reason is DLL_PROCESS_ATTACH, I would like to instantiate a form. This form should be run on a separate thread. When my function FOO() inside my DLL is called, I would like to take the information from FOO(), dispatch it to the form for rendering. So, more specifically: i) What is the proper way to create a DLL project and have the ability to have Windows forms created in the designer be available to the DLL? ii) What is the correct way to give this form its own thread and message processing loop? iii) How do I dispatch information from the unmanaged DLL functions to the form, or, alternatively a managed class that can update its own state and the form? The form inside the DLL is sort of a "monitor" for data passing in and out of the DLL, so I can keep track of errors/bugs, but not change the core functionality of the DLL functions that are available.

    Read the article

  • Can someone tell me why my dataset wont save correctly to the database in simple winforms app?

    - by Mike
    I have been struggling with this all day and I know it is probably something stupid. My code is below. If I call save then exit my program and start again I can save images to my events but if I just call save when I try to add an image and call save again I get a foreign key error. From what I know I thought my save method was updating the database from my dataset so the event associated with the image should exist. Anyway here is my save method... Private Sub Save() Me.Validate() EventsBindingSource.EndEdit() ImagesBindingSource.EndEdit() TableAdapterManager.UpdateAll(EventDataSet) EventDataSet.AcceptChanges() End Sub Am I doing this wrong? Is this enough detail?

    Read the article

  • What event should I handle to execute code when WinForms application switches from Run mode to Desig

    - by dotnetuser
    I am running a Windows form application and I need to execute a piece of code when I switch to design mode. I have a handler for the OnEnterDesignMode debugger event and this gets hit if I am debugging the application and then switch to design mode. However, this does not get hit if I initially start without debugging and then switch to design mode. What event do I need to handle in order that certain code is executed when switching from Run mode to Design mode?

    Read the article

  • New Themes New Benefits (WinForms)

    We believe that working hard on something can be great fun at the end when everything is done and the seeds have resulted in the sweetest fruits. This is the case with the new Theming Mechanism and the new Visual Style Builder which we introduced as of Q1 2010.   I am not going to dive into any details on the new concepts behind all this stuff, but will simply focus on the numbers: both in terms of loading speed and memory usage. As you may already know, the new approach we use to style our controls uses the so called Style Repository which stores style settings that can be reused throughout the whole theme. As a result, we have estimated that the size of our themes has been significantly reduced. For instance, the size of all XML files of the Desert theme sums up to 1.83 MB. The case with the new version of the Desert theme is drastically different. Despite the fact that the new theme consists of more XML files compared to the old, its size is only 707 KB!   Furthermore, we have performed a simple performance test since the common sense tells us that such a great improvement in terms of memory footprint should be followed by a great improvement in terms of speed. We have estimated that loading and applying the new Desert theme to a form containing all RadControls for WinForms takes roughly 30% less time compared to the same operation with the old version of the Desert theme. The following screenshots briefly demonstrate the scenario which we used to estimate the loading time difference between the old and the new Desert theme:     Here, the old Desert theme is applied to all controls on the Form which takes almost 1,3 seconds.     Applying the new Desert theme (based on the new Theming Mechanism) takes about 0,78 seconds.   On top of all these great improvements, we can add the fact that the new Visual Style Builder significantly reduces the time needed to style a control by entirely changing the approach compared to the old version of this tool. You can be sure that we have already prepared some great new stuff for Q1 2010 SP1 that will simplify things further so that designing themes with the new VSB will become more fun than ever!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • New Themes New Benefits (WinForms)

    We believe that working hard on something can be great fun at the end when everything is done and the seeds have resulted in the sweetest fruits. This is the case with the new Theming Mechanism and the new Visual Style Builder which we introduced as of Q1 2010.   I am not going to dive into any details on the new concepts behind all this stuff, but will simply focus on the numbers: both in terms of loading speed and memory usage. As you may already know, the new approach we use to style our controls uses the so called Style Repository which stores style settings that can be reused throughout the whole theme. As a result, we have estimated that the size of our themes has been significantly reduced. For instance, the size of all XML files of the Desert theme sums up to 1.83 MB. The case with the new version of the Desert theme is drastically different. Despite the fact that the new theme consists of more XML files compared to the old, its size is only 707 KB!   Furthermore, we have performed a simple performance test since the common sense tells us that such a great improvement in terms of memory footprint should be followed by a great improvement in terms of speed. We have estimated that loading and applying the new Desert theme to a form containing all RadControls for WinForms takes roughly 30% less time compared to the same operation with the old version of the Desert theme. The following screenshots briefly demonstrate the scenario which we used to estimate the loading time difference between the old and the new Desert theme:     Here, the old Desert theme is applied to all controls on the Form which takes almost 1,3 seconds.     Applying the new Desert theme (based on the new Theming Mechanism) takes about 0,78 seconds.   On top of all these great improvements, we can add the fact that the new Visual Style Builder significantly reduces the time needed to style a control by entirely changing the approach compared to the old version of this tool. You can be sure that we have already prepared some great new stuff for Q1 2010 SP1 that will simplify things further so that designing themes with the new VSB will become more fun than ever!Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • C# 5.0 Async/Await Demo Code

    - by Paulo Morgado
    I’ve published the sample code I use to demonstrate the use of async/await in C# 5.0. You can find it here. Projects PauloMorgado.AyncDemo.WebServer This project is a simple web server implemented as a console application using Microsoft ASP.NET Web API self hosting and serves an image (with a delay) that is accessed by the other projects. This project has a dependency on Json.NET due to the fact the the Microsoft ASP.NET Web API hosting has a dependency on Json.NET. The application must be run on a command prompt with administrative privileges or a urlacl must be added to allow the use of the following command: netsh http add urlacl url=http://+:9090/ user=machine\username To remove the urlacl, just use the following command: netsh http delete urlacl url=http://+:9090/ PauloMorgado.AsyncDemo.WindowsForms This Windows Forms project contains three regions that must be uncommented one at a time: Sync with WebClient This code retrieves the image through a synchronous call using the WebClient class. Async with WebClient This code retrieves the image through an asynchronous call using the WebClient class. Async with HttpClient with cancelation This code retrieves the image through an asynchronous call with cancelation using the HttpClient class. PauloMorgado.AsyncDemo.Wpf This WPF project contains three regions that must be uncommented one at a time: Sync with WebClient This code retrieves the image through a synchronous call using the WebClient class. Async with WebClient This code retrieves the image through an asynchronous call using the WebClient class. Async with HttpClient with cancelation This code retrieves the image through an asynchronous call with cancelation using the HttpClient class.

    Read the article

  • Beware when using .NET's named pipes in a windows forms application

    - by FransBouma
    Yesterday a user of our .net ORM Profiler tool reported that he couldn't get the snapshot recording from code feature working in a windows forms application. Snapshot recording in code means you start recording profile data from within the profiled application, and after you're done you save the snapshot as a file which you can open in the profiler UI. When using a console application it worked, but when a windows forms application was used, the snapshot was always empty: nothing was recorded. Obviously, I wondered why that was, and debugged a little. Here's an example piece of code to record the snapshot. This piece of code works OK in a console application, but results in an empty snapshot in a windows forms application: var snapshot = new Snapshot(); snapshot.Record(); using(var ctx = new ORMProfilerTestDataContext()) { var customers = ctx.Customers.Where(c => c.Country == "USA").ToList(); } InterceptorCore.Flush(); snapshot.Stop(); string error=string.Empty; if(!snapshot.IsEmpty) { snapshot.SaveToFile(@"c:\temp\generatortest\test2\blaat.opsnapshot", out error); } if(!string.IsNullOrEmpty(error)) { Console.WriteLine("Save error: {0}", error); } (the Console.WriteLine doesn't do anything in a windows forms application, but you get the idea). ORM Profiler uses named pipes: the interceptor (referenced and initialized in your application, the application to profile) sends data over the named pipe to a listener, which when receiving a piece of data begins reading it, asynchronically, and when properly read, it will signal observers that new data has arrived so they can store it in a repository. In this case, the snapshot will be the observer and will store the data in its own repository. The reason the above code doesn't work in windows forms is because windows forms is a wrapper around Win32 and its WM_* message based system. Named pipes in .NET are wrappers around Windows named pipes which also work with WM_* messages. Even though we use BeginRead() on the named pipe (which spawns a thread to read the data from the named pipe), nothing is received by the named pipe in the windows forms application, because it doesn't handle the WM_* messages in its message queue till after the method is over, as the message pump of a windows forms application is handled by the only thread of the windows forms application, so it will handle WM_* messages when the application idles. The fix is easy though: add Application.DoEvents(); right before snapshot.Stop(). Application.DoEvents() forces the windows forms application to process all WM_* messages in its message queue at that moment: all messages for the named pipe are then handled, the .NET code of the named pipe wrapper will react on that and the whole process will complete as if nothing happened. It's not that simple to just say 'why didn't you use a worker thread to create the snapshot here?', because a thread doesn't get its own message pump: the messages would still be posted to the window's message pump. A hidden form would create its own message pump, so the additional thread should also create a window to get the WM_* messages of the named pipe posted to a different message pump than the one of the main window. This WM_* messages pain is not something you want to be confronted with when using .NET and its libraries. Unfortunately, the way they're implemented, a lot of APIs are leaky abstractions, they bleed the characteristics of the OS objects they hide away through to the .NET code. Be aware of that fact when using them :)

    Read the article

  • Small app structure review

    - by Lorenzo
    Hi, I would be grateful if someone could review following: I have a main Form app. OnLoad it displays with Docstyle=Fill the main menu which is done by user control. If the user selects a choice in that Menu control, it fires an event (with one parameter Choice) which main forms reacts on. If the choice is run the app, it closes the user control (dipose) and call method starting the app. If the choice is to quit, it calls Application.Exit. Is that alright form programmers point of view?

    Read the article

  • Software development project inception phase

    - by john ryan
    Currently our team develops Web Applications and now we are going to Windows Forms applications. I have created the inception phase for our Windows Forms project structure. eg: ApplicationSolution --> Security Project(Login Authentication) a. Users will be registered with different applications in our application database. eg: ProjectApplicationId|ProjectName | UserId 1 |ProjectApplication1| user 2 |ProjectApplication2| user b. Execute Application (Start) c. On Security dialog, application automatically get the userid of the user and see all the application it is registered using System.Security.Principal.WindowsIdentity.GetCurrent() eg: Prototype Welcome User! Please Choose Appliations you are registered on below: ProjectApplication1 <--this will be a dropdown ProjectApplication2 Password: [*********************] [Access Application Button] d. User selects the application with its password e. If the password is incorrect (application.exit()) else execute Selected Application eg: ProjectApplication1 is selected then execute ProjectApplication1 --> ProjectApplication1 --> ProjectApplication2 --> Many to come ++ if ProjectApplications has been closed then restart security Application. My questions on this use case: Is my use case possible? Can you give me any recommendations ? Currently we use setup and deployment to create installer in each Windows Forms application.

    Read the article

  • Changelog Management

    - by Gnial0id
    I'm currently developing a WinForm application. In order to inform the client about the improvements and corrections made during the last version, I would like to manage and display a changelog. I mostly found existing changelog on website (the term changelog is pretty used) or explanation on how to manage the release numbers, which I don't care. So, these are my questions: How do I manage a changelog (using XML, pure text in the app, etc.) in a desktop application? How do I present it to the user (external website, inside the winform application)?

    Read the article

  • How to properly structure a project in winform?

    - by user850010
    A while ago I started to create a winform application and at that time it was small and I did not give any thought of how to structure the project. Since then I added additional features as I needed and the project folder is getting bigger and bigger and now I think it is time to structure the project in some way, but I am not sure what is the proper way, so I have few questions. How to properly restructure the project folder? At the moment I am thinking of something like this: Create Folder for Forms Create Folder for Utility classes Create Folder for Classes that contain only data What is the naming convention when adding classes? Should I also rename classes so that their functionality can be identified by just looking at their name? For example renaming all forms classes, so that their name ends with Form. Or is this not necessary if special folders for them are created? What to do, so that not all the code for main form ends up in Form1.cs Another problem I encountered is that as the main form is getting more massive with each feature I add, the code file (Form1.cs) is getting really big. I have for example a TabControl and each tab has bunch of controls and all the code ended up in Form1.cs. How to avoid this? Also, Do you know any articles or books that deal with these problems?

    Read the article

  • Where to store front-end data for "object calculator"

    - by Justin Grahn
    I recently have completed a language library that acts as a giant filter for food items, and flows a bit like this :Products -> Recipes -> MenuItems -> Meals and finally, upon submission, creates an Order. I have also completed a database structure that stores all the pertinent information to each class, and seems to fit my needs. The issue I'm having is linking the two. I imagined all of the information being local to each instance of the product, where there exists one backend user who edits and manipulates data, and multiple front end users who select their Meal(s) to create an Order. Ideally, all of the front end users would have all of this information stored locally within the library, and would update the library on startup from a database. How should I go about storing the data so that I can load it into the library every time the user opens the application? Do I package a database onboard and just load and populate every time? The only method I can currently conceive of doing this, even if I only have 500 possible Product objects, would require me to foreach the list for every Product that I need to match to a Recipe and so on and so forth every time I relaunch the program, which seems like a lot of wasteful loading. Here is a general flow of my architecture: Products: public class Product : IPortionable { public Product(string n, uint pNumber = 0) { name = n; productNumber = pNumber; } public string name { get; set; } public uint productNumber { get; set; } } Recipes: public Recipe(string n, decimal yieldAmt, Volume.Unit unit) { name = n; yield = new Volume(yieldAmt, unit); yield.ConvertUnit(); } /// <summary> /// Creates a new ingredient object /// </summary> /// <param name="n">Name</param> /// <param name="yieldAmt">Recipe Yield</param> /// <param name="unit">Unit of Yield</param> public Recipe(string n, decimal yieldAmt, Weight.Unit unit) { name = n; yield = new Weight(yieldAmt, unit); } public Recipe(Recipe r) { name = r.name; yield = r.yield; ingredients = r.ingredients; } public string name { get; set; } public IMeasure yield; public Dictionary<IPortionable, IMeasure> ingredients = new Dictionary<IPortionable,IMeasure>(); MenuItems: public abstract class MenuItem : IScalable { public static string title = null; public string name { get; set; } public decimal maxPortionSize { get; set; } public decimal minPortionSize { get; set; } public Dictionary<IPortionable, IMeasure> ingredients = new Dictionary<IPortionable, IMeasure>(); and Meal: public class Meal { public Meal(int guests) { guestCount = guests; } public int guestCount { get; private set; } //TODO: Make a new MainCourse class that holds pasta and Entree public Dictionary<string, int> counts = new Dictionary<string, int>(){ {MainCourse.title, 0}, {Side.title , 0}, {Appetizer.title, 0} }; public List<MenuItem> items = new List<MenuItem>(); The Database just stores and links each of these basic names and amounts together usings ID's (RecipeID, ProductID and MenuItemID)

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >