Sign in to follow this  
Followers 0
oren

some of my gui has the same pointer??

12 posts in this topic

Hello I'm trying to build a backgomman GUI with autoit..

Its going Ok allot of debug-in..

Anyway I have a problem ..

I use guictrlcreatepic for the backgammon pieces , and when someone move a piece or eat one I need to delete the guictrlcreatepic with guictrldelete and create a new one with guictrlcreatepic in the new location, Changing the location of the pic with GUICtrlSetPos or something else is not possible Because I use a different program to compute the pc moves , and then I get a new state with txt file... exc.. I just have to delete a piece and then recreate it...

Anyway my problem is that after the first initialization of the table when I move a piece ,I delete it from one location and then I use guictrlcreatepic again ,But the problem is that the new piece pointer that I get is already in use...

And then If I need to delete the new piece I delete them both

for example:

$Board[1][0][0]= 9
$Board[1][1][0]= 10
$Board[6][0][0]= 29
$Board[6][1][0]= 30
$Board[6][2][0]= 31
$Board[6][3][0]= 32
$Board[6][4][0]= 33
$Board[8][0][0]= 26
$Board[8][1][0]= 27
$Board[8][2][0]= 28
$Board[8][3][0]= 64
$Board[12][0][0]= 4
$Board[12][1][0]= 5
$Board[12][2][0]= 6
$Board[12][3][0]= 7
$Board[12][4][0]= 8
$Board[13][0][0]= 19
$Board[13][1][0]= 20
$Board[13][2][0]= 21
$Board[13][3][0]= 22
$Board[13][4][0]= 23
$Board[17][0][0]= 11
$Board[17][1][0]= 12
$Board[17][2][0]= 13
$Board[19][0][0]= 14
$Board[19][1][0]= 15
$Board[19][2][0]= 16
$Board[19][3][0]= 17
$Board[19][4][0]= 18
$Board[21][0][0]= 13
$Board[22][0][0]= 18
$Board[24][0][0]= 24
$Board[24][1][0]= 25

This is the array for the gui pointers ... as you can see when I created a new pic in $Board[21][0][0] and in $Board[22][0][0] they received the pointers 13 and 18 that are already in use and when I need to delete only $Board[22][0][0] with guictrldelete I also delete $Board[19][4][0]

Did I mange to say it clearly ...?

Can anyone help?

If I'm not clear I can try again

Thank you.

Share this post


Link to post
Share on other sites



oren,

