CodyBarrett Posted May 2, 2009 Share Posted May 2, 2009 iive looked through 18 pages on this subject.. i know ive seen it before in on script on here or another but can't remember where... i would like to know how IF the mouse position is over top of a label then put a border around the label and when it leaves the controls possition it resests it to what it was before here is an example of a GUI and label.. anyone know how to do this? i prefer to use labels over buttons but i want it to look like a button.. labels i find are more customizable #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Misc.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Opt ('GUIoneventmode',1) $GUI = GUICreate ( 'Example', 300, 300, -1, -1, -2138570616) $Label = GUICtrlCreateLabel ('TEST', 50, 50, 200, 200, $SS_CENTER) GUICtrlSetColor (-1, 0xFFFFFF) GUICtrlSetFont (-1, 50, 900) GUICtrlSetBkColor (-1, 0x2e2e2e) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit') GUISetState() While 1 WEnd Func _exit () Exit EndFunc [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Authenticity Posted May 2, 2009 Share Posted May 2, 2009 Maybe something like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Misc.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Opt ('GUIoneventmode',1) $pt = DllStructCreate($tagPOINT) $fSet = False $GUI = GUICreate ( 'Example', 300, 300, -1, -1, -2138570616) $Label = GUICtrlCreateLabel ('TEST', 50, 50, 200, 200, $SS_CENTER) $hLabel = GUICtrlGetHandle(-1) GUICtrlSetColor (-1, 0xFFFFFF) GUICtrlSetFont (-1, 50, 900) GUICtrlSetBkColor (-1, 0x2e2e2e) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit') GUISetState() While 1 $aPos = MouseGetPos() DllStructSetData($pt, 1, $aPos[0]) DllStructSetData($pt, 2, $aPos[1]) $hWnd = _WinAPI_WindowFromPoint($pt) If $hWnd = $hLabel Then If Not $fSet Then GUICtrlSetBkColor($Label, 0xe2e2e2) GUICtrlSetColor ($Label, 0) $fSet = True EndIf Else If $fSet Then GUICtrlSetBkColor($Label, 0x2e2e2e) GUICtrlSetColor ($Label, 0xFFFFFF) $fSet = False EndIf EndIf Sleep(50) WEnd Func _exit () GUIDelete() Exit EndFunc Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 well.. that makes the color change... what im looking for is having a black label... with a white border around it.. i can do that.. but it erases my text when it happens andy other ideas TY anyway Authenticity [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Authenticity Posted May 2, 2009 Share Posted May 2, 2009 Using GDIPlus.au3: expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Misc.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Opt ('GUIoneventmode',1) _GDIPlus_Startup() $pt = DllStructCreate($tagPOINT) $fSet = False $GUI = GUICreate ( 'Example', 300, 300, -1, -1, -2138570616) $Label = GUICtrlCreateLabel ('TEST', 50, 50, 200, 200, $SS_CENTER) $hLabel = GUICtrlGetHandle(-1) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hLabel) $hPen = _GDIPlus_PenCreate(0, 10) GUICtrlSetColor (-1, 0xFFFFFF) GUICtrlSetFont (-1, 50, 900) GUICtrlSetBkColor (-1, 0x2e2e2e) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit') GUISetState() While 1 $aPos = MouseGetPos() DllStructSetData($pt, 1, $aPos[0]) DllStructSetData($pt, 2, $aPos[1]) $hWnd = _WinAPI_WindowFromPoint($pt) If $hWnd = $hLabel Then If Not $fSet Then _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) $fSet = True EndIf Else If $fSet Then _GDIPlus_PenSetColor($hPen, 0xFF2E2E2E) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) $fSet = False EndIf EndIf Sleep(50) WEnd Func _exit () GUIDelete() _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 2, 2009 Moderators Share Posted May 2, 2009 CodyBarrett, Is this any help?:expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0x8080FF, $hGUI) $hlabel_2 = GUICtrlCreateLabel("Test", 15, 15, 90, 90) GUICtrlSetBkColor(-1, 0xFF8080) GUISetState() $fFlag = False While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[4] = $hLabel_2 And $fFlag = False Then $sContent = GUICtrlRead($hLabel_2) GUICtrlDelete($hlabel_2) $hlabel_1 = GUICtrlCreateLabel("", 10, 10, 100, 100) GUICtrlSetBkColor(-1, 0xFFFFFF) $hLabel_2 = GUICtrlCreateLabel($sContent, 15, 15, 90, 90) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0xFFFFFF) $fFlag = True ElseIf $aInfo[4] <> $hLabel_2 And $fFlag = True Then $sContent = GUICtrlRead($hLabel_2) GUICtrlDelete($hlabel_1) GUICtrlDelete($hlabel_2) $hLabel_2 = GUICtrlCreateLabel($sContent, 15, 15, 90, 90) GUICtrlSetBkColor(-1, 0xFF8080) GUICtrlSetColor(-1, 0x000000) $fFlag = False EndIf WEnd M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 (edited) sorry Authenticity im not ready for GDI+ yet and THANK YOU Melba23 that was exactly what i was looking for lmao EDIT and yet.. haha isn't there an easyer way other than deleteing the controls... Edited May 2, 2009 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Authenticity Posted May 2, 2009 Share Posted May 2, 2009 lol ;] expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Misc.au3> #include <ButtonConstants.au3> #include <StaticConstants.au3> Opt ('GUIoneventmode',1) _GDIPlus_Startup() $pt = DllStructCreate($tagPOINT) $fSet = False $fFlash = True $GUI = GUICreate ( 'Example', 300, 300, -1, -1, -2138570616) $Label = GUICtrlCreateLabel ('TEST', 50, 50, 200, 200, $SS_CENTER) $hLabel = GUICtrlGetHandle(-1) $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hLabel) $hPen = _GDIPlus_PenCreate(0, 10) GUICtrlSetColor (-1, 0xFFFFFF) GUICtrlSetFont (-1, 50, 900) GUICtrlSetBkColor (-1, 0x2e2e2e) GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit') GUISetState() While 1 $aPos = GUIGetCursorInfo() $Ctrl = $aPos[4] If $Ctrl = $Label Then If Not $fSet Then _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) AdlibEnable('_FlashWindow', 500) $fSet = True EndIf Else If $fSet Then AdlibDisable() _GDIPlus_PenSetColor($hPen, 0xFF2E2E2E) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) $fSet = False EndIf EndIf Sleep(50) WEnd Func _exit () GUIDelete() _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() Exit EndFunc Func _FlashWindow() $fFlash = Not $fFlash If $fFlash Then _GDIPlus_PenSetColor($hPen, 0xFFFFFFFF) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) Else _GDIPlus_PenSetColor($hPen, 0xFF2E2E2E) _GDIPlus_GraphicsDrawRect($hGraphics, 0, 0, 200, 200, $hPen) EndIf EndFunc Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 ugh.... D: GDI+!!!!! nuuuuu lol ill look through it thanks anyway haha [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 2, 2009 Moderators Share Posted May 2, 2009 CodyBarrett, Look - no deletes! :-)#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0x8080FF, $hGUI) $hlabel_1 = GUICtrlCreateLabel("", 10, 10, 100, 100) GUICtrlSetBkColor(-1, 0x8080FF) $hlabel_2 = GUICtrlCreateLabel("Test", 15, 15, 90, 90) GUICtrlSetBkColor(-1, 0xFF8080) GUISetState() $fFlag = False While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[4] = $hLabel_2 And $fFlag = False Then GUICtrlSetBkColor($hlabel_1, 0xFFFFFF) GUICtrlSetBkColor($hlabel_2, 0x000000) GUICtrlSetColor($hlabel_2, 0xFFFFFF) $fFlag = True ElseIf $aInfo[4] <> $hLabel_2 And $fFlag = True Then GUICtrlSetBkColor($hlabel_1, 0x8080FF) GUICtrlSetBkColor($hlabel_2, 0xFF8080) GUICtrlSetColor($hlabel_2, 0xFFFFFF) $fFlag = False EndIf WEnd M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 haha i figured that out 5 mins before you posted this.. BUT! i have another problem.. using this in a For loop... inside a while loop... make a flicker because i have an array of labels and thats why i didn't want to delete them... but this array is causseing a flicker... a CONSTANT flicker [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted May 2, 2009 Share Posted May 2, 2009 Hmmmm. This is interesting and I'm not sure if it's expected behaviour or a bug. I thought you could do what you wanted using Styles however if you set the styles as below the text doesn't display. #include<StaticConstants.au3> GUICreate("Test GUI") $hLabel = GUICtrlCreateLabel("TEST LABEL", 10, 10, 150, 20) $hLabel1 = GUICtrlCreateLabel("TEST LABEL White", 10, 40, 150, 20, BitOr($GUI_SS_DEFAULT_LABEL,$SS_WHITEFRAME)) $hLabel2 = GUICtrlCreateLabel("TEST LABEL Black", 10, 80, 150, 20, BitOr($GUI_SS_DEFAULT_LABEL,$SS_BLACKFRAME)) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit Wend George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 yeah... thats why i made this topic D':... it doesn't even allow you to set the text after you change the style... [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted May 2, 2009 Share Posted May 2, 2009 yeah... thats why i made this topic D':... it doesn't even allow you to set the text after you change the style...And I just checked it with the MS control tool and it does the same thing so I can assume it's normal behavior which seems somewhat stupid. Maybe it just doesn't work with the XP theme? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
martin Posted May 2, 2009 Share Posted May 2, 2009 ..and if you have lots of labels you only need one label fo rthe border. expandcollapse popup#include <GUIConstantsEx.au3> #include <windowsconstants.au3> #include <staticconstants.au3> $hGUI = GUICreate("Test", 500, 520) GUISetBkColor(0x8080FF, $hGUI) Global $hlabel[5],$lastlabel For $n = 0 To 4 $hlabel[$n] = GUICtrlCreateLabel("Test " & $n + 1, 15, 15 + 100 * $n, 90, 90) GUICtrlSetBkColor(-1, 0xFF8080) Next $hlabelBorder = GUICtrlCreateLabel("", 10, 10, 100, 100, BitOR($GUI_SS_DEFAULT_LABEL, $WS_CLIPSIBLINGS)) GUICtrlSetBkColor(-1, 0xFFFFFF);8080FF) GUICtrlSetState(-1, $GUI_HIDE) GUISetState() $fFlag = False $LastLabel = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch $aInfo = GUIGetCursorInfo($hGUI) If Not @error Then If $aInfo[4] <> $LastLabel Then Switch $aInfo[4] Case $hlabel[0] To $hlabel[4] If $LastLabel <> 0 Then GUICtrlSetBkColor($LastLabel, 0xFF8080) GUICtrlSetColor($LastLabel, 0) EndIf GUICtrlSetColor($aInfo[4], 0xFFFFFF) GUICtrlSetBkColor($aInfo[4], 0) $lp = ControlGetPos($hGUI, "", $aInfo[4]) ControlMove($hGUI, "", $hlabelBorder, $lp[0] - 5, $lp[1] - 5) GUICtrlSetState($hlabelBorder, $GUI_SHOW) $LastLabel = $aInfo[4] Case $hlabelBorder ;ConsoleWrite("border" & @CRLF) Case Else If $LastLabel <> 0 Then HideBorder() EndSwitch EndIf Else If $LastLabel <> 0 Then HideBorder() EndIf WEnd Func HideBorder() GUICtrlSetBkColor($LastLabel, 0xFF8080) GUICtrlSetColor($LastLabel, 0) GUICtrlSetState($hlabelBorder, $GUI_HIDE) $LastLabel = 0 EndFunc ;==>HideBorder 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 More sharing options...
CodyBarrett Posted May 2, 2009 Author Share Posted May 2, 2009 holy... thank you martin that works now [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now