Jump to content

GuiGetCursorInfo Error !


 Share

Recommended Posts

Hi,

In my gui I have two cases that use the Guigetcursorinfo parameter. One is related when the user right click on a certain picture and the other one happen when the user has his cursor over a picture. The problem that I encounter is that those two Guigetcursorinfo are in conflict.

I setted it so when I right click on a picture, it make it blank. It was working fine alone until I added another function using the Guigetcursorinfo. I now have to click 2-3 time before the image become blank ( because I think it make 2 checks with Guigetcursorinfo). How can I correct this problem?

SEE ATTACHED FILE

#include <GuiConstants.au3>

GuiCreate("", 200, 350,-1, -1)

$Blank = @ScriptDir & "\Images\blank.bmp"
$Blue =  @ScriptDir & "\Images\blue.bmp"
$File1 = @ScriptDir & "\Images\blank.bmp"

$label_1 =  GUICtrlCreateLabel("Mouse over buttons", 55, 30)
$Picture_0 = GuiCtrlCreatePic($Blank, 30, 55, 35, 35)
$Picture_1 = GuiCtrlCreatePic($Blank, 70, 55, 35, 35)
$Picture_2 = GuiCtrlCreatePic($Blank, 110, 55, 35, 35)

$label_2 =  GUICtrlCreateLabel("Right click to set the picture blank", 30, 135)
$Picture_3 = GuiCtrlCreatePic($Blank, 60, 160, 35, 35)
$Picture_4 = GuiCtrlCreatePic($Blank, 97, 160, 35, 35)
$Picture_5 = GuiCtrlCreatePic($Blank, 60, 197, 35, 35)
$Picture_6 = GuiCtrlCreatePic($Blank, 97, 197, 35, 35)

$Button_1 = GuiCtrlCreateButton("", 79, 300, 35, 35, $BS_BITMAP)
GUICtrlSetImage($Button_1, $Blue)
$label_3 =  GUICtrlCreateLabel("Click to set the picture blue", 30, 280)



