What is wrong? I don't get it!
Posted: Mon Dec 10, 2007 9:50 am
Hi All,
I'm experimenting with bits of code from here and there. So I put this code together expecting to see all the info in the designated string gadgets yet the first string gadget seem to be updated and everything else appart form the box is not been refreshed. Any Idea why. Have i missed something?
Yes I'm new to purebasic, but love it!
I'm experimenting with bits of code from here and there. So I put this code together expecting to see all the info in the designated string gadgets yet the first string gadget seem to be updated and everything else appart form the box is not been refreshed. Any Idea why. Have i missed something?
Yes I'm new to purebasic, but love it!
Code: Select all
;{ Windows
Enumeration
#Window_0
EndEnumeration
;}
;{ Gadgets
Enumeration
#String_0
#String_1
#String_2
#String_3
#String_4
#Frame3D_5
#Button_6
EndEnumeration
;}
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
;}
WindowDC.l = GetWindowDC_(#Null)
Global CPosX=2
Global CPosY=2
Global Width=80
Global Height=95
Procedure UpdateColor(Colour.l)
RedComponent.l = Red(Colour)
GreenComponent.l = Green(Colour)
BlueComponent.l = Blue(Colour)
;SetGadgetColor(#Frame3D_5,#PB_Gadget_BackColor,RGB(RedComponent,GreenComponent,BlueComponent))
Box(CPosX+3,CPosY+3,Width-6,Height-6,RGB(RedComponent,GreenComponent,BlueComponent))
EndProcedure
Procedure OpenWindow_Window_0()
GPosX=85
GposY=2
GWidth=180
GHeight=20
Gspace=25
If OpenWindow(#Window_0, 450, 197, 268, 170, "Pick Color", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
If CreateGadgetList(WindowID(#Window_0))
;StringGadget(#String_0, 1,1,290,20,"", #PB_String_ReadOnly);MOUSE COORDS
StringGadget(#String_1, GPosX, GposY, GWidth, GHeight, "", #PB_String_ReadOnly);Mouse Coords
StringGadget(#String_2, GPosX, GposY+Gspace, GWidth, GHeight, "", #PB_String_ReadOnly);RGB
StringGadget(#String_3, GPosX,GposY+Gspace*2, GWidth, GHeight, "", #PB_String_ReadOnly);hex
StringGadget(#String_4, GPosX, GposY+Gspace*3, GWidth, GHeight,"", #PB_String_ReadOnly);Window handle under mouse
Frame3DGadget(#Frame3D_5,CPosX , CPosY, Width, Height , "", #PB_Frame3D_Double)
ButtonGadget(#Button_6, 89, 120, 85, 40, "Close")
EndIf
EndIf
EndProcedure
OpenWindow_Window_0()
Repeat
GetCursorPos_(Coords.POINT) ;get x/y position of mouse into point structure
wDC = WindowFromPoint_ (Coords\x, Coords\y) ;get the windows handle under the mouse
Colour = GetPixel_(WindowDC, Coords\x, Coords\y) ; get the colour of pixel under the mouse
RedC.l = Red(Colour)
GreenC.l = Green(Colour)
BlueC.l = Blue(Colour)
PixelColour.s = "R:"+Str(RedC)+" G:"+Str(GreenC)+" B:"+Str(BlueC)
PixelColourHex.s = "$"+Hex(RedC)+Hex(GreenC)+Hex(BlueC)
MousePosition.s = "PosX: "+Str(Coords\x)+" PosY: "+Str(Coords\y)
WindowsHandle.s = "wH: "+Str(wDC)+" Hex$"+Hex(wDC)
SetGadgetText(#String_1,MousePosition )
SetGadgetText(#String_2,PixelColour)
SetGadgetText(#String_3,PixelColourHex)
SetGadgetText(#String_4,WindowsHandle)
If StartDrawing(WindowOutput(#Window_0))
UpdateColor(Colour)
StopDrawing()
EndIf
Event = WaitWindowEvent()
Select Event
; ///////////////////
Case #PB_Event_Gadget
EventGadget = EventGadget()
EventType = EventType()
If EventGadget = #String_0
ElseIf EventGadget = #String_2
ElseIf EventGadget = #String_3
ElseIf EventGadget = #String_4
ElseIf EventGadget = #Frame3D_5
ElseIf EventGadget = #Button_6
End
EndIf
; ////////////////////////
Case #PB_Event_CloseWindow
EventWindow = EventWindow()
If EventWindow = #Window_0
CloseWindow(#Window_0)
Break
EndIf
EndSelect
Delay(1)
ForEver
;
;}