Daily Archives

Articles indexed Thursday May 6 2010

Page 1/118 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to take the snapshot of a IE webpage through a BHO (C#)

    - by Kapil
    Hi, I am trying to build an IE BHO in C# for taking the snapshot of a webpage loaded in the IE browser. Here is what I'm trying to do: public class ShowToolbarBHO : BandObjectLib.IObjectWithSite { IWebBrowser2 webBrowser = null; public void SetSite (Object site) { ....... if (site != null) { ...... webBrowser = (IWebBrowser2)site; ...... } } } Also, I p/invoke the following COM methods: [Guid("0000010D-0000-0000-C000-000000000046")] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [ComImportAttribute()] public interface IViewObject { void Draw([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, [In] IntPtr ptd, IntPtr hdcTargetDev, IntPtr hdcDraw, [MarshalAs(UnmanagedType.LPStruct)] ref COMRECT lprcBounds, [In] IntPtr lprcWBounds, IntPtr pfnContinue, int dwContinue); int GetColorSet([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, [In] IntPtr ptd, IntPtr hicTargetDev, [Out] IntPtr ppColorSet); int Freeze([MarshalAs(UnmanagedType.U4)] int dwDrawAspect, int lindex, IntPtr pvAspect, out IntPtr pdwFreeze); int Unfreeze([MarshalAs(UnmanagedType.U4)] int dwFreeze); int SetAdvise([MarshalAs(UnmanagedType.U4)] int aspects, [MarshalAs(UnmanagedType.U4)] int advf, [MarshalAs(UnmanagedType.Interface)] IAdviseSink pAdvSink); void GetAdvise([MarshalAs(UnmanagedType.LPArray)] out int[] paspects, [MarshalAs(UnmanagedType.LPArray)] out int[] advf, [MarshalAs(UnmanagedType.LPArray)] out IAdviseSink[] pAdvSink); } [StructLayoutAttribute(LayoutKind.Sequential)] public class COMRECT { public int left; public int top; public int right; public int bottom; public COMRECT() { } public COMRECT(int left, int top, int right, int bottom) { this.left = left; this.top = top; this.right = right; this.bottom = bottom; } } [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [ComVisibleAttribute(true)] [GuidAttribute("0000010F-0000-0000-C000-000000000046")] [ComImportAttribute()] public interface IAdviseSink { void OnDataChange([In]IntPtr pFormatetc, [In]IntPtr pStgmed); void OnViewChange([MarshalAs(UnmanagedType.U4)] int dwAspect, [MarshalAs(UnmanagedType.I4)] int lindex); void OnRename([MarshalAs(UnmanagedType.Interface)] object pmk); void OnSave(); void OnClose(); } Now When I take the snapshot: I make a call CaptureWebScreenImage((IHTMLDocument2) webBrowser.document); public static Image CaptureWebScreenImage(IHTMLDocument2 myDoc) { int heightsize = (int)getDocumentAttribute(myDoc, "scrollHeight"); int widthsize = (int)getDocumentAttribute(myDoc, "scrollWidth"); Bitmap finalImage = new Bitmap(widthsize, heightsize); Graphics gFinal = Graphics.FromImage(finalImage); COMRECT rect = new COMRECT(); rect.left = 0; rect.top = 0; rect.right = widthsize; rect.bottom = heightsize; IntPtr hDC = gFinal.GetHdc(); IViewObject vO = myDoc as IViewObject; vO.Draw(1, -1, (IntPtr)0, (IntPtr)0, (IntPtr)0, (IntPtr)hDC, ref rect, (IntPtr)0, (IntPtr)0, 0); gFinal.ReleaseHdc(); gFinal.Dispose(); return finalImage; } I am not getting the image of the webpage. Rather I am getting an image with black background. I am not sure if this is the right way of doing it, but I found over the web that IViewObject::Draw method is used for taking the image of a webpage in IE. I was earlier doing the image capture using the Native PrintWindow() method as mentioned in the following codeproject's page - http://www.codeproject.com/KB/graphics/IECapture.aspx But the image size is humongous! I was trying to see if I can reduce the size by using other techniques. It would be great if someone can point out the mistakes (I am sure there would be many) in my code above. Thanks, Kapil

    Read the article

  • Linq-to-SQL Grouping not ordering correctly

    - by Grant
    Hi can someone help me convert this tsql statement into c# linq2sql? select [series] from table group by [series] order by max([date]) desc This is what i have so far - the list is not in correct order.. var x = from c in db.Table orderby c.Date descending group c by c.Series into d select d.Key;

    Read the article

  • What does it take to prove this Contract.Requires?

    - by John Gietzen
    I have an application that runs through the rounds in a tournament, and I am getting a contract warning on this simplified code structure: public static void LoadState(IList<Object> stuff) { for(int i = 0; i < stuff.Count; i++) { // Contract.Assert(i < stuff.Count); // Contract.Assume(i < stuff.Count); Object thing = stuff[i]; Console.WriteLine(thing.ToString()); } } The warning is: contracts: requires unproven: index < @this.Count What am I doing wrong? How can I prove this on an IList<T>? Is this a bug in the static analyzer? How would I submit a bug report to Microsoft?

    Read the article

  • Formatting XML using XSLT1.0

    - by DS
    Hi, I have the following xml: <Subscriptions> <Subscription> <Uplink> <Size>15</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class D</Name> </Subscription> <Subscription> <Uplink> <Size>10</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class A</Name> </Subscription> <Subscription> <Downlink> <Size>50</Size> <Unit>Mbps</Unit> </Downlink> <Name>Class B</Name> </Subscription> <Subscription> <Uplink> <Size>10</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class B</Name> </Subscription> <Subscription> <Downlink> <Size>40000</Size> <Unit>Mbps</Unit> </Downlink> <Name>Class A</Name> </Subscription> <Subscription> <Downlink> <Size>20</Size> <Unit>Mbps</Unit> </Downlink> <Name>Class C</Name> </Subscription> <Subscription> <Downlink> <Size>45</Size> <Unit>Mbps</Unit> </Downlink> <Name>Class D</Name> </Subscription> </Subscriptions> I want to group it in the following format based on name using XSLT1.0. Please help <?xml version="1.0" encoding="UTF-8"?> <Subscriptions> <Subscription> <Downlink> <Size>45</Size> <Unit>Mbps</Unit> </Downlink> <Uplink> <Size>15</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class D</Name> </Subscription> <Subscription> <Downlink> <Size>40000</Size> <Unit>Mbps</Unit> </Downlink> <Uplink> <Size>10</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class A</Name> </Subscription> <Subscription> <Downlink> <Size>50</Size> <Unit>Mbps</Unit> </Downlink> <Uplink> <Size>10</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class B</Name> </Subscription> <Subscription> <Downlink> <Size>20</Size> <Unit>Mbps</Unit> </Downlink> <Uplink> <Size>0</Size> <Unit>Mbps</Unit> </Uplink> <Name>Class C</Name> </Subscription> </Subscriptions> Thanks & Regards, D

    Read the article

  • 8GB, but have to run Windows Xp (32 Bit). Anything I can do with the additional memory?

    - by user12889
    I ordered a new computer with 8GB RAM with the plan to run Windows 7, 64Bit. Turns out now, that I need to run a 32Bit OS (XP or 7) due to some software which does not run on 64Bit yet (not even with any of the available compatibility settings / modes). Is there anything I can do with the memory above 4GB in this scenario? I'm willing to consider creative solutions like running a hypervisor under XP that offers the memory as a RAM-Disk for swapping etc. ? The software that does not run on 64Bit is CISCO VPN (there seems to be a half-working solution for that) and CISCO IP phone / webcam integration "CISCO Unified Video Advantage" (there is apparently no solution for that).

    Read the article

  • Get remote file path location

    - by jungle_programmer
    Hi all, I am working with PHP and would like to get a remote file path location so that I can read file contents. I would like the user to direct to a particular file, which can be located anywhere in the computer, so that it can be processed by the script. Thanks

    Read the article

  • converting between struct and byte array

    - by chonch
    his question is about converting between a struct and a byte array. Many solutions are based around GCHandle.Alloc() and Marshal.StructureToPtr(). The problem is these calls generate garbage. For example, under Windows CE 6 R3 about 400 bytes of garbarge is made with a small structure. If the code below could be made to work the solution could be considered cleaner. It appears the sizeof() happens too late in the compile to work. public struct Data { public double a; public int b; public double c; } [StructLayout(LayoutKind.Explicit)] public unsafe struct DataWrapper { private static readonly int val = sizeof(Data); [FieldOffset(0)] public fixed byte Arr[val]; // "fixed" is to embed array instead of ref [FieldOffset(0)] public Data; // based on a C++ union }

    Read the article

  • Java: Checking if PC is idle

    - by Scott Straughan
    This is a rather tricky question as I have found no information online. Basically, I wish to know how to check if a computer is idle in Java. I wish a program to only work if the computer is in active use but if it is idle then to not. The only way i can think of doing this is hooking into the mouse/keyboard and having a timer. MSN Messenger has that "away" feature, I wish for something similar to this.

    Read the article

  • Recommendations for keeping a build server updated

    - by gareth_bowles
    As a guy who frequently switches between QA, build and operations, I keep running into the issue of what to do about operating system updates on the build server. The dichotomy is the same on Windows, Linux, MacOS or any other o/s that can update itself via the internet: The QA team wants to keep the build server exactly as it is from the beginning of the product release cycle to the end, since installing updates could destabilize the server and means that successive builds aren't made against the same baseline. The ops team wants the software to be deployed on a system with all the latest security patches; this can mean that the software isn't deployed on exactly the same version of the o/s that it was built on. I usually mitigate this by taking release candidate builds and installing them on a test server that has a completely up-to-date o/s, repeating the automated tests that are run on the build server and doing some additional system level testing to make sure everything looks good before deployment. However, this seems inefficient to me; does anyone have a better way ?

    Read the article

  • How does GCC compile applications that reference a static library

    - by technobrat
    I've read that the gcc compiler can perform certain optimization when compiling an application that references a static library, for instance - it will "pull" in only that code from the static library that the application depends upon. This helps keep the size of the application's executable to a minimum if portions of the static library are not being used by the app. 1) Is this true? 2) How does GCC know what code from the static library the application is actually using? Does it only look t the header files that are included (directly and indirectly) in the application and then pull code accordingly? Or does it actually look at what methods from the static library are being called?

    Read the article

  • Determine the width of the vertical scroll bar in a ScrollViewer

    - by juharr
    I'm using a ScrollViewer to display an Image. The Image has a ScaleTransform set as one of it's LayoutTransforms. I've got it setup to fit the width of the image into the ActualSize of the ScrollViewer. My problem is that if the image height requires the vertical scrollbar to be present (I have it set to Auto) then my image is scaled just a little bit to much. I know how to determine if the scrollbar would be present and how to get the correct scale, but I cannot figure out how to determine what the actual width of the scrollbar is. I guess I could just guess at it, but I'd like something that would work if I later add styles to my application that would result in the scrollbars being a different size. Additionally I'm also doing Fit to Height and would need to get the Height of the horizontal scrollbar when it would be visible (I'm assuming that the answer to getting the width of the vertical scrollbar would make getting the height of the horizontal scrollbar obvious).

    Read the article

  • Drupal image management

    - by vian
    Please suggest how should I approach these requirements. What ready-to-use solutions (modules) are best suited to achieve something like this: What I need is an image library that has searchable, tagged images that are already resized when we publish them. If the author searches the library and the image he needs isn’t there, he can upload one and have it added to the index. The important thing is that images in the library can be sorted into three categories: News images, top story images and feature images so that, over time, we don’t end up with hundreds of images crammed into one folder, thus making browsing a pain (and to prevent someone from something like: Searching for a keyword so they can find an image for the news, picking an image, and then seeing it’s 1600X. 1200). Also, I need something which will assemble thumbnail galleries easily. I don’t want to have to go to the image library, get a URL, go back, paste it in, etc. I should be able to pick, say, 8 images and say “create gallery”. How this objective is achieved is flexible, but I am looking for a shortcut to get around assembling screenshot galleries by hand.

    Read the article

  • jQuery: why does my live() handler declaration error out when the analogous click() one doesn't?

    - by Jason
    I have the following in a javascript file (using jQuery as well): $(function(){ $('#mybutton').live('click',myObject.someMethod); }); var myObject = { someMethod: function() { //do stuff } }; I get a js error on pageload that says "myObject isn't defined". However, when I change the event handler in the doc.ready function to: $('#mybutton').live('click', function(){ myObject.someMethod(); }); it works! I have code structured like the first example all over my codebase that works. W T F??

    Read the article

  • How to remotely connect to jmx on tomcat using ssh tunnelling and not break ehcache...

    - by Unsavory
    I've followed the instructions in the following link to create my own RMI registry and jmx server on a single port inside tomcat. According to the comments, I need to set -Djava.rmi.server.hostname=localhost. Once I do that, I can indeed connect to my server via jconsole using ssh port forwarding. http://blogs.sun.com/jmxetc/entry/connecting_through_firewall_using_jmx However, I've found it has the very bad side affect of breaking our ehcache replication which uses RMI. It fails complaining that it cannot bootstrap from remote peer localhost. I'm guessing because the peers all have their rmi server hostname set to localhost from setting -Djava.rmi.server.hostname=localhost. Does anyone have a possible workaround to this problem?

    Read the article

  • SIMPLE OpenSSL RSA Encryption in C/C++ is causing me headaches

    - by Josh
    Hey guys, I'm having some trouble figuring out how to do this. Basically I just want a client and server to be able to send each other encrypted messages. This is going to be incredibly insecure because I'm trying to figure this all out so I might as well start at the ground floor. So far I've got all the keys working but encryption/decryption is giving me hell. I'll start by saying I am using C++ but most of these functions require C strings so whatever I'm doing may be causing problems. Note that on the client side I receive the following error in regards to decryption. error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check failed I don't really understand how padding works so I don't know how to fix it. Anywho here are the relevant variables on each side followed by the code. Client: RSA *myKey; // Loaded with private key // The below will hold the decrypted message unsigned char* decrypted = (unsigned char*) malloc(RSA_size(myKey)); /* The below holds the encrypted string received over the network. Originally held in a C-string but C strings never work for me and scare me so I put it in a C++ string */ string encrypted; // The reinterpret_cast line was to get rid of an error message. // Maybe the cause of one of my problems? if(RSA_private_decrypt(sizeof(encrypted.c_str()), reinterpret_cast<const unsigned char*>(encrypted.c_str()), decrypted, myKey, RSA_PKCS1_OAEP_PADDING)==-1) { cout << "Private decryption failed" << endl; ERR_error_string(ERR_peek_last_error(), errBuf); printf("Error: %s\n", errBuf); free(decrypted); exit(1); } Server: RSA *pkey; // Holds the client's public key string key; // Holds a session key I want to encrypt and send //The below will hold the encrypted message unsigned char *encrypted = (unsigned char*)malloc(RSA_size(pkey)); // The reinterpret_cast line was to get rid of an error message. // Maybe the cause of one of my problems? if(RSA_public_encrypt(sizeof(key.c_str()), reinterpret_cast<const unsigned char*>(key.c_str()), encrypted, pkey, RSA_PKCS1_OAEP_PADDING)==-1) { cout << "Public encryption failed" << endl; ERR_error_string(ERR_peek_last_error(), errBuf); printf("Error: %s\n", errBuf); free(encrypted); exit(1); } Let me once again state, in case I didn't before, that I know my code sucks but I'm just trying to establish a framework for understanding this. I'm sorry if this offends you veteran coders. Thanks in advance for any help you guys can provide!

    Read the article

  • Why is the compiler not selecting my function-template overload in the following example?

    - by Steve Guidi
    Given the following function templates: #include <vector> #include <utility> struct Base { }; struct Derived : Base { }; // #1 template <typename T1, typename T2> void f(const T1& a, const T2& b) { }; // #2 template <typename T1, typename T2> void f(const std::vector<std::pair<T1, T2> >& v, Base* p) { }; Why is it that the following code always invokes overload #1 instead of overload #2? void main() { std::vector<std::pair<int, int> > v; Derived derived; f(100, 200); // clearly calls overload #1 f(v, &derived); // always calls overload #1 } Given that the second parameter of f is a derived type of Base, I was hoping that the compiler would choose overload #2 as it is a better match than the generic type in overload #1. Are there any techniques that I could use to rewrite these functions so that the user can write code as displayed in the main function (i.e., leveraging compiler-deduction of argument types)?

    Read the article

  • SharePoint Webpart and ASP.NET User Control

    - by tbischel
    I am developing SharePoint Web Parts for MOSS 2007 on Visual Studio 2008. Up until now, I've been adding all my controls by hand to the code behind... but an earlier post suggested I could use the designer to create an ASP.NET User Control, then add it to the webpart, and everything is happy... See figure 5 for an example. However, I can't seem to add a new ASP.NET User Control to my MOSS WebPart project, the template just doesn't appear. If I create a WebApplication and make my User Control in there, I can't see any SharePoint templates to add to the project. Finally, I tried copying a simple aspx file and its code behind to my webpart directly, and adding them as an "existing component"... but now the designer won't recognize the aspx file. Next, I'd probably try adding two projects to my solution, and just referencing any dll's from the ASP.NET application... So how do I get an ASP control into my SharePoint WebPart project so that I can use the Visual Studio designer?

    Read the article

  • Remote Desktop keeps asking me to accept a Certificate?

    - by Pure.Krome
    Hi folks, i'm using Remote Desktop on Windows 7 RC1, connecting to a Windows 2008 server. Everytime i start a connection, i get the following popup window :- The certificate problem makes sense - it was created from my own server, which is not an offical certificate authority. Sure. So I need to tell my machine that any certificate that comes from my server, can u please accept. So i View the certificate and install it. I let it determine the best place to install it. eg Unfortunately, every time i connect, i still get that popup question. So i tried to manually tell where to install it. I said to install it at eg. but still i get the warning question. So .. does anyone have any suggestions?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >