Jump to content
Sign in to follow this  
darzanmihai

Need some help!

Recommended Posts

darzanmihai

What would be the reason for witch I cannot create a graphic with GUICtrlCreateGraphic after deleleing it, but in certain conditions:

I have a Gui in witch I have 2 buttons:

- one button is for refreshing the Graphic

- the other button is for opening a child gui

For refreshing the Graphic I am deleting it and then creating it again GUICtrlCreateGraphic .

Everithing is fine until I open the child gui by pressing the button. After closing the child gui, when I refresh the Graphic, it delets it but it wont create it again and the function GUICtrlCreateGraphic returns 0.

I have no ideea what is the reason for this.

Thank you!


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites
dbzfanatic

Share this post


Link to post
Share on other sites
darzanmihai

Could you post your script? Maybe one of us can find a flaw in your coding and it would certainly make things easier.

The button $GenerareGrafice deletes the graphic control and creates it again. It works fine until I press $AlegeCumparatori or $AlegeFurnizori. After pressing one of those 2 buttons, when I press $GenerareGrafice the graphic will only be deleted but not created again: GUICtrlCreateGraphic() returns 0

Thanks in advance!


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites
enaiman

Could you post your script?

You don't have to take this "literally" - you have to prepare a small verion of your script (an example) to show your problem. I doubt some1 will have enough time and patience to look through 1000+ line of code searching for error.

Take this as a friendly advice. You should do accordingly if you want some1 to give you any help.

Also, try some debugging first: use some messageboxes, error codes check to see where your problem is; the best help will come from yourself.

EDIT: a working example must be provided if you choose to post your original script; your code is incomplete, all #Include are missing.

EDIT2 : "inaltimea" is more apropriate than "grosimea" (that's how you translate "height") ;) (just kidding a little bit :D )

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
darzanmihai

You don't have to take this "literally" - you have to prepare a small verion of your script (an example) to show your problem. I doubt some1 will have enough time and patience to look through 1000+ line of code searching for error.

Take this as a friendly advice. You should do accordingly if you want some1 to give you any help.

Also, try some debugging first: use some messageboxes, error codes check to see where your problem is; the best help will come from yourself.

EDIT: a working example must be provided if you choose to post your original script; your code is incomplete, all #Include are missing.

EDIT2 : "inaltimea" is more apropriate than "grosimea" (that's how you translate "height") ;) (just kidding a little bit :D )

I know what you are saying, and I prepared a small version of the code, but everithing worked just fine...that is why I posted the code you have seen!

I have tried debugging, but the only thing I have found is that the GuiCtrlCreateGraphic() returns 0.....no error no nothing!

This is the include list:

#include <GUIConstants.au3>

#include <WindowsConstants.au3>

#include <ComboConstants.au3>

#include <GuiListView.au3>

#include <ExcelCOM_UDF.au3>

#include <Array.au3>

#include <File.au3>

#include <GuiComboBox.au3>

#include <Constants.au3>

#include <SQLite.au3>

#include <sqlite.dll.au3>

#include <StaticConstants.au3>


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites
enaiman

Well, after some time spend building this example I've noticed a particular behaviour of GUICtrlCreateGraphic

Example:

#include <GUIConstantsEx.au3>

GUICreate("1", 200, 200, 100)
$but2 = GUICtrlCreateButton("Create Gr Success", 20, 170, 160, 25)
GUISetState()
GUICreate ("2", 200, 200, 310)
GUISetState()
$but = GUICtrlCreateButton("Create Gr Fail", 20, 170, 160, 25)
$gg = GUICreate ("3", 200, 200, 520)
GUISetState()

Do
    $msg = GUIGetMsg()

    If $msg = $but Then
        GUIDelete($gg)
        
        $a = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "a = "&$a, 2)
    EndIf
    If $msg = $but2 Then
        $b = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "b = "&$b, 2)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

Particular behaviour: GUICtrlCreateGraphic will try to create the graphic always on the last form created if the last form was deleted then GUICtrlCreateGraphic will fail.

My friend - I think that was what happened to you - you have created a new gui and deleted it and your function was trying to write on that GUI.