If I understand you correctly then what you say is happening should be impossible. :(

The "pointers" you refer to are known as ControlIDs and are returned by AutoIt when it creates a native control. The ControlIds are the index numbers for the elements of an internal array which AutoIt uses to track the controls it has created. When a new control is created it takes the first empty slot in the array - whenever I have deleted and then immediately recreated a control I usually get the same ControlID, which is hardly surprising given what I have just explained.

If your diagnosis is correct, there are very many scripts out there which would no longer run at all - so I am tempted to suggest that there is another problem somewhere. :D

Could you post the code you are using to initialise, delete and recreate the pieces - perhaps that will give us a clue as to what is going wrong. :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

This is the code for creating

Func draw($Colr,$Cols,$s)
;ConsoleWrite(@crlf & $Cols & "   "  & $s &@cr  )
Local $ColIm
Local $Loc
;MsgBox(1,1, $Colr & "   " & $Cols & "  " & $s)
    if $Colr == "w" Then
        if $s>4 Then
            $ColIm = "\imgs\white"&$s-4&".png"
        Else
            $ColIm = "\imgs\white.png"
        EndIf
        
    Else
        if $s>4 Then
            $ColIm = "\imgs\black"&$s-4&".png"
        Else
            $ColIm = "\imgs\black.png"
        EndIf
        
    EndIf


if  $Cols == 0 Then
    $ColIm = "\imgs\white"&$s&".png"
    $Loc = 240
    $t=0
ElseIf $Cols==25 Then
    $ColIm = "\imgs\black"&$s&".png"
    $Loc = 310
    $t=0
Else
    $t=$s
    $Board[$Cols][$t][1]=$Colr
    if $Cols <= 12 Then
        if $s>5 Then
            $Loc=34
        Else
            $Loc = 34+40*$s
        EndIf
    Else
        if $s>5 Then
            $Loc =530
        Else
            $Loc = 530-40*$s
        EndIf
        
    EndIf
EndIf


            
            $Board[$Cols][$t][0]= guictrlcreatepic("",$LocationT[$Cols],$Loc)
            $hGreen1  = _Icons_Bitmap_Load(@ScriptDir & $ColIm)
            _SetHImage($Board[$Cols][$t][0],$hGreen1 )
            GuiCtrlSetState(-1,$GUI_DISABLE)

        
EndFunc

and the code for deleting is normal

GUICtrlDelete($Board[$i+1][$s][0])

Share this post


Link to post
Share on other sites

I think that there may be a problem with GUICtrlDelete, I posted an example script showing that using it causes problems when trying to navigate a ListView, and it may be similar to the issue that you're having with using it to delete the pictures on your program.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

-delete-

Edited by oren

Share this post


Link to post
Share on other sites

oren,

You use a 3D array for storing your ControlIDs - that makes for a pretty complicated structure to access. Are you sure you are accessing the correct element each time you create and delete? :graduated:

What exactly are the dimensions of the array that you use in $Board[$Cols][$t][0] and $Board[$i+1][$s][0] when you create/delete the controls. :(

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

oren,

You use a 3D array for storing your ControlIDs - that makes for a pretty complicated structure to access. Are you sure you are accessing the correct element each time you create and delete? :graduated:

What exactly are the dimensions of the array that you use in $Board[$Cols][$t][0] and $Board[$i+1][$s][0] when you create/delete the controls. :(

M23

No man I pretty sure I'm accessing the correct element eact time I create and delete

The dimension of the board are Board[26][15][2]

board[ Loction of the board ] [ Hight] [0] = ControlID

board[ Loction of the board ] [ Hight] [1] = ('b','w',0) => b="black" , w= "white" 0=empty

I'm really really sure I am accessing the right ControlID

What about what BrewManNH said I didnt really understood him.

Share this post


Link to post
Share on other sites

oren,

I like playing backgammon a lot, so I am very interested in helping you with your project. If I ask questions it is only to try and understand what is going on, not to criticize your coding. :(

I understand your array works like this - am I correct?

|
|    O
| O  O    O
#___________
  |  |    |
  |  |    This piece is [4][0][0]
  |  |
  |  These pieces are [2][0][0] and [2][1][0]
  |
  This piece is [1][0][0]

Now in your first post you show an array with 33 entries - when I play backgammon I only use 30 pieces. Remember that you need to amend the array as well as delete and recreate the pieces or you could well get duplicate entries in the array. Are you doing that? :graduated:

If you could post the whole script and an example of the text file you are using to set the pieces it would make life a lot easier. :D

M23

P.S. BrewManNH's comment referred to a problem he was having with deleting items in sorted ListViews - I do not believe it has any relevance to what we are discussing here. Nor do I belive there is any problem with GUICtrlDelete - I think it would have manifested itself a long time ago. :D


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

oren,

I like playing backgammon a lot, so I am very interested in helping you with your project. If I ask questions it is only to try and understand what is going on, not to criticize your coding. :(

I understand your array works like this - am I correct?

|
|    O
| O  O    O
#___________
  |  |    |
  |  |    This piece is [4][0][0]
  |  |
  |  These pieces are [2][0][0] and [2][1][0]
  |
  This piece is [1][0][0]

Now in your first post you show an array with 33 entries - when I play backgammon I only use 30 pieces. Remember that you need to amend the array as well as delete and recreate the pieces or you could well get duplicate entries in the array. Are you doing that? :graduated:

If you could post the whole script and an example of the text file you are using to set the pieces it would make life a lot easier. :D

M23

P.S. BrewManNH's comment referred to a problem he was having with deleting items in sorted ListViews - I do not believe it has any relevance to what we are discussing here. Nor do I belive there is any problem with GUICtrlDelete - I think it would have manifested itself a long time ago. :D

Mr man!!!!

Thank you///

The thing is that after I used GUICtrlDelete I left the contorlID in the array... Adding a simple $Board[22][0][0]=0 FIX the problem really really really thank you...

The project is nice I need to build (university) a program that play backgomman using the program language prolog so the PC move computing is been done by prolog the autoit is more for the gui///

If you interested I can send you the soruce code, But I can not publish it in here...

Thank you again.

Share this post


Link to post
Share on other sites

oren,

Delighted you got it fixed. :(

I told you GUICtrlDelete worked! :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

One more question..

If I want the array location to be clear after using GUICtrlDelete, WHat integer should I use ? does $Board[22][0][0]=0 Is good , Is there no option that the controlID will give the integer 0?

Thank you.

Share this post


Link to post
Share on other sites

oren,

0 would be good. You can see from this short script that the returned ControlIDs (= internal array indices) start at 3 - I presume that the earlier elements are used by AutoIt to track the hidden window it uses - and that using 0 in GUICtrlDelete does not cause a problem: :graduated:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hButton = GUICtrlCreateButton("Test", 10, 10, 80, 30)
ConsoleWrite($hButton & @CRLF)

GUICtrlDelete(0)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            MsgBox(0, "", "I still work!")
    EndSwitch
WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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