Results 1 to 5 of 5

Thread: Here's a couple of things I need help with

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    26

    Question Here's a couple of things I need help with

    Firstly,

    I need the forms in my project to remember where they were on last load.


    Secondly,
    I also need (this one's a bit trickier) to be able to have certain text in a RichTextBox displayed certain colours.
    E.G. Like in html editors that set different tags <tag> to different colours

    I have no idea where to start on this one.

    Is backlighting the text also possible?


    Thanks to anyone who replies.

    You guys sure know a lot of stuff.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Using the registery by using SaveSetting and GetSetting 
    
    Option Explicit 
    '
    'assuming you have only one form this will work 
    
    'if you want to delete the save settings click on command2 
    
    Private Sub Command2_Click() 
    'this will delete it from the register if you are finished 
    'with playing with it 
    DeleteSetting "project1", "Left" 
    DeleteSetting "project1", "Top" 
    
    End Sub 
    
    Private Sub Form_Load() 
    'this will load it into the register 
    Me.Top = GetSetting("project1", "Top", "Value", 0) 
    Me.Left = GetSetting("project1", "Left", "Value", 0) 
    End Sub 
    
    
    Private Sub Form_Unload(Cancel As Integer) 
    'this will save it into the register when you quit 
    Dim x, y 
    x = Me.Top 
    y = Me.Left 
    SaveSetting "project1", "Top", "Value", x 
    SaveSetting "project1", "Left", "Value", y 
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'here is a start

    Code:
    'using this I color all words Reference blue.
     Private Sub MakeColored()
     Dim x
        For x = 1 To Len(RichTextBox1.Text)
            If Mid(RichTextBox1.Text, x, Len("Reference")) = "Reference" Then
                RichTextBox1.SelStart = x - 1
                RichTextBox1.SelLength = Len("Reference")
                RichTextBox1.SelColor = vbBlue
                RichTextBox1.SelLength = 0
                RichTextBox1.SelColor = vbBlack
                x = (x - 1) + Len("Reference")
            Else
                RichTextBox1.SelColor = vbBlack
            End If
        Next x
    
        RichTextBox1.SelStart = Len(RichTextBox1.Text)
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    1) You could store the left and top properties of a form in the registry. I use this code to accomplish this. It works for more than 1 form too :
    Code:
    Private Sub Form_Load()
    
       Me.Move GetSettingString(HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Left"), GetSettingString(HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Top")
    
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    
        If Me.WindowState <> vbMinimized Then
            ' Save form window position LEFT
            SaveSettingString HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Left", Me.Left
            ' TOP
            SaveSettingString HKEY_LOCAL_MACHINE, "Software\MyCompany\MyApp\User Preferences\Window Pos", Me.Name & "Top", Me.Top
        End If
    
    End Sub
    You'll need to include the attached registry.bas for this to work!

    2) There are loads of threads around asking the same sort of thing. Try this or perform a search for "Colour Coding"
    Attached Files Attached Files

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2001
    Posts
    26
    Thanks all.

    Done the pos thing now.

    I got the colour thing working, it's great, but, no I need to do this with it:-


    Original Text:-

    blah ( blah
    ( blash

    ) blah
    )

    Changed to:-

    blah "(red" blah
    "(blue" blash

    ")blue" blah
    ")red"


    and other colours for other depths.

    Am I asking to much?

    I looked at the other post on this, but it doesn't cover this one.

    Plus, your reference blue code was good, but i would change:-
    references
    to
    <blue>reference<blue>s

    Is there a way to search for words? Can you use RegExp's in VB? I'm used to them in perl.
    Last edited by kryten; Jun 10th, 2001 at 12:36 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width