PureBoard https://www.purebasic.fr/german/ |
|
Lieber Weihnachtsmann: GetWindowColor + GetGadgetColor https://www.purebasic.fr/german/viewtopic.php?f=2&t=31778 |
Seite 1 von 1 |
Autor: | hjbremer [ 18.12.2019 15:52 ] |
Betreff des Beitrags: | Lieber Weihnachtsmann: GetWindowColor + GetGadgetColor |
Lieber Weihnachtsmann: Ich wünsche mir das GetWindowColor + GetGadgetColor endlich auch ohne einen SetColor Befehl die richtigen Farbwerte zurück geben. Und nicht -1 Auch StartDrawing() ist unzuverlässig, siehe auf Button drücken Code: OpenWindow(0, 0, 0, 322, 200, "Lieber Weihnachtsmann", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(1, 8, 8, 150, 180, #PB_Container_Flat) CloseGadgetList() PanelGadget(2, 165, 8, 150, 180) AddGadgetItem (2, -1, "Panel 1") ButtonGadget(3, 20, 50, 80, 30, "drücken") AddGadgetItem (2, -1, "Panel 2") CloseGadgetList() Debug "Background-Farben ohne SetColor" Debug GetWindowColor(0) Debug Hex(GetWindowColor(0)) Debug GetGadgetColor(1, #PB_Gadget_BackColor) Debug Hex(GetGadgetColor(1, #PB_Gadget_BackColor)) Debug GetGadgetColor(2, #PB_Gadget_BackColor) Debug Hex(GetGadgetColor(2, #PB_Gadget_BackColor)) Debug "" Debug "Background-Farbe mit StartDrawing()" StartDrawing(WindowOutput(0)) Debug Hex(Point(1,1)) StopDrawing() Repeat : Event = WaitWindowEvent() Select Event Case #PB_Event_Gadget Select EventGadget() Case 3 SetWindowColor(0, #Green) SetGadgetColor(1, #PB_Gadget_BackColor, #Blue) Debug "" Debug "Background-Farben nach SetColor" Debug GetWindowColor(0) Debug Hex(GetWindowColor(0)) Debug GetGadgetColor(1, #PB_Gadget_BackColor) Debug Hex(GetGadgetColor(1, #PB_Gadget_BackColor)) StartDrawing(WindowOutput(0)) Debug Hex(Point(1,1)) + " <--- Buh" StopDrawing() EndSelect EndSelect Until Event = #PB_Event_CloseWindow |
Autor: | ccode_new [ 18.12.2019 19:53 ] |
Betreff des Beitrags: | Re: Lieber Weihnachtsmann: GetWindowColor + GetGadgetColor |
TADA! Code: Procedure.s GUICtrlGetBkColor(win.i, gad.i)
Protected.i hwnd, hdc, icolor Protected.s scolor If IsGadget(gad) UpdateWindow_(WindowID(win)) StartDrawing(WindowOutput(win)) icolor = Point(GadgetX(gad)+1, GadgetY(gad)+1) StopDrawing() Red = Red(iColor) Green = Green(iColor) Blue = Blue(iColor) scolor = RSet(Hex(Red), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Blue), 2, "0") ProcedureReturn sColor Else ProcedureReturn "Error" EndIf EndProcedure Procedure.s GUIGetBkColor(win.i) Protected.i hwnd, hdc, icolor Protected.s scolor If IsWindow(win) UpdateWindow_(WindowID(win)) hwnd = WindowID(win) hdc = GetDC_(hwnd) iColor = GetPixel_(hdc, 0, 0) ReleaseDC_(hwnd, hdc) Red = Red(iColor) Green = Green(iColor) Blue = Blue(iColor) scolor = RSet(Hex(Red), 2, "0") + RSet(Hex(Green), 2, "0") + RSet(Hex(Blue), 2, "0") ProcedureReturn sColor Else ProcedureReturn "Error" EndIf EndProcedure Procedure KnopfGedrueckt() SetWindowColor(0, #Green) SetGadgetColor(1, #PB_Gadget_BackColor, #Blue) ; Debug "" ; Debug "Background-Farben nach SetColor" ; Debug GetWindowColor(0) ; Debug Hex(GetWindowColor(0)) ; Debug GetGadgetColor(1, #PB_Gadget_BackColor) ; Debug Hex(GetGadgetColor(1, #PB_Gadget_BackColor)) ; ; ; StartDrawing(WindowOutput(0)) ; ; Debug Hex(Point(1,1)) ; ; StopDrawing() ; Debug GUIGetBkColor(0) Debug GUICtrlGetBkColor(0, 1) EndProcedure OpenWindow(0, 0, 0, 322, 200, "Lieber Weihnachtsmann", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) ContainerGadget(1, 8, 8, 150, 180, #PB_Container_Flat) CloseGadgetList() PanelGadget(2, 165, 8, 150, 180) AddGadgetItem (2, -1, "Panel 1") ButtonGadget(3, 20, 50, 80, 30, "drücken") AddGadgetItem (2, -1, "Panel 2") CloseGadgetList() ; Debug "" ; Debug "Background-Farbe mit StartDrawing()" ; ; Debug "Background-Farben ohne SetColor" ; Debug GetWindowColor(0) ; ; Debug Hex(GetWindowColor(0)) ; ; Debug GetGadgetColor(1, #PB_Gadget_BackColor) ; Debug Hex(GetGadgetColor(1, #PB_Gadget_BackColor)) ; ; Debug GetGadgetColor(2, #PB_Gadget_BackColor) ; Debug Hex(GetGadgetColor(2, #PB_Gadget_BackColor)) ; ; ; StartDrawing(WindowOutput(0)) ; ; Debug Hex(Point(1,1)) ; ; StopDrawing() Debug GUIGetBkColor(0) Debug GUICtrlGetBkColor(0, 1) BindGadgetEvent(3, @KnopfGedrueckt()) Repeat : Event = WindowEvent() Until Event = #PB_Event_CloseWindow |
Seite 1 von 1 | Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |