
dynamic_sysop
Leaders
-
Posts
1044 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by dynamic_sysop
-
Hi guys n gals , i have knocked up a little bit of code which may provide usefull. i guess most people are aware that if you try closing your Main Form, while trying to leave a second Form open ( ie: Form2.Show , Form1.Close ) , you end up with the Application closing completely. well not anymore ;) in a Module ( with a Sub Main set as the Start-up object ) ... '/// add a module to your application , then set it's Sub Main as your start-up object Imports System.Windows.Forms Module Module1 Sub main() Dim frmMain As New Form1 frmMain.Show() Application.Run() '/// NOTE : i run the application without a start-up Main form. End Sub End Module in Form1 ( which will load as your default form in this instance ) ... Private closeApp As Boolean = True Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click closeapp = False Dim frm2 As New Form2 frm2.Show() Me.Close() End Sub Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing If closeApp Then Application.Exit() End If End Sub Form2 will now show and Form1 will close without the Application exiting , in form2 , to close the app i put a simple ... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Application.Exit() End Sub included is a sample source. Project1.zip
-
J# has a great in-built win32 Package , you can use it to play sound ( and nearly all api calls / constants are in it ) , eg: to play sound ... [color=Green]// this is in J#[/color] [color=Blue]private void[/color] button1_Click (Object sender, System.EventArgs e) { com.ms.win32.Winmm.PlaySound("C:\\WINDOWS\\MEDIA\\Windows XP Startup.wav" , 0 , com.ms.win32.wins.SND_FILENAME | com.ms.win32.wins.SND_ASYNC); }
-
like this you mean maybe? string s = "abc{e4e5f4} def"; MessageBox.Show(Regex.Split(s , "([{}]+)")[2]);
-
CType to Long for API FloodFill
dynamic_sysop
replied to Invictus's topic in Interoperation / Office Integration
have you not tried the ColorTranslator class then? , eg: '/// specify Integer / Int32 for crColor in the Api Public Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Int32) As Int32 Private Sub FloodFill(ByVal FillColor As Color, ByVal X As Integer, ByVal Y As Integer) '/// get the integer value of your color using the ColorTranslator which is part of .NET Dim lFillColor As Int32 = ColorTranslator.ToWin32(FillColor) '/// rest of your code End Sub -
you could add a reference to System.Management , then retrieve the Mac Addresses of any network cards like this ... '/// add a reference to System.Management , then use the following code. Dim mObject As New Management.ManagementClass("Win32_NetworkAdapter") Dim mCol As Management.ManagementObjectCollection = mObject.GetInstances Dim m As Management.ManagementObject For Each m In mCol Console.WriteLine(m.Properties("MACAddress").Value) Next
-
on the last post , what would happen if the number contained an E after the dot , eg: 1.E560 , it wouldn't be recognized as a numeric. here's an example i made a while ago ( i posted this in the codebank of another vb forum when i made it ) private bool IsNumeric(object ValueToCheck) { double Dummy = new double(); string InputValue = Convert.ToString(ValueToCheck); bool Numeric = double.TryParse( InputValue , System.Globalization.NumberStyles.Any , null , out Dummy); return Numeric; }
-
from memory , you can re-write the rtf text to add line numbers etc... , but you need a good understanding of rich text. you could always put a label / textbox to the left of the richtextbox , set the styles of both label and rtf box to no border , then draw a rectangle ( border ) around them both together to give the appearance of just a richtextbox being there.
-
here's my C# bit for it ... private const int SRCCOPY = 0xCC0020; // other stuff i use ( to create a bitmap of a webpage ;) ) BitBlt( dest , 0 , 0 , rct.Right , rct.Bottom - 130 , source, 0 , 0 , SRCCOPY ); in vb.net it'd be ... Private Const SRCCOPY As Integer = &HCC0020;
-
you can use the Equals method ( also there's a CompareTo method , which returns -1 for False , or 0 for True ) Dim uint1 As UInt32 = Convert.ToUInt32(123) Dim uint2 As UInt32 = Convert.ToUInt32(123) Dim bResult As Boolean = uint1.Equals(uint2) '/// compare the 2 UInt32's using Equals MessageBox.Show(bResult)
-
here's a quick example i knocked up for you ... Public Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer Public Enum FO_FLAGS As Integer FO_COPY = &H2 FO_DELETE = &H3 FO_MOVE = &H1 End Enum <System.Runtime.InteropServices.StructLayout( _ System.Runtime.InteropServices.LayoutKind.Sequential)> _ Public Structure SHFILEOPSTRUCT Public hWnd As Integer Public wFunc As FO_FLAGS Public pFrom As String Public pTo As String Public fFlags As Integer Public fAborted As Integer Public hNameMaps As Integer Public sProgress As String End Structure Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim shStruct As New SHFILEOPSTRUCT With shStruct .pFrom = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) .pTo = "F:\test_folder" .wFunc = FO_FLAGS.FO_COPY End With SHFileOperation(shStruct) End Sub
-
try the visual styles bit before initialize component , eg: Public Sub New() MyBase.New() Application.EnableVisualStyles() Application.DoEvents() InitializeComponent() End Sub that works for me.
-
like this ... Dim types As Type() = {GetType(String), GetType(Integer)}
-
try this , i knocked it up quickly , but i think it's the sort of thing to start you off ... Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim lblThread As New Threading.Thread(AddressOf ScrollText) lblThread.Start() '/// handle it in a seperate thread , so you don't lag the Application. End Sub Private Sub ScrollText() Dim strString As String = Label1.Text '/// reference to the original string of text in the label Dim g As Graphics = Label1.CreateGraphics Dim sz As SizeF = g.MeasureString(Label1.Text, Label1.Font) Dim sWidth As Integer = Convert.ToInt32(sz.Width) If sWidth > Label1.Width Then '/// if the string is wider than the label Dim x As Integer = strString.Length For i As Integer = 0 To strString.Length Label1.Text = strString.Substring(x) x -= 1 Threading.Thread.Sleep(90) '/// allow the scroll to be slow enough to see. Application.DoEvents() Next End If End Sub
-
Enumerate form classes (Foreach all classes?)
dynamic_sysop
replied to keitsi's topic in Windows Forms
one last note on it ( cuz i don't wanna take over the thread ;) ) ... lol , the best thing is , we are also in the process of moving house ( on tuesday we are moving house to a new location a couple of hours away from where we are now ) so , i'm coding , running a house with my wife / 5 kids / 3 cats and moving also :eek: hard work , but fun. -
Enumerate form classes (Foreach all classes?)
dynamic_sysop
replied to keitsi's topic in Windows Forms
i have 5 kids mate :D ( and 3 cats :eek: ) i have posted that code many times now in different formats , it's good for finding forms , then checking if they are open / closing with a SendMessage( handle , WM_CLOSE , 0 , 0 ) ;) -
try the ImageFromStream method ;) PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize Dim wc As New Net.WebClient PictureBox1.Image = Image.FromStream(wc.OpenRead("http://www.google.com/images/logo.gif")) wc.Dispose()
-
Enumerate form classes (Foreach all classes?)
dynamic_sysop
replied to keitsi's topic in Windows Forms
if you want to search for all Forms in your app ( open or not ) ... [color=Blue]Dim[/color] frmType [color=Blue]As[/color] Type [color=Blue]For Each[/color] frmType [color=Blue]In [/color] Reflection.Assembly.GetExecutingAssembly.GetTypes [color=Blue]If[/color] frmType.IsSubclassOf([color=Blue]GetType[/color](Form)) [color=Blue]Then[/color] [color=Blue]Dim[/color] f [color=Blue]As[/color] Form = frmType.InvokeMember([color=Blue]Nothing[/color], Reflection.BindingFlags.CreateInstance, [color=Blue]Nothing[/color], [color=Blue]New[/color] Form, [color=Blue]Nothing[/color]) [color=Green] '/// do stuff for each form it finds.[/color] [color=Blue]End If[/color] [color=Blue]Next[/color] -
if you are making the mdi child from inside the main form ( parent ) ... frmDocument.MdiParent = this; if it's in a module , you would need to declare a reference to the parent form in the module , then set that reference to your parent form as the parent , eg: void someVoid(frmMain frm) { frmDocument.MdiParent = (frmMain)frm; }
-
if you are loading a bit of data that may be slowing down the new form when it's opening , try using a new Threading.Thread to handle this ( put the code which is in Form_Load into the thread instead ) , eg: [color=Blue]Private Sub[/color] Form1_Load([color=Blue]ByVal[/color] sender [color=Blue]As[/color] System.Object, [color=Blue]ByVal[/color] e [color=Blue]As[/color] System.EventArgs) [color=Blue]Handles MyBase[/color].Load [color=Blue]Dim[/color] lThread [color=Blue]As New[/color] Threading.Thread([color=Blue]AddressOf[/color] LoadThread) lThread.Start() [color=Blue]End Sub[/color] [color=Blue]Sub[/color] LoadThread() [color=Green]'/// load any heavy data that may slow the Form down when opening here.[/color] [color=Blue]Return[/color] [color=Blue]End Sub[/color]
-
well either use the vb6 method of Asc ( "Đ" ) , or as i did it ... [color=Blue]Dim[/color] NumForChar [color=Blue]As Byte[/color]() = System.Text.Encoding.Default.GetBytes("Đ") MessageBox.Show(NumForChar(0))
-
CType to Long for API FloodFill
dynamic_sysop
replied to Invictus's topic in Interoperation / Office Integration
you shouldn't really use Longs in vb.net ( it doesn't like them much ) , try using the vb.net version of the Api FloodFill putting IntPtr as the hdc , Color as crColor etc... in the Api , eg: Private Declare Function FloodFill Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal x As Int32, ByVal y As Int32, ByVal crColor As Color) As Int32 if you want to convert an IntPtr to a Long , you can do this ... Dim ipDC As IntPtr = grPictureBox.GetHdc Dim lng As Int64 = Convert.ToInt64(ipDc.ToInt32) '/// int64 is Long in .net -
you can also use invalidate... private void button1_Click(object sender, System.EventArgs e) { this.Invalidate(); }
-
javascript problem (don't know where else to ask)
dynamic_sysop
replied to DimkaNewtown's topic in General
you are trying to show the actual dialog form as an alert , you would need to specify a property ( eg: Name , Text etc.. ) eg: alert(wtmp.Name); // specifying the Name property would return an alert showing the form's name. -
MDI & a panel wich is made unvisible ...:-(
dynamic_sysop
replied to reinier's topic in Windows Forms
when showing the mdiChild , assign the parent property ( as you probably are ) , then you need to make a Cast of the parent form when closing the mdiChild form , eg: '/// In the MdiParent form , when showing the child form... Dim frmChild As New Form2 frmChild.MdiParent = Me '/// assign the mdi parent / mdi child relationship here. frmChild.Show() Dim ctl As Control For Each ctl In Controls If Not ctl.Name Is frmChild.Name Then ctl.Visible = False '/// hide the mdiparent's controls. End If Next '/// in the MdiChild when closing , to re-show the controls on the parent ... Private Sub Form2_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing Dim frmParent As Form1 = DirectCast(Me.MdiParent, Form1) Dim ctl As Control For Each ctl In frmParent.Controls ctl.Visible = True Next End Sub