Jump to content

Prevent a control from being redrawed


Kip
 Share

Recommended Posts

Hi,

I want to stop a control being redrawed. It works pretty well actually, using:

_SendMessage($hButton, $WM_SETREDRAW, False, 0)

But then, when I want to start drawing again using:

_SendMessage($hButton, $WM_SETREDRAW, True, 0)
it doesn't redraw.

I tried several combinations with _WinAPI_RedrawWindow($hButton) and _WinAPI_InvalidateRect($hButton)

but none of them work.

Thnx, Kip ;)

Edited by Kip
Link to comment
Share on other sites

Bump ;)

Can you give some sample code for us to play with?
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.
Link to comment
Share on other sites

  • 3 weeks later...

Nevermind, I already got it working.

How? Please post your resolution of the first issue, as others may find this topic in search for the same answer.

Btw: Does anyone know how to get messages from a control that isn't being painted.

Because when I stop redrawing, lets say, a button, it doesnt notify me anymore when it is pressed.

Messages? Have you tried it in event mode?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

How? Please post your resolution of the first issue, as others may find this topic in search for the same answer.

By calling _SendMessage($hButton, $WM_SETREDRAW, False, 0) outside the notification.

#Include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>

$Draw = 0

$GUI = GUICreate("Buttons", 500, 400)
    
    $iButton = GUICtrlCreateButton("Frozen",100,100,120,23)
    $hButton = GUICtrlGetHandle($iButton)
    
    GUIRegisterMsg($WM_PAINT, "Paint")
    
GUISetState()


While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
            
        Case $iButton
            
            MsgBox(0,"sdsds","sdsds")
            
    EndSwitch
    
    If $Draw = 1 Then
        
        _SendMessage($hButton,$WM_SETREDRAW,False,0); Wont be redrawed. It's 'Frozen'
        
        $Draw = 0
    EndIf
    
WEnd


Func Paint($hWnd, $iMsg, $wParam, $lParam)
    
    If $hWnd = $GUI Then
        
        _SendMessage($hButton,$WM_SETREDRAW,True,0)
        
        _WinAPI_RedrawWindow($GUI)
        
        $Draw = 1
        
    EndIf
    
EndFunc
Link to comment
Share on other sites

By calling _SendMessage($hButton, $WM_SETREDRAW, False, 0) outside the notification.

Thanks for posting the resolution. >_<

On having the control still work while not being redrawn, did you try GuiOnEventMode?

:)

Edit: Nope, not in EventMode either. (I couldn't figure out what the point of registering $WM_PAINT was, so I took it out.)

#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>

Opt("GuiOnEventMode", 1)

$Draw = True
$n = 0

$GUI = GUICreate("Buttons", 500, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")

$iButton_1 = GUICtrlCreateButton("UnFrozen: " & $n, 100, 100, 200, 23)
$hButton_1 = GUICtrlGetHandle(-1)
GUICtrlSetOnEvent(-1, "_ButtonHit")

$iButton_2 = GUICtrlCreateButton("Freeze", 100, 200, 200, 23)
GUICtrlSetOnEvent(-1, "_ButtonHit")

GUISetState()

AdlibEnable("_IncrementN", 2000)

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc  ;==>_Quit

Func _ButtonHit()
    Switch @GUI_CtrlId
        Case $iButton_1
            MsgBox(0, "Button", "$n = " & $n)
        Case $iButton_2
            $Draw = Not $Draw
            If $Draw Then
                GUICtrlSetData($iButton_2, "Freeze")
                _SendMessage($hButton_1, $WM_SETREDRAW, True, 0); Will be redrawn. It's 'UnFrozen'
            Else
                GUICtrlSetData($iButton_2, "UnFreeze")
                GUICtrlSetData($iButton_1, "Frozen")
                _SendMessage($hButton_1, $WM_SETREDRAW, False, 0); Wont be redrawn. It's 'Frozen'
            EndIf
    EndSwitch
EndFunc  ;==>_ButtonHit

Func _IncrementN()
    $n += 1
    GUICtrlSetData($iButton_1, "UnFrozen: " & $n)
EndFunc  ;==>_IncrementN
Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...