I Dim a graphic “Public Ax1g1 As Graphics = MYform1.CreateGraphics” and the call the “bitblt” function to capture the image and then I release the handle “Ax1g1.ReleaseHdc(dc1)” On any subsequent call to this class “Ax1ThumbnailClass.AxCaptureImage” I get an invalid parameter exception on Ax1g1.ReleaseHdc(dc1). I’ve tried not releasing the handles and I do not get the exception but the captured image is blank. Help greatly appreciated!!!! ********************CALLING CODE*********************** Ax1Thumbnail.AxCaptureImage(MYform1.AxWebBrowser1.Location.X, MYform1.AxWebBrowser1.Location.Y) Myform2.thumbScr1.Image = Ax1Thumbnail.Ax1Image.GetThumbnailImage(50, 50, Nothing, Nothing) Public Class Ax1ThumbnailClass Public Ax1g1 As Graphics = MYform1.CreateGraphics() Public Ax1Image = New Bitmap(150, 150, Ax1g1) Public Ax1g2 As Graphics = Graphics.FromImage(Ax1Image) Public dc1 As IntPtr = Ax1g1.GetHdc() Public dc2 As IntPtr = Ax1g2.GetHdc() Public Sub AxCaptureImage(ByVal Browser1 As Integer, ByVal Browser2 As Integer) CallBitBlt.BitBlt(dc2, 0, 0, 150, 150, dc1, Browser1, Browser2, SSRCCOPY) Ax1g1.ReleaseHdc(dc1) Ax1g2.ReleaseHdc(dc2) End Sub End Class Public Class bitbltClass _ Public Shared Function BitBlt(ByVal hdcDest As IntPtr, _ ByVal nXDest As Integer, _ ByVal nYDest As Integer, _ ByVal nWidth As Integer, _ ByVal nHeight As Integer, _ ByVal hdcSrc As IntPtr, _ ByVal nXSrc As Integer, _ ByVal nYSrc As Integer, _ ByVal dwRop As System.Int32) As Boolean End Function End Class Thanks, GregC
gregcost
Posts
-
Questions about releasing handles. -
Call a form’s sub from a Sub Main()Hi John, THANKS! It worked GREAT! :) Thanks, GregC
-
Call a form’s sub from a Sub Main()Hi should have added that this is an event. Public Sub loadFromFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loadFromFile.Click is it possible to raise an event on another form from a sub main? i'm not quite sure how to code that. Would i need to change the above click event code and how would I call or raise the event from the sub main? And would rasing the event execute the click event? Thanks, GregC
-
Call a form’s sub from a Sub Main()I start my project with a module called SubmainController.vb which contains a Public Sub Main() In this public sub main I want to call a sub from another form in the project. I’ve tried the following without ant success. Dim Myform1 as new Form1 Call Myform1.LoadFromFile (property access my assign to the property or use its value Dim ProjectName as string “Web Project” Call ProjectName.Myform1.LoadFromFile (myform1 not a member of string) I though this would be simple. I appreciate help Thanks GregC Thanks, GregC
-
Starting PowerPoint in a webbrowser controlI can use Knowledge base article 243058 to open a office application like Word or Excel but when I try to open PowerPoint it open the presentation of the .ppt file and not powerpoint as the other file types do. Is there another ppt file type that will trip the opening of the product itself with a presentation loaded or at least can I open a power point in the control and then open a ppt presentation? Is there another way to embed an Office application in a windows form other than using the a Webbrowser control? Thanks, GregC
-
Run an external application hiddenFrom my windows.net application I can shell to an external application and run it using sendKeys.Wait keystrokes. … This all works fine but it does it out in the open. When I use AppWinStyle.Hide or ApWinStyle.MinimizedFocus or ApWinStyle.MinimizedNoFocus the application appears when the “ENTER” is execute and again when the “F9” is executed Otherwise it is hidden or minimized. Any Ideas? Thanks GregC Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ProcID = Shell("C:\wincopy\wincopy.exe", AppWinStyle.Hide) AppActivate(ProcID) SendKeys.SendWait("{ENTER}") SendKeys.SendWait("{F9}") End Sub Thanks, GregC
-
Gif animation do you need the Image Animation Class?I have an animated gif set to play once (not loop forever) I can display an animated gif in a form using the following: picturebox.Image = Image.FromFile("c:\directory\image.gif") The image displays correctly but plays forever even though it is set to play only once. Without going through all the heavy lifting of using the Image animation class and counting frames. Is there a way to stop the animation after one play? Thanks, GregC
-
Thumbnail an html page directly from IE programmatically?I would like to grab an HTML page from a WebBrowser control and thumbnail it to a picturebox control. Anyone out there know how to do this? The only way I can see to do this is to use shareware or a commercial product to convert an html page to a bmp, external to the program, save it on disk and then use GetThumbnailImage to thumbnail it. Thanks, GregC
-
TransparencyKey usage consuming memoryI can open up to 5 Webbrowser controls on 5 separate forms. A medium size panel control on each form is transparent. I can only open up to 3 forms before memory is exhausted. As a test, when I eliminate the transparency I have opened the same form up to 50 times without any problems. Has anyone else run into this problem using the TransparencyKey? I can’t find anything at MS on memory consumption and the transparencyKey property. :omg: Thanks, GregC
-
Does this COM dll look unregistered?I’m a Network engineer I’m not programmer heavy and I think I understand what you are saying. I did try the code exactly as stated in the article but I ran into other problems (below) with the dim statements. What I was attempting to do was to go a different way. I was hoping I could set the field True in the CEventObjclass (which I thought this code is trying to do) and if I could do that I was hoping I could set return value true always regardless of an onError event so that I could continually disable script error checking. Ok that being said are you saying that the field being made available through the interfaces (really address pointers), passed in a sense to its subscribers (a webbrowser control) is really a property of IE? Am I correct in understanding what you are saying? I’m getting Com errors with the standard dims described in the article. The first Interface dim works fine: dim withevents for HTMLDocument The second interface dim does not work: Dim WithEvents objwind As New mshtml.HTMLWindow2() Additional information: COM object with CLSID {D48A6EC6-6A4A-11CF-94A7-444553540000} is either not valid or not registered. And of course the third does not work either: Dim objevent As New CEventObj() did not work as stated in the article Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered. In trying to resolve the COMException for the dim of Interface CEventObj I have tried un-registering and re-registering the interop dll Microsoft.mshtml.dll in \Program Files\Microsoft.net\Primary Interop Assembles\ Any ideas? I get the same kind of error when trying the code it exactly in the KBase Article. Please let me know if my understanding now about passing the field is correct. After all I never get upset about this stuff everything we do is a learning experience. Thanks, GregC
-
Does this COM dll look unregistered?Hi Stephane, Sorry, yes the dim I wrote as I was writing the message is the interface, I left off the Class suffix. I have tried it a bunch of different ways Dim objevent As New CEventObjClass() Dim objevent As New mshtml.CeventObjClass In fact none of the classes will work in the dll. I get the same COMException for any I try. What I’m actually trying is to get MS Knowledge Base Article 279535 to work. The short program uses a property in the class CEeventObjClass to disable script error checking for forms hosting a WebBrowser control. For whatever reasons Microsoft did not implement this disabling script feature for WebBrowser controls by selecting it from IE (even through it is really the same object). It is available for IE. So they supply you with a code example in VB6 not VB.net to address this problem. Actually I can understand why they did it this way because you might want to disable script error checking for IE but not completely across any applications that host Web controls on the same system. So since I’m trying to rework MS code I’m not flying to blind… Or am I!!!! Well, if you think of anything please let me know and thanks for your help! Thanks, GregC
-
Does this COM dll look unregistered?Hi Stephane, One more thing even if I spell it all out like Dim objevent As New mshtml.CEventObjClass() I get the same result Thanks, GregC :(
-
Does this COM dll look unregistered?Hi Stephane, Yes it is Interop but isn’t the underlying code in MSTHML.dll? Or am I missing something? The statement is also so simple. Dim objevent As New CEventObj() Of interest when I create a Console.WriteLine(objevent.returnValue), property in the CeventObjClass, Studio based on the dim does not complain and shows me the correct object list to select .returnValue from the class. Thanks, GregC
-
Does this COM dll look unregistered?Because it doesn't to me. Exception:---------------------------------------------------------------------------------- An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test Form exe Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered. From Registry:------------------------------------------------------------------------------ [HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32] "Class"="mshtml.CEventObjClass" "Assembly"="Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "RuntimeVersion"="v1.0.3705" [HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32\7.0.3300.0] "Class"="mshtml.CEventObjClass" "Assembly"="Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" "RuntimeVersion"="v1.0.3705" From Gacutil /L: (GAC)---------------------------------------------------------------------- Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, Custom=null And Finally my own investigation of 3050f48a-98b5-11cf-bb82-00aa00bdce0b using--------------------------- Dim csCEventObjCLASS As New Guid("3050F48A-98B5-11CF-BB82-00AA00BDCE0B") Dim C_CEventObjCLASS As Type = Type.GetTypeFromCLSID(csCEventObjCLASS, True) CLASSName mshtml.CEventObjClass IsClass) TRUE IsCOMObject) TRUE IsInterface) FALSE IsPointer) FALSE Namespace) mshtml Module) MSHTML.dll Name) CEventObjClass GUID) 3050f48a-98b5-11cf-bb82-00aa00bdce0b Assembly) Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Assembly.Location) c:\winnt.0\assembly\gac\microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\microsoft.mshtml.dll Assembly.CodeBase) file:///c:/winnt.0/assembly/gac/microsoft.mshtml/7.0.3300.0__b03f5f7f11d50a3a/microsoft.mshtml.dll Assembly.GlobalAssemblyCache) TRUE Assembly.FullName) Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Assembly.GetCallingAssembly) System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Assembly.GetEntryAssembly) Test Form Focus, Version=1.0.1434.13227, Culture=neutral, PublicKeyToken=null Assembly.GetExecutingAssembly) Test Form Focus, Version=1.0.1434.13227, Culture=neutral, PublicKeyToken=null Assembly.GetExportedTypes) System.Type[] Assembly.GetFiles) System.IO.FileStream[] Assembly.GetLoadedModules) System.Reflection.
-
Help with COMExceptionI'm trying to set a property in the following class: Public Class CEventObj Member of mshtml The property is: Public Property returnValue As Object Member of mshtml.CEventObj When I try: Dim objevent As New mshtml.CEventObjClass() OR Dim objevent As New mshtml.CEventObj() OR Dim objevent As New CEventObjClass() OR Dim objevent As New CEventObj() I get the following error, also the CSLID from the Object Browser of 3050F558-98B5-11CF-BB82-00AA00BDCE0B is different from the COMException error message An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test Form .exe Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered. The Registry states the CSLID 3050F48A-98B5-11CF-BB82-00AA00BDCE0B from COMError message is the following: HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}... default(not set) HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32... Assembly(Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Class(mshtml.CEventObjClass) Runtime version(v1.0.3705) The Registry states the CSLID 3050F558-98B5-11CF-BB82-00AA00BDCE0B from the Object Browser view is the following: HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B} default(DispCEventObj) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid... default(00020420-0000-0000-C000-000000000046) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid32... default(00020420-0000-0000-C000-000000000046) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B} TypeLib(3050F1C5-98B5-11CF-BB82-00AA00BDCE0B) Just to be sure I ran regsvr32 mshtml.dll sucessfully What is going on? the CSLId from the COMException InprocServer32 points to Class(mshtml.CEventObjClass). H E L P! Thanks, GregC
-
Help on Com ExceptionI'm trying to set a property in the following class: Public Class CEventObj Member of mshtml The property is: Public Property returnValue As Object Member of mshtml.CEventObj When I try: Dim objevent As New mshtml.CEventObjClass() OR Dim objevent As New mshtml.CEventObj() OR Dim objevent As New CEventObjClass() OR Dim objevent As New CEventObj() I get the following error, also the CSLID from the Object Browser of 3050F558-98B5-11CF-BB82-00AA00BDCE0B is different from the COMException error message An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Test Form .exe Additional information: COM object with CLSID {3050F48A-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered. The Registry states the CSLID 3050F48A-98B5-11CF-BB82-00AA00BDCE0B from COMError message is the following: HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}... default(not set) HKEY_CLASSES_ROOT\CLSID\{3050F48A-98B5-11CF-BB82-00AA00BDCE0B}\InprocServer32... Assembly(Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a) Class(mshtml.CEventObjClass) Runtime version(v1.0.3705) The Registry states the CSLID 3050F558-98B5-11CF-BB82-00AA00BDCE0B from the Object Browser view is the following: HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B} default(DispCEventObj) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid... default(00020420-0000-0000-C000-000000000046) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B}\ProxyStubClsid32... default(00020420-0000-0000-C000-000000000046) HKEY_CLASSES_ROOT\Interface\{3050F558-98B5-11CF-BB82-00AA00BDCE0B} TypeLib(3050F1C5-98B5-11CF-BB82-00AA00BDCE0B) Just to be sure I ran regsvr32 mshtml.dll sucessfully What is going on? the CSLId from the COMException InprocServer32 points to Class(mshtml.CEventObjClass). H E L P! Thanks, GregC