Jump to content
Xtreme .Net Talk

modtheplanet

Members
  • Posts

    8
  • Joined

  • Last visited

modtheplanet's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. A Little Help? ok the new function works, but i cant get the rename function to work, any ideas? Private Sub tabControl1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles TabControl1.MouseDown If e.Button = MouseButtons.Right Then Dim i As Integer = 0 For i = 0 To tabControl1.TabCount - 1 If tabControl1.GetTabRect(i).Contains(e.X, e.Y) Then tabControl1.SelectedIndex = i Exit For End If Next Dim cMenu As ContextMenu Dim Menus(2) As MenuItem Dim intKey As Integer Menus(0) = New MenuItem("&New Tab", AddressOf AddTab) Menus(1) = New MenuItem("&Edit Tab", AddressOf RenameTab) Menus(2) = New MenuItem("&Delete") cMenu = New ContextMenu(Menus) cMenu.Show(sender, New Point(e.X, e.Y)) 'display contextmenu.. End If End Sub Private Sub AddTab(ByVal Sender As System.Object, ByVal e As System.EventArgs) Dim MyNewTabPage As New TabPage With MyNewTabPage .Text = "New Page" End With TabControl1.TabPages.Add(MyNewTabPage) End Sub Private Sub RenameTab(ByVal Sender As System.Object, ByVal e As System.EventArgs) TextBox2.Text = DirectCast(Sender.Parent, ContextMenu).SourceControl.ToString MsgBox("rename") With DirectCast(Sender.Parent, ContextMenu).SourceControl .Text = "blah" End With End Sub
  2. Ok this is what i want to do: i have a label on form1. when the user clicks on this label a new form is loaded called 'rename'. with a textbox and a button. the user will be able to type in the textbox to the name they want to rename the label too. now they will then click the button to commit the changes. then the rename form will close and the label on form1 will change to what the user entered in the textbox on the rename form. ok i am able to save what the user enters in the textbox but i dont know how to find when the user closes the form and to commit the changes. any ideas?
  3. thank you very much, it works now!!
  4. if i comment out the addhandler line it shows the label with the image, if the addhandler line is there not commented out it doesnt, even with .visible and .enabled set to true
  5. ok this will compile but will not show the label that i am creating i think that the problem lies somewhere with the: Handles MyBase.Click Private Sub addlabel(ByVal myImage As Bitmap) Static num As Integer Dim size As Integer size = myImage.Height + 25 Dim ctl As Control num += 1 ReDim TextBoxes(num) TextBoxes(num - 1) = New MyLabel With TextBoxes(num - 1) .Size = myImage.Size .Height = size .Text = "test" .Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) .TextAlign = ContentAlignment.BottomCenter .Location = New System.Drawing.Point(10, num * (.Height + 10)) .Image = myImage AddHandler ctl.Click, AddressOf Labels_Click End With TabPage1.Controls.Add(TextBoxes(num - 1)) End Sub Public Sub Labels_Click(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Click MsgBox(Me.Name, "clicked") End Sub
  6. I am able to create my labels with the image passed, but i want to add an event that if the user clicks on the label it displays a message box or loads another form, something like that. This is what I have, and its not even close to working. :confused: Private Sub addlabel(ByVal myImage As Bitmap) Static num As Integer Dim ctl As Control num += 1 ReDim TextBoxes(num) TextBoxes(num - 1) = New MyLabel With TextBoxes(num - 1) .Size = myImage.Size .Location = New System.Drawing.Point(10, num * (.Height + 10)) .Image = myImage AddHandler (ctl, Labels_Click) End With TabPage1.Controls.Add(TextBoxes(num - 1)) End Sub Public Sub Labels_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Labels_Click.Click MsgBox(Me.Name, "clicked") End Sub
  7. my code breaks on this line: myIconImage = New Bitmap(largeIcon.Height, largeIcon.Width) give the error: An unhandled exception of type 'System.NullReferenceException' occured in blah.exe Additional Information: Object Reference not set to an instance of an object here is the module code for IconEx: Public Class IconEx #Region " API " Private Const MAX_PATH = 260 Private Const SHGFI_LARGEICON = &H0 Private Const SHGFI_SMALLICON = &H1 Private Const SHGFI_ICON = &H100 Private Structure SHFILEINFO Dim hIcon As IntPtr Dim iIcon As Integer Dim dwAttributes As Integer <VBFixedString(MAX_PATH)> Dim szDisplayName As String <VBFixedString(80)> Dim szTypeName As String End Structure Private Declare Function SHGetFileInfo Lib "shell32.dll" Alias "SHGetFileInfoA" ( _ ByVal pszPath As String, _ ByVal dwFileAttributes As Integer, _ ByRef psfi As SHFILEINFO, _ ByVal cbFileInfo As Integer, _ ByVal uFlags As Integer) As Integer #End Region Private Shared Function _geticon(ByVal file As String, ByVal size As Integer) As Icon Dim fileIcon As Icon Dim m As System.Runtime.InteropServices.Marshal Dim shinfo As SHFILEINFO 'This gets the icon out of the specified file and puts it into the shinfo struct, and 'out into an Icon object. If SHGetFileInfo(file, 0, shinfo, m.SizeOf(shinfo), SHGFI_ICON Or size) Then fileIcon = Icon.FromHandle(shinfo.hIcon) Return fileIcon End If End Function 'Retrieves the 16x16 icon for a file Public Shared Function GetAssociatedIconSmall(ByVal file As String) As Icon If Not System.IO.File.Exists(file) Then Throw New IO.FileNotFoundException("The specified file was not found", file) Else Return IconEx._geticon(file, SHGFI_SMALLICON) End If End Function 'Retrieves the 32x32 icon for a file Public Shared Function GetAssociatedIconLarge(ByVal file As String) As Icon If Not System.IO.File.Exists(file) Then Throw New IO.FileNotFoundException("The specified file was not found", file) Else IconEx._geticon(file, SHGFI_LARGEICON) End If End Function End Class
  8. the IconEx.GetAssociatedIconLarge returns a icon object i need to take its icon object and display it in a picturebox, how do you do that? then i need to save the icon to VB6code : appath & "\icons" & icon this is what i have minus the saving which i cant seem to grasp either. Dim largeIcon As Icon = IconEx.GetAssociatedIconLarge("C:\Program Files\AIM\aim.exe") 'returns a icon object Dim myIconImage As New Bitmap(largeIcon.Width, largeIcon.Height) myIconImage = New Bitmap(largeIcon.Height, largeIcon.Width) myIconImage = largeIcon.ToBitmap Me.PictureBox1.Image = myIconImage
×
×
  • Create New...