GuiSetState()
While 1
    $msg = GuiGetMsg()
    
    
    
        For $a = 0 to 2
            $GuiCursor = GUIGetCursorInfo()
            If $GuiCursor[4] = Eval('Picture_' & $a) Then
                
            If $GuiCursor[4] = 4  Then
                    
                        GuiCtrlSetImage($Picture_0, $Blue)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 5 Then
                    
                        GuiCtrlSetImage($Picture_1, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 6 Then
                    
                        GuiCtrlSetImage($Picture_2, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        
                    EndIf
                
            EndIf
        Next
    
    
    
    Select
        
        

        Case $msg = $GUI_EVENT_SECONDARYDOWN
        $GuiCursor = GUIGetCursorInfo()
        
        ;Set the square blank on right click
        For $a = 3 to 6
            If $GuiCursor[4] = Eval('Picture_' & $a) Then
                GUICtrlSetImage($GuiCursor[4],$Blank)
            Else
            EndIf
        Next
        
    Case $msg = $Button_1
        $File1 = @ScriptDir & "\Images\blue.bmp"
    Case $msg = $Picture_3
        GUICtrlSetImage($Picture_3,$File1)
    Case $msg = $Picture_4
        GUICtrlSetImage($Picture_4,$File1)
    Case $msg = $Picture_5
        GUICtrlSetImage($Picture_5,$File1)
    Case $msg = $Picture_6
        GUICtrlSetImage($Picture_6,$File1)
        
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
    EndSelect
WEnd
Exit

GuiGetCursor_Info_Error.rar

Edited by J0ker
Link to comment
Share on other sites

Ok I found out that I add to put every GuiGetCursorInfo on a restriction case (If or Case). That corrected the first problem.

If $blabla = 0, everything work fine (except the mouse over)

Now, If $blabla = 1 then the "right click" case doesnt work anymore !

Whenever the "mouse over" statement is called, every other things in my Gui (buttons,radios,etc..) stop working.

Why?

Edited by J0ker
Link to comment
Share on other sites

You certainly caught me when I was editing :shocked:

I removed the first Next, because it wasnt doing anything.

I think that error came from the fact that the While loop stop everytime and the $Blabla = 1 and he skip every other cases. I would have to find a working $msg = instead of $Blabla = 1.

Please I need help!

Edited by J0ker
Link to comment
Share on other sites

.... this just can't be right

GUICtrlSetImage($GuiCursor[4],$Blank)

EDIT: Sorry, that "can" work

I have already made _ControlHover(), ButtonHover() and EzSkin 1-2-3

any of these should help

I have no intentions of re-inventing the wheel with your style

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

OK I made a script to show exactly what happen in my real script:

SEE ATTACHED FILE

#include <GuiConstants.au3>

GuiCreate("", 200, 350,-1, -1)

$Blank = @ScriptDir & "\Images\blank.bmp"
$Blue =  @ScriptDir & "\Images\blue.bmp"
$File1 = @ScriptDir & "\Images\blank.bmp"

$label_1 =  GUICtrlCreateLabel("Mouse over buttons", 55, 30)
$Picture_0 = GuiCtrlCreatePic($Blank, 30, 55, 35, 35)
$Picture_1 = GuiCtrlCreatePic($Blank, 70, 55, 35, 35)
$Picture_2 = GuiCtrlCreatePic($Blank, 110, 55, 35, 35)

$label_2 =  GUICtrlCreateLabel("Right click to set the picture blank", 30, 135)
$Picture_3 = GuiCtrlCreatePic($Blank, 60, 160, 35, 35)
$Picture_4 = GuiCtrlCreatePic($Blank, 97, 160, 35, 35)
$Picture_5 = GuiCtrlCreatePic($Blank, 60, 197, 35, 35)
$Picture_6 = GuiCtrlCreatePic($Blank, 97, 197, 35, 35)

$Button_1 = GuiCtrlCreateButton("", 79, 300, 35, 35, $BS_BITMAP)
GUICtrlSetImage($Button_1, $Blue)
$label_3 =  GUICtrlCreateLabel("Click to set the picture blue", 30, 280)



GuiSetState()
While 1
    $msg = GuiGetMsg()
    
    
    
        For $a = 0 to 2
            $GuiCursor = GUIGetCursorInfo()
            If $GuiCursor[4] = Eval('Picture_' & $a) Then
                
            If $GuiCursor[4] = 4  Then
                    
                        GuiCtrlSetImage($Picture_0, $Blue)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 5 Then
                    
                        GuiCtrlSetImage($Picture_1, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 6 Then
                    
                        GuiCtrlSetImage($Picture_2, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        
                    EndIf
                
            EndIf
        Next
    
    
    
    Select
        
        

        Case $msg = $GUI_EVENT_SECONDARYDOWN
        $GuiCursor = GUIGetCursorInfo()
        
        ;Set the square blank on right click
        For $a = 3 to 6
            If $GuiCursor[4] = Eval('Picture_' & $a) Then
                GUICtrlSetImage($GuiCursor[4],$Blank)
            Else
            EndIf
        Next
        
    Case $msg = $Button_1
        $File1 = @ScriptDir & "\Images\blue.bmp"
    Case $msg = $Picture_3
        GUICtrlSetImage($Picture_3,$File1)
    Case $msg = $Picture_4
        GUICtrlSetImage($Picture_4,$File1)
    Case $msg = $Picture_5
        GUICtrlSetImage($Picture_5,$File1)
    Case $msg = $Picture_6
        GUICtrlSetImage($Picture_6,$File1)
        
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
        
    EndSelect
WEnd
Exit
oÝ÷ Ù¦¢÷­+)j»h~Ø^±Êâ¦Ûh±ç¡£az¸ ×%É0¢¹¢ºÞrÙrjëh×6
    
        For $a = 0 to 2
            $GuiCursor = GUIGetCursorInfo()
            If $GuiCursor[4] = Eval('Picture_' & $a) Then
                
            If $GuiCursor[4] = 4  Then
                    
                        GuiCtrlSetImage($Picture_0, $Blue)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 5 Then
                    
                        GuiCtrlSetImage($Picture_1, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_2, $Blank)
            
            ElseIf  $GuiCursor[4] = 6 Then
                    
                        GuiCtrlSetImage($Picture_2, $Blue)
                        GuiCtrlSetImage($Picture_0, $Blank)
                        GuiCtrlSetImage($Picture_1, $Blank)
                        
                    EndIf
                
            EndIf
        Next

As you can see, when there are 2 GuiGetCursorInfo, they are in conflict. In GuiGetCursorInfo ERROR.au3, it take 2-3 right clicks to delete (set blank) correctly the picture. However, when there are only 1 GuiGetCursorInfo, it take 1 right click to delete the picture. Anyone can help me solve this problem?

GuiGetCursor_Info_Error.rar

Edited by J0ker
Link to comment
Share on other sites

The file you uploaded doesnt work correctly on right click. It take 3-4 clicks to change the picture to red correctly.

I have the same problem in my script.

:shocked:

Edited by J0ker
Link to comment
Share on other sites

untested

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $Button_1
            $File1 = @ScriptDir & '\Images\blue.bmp'
        Case $Picture_3, $Picture_4, $Picture_5, $Picture_6
            GUICtrlSetImage( $msg, $File1)
    EndSwitch
    
    $GuiCursor = GUIGetCursorInfo()
    Switch $GuiCursor[4]
        Case $Picture_0, $Picture_1, $Picture_2
            GuiCtrlSetImage( $GuiCursor[4], $Blue)
            For $i = 0 To 2
                If Eval( 'Picture_' & $i) <> $GuiCursor[4] Then
                    GuiCtrlSetImage( Eval( 'Picture_' & $i), $Blank)
                EndIf
            Next
        Case $Picture_3, $Picture_4, $Picture_5, $Picture_6
            If $GuiCursor[3] Then
                GUICtrlSetImage( $GuiCursor[4], $Blank)
            EndIf
    EndSwitch
WEnd
Exit
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...