
dynamic_sysop
Leaders
-
Posts
1044 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by dynamic_sysop
-
try adding the window.ResizeTo function in your javascript line m8 , eg: [color=Blue]Dim[/color] pr [color=Blue]As New[/color] Process pr.Start("javascript:window.open([color=Green]'http://www.samsmith.co.nz/tab'[/color][color=Blue],[/color] [color=Green]'_self'[/color][color=Blue], [/color] [color=Green]'menubar=no,scrollbars=no,toolbar=no,width=500,height=520'[/color]);window.resizeTo(500[color=Blue],[/color]520);") [color=Green]'/// note the window.resizeTo(500,520); bit i added and also the '_self' part ( to use the same window )[/color] hope it helps :)
-
that post shows you how to open a file on the internet and read it ( for displaying or saving etc... ) the system.net.webclient allows you to do this easily , here's a quick example that may look a little easier to understand ... [color=DarkGreen]'///download from the internet to a byte array...[/color] [color=Blue]Dim [/color] wClient [color=Blue]As New[/color] System.Net.WebClient [color=Blue]Dim[/color] bHtml [color=Blue]As Byte[/color]() = wClient.DownloadData("http://google.com") [color=DarkGreen]'/// you would specify the path of the text file where it says google.com[/color] [color=Blue]Dim[/color] html [color=Blue]As String[/color] = System.Text.Encoding.Default.GetString(bHtml) MessageBox.Show(html) wClient.Dispose() hope it helps :)
-
VB.Net - VB6 RichTextBox.Seltext alternative?
dynamic_sysop
replied to predseda's topic in Windows Forms
use the SelectionText property , eg: RichTextBox1.SelectionText = "the text to add to the richtextbox" -
the main part ( the interface it's self ) ... #Region " IActiveDesktop Interface" <ComImport(), Guid("F490EB00-1240-11D1-9888-006097DEACF9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)> _ Public Interface IActiveDesktop '/// '// these functions need to be in the same order as seen in the SHLOBJ.H C/C++ Header file... '/// Function ApplyChanges(ByVal dwFlags As Integer) As IntPtr '///HRESULT ApplyChanges(DWORD dwFlags); Function GetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As System.Text.StringBuilder, ByVal cchWallpaper As Integer, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetWallpaper(LPWSTR pwszWallpaper,UINT cchWallpaper,DWORD dwReserved); Function SetWallpaper(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszWallpaper As String, ByVal dwReserved As Integer) As IntPtr '///HRESULT SetWallpaper(LPCWSTR pwszWallpaper,DWORD dwReserved); Function GetWallpaperOptions(ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetWallpaperOptions(LPWALLPAPEROPT pwpo,DWORD dwReserved); Function SetWallpaperOptions(<[in]()> ByRef pwpo As _win32._tagWALLPAPEROPT, ByVal dwReserved As Integer) As IntPtr '///HRESULT SetWallpaperOptions(LPCWALLPAPEROPT pwpo,DWORD dwReserved); Function GetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As System.Text.StringBuilder, ByVal cchPattern As Integer, ByVal dwReserved As Integer) As IntPtr 'HRESULT GetPattern(LPWSTR pwszPattern,UINT cchPattern,DWORD dwReserved); Function SetPattern(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszPattern As String, ByVal dwReserved As Integer) As IntPtr '///HRESULT SetPattern(LPCWSTR pwszPattern,DWORD dwReserved); Function GetDesktopItemOptions(ByRef pco As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetDesktopItemOptions(LPCOMPONENTSOPT pco,DWORD dwReserved); Function SetDesktopItemOptions(<[in]()> ByRef pcomp As _win32._tagCOMPONENTSOPT, ByVal dwReserved As Integer) As IntPtr '///HRESULT SetDesktopItemOptions(LPCCOMPONENTSOPT pcomp,DWORD dwReserved); Function AddDesktopItem(<[in]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr '///HRESULT AddDesktopItem(LPCOMPONENT pcomp,DWORD dwReserved); Function AddDesktopItemWithUI(ByVal hwnd As IntPtr, <[in]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr '///HRESULT AddDesktopItemWithUI(HWND hwnd,LPCOMPONENT pcomp,DWORD dwFlags); Function ModifyDesktopItem(<[in]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr '///HRESULT ModifyDesktopItem(LPCCOMPONENT pcomp,DWORD dwFlags); Function RemoveDesktopItem(<[in]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr '///HRESULT RemoveDesktopItem(LPCCOMPONENT pcomp,DWORD dwReserved); Function GetDesktopItemCount(ByRef lpiCount As Integer, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetDesktopItemCount(LPINT lpiCount,DWORD dwReserved); Function GetDesktopItem(ByVal nComponent As Integer, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetDesktopItem(int nComponent,LPCOMPONENT pcomp,DWORD dwReserved); Function GetDesktopItemByID(ByVal dwID As IntPtr, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetDesktopItemByID(DWORD dwID,LPCOMPONENT pcomp,DWORD dwReserved); Function GenerateDesktopItemHtml(<MarshalAs(UnmanagedType.LPWStr)> ByVal pwszFileName As String, <[in]()> ByRef pcomp As _win32._tagCOMPPOS, ByVal dwReserved As Integer) As IntPtr '///HRESULT GenerateDesktopItemHtml(LPCWSTR pwszFileName,LPCOMPONENT pcomp,DWORD dwReserved); Function AddUrl(ByVal hwnd As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal pszSource As String, <[in]()> ByRef pcomp As _win32._tagCOMPONENT, ByVal dwFlags As Integer) As IntPtr '///HRESULT AddUrl(HWND hwnd,LPCWSTR pszSource,LPCOMPONENT pcomp,DWORD dwFlags); Function GetDesktopItemBySource(<MarshalAs(UnmanagedType.LPWStr)> ByVal pszSource As String, ByRef pcomp As _win32._tagCOMPONENT, ByVal dwReserved As Integer) As IntPtr '///HRESULT GetDesktopItemBySource(LPCWSTR pszSource,LPCOMPONENT pcomp,DWORD dwReserved); End Interface #End Region #Region " win32 constants and structs " Public Class _win32 Public Const AD_APPLY_ALL As Integer = AD_APPLY_SAVE Or AD_APPLY_HTMLGEN Or AD_APPLY_REFRESH Public Const AD_APPLY_BUFFERED_REFRESH As Integer = &H10 Public Const AD_APPLY_DYNAMICREFRESH As Integer = &H20 Public Const AD_APPLY_FORCE As Integer = &H8 Public Const AD_APPLY_HTMLGEN As Integer = &H2 Public Const AD_APPLY_REFRESH As Integer = &H4 Public Const AD_APPLY_SAVE As Integer = &H1 Public Const COMP_ELEM_ALL As Integer = COMP_ELEM_TYPE Or COMP_ELEM_CHECKED Or COMP_ELEM_DIRTY Or COMP_ELEM_NOSCROLL Or COMP_ELEM_POS_LEFT Or COMP_ELEM_SIZE_WIDTH Or COMP_ELEM_SIZE_HEIGHT Or COMP_ELEM_POS_ZINDEX Or COMP_ELEM_SOURCE Or COMP_ELEM_FRIENDLYNAME Or COMP_ELEM_POS_TOP Or COMP_ELEM_SUBSCRIBEDURL Or COMP_ELEM_ORIGINAL_CSI Or COMP_ELEM_RESTORED_CSI Or COMP_ELEM_CURITEMSTATE Public Const COMP_ELEM_CHECKED As Integer = &H2 Public Const COMP_ELEM_CURITEMSTATE As Integer = &H4000 Public Const COMP_ELEM_DIRTY As Integer = &H4 Public Const COMP_ELEM_FRIENDLYNAME As Integer = &H400 Public Const COMP_ELEM_NOSCROLL As Integer = &H8 Public Const COMP_ELEM_ORIGINAL_CSI As Integer = &H1000 Public Const COMP_ELEM_POS_LEFT As Integer = &H10 Public Const COMP_ELEM_POS_TOP As Integer = &H20 Public Const COMP_ELEM_POS_ZINDEX As Integer = &H100 Public Const COMP_ELEM_RESTORED_CSI As Integer = &H2000 Public Const COMP_ELEM_SIZE_HEIGHT As Integer = &H80 Public Const COMP_ELEM_SIZE_WIDTH As Integer = &H40 Public Const COMP_ELEM_SOURCE As Integer = &H200 Public Const COMP_ELEM_TYPE As Integer = &H1 Public Const COMP_ELEM_SUBSCRIBEDURL As Integer = &H800 Public Const COMP_TYPE_CONTROL As Integer = 3 Public Const COMP_TYPE_HTMLDOC As Integer = 0 Public Const COMP_TYPE_PICTURE As Integer = 1 Public Const COMP_TYPE_WEBSITE As Integer = 2 Public Const COMPONENT_DEFAULT_LEFT As Integer = &HFFFF Public Const COMPONENT_DEFAULT_TOP As Integer = &HFFFF Public Const IS_FULLSCREEN As Integer = &H2 Public Const IS_NORMAL As Integer = &H1 Public Const IS_SPLIT As Integer = &H4 Public Const MAX_PATH As Integer = 260 Public Const WPSTYLE_CENTER As Integer = 0 Public Const WPSTYLE_MAX As Integer = 3 Public Const WPSTYLE_STRETCH As Integer = 2 Public Const WPSTYLE_TILE As Integer = 1 <StructLayout(LayoutKind.Sequential)> _ Public Structure _tagCOMPSTATEINFO Private dwSize As Integer Private iLeft As Integer Private iTop As Integer Private dwWidth As Integer Private dwHeight As Integer Private dwItemState As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure _tagCOMPPOS Private dwSize As Integer Private iLeft As Integer Private iTop As Integer Private dwWidth As Integer Private dwHeight As Integer Private izIndex As Integer <MarshalAs(UnmanagedType.Bool)> _ Private fCanResize As Boolean <MarshalAs(UnmanagedType.Bool)> _ Private fCanResizeX As Boolean <MarshalAs(UnmanagedType.Bool)> _ Private fCanResizeY As Boolean Private iPreferredLeftPercent As Integer Private iPreferredTopPercent As Integer End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure _tagCOMPONENT Public dwSize As Integer Public dwID As Integer Public iComponentType As Integer <MarshalAs(UnmanagedType.Bool)> _ Public fChecked As Boolean <MarshalAs(UnmanagedType.Bool)> _ Public fDirty As Boolean <MarshalAs(UnmanagedType.Bool)> _ Public fNoScroll As Boolean Public cpPos As _tagCOMPPOS <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> _ Public wszFriendlyName As String <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2084)> _ Public wszSource As String <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=2084)> _ Public wszSubscribedURL As String Public dwCurItemState As Integer Public csiOriginal As _tagCOMPSTATEINFO Public csiRestored As _tagCOMPSTATEINFO End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure _tagCOMPONENTSOPT Public dwSize As Integer <MarshalAs(UnmanagedType.Bool)> _ Public fEnableComponents As Boolean <MarshalAs(UnmanagedType.Bool)> _ Public fActiveDesktop As Boolean End Structure <StructLayout(LayoutKind.Sequential)> _ Public Structure _tagWALLPAPEROPT Public dwSize As Integer Public dwStyle As Integer End Structure End Class #End Region
-
i've decided to post an example on Implementing the IActiveDesktop interface in vb.net , examples in c# / j# can be found on my personal website. here's the vb.net example ( part 1 ) ... <DllImport("OLE32.DLL")> _ Public Shared Function CoCreateInstance( _ ByRef ClassGuid As Guid, _ ByVal pUnkOuter As IntPtr, _ ByVal dwClsContext As Integer, _ ByRef InterfaceGuid As Guid, _ ByRef Result As IActiveDesktop) As IntPtr End Function Private CLSID_ActiveDesktop As New Guid("75048700-EF1F-11D0-9888-006097DEACF9") Private IID_IActiveDesktop As New Guid("F490EB00-1240-11D1-9888-006097DEACF9") Private Const CLSCTX_INPROC_SERVER As Integer = 1 Private ActiveDesktop As IActiveDesktop Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load CoCreateInstance(CLSID_ActiveDesktop, _ IntPtr.Zero, CLSCTX_INPROC_SERVER, _ IID_IActiveDesktop, ActiveDesktop) End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If SUCCEEDED(ActiveDesktop) Then Marshal.ReleaseComObject(ActiveDesktop) End If End Sub Private Function SUCCEEDED(ByVal obj As Object) As Boolean '/// checks to see if an object is created or " Nothing " If Not obj Is Nothing Then Return True Else Return False End If End Function Private Function makethumb() As Boolean Return False End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If SUCCEEDED(ActiveDesktop) Then Dim sBuilder As New StringBuilder(_win32.MAX_PATH) ActiveDesktop.GetWallpaper(sBuilder, sBuilder.Capacity, 0) Label1.Text = sBuilder.ToString '/// create a thumbnail image of your current wallpaper and display in a picturebox. Dim imgCallback As New Image.GetThumbnailImageAbort(AddressOf makethumb) Dim bmp As Bitmap = Bitmap.FromFile(Label1.Text) Dim imgThumb As Image = bmp.GetThumbnailImage((PictureBox1.Width / bmp.Width) * bmp.Width, (PictureBox1.Height / bmp.Height) * bmp.Height, imgCallback, IntPtr.Zero) PictureBox1.Image = imgThumb End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If SUCCEEDED(ActiveDesktop) Then Dim OD As New OpenFileDialog With OD .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) .Filter = "Jpeg |*.jpg|Bitmap |*.bmp" If .ShowDialog = DialogResult.OK Then ActiveDesktop.SetWallpaper(OD.FileName, 0) ActiveDesktop.ApplyChanges(_win32.AD_APPLY_FORCE Or _win32.AD_APPLY_SAVE Or _win32.AD_APPLY_REFRESH) End If End With End If End Sub End Class and the sample project also. IActiveDesktop_in_VB.zip
-
x and y should be the location of your button , not it's width and height ( the screen x and screen y positions )
-
Using API functions in Windows Forms (C++)
dynamic_sysop
replied to yelp666's topic in Interoperation / Office Integration
take a look at the example i posted in the code-bank of this forum on using graphics in C++ ( windows forms .NET ) , here's the link ... Printscreen / alt+Printscreen including Cursor , in C++ -
Printscreen / alt+Printscreen including Cursor , in C++
dynamic_sysop
posted a topic in Code Library
An example of taking a screenshot of either the entire desktop , or a window by it's handle. included in the screenshot is the Cursor at it's position at the time of the shot ( unlike windows , which doesn't show the Cursor ) This for me has proved to be the most challenging of projects, i've built it all in C++ ( .NET win forms , but using standard C++ api calls etc... ) #pragma once #include <windows.h> #include "Winuser.h" // then to use the sample ( i've used a button and 2 radio buttons in this case ) ... private: void button1_Click(System::Object * sender, System::EventArgs * e) { IntPtr handle = IntPtr::Zero; int width = NULL; int height = NULL; int x = NULL; int y = NULL; if(radioButton1->Checked == true) { // // specify the handle of the Form // and the form's sizes / positions handle = this->get_Handle(); width = this->get_Width(); height = this]->get_Height(); x = this->get_Location().get_X(); y = this->get_Location().get_Y(); } else { // // specify the handle of the Desktop // and the Desktop's sizes / positions. handle = GetDesktopWindow(); Screen *r = Screen::PrimaryScreen; width = r->Bounds.get_Width(); height = r->Bounds.get_Height(); x = 0; y = 0; } // // now lets try to make a Screenshot which includes the Cursor ( unlike the Screenshot that Windows takes ) Snapshot(handle , width , height , x , y); } private: void Snapshot(IntPtr hHandle , int width , int height , int x , int y) { /// //The GetWindowDC function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars. ///See Msdn Article for more info ... [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_0hcz.asp[/url] HDC srcHDC = GetWindowDC((HWND)hHandle.ToInt32()); /// //The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device. ///See Msdn Article for more info ... [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_499f.asp[/url] HDC destHDC = CreateCompatibleDC(srcHDC); /// //The CreateCompatibleBitmap function creates a bitmap compatible with the device that is associated with the specified device context. ///See Msdn Article for more info ... [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_1cxc.asp[/url] HBITMAP bmpDC = CreateCompatibleBitmap(srcHDC , width , height); /// //The SelectObject function selects an object into the specified device context (DC). The new object replaces the previous object of the same type. ///See Msdn Article for more info ... [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_9v3o.asp[/url] HGDIOBJ objHDC = SelectObject(destHDC, bmpDC); /// //The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context. ///See Msdn Article for more info ... [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_0fzo.asp[/url] BitBlt(destHDC, 0, 0, width, height, srcHDC, 0, 0, SRCCOPY); SelectObject(destHDC, objHDC); /// // here i cast a Bitmap ( .NET / C# type Bitmap ) from the C++ style HBITMAP /// for this i use " dynamic_cast " , which is seen in .NET as DirectCast. Bitmap *bmp = dynamic_cast<Bitmap*>(Bitmap::FromHbitmap(bmpDC)); /// //now i create a Graphics object , to enable the Cursor to be Drawn in it's Correct Position. Graphics *g = dynamic_cast<Graphics*>(Graphics::FromImage(bmp)); System::Windows::Forms::Cursor *csr=Cursor::get_Current(); System::Drawing::Point pnt = (System::Drawing::Point)csr->get_Position(); /// // this was quite tricky as creating a new Rectangle threw alsorts of problems, until i found the FromLTRB property. System::Drawing::Rectangle r= System::Drawing::Rectangle::FromLTRB((int)(pnt.get_X() - 10) - x,(int)(pnt.get_Y() - 10) - y,(int)csr->get_Size().get_Width() ,(int)csr->get_Size().get_Width()); /// // now i draw the Cursor on to the Graphics object of the bitmap. csr->Draw( g , r); /// //next i clean up any Resources used by the above calls. ReleaseDC((HWND)hHandle.ToInt32(), srcHDC); DeleteDC(destHDC); DeleteObject(bmpDC); /// // finally i save the Bitmap ( this was the Reason for using a .NET Bitmap , makes saving alot simpler ) . bmp->Save("C:\\test123.bmp" , System::Drawing::Imaging::ImageFormat::Bmp ); MessageBox(NULL , "ScreenShot Complete","Dynamic's C++ ScreenShot App",MB_ICONINFORMATION); } i've included a sample project ( it's VS2003 , so VS2002 users would need to convert the project or copy the code in to their version ) PrintScreen_in_C.zip -
Imports System.Runtime.InteropServices add the above line ^^^ at the very top of your code window.
-
well i made a project to save a webpage as an image a while back ( un released ) , but based on that idea , i have knocked this together for you ... this uses gdi api calls rather than PRNT SCRN it allows you to specify where to save the file / bmp or jpeg it puts the Cursor in the Correct position on the ScreenShot of your Form #Region " Api Calls " Private Const SRCCOPY As Integer = &HCC0020 <DllImport("gdi32.dll")> _ Private Shared Function BitBlt(ByVal hDestDC As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As IntPtr, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal dwRop As Integer) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function CreateCompatibleBitmap(ByVal hdc As IntPtr, ByVal nWidth As Integer, ByVal nHeight As Integer) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function CreateCompatibleDC(ByVal hdc As IntPtr) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function DeleteDC(ByVal hdc As IntPtr) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function DeleteObject(ByVal hObject As IntPtr) As IntPtr End Function <DllImport("user32.dll")> _ Private Shared Function GetWindowDC(ByVal hwnd As IntPtr) As IntPtr End Function <DllImport("user32.dll")> _ Private Shared Function GetWindowRect(ByVal hwnd As IntPtr, ByRef lpRect As Rectangle) As Integer End Function <DllImport("user32.dll")> _ Private Shared Function ReleaseDC(ByVal hwnd As IntPtr, ByVal hdc As IntPtr) As IntPtr End Function <DllImport("gdi32.dll")> _ Private Shared Function SelectObject(ByVal hdc As IntPtr, ByVal hObject As IntPtr) As IntPtr End Function #End Region Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ScreenTake() End Sub Private Sub ScreenTake() Dim srcHdc As IntPtr = GetWindowDC(Handle) [color=Green]'/// Handle being the Form's Handle[/color] Dim destHdc As IntPtr = CreateCompatibleDC(srcHdc) Dim bmpDc As IntPtr = CreateCompatibleBitmap(srcHdc, Width, Height) Dim objDc As IntPtr = SelectObject(destHdc, bmpDc) BitBlt(destHdc, 0, 0, Width, Height, srcHdc, 0, 0, SRCCOPY) SelectObject(destHdc, objDc) [color=Green]'/// create a bitmap from bmpDc...[/color] Dim bmp As Bitmap = DirectCast(Bitmap.FromHbitmap(bmpDc), Bitmap) [color=Green]'/// now we create a graphics object to draw the Cursor in the correct place.[/color] Dim g As Graphics = Graphics.FromImage(bmp) Dim p As Point = Cursor.Position [color=Green]'/// draw the cursor in the correct position...[/color] Cursor.Draw(g, New Rectangle((p.X - 10) - Me.Location.X, (p.Y - 10) - Me.Location.Y, Cursor.Clip.Height, Cursor.Clip.Height)) [color=Green]'/// clean up resources....[/color] ReleaseDC(Handle, srcHdc) DeleteDC(destHdc) DeleteObject(bmpDc) g.Dispose() [color=Green]'/// save your screenshot...[/color] Dim saveDg As New SaveFileDialog With saveDg .InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) .Filter = "JPeg|*.jpg|Bitmap|*.bmp" .FileName = "imgScreen" If .ShowDialog() = DialogResult.OK Then bmp.Save(.FileName) Else bmp.Save(Application.StartupPath & "\imgScreen.bmp") End If End With End Sub
-
am i correct in assuming you want to really take a shot of the whole screen? ( as well as obviously the Cursor )
-
yes , use the same webbrowser control ;) , add it to your toolbox ( it's under the COM tab when you click to add a component to the toolbox ) in the next version of .NET ( Whidbey ) it's got a new webbrowser to replace using the vb6 type.
-
like this ... Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If MessageBox.Show("do you wish to close", Me.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then e.Cancel = False '/// close the form Else e.Cancel = True '/// keep form open End If End Sub
-
item check completes upon Mouse_Up , hence trying to retrieve the current amount of checked items won't work via item_checked . this is what i'd do ... Private checkeditems As Boolean = False '/// a trigger to check for items that are " Checked " Private Sub ListView1_ItemCheck(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckEventArgs) Handles ListView1.ItemCheck If e.NewValue <> e.CurrentValue Then checkeditems = True End If End Sub Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp If checkeditems Then MessageBox.Show(ListView1.CheckedItems.Count) checkeditems = False '/// reset to carry on being able to look for checked items next time. End If End Sub
-
Problems with Screen.PrimaryScreen.Bounds
dynamic_sysop
replied to madagadaguda's topic in Windows Forms
why don't you use the Microsoft.Win32.SystemEvents.DisplaySettingsChanged event it should work fine ( does for me here ) , eg: [color=Blue]private void[/color] Form1_Load([color=Blue]object[/color] sender, System.EventArgs e) { Microsoft.Win32.SystemEvents.DisplaySettingsChanged +=[color=Blue]new[/color] System.EventHandler(this.DisplaySettingsChanged); } [color=Blue]private void[/color] DisplaySettingsChanged([color=Blue]object[/color] sender , System.EventArgs e) { MessageBox.Show("Display Settings Changed\n" + Screen.PrimaryScreen.Bounds.Width.ToString() + "\n" + Screen.PrimaryScreen.Bounds.Height.ToString()); } -
like this ... Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.Shift AndAlso e.KeyValue = Keys.I Then MessageBox.Show("shift and I pressed") End If End Sub
-
Sending email through user's default email program
dynamic_sysop
replied to DiverDan
's topic in General
have you tried replacing the line breaks with the html tag <br> , like Hi<br>there. -
you can pass any html tags directly to the microsoft webbrowser control ( look in to the mshtml.HtmlDocumentClass ) if you open your browser with a blank page ( to initialize it ) then you can open / write to / close the webbrowser's document. in a few simple line ... Private doc As mshtml.HTMLDocumentClass '/// reference the microsoft mshtml object library. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load br.Navigate("about:blank") '/// initialize the document. End Sub Private Sub br_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles br.DocumentComplete doc = DirectCast(br.Document, mshtml.HTMLDocumentClass) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not doc Is Nothing Then doc.IHTMLDocument2_open() doc.IHTMLDocument2_write("<B>some bold text</B><br>") doc.IHTMLDocument2_write("some normal text") doc.IHTMLDocument2_close() End If End Sub
-
use the Form's MouseDown event , eg: Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then MessageBox.Show("you clicked the Left mouse button") End If End Sub
-
As Joe said , you may wish to use string.Split . Also you can use Regex.Split ( which i seem to find much better and faster ) ... // example using string.Split ... string[] str = "some stuff with spaces in it".Split(' '); foreach(string s in str) { Console.WriteLine(s); } // example using Regex ... string str = "some stuff with spaces in it"; foreach(string s in System.Text.RegularExpressions.Regex.Split(str , " ")) { Console.WriteLine(s); }
-
can't get a text box te receive input focus
dynamic_sysop
replied to my_lou's topic in Windows Forms
it seems you are calling an AfterSelect event which is nothing to do with a treeview :rolleyes: you need to be calling TreeView1_AfterSelect not AfterSelect , eg: [color=Green]'/// in a sub or whatever you use to call afterselect of the treeview...[/color] TreeView1_AfterSelect(sender , e) [color=Green]'/// calls the TreeView's AfterSelect event.[/color] [color=Green]'/// not RaiseEvent AfterSelect(sender, e)[/color] -
you can use an ArrayList ( or an Array ) to store your .csv file in one go like this ... Dim sReader As New IO.StreamReader(New IO.FileStream("C:\Program Files\Microsoft Visual Studio\VC98\Lib\WIN32API.csv", IO.FileMode.Open)) Dim arr As ArrayList = ArrayList.Adapter(sReader.ReadToEnd.ToCharArray) sReader.Close() MessageBox.Show(arr.Count)
-
no demo project need for this as it's only a few lines of code , anyway it's a little code i knocked together to reverse strings in C# ( reversed in the same way as strReverse in Vb did ) ... private void button1_Click(object sender, System.EventArgs e) { MessageBox.Show(StringReverse("test 123")); } private string StringReverse(string ToReverse) { Array arr = ToReverse.ToCharArray(); Array.Reverse( arr );// reverse the string char[] c = (char[])arr; byte[] b = System.Text.Encoding.Default.GetBytes(c); return System.Text.Encoding.Default.GetString(b); }
-
have you tried manually setting your imagelist as the toolbar's imagelist? ( maybe try within a button click ) eg: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ToolBar1.ImageList = ImageList1 ToolBar1.Buttons(0).ImageIndex = 0 '/// set the first image in the imagelist as the image of the first button on the toolbar. End Sub
-
form2.show , close form1, form2 still active
dynamic_sysop
replied to PROKA's topic in Windows Forms
try this example i posted in the code bank , it allows you to close Form1 when opening Form2 without the application exiting. Link to Example in the Code Bank hope it helps :)