Jump to content



Photo

Dissappearing Graphic n Label on Move Tried Everything...........


  • Please log in to reply
4 replies to this topic

#1 PhoenixXL

PhoenixXL

    Be what you are, believe me its always the BEST...

  • Active Members
  • PipPipPipPipPipPip
  • 1,337 posts

Posted 20 May 2012 - 12:14 PM

Hey Every1...................
I made a Virtual Scroll Bar like Thing Using Buttons and Graphic(also with Labels ,Pictures, and Buttons)...........
The Problem is when i Drag the Graphic, Label ,Picture, or Button it Dissapers..........
I have Already Tried to set the BK_COLOR of label to Transparent .............
But No luck ,..............
Please Help Me Out................
Code..........::
AutoIt         
#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author:      Phoenix XL Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sgui=GUICreate('Testing........',500,400,100,100) Local $sBtn[2]=[GUICtrlCreateButton('UP',225,20,50,30),GUICtrlCreateButton('DOWN',225,350,50,30)] Local $sLabel=GUICtrlCreateGraphic(225,70,50,35) GuiCtrlSetState(-1,$GUI_ONTOP) GUICtrlSetBkColor(-1, 0x000000) GUIRegisterMsg($WM_COMMAND,'WM_COMMAND') GUISetState() Local $nMsg,$sPos While $nMsg<>-3 $nMsg=GUIGetMsg() $sPos=ControlGetPos($sgui,'',$sLabel) ConsoleWrite($sPos[1]+$sPos[3]&@CRLF) Switch $nMsg   Case $sBtn[0]    If $sPos[1]+$sPos[3]<=70+25 Then ContinueLoop    ControlMove($sgui,'',$sLabel,$sPos[0],$sPos[1]-1)   Case $sBtn[1]    If $sPos[1]+$sPos[3]>=345 Then ContinueLoop    ControlMove($sgui,'',$sLabel,$sPos[0],$sPos[1]+1) EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)     Local $nID = BitAND($wParam, 0xFFFF),$sMousePos     Switch BitShift($wParam, 16) ; message code   Case 0,1 ; $STN_CLICKED or Double    While 1     $sMousePos=GUIGetCursorInfo($sgui)     If Not $sMousePos[2] Then ExitLoop     If $sMousePos[1]<=345-35 And $sMousePos[1]>=70-10 Then      ControlMove($sgui,'',$sLabel,225,$sMousePos[1])     EndIf    WEnd     EndSwitch     Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _MakeLong($LoWord,$HiWord)   Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc

PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. | Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. | MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead.







#2 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 20 May 2012 - 04:00 PM

You do long lasting blocking code in WM_COMMAND.
This is main source of odd behaviour.

Here is fixed version, blocking code moved from WM_COMMAND to main message loop.

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sgui = GUICreate('Testing........', 500, 400, 100, 100) Local $sBtn[2] = [GUICtrlCreateButton('UP', 225, 20, 50, 30), GUICtrlCreateButton('DOWN', 225, 350, 50, 30)] ;~ Local $sLabel = GUICtrlCreateGraphic(225, 70, 50, 35) Local $sLabel = GUICtrlCreateLabel('', 225, 70, 50, 35) GUICtrlSetState(-1, $GUI_ONTOP) GUICtrlSetBkColor(-1, 0x000000) GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState() Global $drag = False Local $nMsg, $sPos While $nMsg <> -3     $nMsg = GUIGetMsg()     $sPos = ControlGetPos($sgui, '', $sLabel) ;~   ConsoleWrite($sPos[1] + $sPos[3] & @CRLF)     Switch $nMsg         Case $sBtn[0]             If $sPos[1] + $sPos[3] <= 70 + 25 Then ContinueLoop             ControlMove($sgui, '', $sLabel, $sPos[0], $sPos[1] - 1)         Case $sBtn[1]             If $sPos[1] + $sPos[3] >= 345 Then ContinueLoop             ControlMove($sgui, '', $sLabel, $sPos[0], $sPos[1] + 1)     EndSwitch         If $drag Then         While 1             $sMousePos = GUIGetCursorInfo($sgui)             If Not $sMousePos[2] Then ExitLoop             If $sMousePos[1] <= 345 - 35 And $sMousePos[1] >= 70 - 10 Then                 ControlMove($sgui, '', $sLabel, 225, $sMousePos[1])             EndIf         WEnd         $drag = False     EndIf WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)     Local $nID = BitAND($wParam, 0xFFFF), $sMousePos     Switch BitShift($wParam, 16) ; message code         Case 0, 1 ; $STN_CLICKED or Double             $drag = True     EndSwitch     Return $GUI_RUNDEFMSG EndFunc   ;==>WM_COMMAND Func _MakeLong($LoWord, $HiWord)     Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF)) EndFunc   ;==>_MakeLong


