Tab help + redisgn forms at runtime.

Discussion in 'Programming General' started by Michael3455, Aug 1, 2007.

Tab help + redisgn forms at runtime.
  1. Unread #1 - Aug 1, 2007 at 4:45 AM
  2. Michael3455
    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0

    Michael3455 Active Member

    Tab help + redisgn forms at runtime.

    Hello, I'm currently making, what I consider to be, a full featured Webbrowser for my Software Development and Design course and I've ran into a few problems, most of which were easily fixable. However, I've got two I can't work out (Due to laziness on one, and my inability to google properly). Firstly, I can't work out how to do these two tab related things. They are
    1a. Figure out which tab is currently selected
    1b. Figure out how to create a new tab at runtime and add a webbrowser to it.

    Both of those, I think, should be a pretty simple thing. But, alas, I can't figure it out and google hasn't been of much help.

    My second problem isn't really a problem yet, but rather a question on how I should tackle the problem. User redesign at runtime. Basically, I want to enable a user to select a 'design mode' where they can drag and drop certain elements of the form (Buttons, tabcontrols, etc) so they're placed where the user would like them. Also, have options for background colours and button styles (I'll be making the buttons myself, so probably not many different types) and other things of that nature.

    The way I thought I could do this, is when the 'Design Mode' has been selected I disable all the buttons, texts fields and what not, and have an on Mousedown event. As they drag the mouse, I store the location as a point and then update the position of that object (button or whatever it is).


    So, basically I'd just like your opinions on my second problem. Do you think the way I thought of as an efficient and effective way to do it, or is there a better option?

    And, for the first one, some simple code would be much appreciated.

    EDIT: If I've not been clear enough, just tell me and I'll do my best to remedy the situation. Also, I'm not really lazy or a bad googler, I'm just not sure what exactly to google.
     
  3. Unread #2 - Aug 1, 2007 at 6:28 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    Tab help + redisgn forms at runtime.

    you're missing out on the core features of .Net's object orientation. I made a simple sort of webbrowser that opened new tabs at runtime etc. but it was fairly buggy.

    Have you tried searching through the MSDN library? Its there as a help source and code referrence, its amazing how much people never use it.

    http://www.sythe.org/showthread.php?t=183834 - thats my simple code.
     
  5. Unread #3 - Aug 1, 2007 at 6:45 AM
  6. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    Tab help + redisgn forms at runtime.

    Browsers like FireFox and Internet Explorer actually use MDI forms with no borders, but to make a MDI tab strip is not easy, but works much better and faster (You can also customize it better).

    To use a tab control, what you want to do is make a custom tab page which contains a web browser and a property to expose it. Here is a quick code I wrote in 5 minutes.

    Code:
        ''' <summary>
        ''' Returns the web browser in the selected tab.
        ''' </summary>
        Public ReadOnly Property SelectedBrowser() As WebBrowser
            Get
                '' If the tab control has no tab selected it will retur nothing.
                If Me.TabControl1.SelectedTab Is Nothing Then Return Nothing
    
                '' This now checks if the selected tab is a web tab. If it isn't it returns nothing. If it is, it return its web browser control.
                If TypeOf Me.TabControl1.SelectedTab Is WebTab Then Return CType(Me.TabControl1.SelectedTab, WebTab).Browser Else Return Nothing
    
            End Get
        End Property
    
        ''' <summary>
        ''' Adds a new web tab to the tab control.
        ''' </summary>
        Public Sub AddNewTab()
            Me.TabControl1.TabPages.Add(New WebTab)
        End Sub
    
        ''' <summary>
        ''' A class which places a web browser with a tab control automatically.
        ''' </summary>
        Private Class WebTab
            Inherits TabPage
            Private WithEvents WebBrowser As WebBrowser
            Sub New()
                '' Contructs the browser, set its properties and add it to the tab control.
                Me.WebBrowser = New WebBrowser
                Me.Controls.Add(Me.WebBrowser)
                Me.WebBrowser.Dock = DockStyle.Fill
                Me.WebBrowser.Visible = True
                Me.WebBrowser.GoHome()
            End Sub
            ''' <summary>
            ''' Returns an instance of this controls web browser.
            ''' </summary>
            Public ReadOnly Property Browser() As WebBrowser
                Get
                    '' Return the browser control.
                    Return Me.WebBrowser
                End Get
            End Property
            Private Sub WebBrowser_DocumentTitleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles WebBrowser.DocumentTitleChanged
                '' Set the tabs title to the web pages title automatically.
                Me.Text = Me.Browser.DocumentTitle
            End Sub
        End Class
    This code is very basic, and will require a lot more work if you want it to actually be any good.
     
  7. Unread #4 - Aug 1, 2007 at 5:55 PM
  8. Michael3455
    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0

    Michael3455 Active Member

    Tab help + redisgn forms at runtime.

    Thanks very much for the code, Flaming Idiots. It looks very helpful and not so complicated that it's above me :D

    And yeah, I've got around five weeks to do this assignment so I'm just trying to get a basic webbrowser up and running now, then extend and do all sort of other things to it in the following weeks.

    Swan: I generally try searching through MSDN and google extensively before asking questions, but in this case I wasn't able to come up with a likely search term, hence why I came here.
    When I arrive home from school, I'll have alooky at your source code! It sounds like it could be very beneficial!
     
  9. Unread #5 - Aug 1, 2007 at 11:47 PM
  10. cooladrrang
    Joined:
    Jan 21, 2007
    Posts:
    125
    Referrals:
    0
    Sythe Gold:
    0

    cooladrrang Active Member

    Tab help + redisgn forms at runtime.

  11. Unread #6 - Aug 2, 2007 at 5:23 AM
  12. Michael3455
    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0

    Michael3455 Active Member

    Tab help + redisgn forms at runtime.

    Thanks for the offer, but the section 'Web Browser' is pretty simple. However, it showed me how to make a Progress Bar. So that's one less thing to work out :D :D

    Oh well. I'll get started on the browser soon, but not really worry about the design. I'd rather chuck together something that looks horrible and work out the kinks of it all, and then redesign it. :D Hopefully I can work everything out alright.
     
  13. Unread #7 - Aug 3, 2007 at 12:16 AM
  14. cooladrrang
    Joined:
    Jan 21, 2007
    Posts:
    125
    Referrals:
    0
    Sythe Gold:
    0

    cooladrrang Active Member

    Tab help + redisgn forms at runtime.

    well i can help you out alot with the webbrowser so just ask me and ill hlep you
     
  15. Unread #8 - Aug 3, 2007 at 3:18 AM
  16. X Zero
    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0

    X Zero Forum Addict

    Tab help + redisgn forms at runtime.


    umm, how would u navigate the tabs? [solved]
     
  17. Unread #9 - Aug 7, 2007 at 12:57 AM
  18. Michael3455
    Joined:
    Sep 11, 2005
    Posts:
    134
    Referrals:
    0
    Sythe Gold:
    0

    Michael3455 Active Member

    Tab help + redisgn forms at runtime.

    Hey, I've finially started work on the project now (Wasn't going to spend my weekend on a project I'm not totally interested in) and have utilised your code nicely, Flaming Idiots! Thanks again for it. I was just wondering if you'd feel comfortable if I used kept using it in my project. My teacher says it's perfectly fine for me to use others peoples codes, as long as I reference it somewhere in the program (Credits) and also in the documentation that I hand to him.

    Also, my homepage (A forum that I Role-Playing forum I frequent), when it loads, returns a script error. Now, I don't get that when I load it up in IE or FireFox, just the one I'm making now. Now, i think I know the reason for this, but I'm not 100% sure. But anyway, when using the browser control, it has something disabled which stops minor error messages from popping up. I'm pretty sure that's what I read. So, how would I go about disabling that? ((Again, i don't know what to search for so I can't really search google. but I'll try)).
     
  19. Unread #10 - Oct 19, 2007 at 4:11 AM
  20. X Zero
    Joined:
    Jan 21, 2007
    Posts:
    577
    Referrals:
    0
    Sythe Gold:
    0

    X Zero Forum Addict

    Tab help + redisgn forms at runtime.


    soz, ur properly a good person but whats with the spam. Of course he did it was 2 months earlier.
     
< I wish java was more runescape active... | [Source] Adding Browser and tab controls at runtime >

Users viewing this thread
1 guest


 
 
Adblock breaks this site