Search Results

Search found 11001 results on 441 pages for 'native drag drop'.

Page 51/441 | < Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >

  • JQuery not copying state dropdown list 1 to DDL2 on checkbox change

    - by user1001411
    I've looked at similar posts on the subject but none of the recommended solutions have worked for me so I'm not sure where I'm going wrong. I have a billing and shipping address form with a dropdown list for the state. Upon checking/unchecking the "billing address same as shipping" everything copies over except the state dropdown list. The state dropdown list is populated from a SQLDataSource state table. Here's my code: <script type="text/javascript" language="javascript" src="../Scripts/jquery-1.4.1.min.js"></script> <script type="text/javascript"> $(document).ready(function () { $('input:checkbox[id*=chkCopy]').change(function () { if ($(this).is(':checked')) { $('input:text[id*=TextBox5]').val($('input:text[id*=TextBox1]').val()); $('input:text[id*=TextBox7]').val($('input:text[id*=TextBox2]').val()); $('input:text[id*=TextBox9]').val($('input:text[id*=TextBox3]').val()); $('input:text[id*=TextBox12]').val($('input:text[id*=TextBox4]').val()); $('select#DropDownList6').val($("select#DropDownList1").val()); $('input:text[id*=TextBox14]').val($('input:text[id*=TextBox6]').val()); } else { $('input:text[id*=TextBox5]').val(''); $('input:text[id*=TextBox7]').val(''); $('input:text[id*=TextBox9]').val(''); $('input:text[id*=TextBox12]').val(''); $('select#DropDownList6').val(''); $('input:text[id*=TextBox14]').val(''); } }); }); and here is my SQL for the DDL: <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Descr" DataValueField="ID" DataSourceID="SqlDataSource1" Width="254"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" SelectCommand="SELECT * FROM [xrefState]"> </asp:SqlDataSource> the other one: <asp:DropDownList ID="DropDownList6" runat="server" DataTextField="Descr" DataValueField="ID" DataSourceID="SqlDataSource5" Width="254"> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" SelectCommand="SELECT * FROM [xrefState]"> </asp:SqlDataSource>

    Read the article

  • drag drop no longer working once application gets installed.

    - by Sdry
    I have an application that has drag and drop functionality to import images and video's. While developing, and testing through Visual Studio this has never given any problems. After installing through a set up project, everything in the application works fine, except the drag and drop, which seems to be doing nothing. Are there any security settings that need to be set through an installer, or something of that nature that could be preventing drag and drop after installation ?

    Read the article

  • Mongoose 3.1.0: Why the callback in the connection.db.dropDatabase(callback) is never called?

    - by Totty
    Code: var connection = mongoose.createConnection('mongodb://localhost:9000/' + databaseName); connection.db.dropDatabase(function(err){ // never reach this point! debugger; console.log(err); console.log('-------------->Dropped database: ' + databaseName); }); If I do connection.open it says that it's already opening and no multiple calls to "open" are supported for the same connection. Even this doesn't work var conn = mongoose.createConnection('mongodb://localhost',databaseName, 9000, {}, function(){ console.log('created'); // is reached conn.db.dropDatabase(callback); // but the callback is not called anyway }); What is the problem? ("mongoose": "3.1.0") thanks

    Read the article

  • is "else if" faster than "switch() case" ?

    - by John
    Hello, I'm an ex Pascal guy,currently learning C#. My question is the following: Is the code below faster than making a switch? int a = 5; if (a == 1) { .... } else if(a == 2) { .... } else if(a == 3) { .... } else if(a == 4) { .... } else .... And the switch: int a = 5; switch(a) { case 1: ... break; case 2: ... break; case 3: ... break; case 4: ... break; default: ... break; } Which one is faster? I'm asking ,because my program has a similiar structure(many,many "else if" statements). Should I turn them into switches?

    Read the article

  • Display x if x display y if y (bad title I know)

    - by user1914940
    Ok so after reading the title you are most likely like...what? Ok, so I have a jquery code that displays input box if an item with prefix Blue from dropdown menu is selected. Code: $(function() { $('#text1').hide(); $('#select2').on('change', function(event) { var opt = this.options[ this.selectedIndex ]; var picked_blue = $(opt).text().match(/Blue/i); if(picked_blue) { $('#text1').show(); } else { $('#text1').hide(); } }); }); But what I also need to add is to display something else if any other item from dropdown menu is selected.

    Read the article

  • How do you use the C language to produce a ruby gem?

    - by DJTripleThreat
    I would like to see some source code or maybe a link to some that gives at least a stub for writing ruby gems in the C languages (C++?? is that possible too?) Also, some of you may know that Facebook compiles some of their code natively as php extensions for better performance. Is anyone doing this in Rails? If so, what has been your experience with it? Have you found it to be useful? Thanks. Edit: I guess I'll answer my own question with some stuff I learned today but I'm going to leave the question open for another answer because I'd like to see what others have to say on this topic

    Read the article

  • Error installing new rails version. Failed to build gem native extension.

    - by davidcmolina
    I am trying to build my first ruby on rails app using the following guide (http://ruby.railstutorial.org/chapters/a-demo-app#code-demo_gemfile_sqlite_version_redux) and have run into a few obstacles. The first, receiving errors when upgrading to the latest rails version 3.2.8. bash-3.2$ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb creating Makefile make compiling generator.c make: /usr/bin/gcc-4.2: No such file or directory make: *** [generator.o] Error 1 Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection. Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out Even when trying to install from rails app: $ gem install rails Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. /Users/davidmolina/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb creating Makefile make compiling generator.c make: /usr/bin/gcc-4.2: No such file or directory make: *** [generator.o] Error 1 Gem files will remain installed in /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection. Results logged to /Users/davidmolina/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out When trying to Bundle Install: $ bundle install Could not locate Gemfile Background details: Mac OS X Version 10.8.2 Ruby 1.9.3 Rails 2.3.4 I'm wondering if there is a direct one-liner or gem that is missing?

    Read the article

  • SQL SERVER – Fix Error: Microsoft OLE DB Provider for SQL Server error ’80040e07' or Microsoft SQL Native Client error ’80040e07'

    - by pinaldave
    I quite often receive questions where users are looking for solution to following error: Microsoft OLE DB Provider for SQL Server error ’80040e07′ Syntax error converting datetime from character string. OR Microsoft SQL Native Client error ’80040e07′ Syntax error converting datetime from character string. If you have ever faced above error – I have a very simple solution for you. The solution is being very check date which is inserted in the datetime column. This error often comes up when application or user is attempting to enter an incorrect date into the datetime field. Here is one of the examples – one of the reader was using classing ASP Application with OLE DB provider for SQL Server. When he tried to insert following script he faced above mentioned error. INSERT INTO TestTable (ID, MyDate) VALUES (1, '01-Septeber-2013') The reason for the error was simple as he had misspelled September word. Upon correction of the word, he was able to successfully insert the value and error was not there. Incorrect values or the typo’s are not the only reason for this error. There can be issues with cast or convert as well. If you try to attempt following code using SQL Native Client or in your application you will also get similar errors. SELECT CONVERT (datetime, '01-Septeber-2013', 112) The reason here is very simple, any conversion attempt or any other kind of operation on incorrect date/time string can lead to the above error. If you not using embeded dynamic code in your application language but using attempting similar operation on incorrect datetime string you will get following error. Msg 241, Level 16, State 1, Line 2 Conversion failed when converting date and/or time from character string. Remember: Check your values of the string when you are attempting to convert them to string – either there can be incorrect values or they may be incorrectly formatted. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: PostADay, SQL, SQL Authority, SQL DateTime, SQL Error Messages, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • How to set the monitor to its native resolution when xrandr approach isn't working?

    - by Krishna Kant Sharma
    I am trying to setup my Samsung syncmaster B2030 monitor in ubuntu 12.04. It's native resolution is 1600x900 which I am not getting in ubuntu and which I am trying to get. I tried using xrandr approach provided in these urls: 1) http://www.ubuntugeek.com/how-change-display-resolution-settings-using-xrandr.html 2) How to set the monitor to its native resolution which is not listed in the resolutions list? S1) I used cvt 1600 900 60 to get the modeline. Output was: # 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz Modeline "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync S2) I then used xrandr and output was: Screen 0: minimum 8 x 8, current 1152 x 864, maximum 8192 x 8192 DVI-I-0 disconnected (normal left inverted right x axis y axis) VGA-0 connected 1152x864+0+0 (normal left inverted right x axis y axis) 0mm x 0mm 1024x768 60.0 + 1360x768 60.0 59.8 1152x864 60.0* 800x600 72.2 60.3 56.2 680x384 119.9 119.6 640x480 59.9 512x384 120.0 400x300 144.4 320x240 120.1 DVI-I-1 disconnected (normal left inverted right x axis y axis) HDMI-0 disconnected (normal left inverted right x axis y axis) which gave me "VGA-0". S3) Then I used xrandr --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync But instead of adding the modeline it just threw an error: X Error of failed request: BadName (named color or font does not exist) Major opcode of failed request: 153 (RANDR) Minor opcode of failed request: 16 (RRCreateMode) Serial number of failed request: 29 Current serial number in output stream: 29 My system details: 1) ubuntu 12.04 LTS 2) Graphic card: GeForce 9400 GT/PCIe/SSE2 (driver is successfully installed. I am checking it in System Settings Details. And it's showing that driver is installed and its "GeForce 9400 GT/PCIe/SSE2") 3) Monitor: Samsung syncmaster B2030 4) Resolutions I am getting: 800x600 1024x768 1152x864 (I am currently using this one) 1360x768 (this one isn't working properly) Does anyone know what I can do? Thanks in advance. UPDATE (1): Today I tried it again. And adding a modeline (using --newmode) worked. But when I used --addmode by: xrandr --addmode VGA-0 1600x900_60.00 It gave this error: X Error of failed request: BadMatch (invalid parameter attributes) Major opcode of failed request: 153 (RANDR) Minor opcode of failed request: 18 (RRAddOutputMode) Serial number of failed request: 29 Current serial number in output stream: 30

    Read the article

  • Node.js : enfin une intégration native sous Windows, le framework événementiel en JavaScript arrive sur le Cloud d'Azure

    Node.js : enfin une intégration native et complète sous Windows Le framework événementiel en JavaScript arrive sur le Cloud d'Azure Mise à jour du 9 novembre 2011 par Idelways Microsoft a manifesté en juin dernier son soutien au projet Node.js, le framework JavaScript événementiel et open source (lire ci-devant). La collaboration de l'entreprise avec Joycent, qui parraine son équipe de développeurs, vient d'aboutir à la version 0.6.0 de Node, qui bénéficie d'un support natif et complet sur la plateforme Windows. Cette troisième édition stable de Node.js exploite l'API Windows « I/O Completion Ports », pour ...

    Read the article

  • NoSQL s'ouvre aux plateformes mobiles, Couchbase Mobile 1.0, la première base de données NoSQL native pour mobile sort

    NoSQL s'ouvre aux plateformes mobiles Couchbase Mobile 1.0, la première base de données NoSQL native pour mobile sortCouchbase, l'une des principales entreprises IT qui ont fait la promotion du NoSQL a récemment annoncé la sortie de son nouveau produit Couchbase Mobile 1.0, une solution pour tirer parti de la puissance du NoSQL à partir d'une plateforme mobile, but de la manoeuvre : promouvoir les applications mobiles NoSQL et conquérir un nouveau marché.Couchbase Mobile qui se décline comme étant...

    Read the article

  • Alt+click-drag window resizing on a Mac? (Similar to X-Windows)

    - by Aaron F.
    Is there a way I can get this behavior on Mac OS? alt + right-click-drag will resize the window, relative to where you've clicked within the window and the window's center alt + left-click-drag will move the window, regardless of where you've clicked within the window. There's a Windows port of this behavior as well: http://www.codeproject.com/KB/DLL/wm.aspx

    Read the article

  • Script / command to drop all connections / locks in Sybase SQL Anywhere 9?

    - by nxzr
    I've recently become responsible for administering an application which is essentially a front end to a Sybase SQL Anywhere 9 database, including the database itself. I'd like to use unload table to efficiently export the data for backup and, in the case of a few tables, ETL to get it into a reporting database / small scale data warehouse. The problem is that the client application crashes and leaves dead connections and shared locks on a pretty regular basis, which seems to prevent unload table from getting the (brief) exclusive locks it needs. Currently I use Sybase Central to verify that these connections are in fact zombies and drop them myself at the end of the day / week. Is there a command or script to drop all connections? Being able to drop everything at once after verifying that they're unneeded would be quite helpful but I haven't found a way to do it.

    Read the article

  • Is it possible to have tab completion of drop-down lists in web pages in Firefox?

    - by Nick Booker
    Does anyone know of a Firefox plugin that would enable tab-completion (or some other key sequence like Alt-L) of items in drop-down lists in web forms? e.g. ou<TAB>in<TAB>s<TAB> for 'OurCompany - Internal Support' Vimperator's hints mode makes it very ergonomic to focus the drop-down list with a key sequence like f13 but the keyboard interface to the drop-down list still sucks. I very frequently have to pick items from a very long list with very long common prefixes among the entries (e.g. 30-40 starting with OurCompany -), which renders both the built-in keyboard interface and the mouse pretty slow and unergonomic. I basically want readline support for filling webforms!

    Read the article

  • Adding an Admin user to an ASP.NET MVC 4 application using a single drop-in file

    - by Jon Galloway
    I'm working on an ASP.NET MVC 4 tutorial and wanted to set it up so just dropping a file in App_Start would create a user named "Owner" and assign them to the "Administrator" role (more explanation at the end if you're interested). There are reasons why this wouldn't fit into most application scenarios: It's not efficient, as it checks for (and creates, if necessary) the user every time the app starts up The username, password, and role name are hardcoded in the app (although they could be pulled from config) Automatically creating an administrative account in code (without user interaction) could lead to obvious security issues if the user isn't informed However, with some modifications it might be more broadly useful - e.g. creating a test user with limited privileges, ensuring a required account isn't accidentally deleted, or - as in my case - setting up an account for demonstration or tutorial purposes. Challenge #1: Running on startup without requiring the user to install or configure anything I wanted to see if this could be done just by having the user drop a file into the App_Start folder and go. No copying code into Global.asax.cs, no installing addition NuGet packages, etc. That may not be the best approach - perhaps a NuGet package with a dependency on WebActivator would be better - but I wanted to see if this was possible and see if it offered the best experience. Fortunately ASP.NET 4 and later provide a PreApplicationStartMethod attribute which allows you to register a method which will run when the application starts up. You drop this attribute in your application and give it two parameters: a method name and the type that contains it. I created a static class named PreApplicationTasks with a static method named, then dropped this attribute in it: [assembly: PreApplicationStartMethod(typeof(PreApplicationTasks), "Initializer")] That's it. One small gotcha: the namespace can be a problem with assembly attributes. I decided my class didn't need a namespace. Challenge #2: Only one PreApplicationStartMethod per assembly In .NET 4, the PreApplicationStartMethod is marked as AllMultiple=false, so you can only have one PreApplicationStartMethod per assembly. This was fixed in .NET 4.5, as noted by Jon Skeet, so you can have as many PreApplicationStartMethods as you want (allowing you to keep your users waiting for the application to start indefinitely!). The WebActivator NuGet package solves the multiple instance problem if you're in .NET 4 - it registers as a PreApplicationStartMethod, then calls any methods you've indicated using [assembly: WebActivator.PreApplicationStartMethod(type, method)]. David Ebbo blogged about that here:  Light up your NuGets with startup code and WebActivator. In my scenario (bootstrapping a beginner level tutorial) I decided not to worry about this and stick with PreApplicationStartMethod. Challenge #3: PreApplicationStartMethod kicks in before configuration has been read This is by design, as Phil explains. It allows you to make changes that need to happen very early in the pipeline, well before Application_Start. That's fine in some cases, but it caused me problems when trying to add users, since the Membership Provider configuration hadn't yet been read - I got an exception stating that "Default Membership Provider could not be found." The solution here is to run code that requires configuration in a PostApplicationStart method. But how to do that? Challenge #4: Getting PostApplicationStartMethod without requiring WebActivator The WebActivator NuGet package, among other things, provides a PostApplicationStartMethod attribute. That's generally how I'd recommend running code that needs to happen after Application_Start: [assembly: WebActivator.PostApplicationStartMethod(typeof(TestLibrary.MyStartupCode), "CallMeAfterAppStart")] This works well, but I wanted to see if this would be possible without WebActivator. Hmm. Well, wait a minute - WebActivator works in .NET 4, so clearly it's registering and calling PostApplicationStartup tasks somehow. Off to the source code! Sure enough, there's even a handy comment in ActivationManager.cs which shows where PostApplicationStartup tasks are being registered: public static void Run() { if (!_hasInited) { RunPreStartMethods(); // Register our module to handle any Post Start methods. But outside of ASP.NET, just run them now if (HostingEnvironment.IsHosted) { Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(StartMethodCallingModule)); } else { RunPostStartMethods(); } _hasInited = true; } } Excellent. Hey, that DynamicModuleUtility seems familiar... Sure enough, K. Scott Allen mentioned it on his blog last year. This is really slick - a PreApplicationStartMethod can register a new HttpModule in code. Modules are run right after application startup, so that's a perfect time to do any startup stuff that requires configuration to be read. As K. Scott says, it's this easy: using System; using System.Web; using Microsoft.Web.Infrastructure.DynamicModuleHelper; [assembly:PreApplicationStartMethod(typeof(MyAppStart), "Start")] public class CoolModule : IHttpModule { // implementation not important // imagine something cool here } public static class MyAppStart { public static void Start() { DynamicModuleUtility.RegisterModule(typeof(CoolModule)); } } Challenge #5: Cooperating with SimpleMembership The ASP.NET MVC Internet template includes SimpleMembership. SimpleMembership is a big improvement over traditional ASP.NET Membership. For one thing, rather than forcing a database schema, it can work with your database schema. In the MVC 4 Internet template case, it uses Entity Framework Code First to define the user model. SimpleMembership bootstrap includes a call to InitializeDatabaseConnection, and I want to play nice with that. There's a new [InitializeSimpleMembership] attribute on the AccountController, which calls \Filters\InitializeSimpleMembershipAttribute.cs::OnActionExecuting(). That comment in that method that says "Ensure ASP.NET Simple Membership is initialized only once per app start" which sounds like good advice. I figured the best thing would be to call that directly: new Mvc4SampleApplication.Filters.InitializeSimpleMembershipAttribute().OnActionExecuting(null); I'm not 100% happy with this - in fact, it's my least favorite part of this solution. There are two problems - first, directly calling a method on a filter, while legal, seems odd. Worse, though, the Filter lives in the application's namespace, which means that this code no longer works well as a generic drop-in. The simplest workaround would be to duplicate the relevant SimpleMembership initialization code into my startup code, but I'd rather not. I'm interested in your suggestions here. Challenge #6: Module Init methods are called more than once When debugging, I noticed (and remembered) that the Init method may be called more than once per page request - it's run once per instance in the app pool, and an individual page request can cause multiple resource requests to the server. While SimpleMembership does have internal checks to prevent duplicate user or role entries, I'd rather not cause or handle those exceptions. So here's the standard single-use lock in the Module's init method: void IHttpModule.Init(HttpApplication context) { lock (lockObject) { if (!initialized) { //Do stuff } initialized = true; } } Putting it all together With all of that out of the way, here's the code I came up with: using Mvc4SampleApplication.Filters; using System.Web; using System.Web.Security; using WebMatrix.WebData; [assembly: PreApplicationStartMethod(typeof(PreApplicationTasks), "Initializer")] public static class PreApplicationTasks { public static void Initializer() { Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility .RegisterModule(typeof(UserInitializationModule)); } } public class UserInitializationModule : IHttpModule { private static bool initialized; private static object lockObject = new object(); private const string _username = "Owner"; private const string _password = "p@ssword123"; private const string _role = "Administrator"; void IHttpModule.Init(HttpApplication context) { lock (lockObject) { if (!initialized) { new InitializeSimpleMembershipAttribute().OnActionExecuting(null); if (!WebSecurity.UserExists(_username)) WebSecurity.CreateUserAndAccount(_username, _password); if (!Roles.RoleExists(_role)) Roles.CreateRole(_role); if (!Roles.IsUserInRole(_username, _role)) Roles.AddUserToRole(_username, _role); } initialized = true; } } void IHttpModule.Dispose() { } } The Verdict: Is this a good thing? Maybe. I think you'll agree that the journey was undoubtedly worthwhile, as it took us through some of the finer points of hooking into application startup, integrating with membership, and understanding why the WebActivator NuGet package is so useful Will I use this in the tutorial? I'm leaning towards no - I think a NuGet package with a dependency on WebActivator might work better: It's a little more clear what's going on Installing a NuGet package might be a little less error prone than copying a file A novice user could uninstall the package when complete It's a good introduction to NuGet, which is a good thing for beginners to see This code either requires either duplicating a little code from that filter or modifying the file to use the namespace Honestly I'm undecided at this point, but I'm glad that I can weigh the options. If you're interested: Why are you doing this? I'm updating the MVC Music Store tutorial to ASP.NET MVC 4, taking advantage of a lot of new ASP.NET MVC 4 features and trying to simplify areas that are giving people trouble. One change that addresses both needs us using the new OAuth support for membership as much as possible - it's a great new feature from an application perspective, and we get a fair amount of beginners struggling with setting up membership on a variety of database and development setups, which is a distraction from the focus of the tutorial - learning ASP.NET MVC. Side note: Thanks to some great help from Rick Anderson, we had a draft of the tutorial that was looking pretty good earlier this summer, but there were enough changes in ASP.NET MVC 4 all the way up to RTM that there's still some work to be done. It's high priority and should be out very soon. The one issue I ran into with OAuth is that we still need an Administrative user who can edit the store's inventory. I thought about a number of solutions for that - making the first user to register the admin, or the first user to use the username "Administrator" is assigned to the Administrator role - but they both ended up requiring extra code; also, I worried that people would use that code without understanding it or thinking about whether it was a good fit.

    Read the article

  • Use native HBitmap in C# while preserving alpha channel/transparency. Please check this code, it works on my computer...

    - by David
    Let's say I get a HBITMAP object/handle from a native Windows function. I can convert it to a managed bitmap using Bitmap.FromHbitmap(nativeHBitmap), but if the native image has transparency information (alpha channel), it is lost by this conversion. There are a few questions on Stack Overflow regarding this issue. Using information from the first answer of this question (How to draw ARGB bitmap using GDI+?), I wrote a piece of code that I've tried and it works. It basically gets the native HBitmap width, height and the pointer to the location of the pixel data using GetObject and the BITMAP structure, and then calls the managed Bitmap constructor: Bitmap managedBitmap = new Bitmap(bitmapStruct.bmWidth, bitmapStruct.bmHeight, bitmapStruct.bmWidth * 4, PixelFormat.Format32bppArgb, bitmapStruct.bmBits); As I understand (please correct me if I'm wrong), this does not copy the actual pixel data from the native HBitmap to the managed bitmap, it simply points the managed bitmap to the pixel data from the native HBitmap. And I don't draw the bitmap here on another Graphics (DC) or on another bitmap, to avoid unnecessary memory copying, especially for large bitmaps. I can simply assign this bitmap to a PictureBox control or the the Form BackgroundImage property. And it works, the bitmap is displayed correctly, using transparency. When I no longer use the bitmap, I make sure the BackgroundImage property is no longer pointing to the bitmap, and I dispose both the managed bitmap and the native HBitmap. The Question: Can you tell me if this reasoning and code seems correct. I hope I will not get some unexpected behaviors or errors. And I hope I'm freeing all the memory and objects correctly. private void Example() { IntPtr nativeHBitmap = IntPtr.Zero; /* Get the native HBitmap object from a Windows function here */ // Create the BITMAP structure and get info from our nativeHBitmap NativeMethods.BITMAP bitmapStruct = new NativeMethods.BITMAP(); NativeMethods.GetObjectBitmap(nativeHBitmap, Marshal.SizeOf(bitmapStruct), ref bitmapStruct); // Create the managed bitmap using the pointer to the pixel data of the native HBitmap Bitmap managedBitmap = new Bitmap( bitmapStruct.bmWidth, bitmapStruct.bmHeight, bitmapStruct.bmWidth * 4, PixelFormat.Format32bppArgb, bitmapStruct.bmBits); // Show the bitmap this.BackgroundImage = managedBitmap; /* Run the program, use the image */ MessageBox.Show("running..."); // When the image is no longer needed, dispose both the managed Bitmap object and the native HBitmap this.BackgroundImage = null; managedBitmap.Dispose(); NativeMethods.DeleteObject(nativeHBitmap); } internal static class NativeMethods { [StructLayout(LayoutKind.Sequential)] public struct BITMAP { public int bmType; public int bmWidth; public int bmHeight; public int bmWidthBytes; public ushort bmPlanes; public ushort bmBitsPixel; public IntPtr bmBits; } [DllImport("gdi32", CharSet = CharSet.Auto, EntryPoint = "GetObject")] public static extern int GetObjectBitmap(IntPtr hObject, int nCount, ref BITMAP lpObject); [DllImport("gdi32.dll")] internal static extern bool DeleteObject(IntPtr hObject); }

    Read the article

  • Accessing native iPhone addressbook database and performing add and delete contacts?

    - by chaitanya
    Hi, In my application I need to implement the address book which should contains the native addressbook details, and the user should be able to add and delete from the address book and it should be updated in the native iphone addressbook. I read somewhere that the iphone native address book database is accesible. In documentation also I saw that addContact and Delete API's are exposed to addressbook. Can anyone please tell me how can I access the native AddressBook of the iphone, and.. how to add and delete contacts from the address book? Can anyone post the sample code for this?

    Read the article

  • How can I compile some parts of C++/CLI code as Native and some part as Managed?

    - by Usman
    Hello, I am calling LoadTypeLib for loading unmanaged type libraries in C++/CLI. I need to compile some code(some code areas) as managed and some code areas as unmanaged(native) code and form a mixed mode class library as executable. What i need to mention between the lines of code so that whatever the part i need to be compiled as managed should compiled as managed and what part I need to be unmanaged(native) should be compiled as native? Regards Usman

    Read the article

  • Loading Native library to external Package in Eclipse not working. is it a Bug?

    - by TacB0sS
    I was about to report a but to Eclipse, but I was thinking to give this a chance here first: If I add an external package, the application cannot find the referenced native library, except in the case specified at the below: If my workspace consists of a single project, and I import an external package 'EX_package.jar' from a folder outside of the project folder, I can assign a folder to the native library location via: mouse over package - right click - properties - Native Library - Enter your folder. This does not work. In runtime the application does not load the library, System.mapLibraryName(Path) also does not work. Further more, if I create a User Library, and add the package to it and define a folder for the native library it still does not. If it works for you then I have a major bug since it does not work on my computer I test this in any combination I could think of, including adding the path to the windows PATH parameter, and so many other ways I can't even start to remember, nothing worked, I played with this for hours and had a colleague try to assist me, but we both came up empty. Further more, if I have a main project that is dependent on few other projects in my workspace, and they all need to use the same 'EX_package.jar' I MUST supply a HARD COPY INTO EACH OF THEM, it will ONLY (I can't stress the ONLYNESS, I got freaked out by this) work if I have a hard copy of the package in ALL of the project folders that the main project has a dependency on, and ONLY if I configure the Native path in each of them!! This also didn't do the trick. please tell me there is a solution to this, this drives me nuts... Thanks, Adam Zehavi.

    Read the article

  • Is there a way to fix the width of drop down list?

    - by Harry Pham
    Here is what I got: <select id="box1"> <option>ABCDEFG</option> </select> <select id="box2"> <option>ABCDEFGHIJKLMNO</option> </select> I have 2 different Drop Down lists. Since the width of a drop down list depends on the width of the longest text in the option, I end up with 2 drop down lists with 2 different widths. This makes my webpage look goofy. What I want is to set it so that both of my drop down lists will have the same width (I'd prefer the width to be very long, so that even the longest item won't be truncated).

    Read the article

< Previous Page | 47 48 49 50 51 52 53 54 55 56 57 58  | Next Page >