But as you can see some problems remains.
I think it's because Graphic control is very nonstandard AutoIt's control so its usage is limited.
I recommend to use Picture control instead. You can use GDI or GDI+ API functions to paint whatever you want on that pictur control if needed.

EDIT: using label instead of graphic fixed it

Edited by Zedna, 20 May 2012 - 04:30 PM.


#3 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 20 May 2012 - 04:49 PM

Here is the link to useful info on WIKI
http://www.autoitscript.com/wiki/GUIRegisterMsg

#4 JScript

JScript

    Goodbye everybody, I got tired of this system adopted here!

  • Active Members
  • PipPipPipPipPipPip
  • 1,062 posts

Posted 20 May 2012 - 08:07 PM

And why not use that way?
AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $sgui = GUICreate('Testing........', 500, 400, 100, 100) Local $sBtn[2] = [GUICtrlCreateButton('UP', 225, 20, 50, 30), GUICtrlCreateButton('DOWN', 225, 350, 50, 30)] Local $sLabel = GUICtrlCreateGraphic(225, 70, 50, 35) GUICtrlSetState(-1, $GUI_ONTOP) GUICtrlSetBkColor(-1, 0x000000) GUISetState() Global $drag = True Local $nMsg, $sPos While $nMsg <> -3     $nMsg = GUIGetMsg()     Switch $nMsg         Case $sBtn[0]             $sPos = ControlGetPos($sgui, '', $sLabel)             If $sPos[1] + $sPos[3] <= 70 + 25 Then ContinueLoop             ControlMove($sgui, '', $sLabel, $sPos[0], $sPos[1] - 10)         Case $sBtn[1]             $sPos = ControlGetPos($sgui, '', $sLabel)             If $sPos[1] + $sPos[3] >= 345 Then ContinueLoop             ControlMove($sgui, '', $sLabel, $sPos[0], $sPos[1] + 10)         Case $sLabel             $sPos = ControlGetPos($sgui, '', $sLabel)             While 1                 $sMousePos = GUIGetCursorInfo($sgui)                 If Not $sMousePos[2] Then ExitLoop                 If $sMousePos[1] <= 345 - 35 And $sMousePos[1] >= 70 - 10 Then                     ControlMove($sgui, '', $sLabel, 225, $sMousePos[1])                 EndIf             WEnd     EndSwitch WEnd

Regards,

João Carlos.

Edited by JScript, 20 May 2012 - 08:13 PM.

http://notebook.forumais.com (Forum Maintenance Notebooks and Desktop)http://autoitbrasil.com/ (AutoIt v3 Brazil!!!)
Spoiler

Posted Image Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere!       


#5 PhoenixXL

PhoenixXL

    Be what you are, believe me its always the BEST...

  • Active Members
  • PipPipPipPipPipPip
  • 1,337 posts

Posted 21 May 2012 - 02:52 AM

Thanx JScript and Zedna.................
Both The Methods Work Flawlessly ;)
PredictText: Predict Text of an Edit Control Like Scite. | Remote Gmail: Execute your Scripts through Gmail. | StringRegExp: Share and learn RegExp. | Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). | Database: An easier approach for _SQ_LITE beginners. | MathsEx: A UDF for Fractions and LCM, GCF/HCF. | FloatingText: An UDF for make your text floating. | Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users