Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. Well... there really isn't any learning involved there. Despite the posting guidelines, I basically handed you the code you need. Understanding and learning aren't requisites. You really ought to take the time to learn something as elementry as arrays, though. Also note that you can change the color depth and image size for the ImageList. If you set the color depth to 24 or 32 bit and set the size to that of your picutre box, you will most likely not see any loss of quality.
  2. You would need to keep track of filenames, of course. This could be done with an arraylist. 'Class scope variable Dim FileNames As New ArrayList 'Within your function If ComboBox2.SelectedItem = ("Baths Style A") Then ComboBox3.Items.Clear() FileNames.Clear() 'Clear our list of filenames ComboBox3.Text = ("Choose the Picture") Dim exedir As String = CurDir() Dim x As String = 1 For Each filename As String In Directory.GetFiles(exedir & "\BATHS & POWDER ROOMS", "BathA*.jpg") ComboBox3.Items.Add("Bath Style A " & x) x = x + 1 FileNames.Add(Io.Path.Combine(exedir & "\\Baths & Powder rooms\\",Filename)) Next End If Then, when a combo item is selected, you can retrieve the assiciated filename by index and use the bitmap constructor to create the image. MyPictureBox.Image = New Bitmap(FileNames(MyCombo.SelectedIndex).ToString) I didn't test the code but it should give you a good idea of what to do.
  3. Or, you could just write some code and create a PNG and test it on your machine.
  4. Is the main form's KeyPreview property set to true?
  5. Diesel, you really need to relax. Even if he wasn't learning, not everyone should be expected to have the same skill set as you. To someone who has never programmed in a language with C syntax, C# would probably look like Chinese. But, hey, ultimately, it all means the same stuff, so if you can't understand Chinese, learn to read, right? Don't mistake that as blatant sarcasm, I'm just trying to make an analogy. Onto a happier note: There are already some good ideas out there, and I like the IComparer trick. Thought I would throw out the first two things that came to me anyways. Last time I made a card shuffling routine I made two arrays as well. The program picked a number from 0 to 51, seeked through the cards (array 1) to the number picked and added that card to the deck (array 2). A card taken is marked, for example, by changing it's rank to zero. Then, we pick a random number from 0 to 50, seek to the nth card, skipping over those marked as taken (i.e. have a rank of zero). Then pick a random number 0 to 49... until you get to the last card. Seeking thought the deck instead of picking random numbers until you find an untaken card eliminates the hit or miss issue that will waste a lot of CPU. A quick and dirty solution would be to populate an ArrayList with all the cards, and transfer randomly picked cards to another ArrayList until none remain. Easy as pie to code, not very CPU-usage friendly. Unless you need to shuffle a very large number of decks, my first method should be quite adequate (although implementing IComparer would certainly involve less code).
  6. Why not create a structure and then create an arraylist to hold that structure. Not that I think that this is something over your head, but here is a quick example. 'You can add/remove members as necessary to hold all relevant info Public Structure AttatchmentInfo Dim Path As String, Size As Long Public Sub New(ByVal Path As String, ByVal size As Long) Me.Path = Path Me.Size = size End Sub Public Sub TestFunction() Dim List As New System.Collections.ArrayList 'Create a list of AttatchmentInfos List.Add(New AttatchmentInfo("C:\\Don\\Run", 100)) List.Add(New AttatchmentInfo("Run\\Don\\Run", 102)) 'Example of how to access info '(elements must be cast to AttatchmentInfo) MessageBox.Show("Att. 1 Path: " & _ DirectCast(List(0), AttatchmentInfo).Path) MessageBox.Show("Att. 2 Size: " & _ DirectCast(List(1), AttatchmentInfo).Size.ToString) End Sub End Structure
  7. How about handle the KeyPress or KeyDown event and check the e.KeyChar/e.KeyCode values. To have the control ignore a key, set e.Handled to true.
  8. An alternative could be to use a toolbar control where the first and last buttons are arrow buttons which hide/show middle buttons to create the effect of their scrolling. Sorry if this is a bit long. Imports System.Windows.Forms Public Class Form1 Inherits System.Windows.Forms.Form Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New Form1) End Sub #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents ToolBar1 As System.Windows.Forms.ToolBar Friend WithEvents ToolBarButton1 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton2 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton3 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton4 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton5 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton6 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton7 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton8 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton9 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton10 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton11 As System.Windows.Forms.ToolBarButton Friend WithEvents ToolBarButton12 As System.Windows.Forms.ToolBarButton <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.ToolBar1 = New System.Windows.Forms.ToolBar Me.ToolBarButton1 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton2 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton3 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton4 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton5 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton6 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton7 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton8 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton9 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton10 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton11 = New System.Windows.Forms.ToolBarButton Me.ToolBarButton12 = New System.Windows.Forms.ToolBarButton Me.SuspendLayout() 'ToolBar1 Me.ToolBar1.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.ToolBarButton1, _ Me.ToolBarButton2, Me.ToolBarButton3, Me.ToolBarButton4, _ Me.ToolBarButton5, Me.ToolBarButton6, Me.ToolBarButton7, _ Me.ToolBarButton8, Me.ToolBarButton9, Me.ToolBarButton10, _ Me.ToolBarButton11, Me.ToolBarButton12}) Me.ToolBar1.DropDownArrows = True Me.ToolBar1.Location = New System.Drawing.Point(0, 0) Me.ToolBar1.Name = "ToolBar1" Me.ToolBar1.ShowToolTips = True Me.ToolBar1.Size = New System.Drawing.Size(360, 42) Me.ToolBar1.TabIndex = 0 Me.ToolBarButton1.Text = "<" Me.ToolBarButton2.Text = "1" Me.ToolBarButton3.Text = "2" Me.ToolBarButton4.Text = "3" Me.ToolBarButton5.Text = "4" Me.ToolBarButton6.Text = "5" Me.ToolBarButton7.Text = "6" Me.ToolBarButton7.Visible = False Me.ToolBarButton8.Text = "7" Me.ToolBarButton8.Visible = False Me.ToolBarButton9.Text = "8" Me.ToolBarButton9.Visible = False Me.ToolBarButton10.Text = "9" Me.ToolBarButton10.Visible = False Me.ToolBarButton11.Text = "0" Me.ToolBarButton11.Visible = False Me.ToolBarButton12.Text = ">" 'Form1 Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(360, 374) Me.Controls.Add(Me.ToolBar1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub #End Region Dim FirstVisible As Integer = 1 Dim LastVisible As Integer = 5 'This is where the scrolling is done. We hide the first/last button (depending 'on which way we scroll) update the "window" variables that specify the 'visible range of buttons, then we show the new last/first button (depending 'on which way we scroll). Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal _ e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick With ToolBar1 If e.Button Is .Buttons(0) AndAlso FirstVisible > 1 Then 'If 'BACK BUTTON' and we are not at the left end of scrolling toolbar .Buttons(LastVisible).Visible = False FirstVisible -= 1 LastVisible -= 1 .Buttons(FirstVisible).Visible = True ElseIf e.Button Is ToolBar1.Buttons(ToolBar1.Buttons.Count - 1) AndAlso _ LastVisible < .Buttons.Count - 2 Then 'If 'FORWARD BUTTON' and we are not at end of scrolling toolbar .Buttons(FirstVisible).Visible = False FirstVisible += 1 LastVisible += 1 .Buttons(LastVisible).Visible = True End If End With End Sub End Class
  9. There is a method via the api that allows you to display a window without taking the "window focus", just as a menu is a separate, independant window, but does not take focus from the window that spawned it. I believe that it had something to do with the SetWindow API, and I know that I found it on a google search for a custom tooltip control (although the exact search terms, I forget). Unfortunately, that is all that I can remember. I hope that it helps.
  10. Just a thought: If you want the files to be recoverable, why not simply remove them to your [application's] own backup folder instead of cluttering the recycle bin?
  11. Generally, I would say that if the file you are deleting isn't a file that the user needs to know about then you should not worry about sending it to the recycle bin; just delete it. If it is a file that needs to be sent to the recycle bin in case the user will want to recover it, a message to the user confirming the delete might be appropriate so that the user knows what is going on. I hope you aren't going do distribute a program that disables the "Are you sure" prompt for deleting the files. Even if it is only temporary, in the event of an error in your application this can cause very undesirable behavior on the end user's machine. I wouldn't wan't such software running on my PC, and depending on how it is programmed, the user might accidentally delete other files without even realizing it any time your program is running. By the look of things, that registry setting may alter other settings as well. Unless you know for a fact that this is not the case, I recommend doing more research on that registry key.
  12. You need a scrollable button control then? Why not just use a toolbar within a scrollable control or a series of buttons in a scrollable control?
  13. You need to import the Microsoft.VisualBasic namespace. This is done as a project-wide import by default in the IDE. This is not the case when using the command-line compiler, so you must either fully qualify the function (Microsoft.VisualBasic.String.Len() [oddly enough, Microsoft.VisualBasic.Len() seems to work as well]) or import the namespace explicitly.
  14. If I were you then I would change the .bmp to .png. Regardless of the image format, you still use the same Bitmap constructor and the behavior is the same.
  15. I wish I was soap. It's like... you don't have to clean yourself. You are the epitome of clean. This is about four years old, but it's me... http://www.geocities.com/marble_eater/Me2.jpg P.S. I've been wondering, why do you hate life?
  16. I never figured out how to use mode x in Qbasic.
  17. Your biggest problem is that you never set rc to anything.
  18. How does the program on a whole work? What sort of values are being entered. Are you simply letting the user enter numbers and totalling the number of times each number is entered?
  19. That is one possible way. Not to be argumentative, but it could also be programmed in another low level language. The QBasic program could also generate some machine language code which could then be executed using the call command. My point would be, of course, that there are various possible methods. And, yes, three cheers for Screen 13.
  20. I do believe that a texture must have dimensions that are powers of two, for example, 64,64, or 128,128, or 256,256. If you provide an image that is 150,150 it must be resampled in order to be compatible with graphics hardware. I'm not positive that this can be done with a sprite, but it should be doable with a quad: Use a 256x256 texture on a 256x256 sprite/quad with a mask so that the area beyond 150,150 simply won't be visible. Of course, masks don't work so well with lossy image formats, so you would have to ditch the jpgs.
  21. There is no purely .Net way to do this. Furthermore, I am pretty sure that you will have no control over color when the progress bar is using Visual Styles, so keep this in mind.
  22. For anyone else with OCD, INFORMATION: Code Project IL Tutorial Code Project IL Introduction (.Net 2.0b) Code Guru IL Tutorial
×
×
  • Create New...