I have no idea if this behaviour is intended for this function. What you have to do is to give up creating and deleting graphics and try to clear the current graphic and draw the new one OVER. I know it's "messy" but ... I can't see what else can you do.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
darzanmihai

Well, after some time spend building this example I've noticed a particular behaviour of GUICtrlCreateGraphic

Example:

#include <GUIConstantsEx.au3>

GUICreate("1", 200, 200, 100)
$but2 = GUICtrlCreateButton("Create Gr Success", 20, 170, 160, 25)
GUISetState()
GUICreate ("2", 200, 200, 310)
GUISetState()
$but = GUICtrlCreateButton("Create Gr Fail", 20, 170, 160, 25)
$gg = GUICreate ("3", 200, 200, 520)
GUISetState()

Do
    $msg = GUIGetMsg()

    If $msg = $but Then
        GUIDelete($gg)
        
        $a = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "a = "&$a, 2)
    EndIf
    If $msg = $but2 Then
        $b = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "b = "&$b, 2)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

Particular behaviour: GUICtrlCreateGraphic will try to create the graphic always on the last form created if the last form was deleted then GUICtrlCreateGraphic will fail.

My friend - I think that was what happened to you - you have created a new gui and deleted it and your function was trying to write on that GUI.

I have no idea if this behaviour is intended for this function. What you have to do is to give up creating and deleting graphics and try to clear the current graphic and draw the new one OVER. I know it's "messy" but ... I can't see what else can you do.

I also thought that this wos the problem.....I shall see what I can do

Thanks!


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

Share this post


Link to post
Share on other sites
enaiman

I'll try to open a ticket for this - I'm not sure if it is intended behaviour or a bug.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
martin

I'll try to open a ticket for this - I'm not sure if it is intended behaviour or a bug.

I don't see that this is a bug. When you create a control the control is created on the last gui referred to. If you have more than one gui, or want the control on a particular gui then you should use GuiSwitch.

#include <GUIConstantsEx.au3>

$g1 = GUICreate("1", 200, 200, 100)
$but2 = GUICtrlCreateButton("Create Gr Success", 20, 170, 160, 25)
$g2 = GUISetState()
GUICreate ("2", 200, 200, 310)
GUISetState()
$but = GUICtrlCreateButton("Create Gr Fail", 20, 170, 160, 25)
$gg = GUICreate ("3", 200, 200, 520)
GUISetState()

Do
    $msg = GUIGetMsg()

    If $msg = $but Then
        GUIDelete($gg)
       guiswitch($g1)
        $a = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "a = "&$a, 2)
    EndIf
    If $msg = $but2 Then
        $b = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "b = "&$b, 2)
    EndIf
Until $msg = $GUI_EVENT_CLOSE
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
enaiman

That's brilliant martin ;)

I've never used GUISwitch before ... well what a better example that we always have something to learn :D

Thanks,


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
darzanmihai

I don't see that this is a bug. When you create a control the control is created on the last gui referred to. If you have more than one gui, or want the control on a particular gui then you should use GuiSwitch.

#include <GUIConstantsEx.au3>

$g1 = GUICreate("1", 200, 200, 100)
$but2 = GUICtrlCreateButton("Create Gr Success", 20, 170, 160, 25)
$g2 = GUISetState()
GUICreate ("2", 200, 200, 310)
GUISetState()
$but = GUICtrlCreateButton("Create Gr Fail", 20, 170, 160, 25)
$gg = GUICreate ("3", 200, 200, 520)
GUISetState()

Do
    $msg = GUIGetMsg()

    If $msg = $but Then
        GUIDelete($gg)
       guiswitch($g1)
        $a = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "a = "&$a, 2)
    EndIf
    If $msg = $but2 Then
        $b = GUICtrlCreateGraphic(20, 50, 100, 100)
        GUICtrlSetBkColor(-1, 0xffffff)
        GUICtrlSetColor(-1, 0)

        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
        GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)

        GUICtrlSetState(-1, $GUI_SHOW)
        MsgBox(0, "return", "b = "&$b, 2)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

It is brilliant....it is so simple...Thank you!


I do not like stupid and idiot people that write idiot things...If you are one, do not write.

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  

×