Jump to content
Xtreme .Net Talk

Audax321

Avatar/Signature
  • Posts

    90
  • Joined

  • Last visited

Everything posted by Audax321

  1. I tried that method, and it works, but it created a lot of bugs in the program because my program depends heavily on it and I'd have to go through all my code. Instead I just drew a rectangle around the item the mouse is over which serves the same purpose well. Now, Is there a way to prevent the listbox from flashing so much whenever listbox.invalidate() is called? Kind of like when you use listbox.beginupdate and listbox.endupdate you don't see the listbox refresh??? Thanks :)
  2. Hello, I have an owner drawn listbox with internal item dragging and dropping already coded. All I want to do know is underline the item that is being dragged over in the listbox. As an example, try draggin someting in WinAmp's (v3.0) Playlist Editor and noticing the thick yellow bar that appears. How can I get this effect? Thanks...
  3. (figured out second question... :) )
  4. That worked! ... thank you :)
  5. Hello, To understand this problem better, please start a VB.NET project and add a listbox (set to OwnerDrawn Fixed) to the form. Then, Copy+Paste the following into the code: Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem e.DrawBackground() If e.Index < 0 Then e.DrawFocusRectangle() Exit Sub End If Dim aBrush As Brush Dim aBrushSelection As Brush e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit aBrushSelection = System.Drawing.Brushes.DarkBlue If (e.State And Windows.Forms.DrawItemState.Selected) = Windows.Forms.DrawItemState.Selected Then aBrush = System.Drawing.Brushes.LawnGreen e.Graphics.FillRectangle(aBrushSelection, e.Bounds) e.Graphics.DrawString(ListBox1.GetItemText(ListBox1.Items.Item(e.Index)), ListBox1.Font, aBrush, e.Bounds.Left, e.Bounds.Top) e.Graphics.DrawRectangle(New Pen(Color.DarkRed), e.Bounds) Else aBrush = System.Drawing.Brushes.Red e.Graphics.DrawString(ListBox1.GetItemText(ListBox1.Items.Item(e.Index)), ListBox1.Font, aBrush, e.Bounds.Left, e.Bounds.Top) End If e.DrawFocusRectangle() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i As Integer For i = 0 To 100 ListBox1.Items.Add("This is item #" & i) Next End Sub After running the application click once on the first item in the listbox and hold down the down arrow on your keyboard. The control will function normally. Now, click once on the last item in the listbox and hold the up arrow on your keyboard. As each item is selected, the previous item does not lose its rectangle. Finally, randomly click on many items and notice the remnants of the rectangles left behind. Why is this happening? :confused:
  6. I ran into another problem. When I tested my application in the previous post, I accidentally left out the resize feature. If I put the image resizing back in, which is done by using GetThumbNail on the Image variable, it again does not allow me to delete the original file. This is understandable because I'm sure VB.NET uses the file while it is resizing it, but it won't give up control of the file even after both Image = Nothing and Image.dispose() are run... Any suggestions???
  7. Hello, Thanks.. CurrentImage.dispose allowed me to delete the files... :)
  8. Hello, I'm writing a program that gets the path to an image and sets it to an image variable: Dim file as String Dim CurrentImage as Image file = "C:\wallpaper.bmp" CurrentImage = Image.FromFile(file) Then, I resize the picture and save it as another filename... CurrentImage = CurrentImage.GetThumbnailImage(NewSize.Width, NewSize.Height, Nothing, Nothing) CurrentImage.Save(NewPath & "\" & "newname.bmp") And, finally the problem occurs: Kill(file) The program will not let me delete the original file because it is being used by another process (which is my program). I found out it was my program because if I delete the image before any of the above code runs, the file is deleted fine. How can I do this in a way that will let me delete the file???? :confused:
  9. Thank you, that worked perfectly. :)
  10. Hello, I think that may work. But, I'm not sure what I should put for this: callback as System.Drawing.Image.GetThumbnailImageAbort I tried looking it up but I'm confused now....
  11. Hello, This question is regarding VB .NET. I have a picture box where an image is set (in the image property) and is stretched when the size of the picture box changes. How can I save the stretched version to the hard drive?? Right now when I use: picturebox.image.save(filename) it just saves the original unstretched image. Also, can I set this stretched image directly to the backgroundimage property of a panel without saving it to disk first??? Thanks.
  12. Hello, I'm teaching myself as much as possible about VB.NET (I used VB6 before). But, I was thinking about making a network IM application that would work on a small Microsoft Network. I want the application to use file send/recieve as well as send instant messages back and forth. But, I have no clue where to start besides adding the controls to the form :) I've never attempted anything like this in VB6, so I'm not sure what to do... please help, thanks.
  13. Does anyone know how to implement crossfading in Visual Basic .NET using Windows Media Player 9???? Thanks...
  14. I think I just figured out why the select event isn't working. I have the contextmenu being displayed when the user right clicks a NotifyIcon in the systray. If I have the same contextmenu display when the user clicks a command button on the form, the code works fine. Is there a way to have the select event get called with the contextmenu linked to the NotifyIcon??? I'm not sure why it would do this... Any ideas??? :confused:
  15. None of the menu items have any child menu items. Just to make sure I put code in the click event for each of the menuitems. So, everytime I clicked a menuitem it ran: MsgBox(mnuVol.MenuItems.Item(item.Index).IsParent) And they are false.
  16. Hello, I am dynamically creating some menuitems and have gotten the click events to work for each menuitem. But, I would also like to add a menuitem.select event for each menuitem. I tried doing it by looping through all the dynamically created controls with the index represented by an integer variable i each time running this: AddHandler mnuVol.MenuItems(i).Select, AddressOf VolMenuHandler But, the VolMenuHandler is not called when I mouse over a menuitem. Any help is appreciated. Thanks..:)
  17. Hello, I had a question regarding shortcut keys in VB: Let's say you have a listbox containing the following items: THIS IS A LIST OF STUFF IN A LISTBOX & NOT A TEXTBOX And then I decide to make a context menu that dynamically creates menu items with the corresponding same text properties at runtime. So, there are 12 menu items each with a text property set to one of the words above. The menu therefore looks like this: THIS IS A LIST OF STUFF IN A LISTBOX _NOT A TEXTBOX Notice how the '& NOT' turned into '_NOT'. Is there a way to have VB .NET ignore the & symbol when changing the text property of a menuitem to a name that contains it???? And by ignore I don't mean I want to remove the & symbol from the name, but I want to keep it, just not have it make a _shortcut command....... Thanks...
  18. Okay this is odd: This will not work because MenuItem2's text will not update. Private Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup Static x as integer x = x + 1 If (MenuItem1.Text = "Menu1") Then MenuItem1.Text = "Menu2" Else MenuItem1.Text = "Menu1" End If MenuItem2.Text = x End Sub BUT, this will work: Private Sub ContextMenu1_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu1.Popup Static x as integer x = x + 1 If (MenuItem1.Text = "Menu1") Then MenuItem1.Text = "Menu2" Else MenuItem1.Text = "Menu1" End If MenuItem2.enabled = False MenuItem2.Text = x MenuItem2.enabled = True End Sub Notice how in the second one I disable the control then enable it. I am guessing this causes VB to redraw the control?
  19. Here is my code: Private Sub ContextMenu5_Popup(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContextMenu5.Popup If (lstPlaylist.Items.Count > 0) Then mnuPlaylist.Enabled = True mnuPlaylist.MenuItems.Clear() Dim i As Integer For i = 0 To lstPlaylist.Items.Count - 1 mnuPlaylist.MenuItems.Add(MediaName, AddressOf PlaylistMenuHandler) Next For i = 0 To lstPlaylist.Items.Count - 1 MediaName = lstPlaylist.GetItemText(lstPlaylist.Items.Item(i)) mnuPlaylist.MenuItems.Item(i).Text = Mid(MediaName, 1, InStr(MediaName, "<") - 1) Next mnuPlaylist.MenuItems.Item(GetCurrentPlayingIndex).Checked = True Else mnuPlaylist.Enabled = False End If End Sub Protected Sub PlaylistMenuHandler(ByVal sender As Object, ByVal e As System.EventArgs) Dim item As MenuItem item = DirectCast(sender, MenuItem) AxWindowsMediaPlayer1.controls.playItem(AxWindowsMediaPlayer1.currentPlaylist.Item(item.Index)) End Sub It works fine once and fails every other time....
  20. Hello, I put the break point in and the code is run before the menu pops up. I have other code in there that changes the menuitem.enabled property of some of the controls and that code works fine. It just has a problem with the menuitem.text property. THanks...
  21. Hello, I am having the same problem as the person that posted this thread was having: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=74437&highlight=menu+item Basically, I have a list of items in a listbox that are dynamically added to a submenu in a context menu. And the items add fine everytime. But, the submenu only expands once. If I go back to access it, the submenu just has an arrow and no menu pops up. The number of items in the submenu indicate that the menu is properly creating all of the new menu items, just not showing them. From what I've seen in VB.NET so far, M$ really screwed up context menus. Let me know if any of you have suggestions... Also, check out my other thread: http://www.xtremedotnettalk.com/showthread.php?s=&postid=374628#post374628 Thanks :(
  22. Well, I have the ContextMenu set as the contextmenu for a NotifyIcon. And I'm not sure what you mean by having an x variable. It still won't allow me to change the text property of a menuitem that is not on the main level of the context menu more than once...
  23. Hello, Thanks for the reply... I put that exact code in and when I accessed the menu the first time it changed the text to HELLO because I set it to WORLD at design time, but if I access the menu item a second time, it doesn't change the text to WORLD like it should. It keeps it as HELLO. I'm not sure why it is doing this. I've done this numerous times in VB6 so it should work in here, but it won't update it.... I have no clue.. :confused: EDIT: I just noticed this also. The menu that I am working with is not on the main level of the context menu. For example, the tree of the context menu looks like this: -ContextMenu -mnuItem1 -mnuItem2 So, mnuItem2 is in a submenu of ContextMenu. I am trying to change the text on mnuItem2. Here is the strange part... if I try to change the text of mnuItem1, the above code works fine. The code doesn't work for mnuItem2 though. I can even disable mnuItem2, I just can't change its text regardless of whether it is enabled or not...
  24. Don't have my code with me right now, but it is basically this: ContextMenu_Popup(variables...) Handles ContextMenu.Popup If(true) Then mnuItem.text = "Hello" Elseif(true) Then mnuItem.text = "World" End if End Sub Now, lets say the IF statement is true when the contextmenu is first popped up, the text on mnuItem will change to HELLO. But, if I go popup the menu again with the ELSEIF statement true and the IF statement FALSE, the text on mnuItem will not change... it will remain HELLO. I used message boxes to check if the code is running the proper if statement and it is... but the text won't change on the menu item... It's really strange because I never had a problem doing this in VB6.
  25. Hello, I have some code under the ContextMenu's popup event that should change the text property of a menuitem at runtime... but it only does it the first time. After that it refuses to change the text property... Any help would be great...:confused:
×
×
  • Create New...