Sign in to follow this  
Followers 0
royalmarine

how can i shorten the text displayed in a drop down box?

3 posts in this topic

Not sure if im going about this the right way, im trying to make a small gui, that gives me a drop down box, with several websites listed. when i select one, and then click "open web site" button, it loads firefox, and goes to the website.

its working, however, i dont want to see the full web address in the drop down box, only some of it.

e.g instead of "www.hotmail.com"

how can i make it show "hotmail"

any help would be great!

#include <GuiConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()

Func _Main()
    Local $website, $web, $msg, $data

    GUICreate("WebSites", 191, 157, (@DesktopWidth - 191) / 2, (@DesktopHeight - 157) / 2)
    $website = GUICtrlCreateCombo("", 30, 60, 130, 21)
    GUICtrlSetData($website, "www.hotmail.com|www.youtube.com")
    $web= GUICtrlCreateButton("Open Web Site", 30, 90, 130, 20)

    GUISetState()
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $msg = $web
                $data = GUICtrlRead($website)
                    ShellExecute("firefox.exe", GUICtrlRead($website))
        EndSelect
    WEnd
    Exit
EndFunc   ;==>_Main

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Well, there's two ways of going about it:

The first, and most flexible, is to have an array structure (either a two dimensional array, or two arrays that are kept in sync) that have the address you want to go to and the text you want displayed.

The second is to use regular expressions to strip off a set bit of text from the front and back ('http://www' and '.com' in this case) and then restore them later when the time comes to spawn firefox.

Personally, I prefer a hybrid approach that would look something like this:

Global Const $WEBSITE_NORMAL = 1
Global Const $WEBSITE_NO_WWW = 2

$someArray[3][2] = [ _
['somewebsite', $WEBSITE_NORMAL], _ ;turns into http://www.somewebsite.com
['someothersite', $WEBSITE_NO_WWW], _ ;turns into http://someothersite.com
['lastwebsite', 'http://www.lastwebsite.com/mywebpage']] ;turns into stored value (http://www.lastwebsite.com/mywebpage)

Hopefully this will give you some ideas.

Edit: This is non-tested, incomplete, semi-psudocode. It will probably not compile.

Edited by Fulano

#fgpkerw4kcmnq2mns1ax7ilndopen (Q, $0); while ($l = <Q>){if ($l =~ m/^#.*/){$l =~ tr/a-z1-9#/Huh, Junketeer's Alternate Pro Ace /; print $l;}}close (Q);[code] tag ninja!

Share this post


Link to post
Share on other sites

Another possibility would be something like this: (this is a ccp of some code I am working on just change it to fit your situation)

$msg = ""

    $gui = GUICreate("Ship to:", 220, 120) ; creates a centered dialog box
    $button_ok = GUICtrlCreateButton("Send", 10, 80, 100)
    $button_cancel = GUICtrlCreateButton("Cancel", 110, 80, 100)
    $Combo_1 = GUICtrlCreateCombo("Select", 10, 40, 200, 21)
    GUICtrlSetData($Combo_1, "|Grunstadt|Stuttgart|Mainz|")
    GUICtrlSetData(-1, "Grunstadt")
    GUICtrlCreateLabel("Select Receiving Facility", 10, 10)
    GUISetState(@SW_SHOW)

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $button_cancel Or $msg = $GUI_EVENT_CLOSE
                GUIDelete()
                Return 0

            Case $msg = $button_ok
                $Menustate = GUICtrlRead($Combo_1)
                If $Menustate = "Grunstadt" Then
                    $var1 = "1342560"
                    $var2 = "7014290600"
                    ExitLoop
                EndIf
                If $Menustate = "Stuttgart" Then
                    $var1 = "1342570"
                    $var2 = "7014291800"
                    ExitLoop
                EndIf
                If $Menustate = "Mainz" Then
                    $var1 = "1342561"
                    $var2 = "7014290900"
                    ExitLoop
                EndIf
                
        EndSelect
    WEnd
    GUIDelete()
    ;end code for popup Facility Selector---------------------------------------------------------------------------------
    
    ;Here some code open FF and send vars

you will have to insert some code here to tell it what to do with the chosen vars.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0