Jump to content

child window problem.


dexxa
 Share

Recommended Posts

i am writing this sudoku script just for fun. i wrote it so that when u click on a button/number, a child window will come up and give u 9 numbers to select. the problem is that the child window sometimes doesnt come up and i get stucked in an infinite loop. i cant figure out why it wouldnt come up. thank you in advance

#include <guiconstants.au3>


Global $b[3][3][3][3]
Global $selected_numb = 0

$parent = GUICreate("Sudoku by me", 290,290,100,100)
GUISetState()

$labels = 1
For $square = 0 To 2 
    For $i = 0 To 2
        For $j = 0 To 2
            For $k = 0 to 2
                $b[$square][$i][$j][$k] = GUICtrlCreateButton("",($i*100)+($k*30),($square*100)+($j*30),30,30);create buttons
;~              TrayTip("",$square&","&$i&","&$j&","&$k,1)
                If $labels = 9 Then
                    $labels = 0
                EndIf
                $labels += 1
;~              sleep(500)
            Next
        Next
    Next
Next

While 1
    $msg = GUIGetMsg()
    
    If $msg = $Gui_Event_Close Then
        Exit
    EndIf

    For $big_row = 0 to 2
        For $big_column = 0 to 2
            For $row = 0 to 2
                For $column = 0 to 2
                    If $msg = $b[$big_row][$big_column][$row][$column] Then
                        $ctrlpos = ControlGetPos("Sudoku by me","",$b[$big_row][$big_column][$row][$column])
                        $winpos = WinGetPos("Sudoku by me")
                        $child = GUICreate("",30,121,$ctrlpos[0]+$winpos[0]+2,$ctrlpos[1]+$winpos[1]+25,BitOr($WS_POPUP,$WS_BORDER,$WS_EX_MDICHILD),-1,$parent);child window
                        GUISetState(@SW_SHOW,$child)
                        
                        $numb = GUICtrlCreateList("",-1,-1,33,125);list of numbers
                        GUICtrlSetData($numb,"1|2|3|4|5|6|7|8|9")
                        GUICtrlSetState($numb,bitor($GUI_FOCUS,$GUI_ONTOP))
                        
                        $selected_numb = 0
                        While $selected_numb = 0
                            $selected_numb = GUICtrlRead($numb)
                        WEnd
                        
                        GUIDelete($child)
                        GUICtrlSetData($b[$big_row][$big_column][$row][$column],$selected_numb)
                    EndIf
                Next
            Next
        Next
    Next
WEnd
Edited by dexxa
Link to comment
Share on other sites

Are you able to give us a sample on how to get it stuck?

I have tried your code and I don't get stuck. Do I have to hit keys, right or left click?

Link to comment
Share on other sites

Hey I looked over the Child GUI part of the script and, I attempted to fix your problem. Try to replace this:

GUISetState(@SW_SHOW,$child)

$numb = GUICtrlCreateList("",-1,-1,33,125);list of numbers
GUICtrlSetData($numb,"1|2|3|4|5|6|7|8|9")
GUICtrlSetState($numb,bitor($GUI_FOCUS,$GUI_ONTOP))

$selected_numb = 0
While $selected_numb = 0
    $selected_numb = GUICtrlRead($numb)
WEnd
         
GUIDelete($child)
GUICtrlSetData($b[$big_row][$big_column][$row][$column],$selected_numb)

UNTESTED

*EDIT* Your script seems work perfectly either way (maybe yours was missing an ExitLoop).

Hope it works :P

Kurt

Edited by _Kurt

Awaiting Diablo III..

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...