Sign in to follow this  
Followers 0
momar33

Can't edit edit box

3 posts in this topic

Why can't I edit the second edit box in this code?

Due to using a database i have include a zip file with everything needed to run it.

SI.zip

Here is the code:

#include <GUIConstants.au3>
#include <database.au3>
#include <variables.au3>

;AutoItSetOption("MustDeclareVars", 1)
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode

$parentGui = GUICreate("Spell Inventory", $parentWidth, $parentHeight, $parentLeft, $parentTop, $WS_OVERLAPPEDWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

GUISetState()

_CreateMenu()

_CreateToolbar($parentGui, $toolBarWidth, $toolBarHeight, $toolBarLeft, $toolBarTop)

$mainGui=GUICreate("mainGui", $mainWidth, $mainHeight, 0, 30, $WS_CHILD, Default, $parentGui)
GUISetState ()

While 1
    Sleep(10)
Wend

Func _Exit()
    If @GUI_WINHANDLE = $child Then
        GUISwitch($child)
        GuiDelete()
    ElseIf @GUI_WINHANDLE = $parentGui Then
        GUISwitch($parentGui)
        GuiDelete()
        Exit
    EndIf
EndFunc

Func _CreateMenu()
    ;-----File Menu-----
    Global $fileMenu = GuiCtrlCreateMenu ("File")
    Global $importMI = GuiCtrlCreateMenuitem ("Import File",$filemenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$filemenu)
    Global $ppOptionsMenu = GuiCtrlCreateMenu ("Print Preview Options",$filemenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$filemenu)
    Global $exitMI = GuiCtrlCreateMenuitem ("Exit",$filemenu)

    ;-----Tools Menu-----
    Global $toolsMenu = GuiCtrlCreateMenu ("Tools")
    Global $manageSpellbooksMI = GuiCtrlCreateMenuitem ("Manage Spellbooks",$toolsMenu)
    Global $manageSchoolsMI = GuiCtrlCreateMenuitem ("Manage Schools",$toolsMenu)
    Global $manageSpellsMI = GuiCtrlCreateMenuitem ("Manage Spells",$toolsMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$toolsMenu)
    Global $manageScrollsMI = GuiCtrlCreateMenuitem ("Manage Scrolls",$toolsMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$toolsMenu)
    Global $searchMI = GuiCtrlCreateMenuitem ("Search",$toolsMenu)

    ;-----Window Menu-----
    Global $windowMenu = GuiCtrlCreateMenu ("Window")
    Global $tileMI = GuiCtrlCreateMenuitem ("Tile",$windowMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$windowMenu)
    Global $cascadeMI = GuiCtrlCreateMenuitem ("Cascade",$windowMenu)

    ;-----About Menu-----
    Global $aboutMenu = GuiCtrlCreateMenu ("About")
    Global $helpTopicsMI = GuiCtrlCreateMenuitem ("Help Topics",$aboutMenu)
    Global $separator = GuiCtrlCreateMenuitem ("",$aboutMenu)
    Global $aboutMI = GuiCtrlCreateMenuitem ("About SI",$aboutMenu)
EndFunc

Func _CreateToolbar($parentGui, $width, $height, $left, $top)
    $toolbar=GUICreate("toolbar", $width, $height, $left, $top, $WS_CHILD, Default, $parentGui)
    $viewSpell = GUICtrlCreateButton ("Spell", 0,0,50,20)
    GUICtrlSetOnEvent(-1, "_Create_VeiwSpell_Window")
    GUISetState ()
EndFunc

Func _Create_VeiwSpell_Window()
    $query = "SELECT * FROM " & $tblname & " WHERE (((Spells.ID)=1 Or (Spells.ID)=2));"
    $record = _RecordSearch($dbname, $query)
    ;$strData = _ReadOneFld($query, $dbname, $fldname)
    
    
    $child = GUICreate("View Spells", 400, 350, 100, 0, BitOR($WS_OVERLAPPEDWINDOW, $WS_CHILD), Default, $mainGui)
    DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($child), "hwnd", WinGetHandle($mainGui))
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    
    GuiCtrlCreateTab(10, 10, 380, 350)
    GUICtrlSetBkColor(-1, 0xE87B38)
    GUICtrlSetResizing(-1,$GUI_DOCKALL)
    
    $tabOne=GuiCtrlCreateTabItem("     Details     ")
    ;GUICtrlSetBkColor(-1, 0xE2E2E2)
    GUICtrlSetBkColor(-1, 0xE87B38)
    
    $top = 50
    Dim $lineSpace[8]
    $labelLeft = 20
    $labelWidth = 90
    $labelHeight = 20
    
    $dataLeft = $labelLeft + 100
    $dataWidth = 250
    $dataHeight = 20
    
    $space = 30
    
    $tempNum = $space
    For $element = 0 to 7 Step 1
        $lineSpace[$element] = $tempNum
        $tempNum = $lineSpace[$element] + $space
    Next
    
    ;$test=GUICreate("mainGui", 380, 350, 30, 30, $WS_CHILD, Default, $mainGui)
    ;GUICtrlSetBkColor(-1, 0xE87B38)
    
    GUICtrlCreateLabel ("",  $labelLeft, $top, $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][2] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top, $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][2])
    ;left, top , width , height
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[0], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][3] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[0], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][3])   
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[1], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][5] & ":")
    GUICtrlCreateLabel ("", $dataLeft, $top + $lineSpace[1], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][5])   
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[2], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][9] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[2], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][9])   
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[3], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][8] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[3], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][8])   
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[4], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][13] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[4], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][13] & " " & $record[1][12])   
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[5], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][10] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[5], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][10])  
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[6], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][11] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[6], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][11])  
    
    GUICtrlCreateLabel ("", $labelLeft, $top + $lineSpace[7], $labelWidth, $labelHeight, $ES_RIGHT)
    GUICtrlSetFont (-1,9, 800, "")
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[0][14] & ":")
    GUICtrlCreateLabel ("", $dataLeft,  $top + $lineSpace[7], $dataWidth, $dataHeight)
    GUICtrlSetFont (-1,9, 400)
    GUICtrlSetResizing (-1,$GUI_DOCKALL)
    GUICtrlSetData(-1, $record[1][14])

    $data = $record[2][15]
    ;MsgBox(0, "", StringLen($data))
    GuiCtrlCreateTabItem("   Description   ")
    If StringLen($data) < 1500 then
        GUICtrlCreateEdit($data, 15, 40, 370, 300, $ES_READONLY)
    Else
        GUICtrlCreateEdit("Why can't i edit this?", 15, 40, 370, 300, $WS_VSCROLL)
    EndIf
    GUICtrlCreateTabitem ("")
    GUICtrlSetState($tabOne, $GUI_SHOW)
    GUISetState()
    
    ;$query = "SELECT " & $tblname & "." & $fldname & " FROM " & $tblname & " WHERE " & $tblname & ".ID=1"
    ;$query = "SELECT First(Spells.Name) AS FirstOfName FROM Spells;"
    ;$query = "SELECT * FROM " & $tblname & " WHERE " & $fldname & " = 1"
EndFunc

Share this post


Link to post
Share on other sites



Anyone?

Share this post


Link to post
Share on other sites

Try to nail it down by trimming down your program to the smallest piece of standalone code which still produces the bug. By that point you may very well find the solution on your own.

For me your program crashes on line 137 of databases.au3 when clicked on "Spell" button, probably because I don't have Access installed and don't plan to.


"be smart, drink your wine"

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