IPAddressGadget()/DateGadget() Back Color

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
akee
Enthusiast
Enthusiast
Posts: 478
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

IPAddressGadget()/DateGadget() Back Color

Post by akee »

Does not change. :(

Code: Select all

OpenWindow(0, 10, 10, 600, 400, "IP Gadget Background")
StringGadget(0, 10, 10, 160, 25, "String")
  SetGadgetColor(0, #PB_Gadget_BackColor, #Blue)

IPAddressGadget(1, 10, 40, 160, 25)
  SetGadgetColor(1, #PB_Gadget_BackColor, #Blue)    ; Does not change to blue.

DateGadget(2, 10, 70, 160, 25)
  SetGadgetColor(2, #PB_Gadget_BackColor, #Red)    ; Does not change to red.

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Last edited by akee on Sun Nov 18, 2012 7:41 pm, edited 2 times in total.
infratec
Always Here
Always Here
Posts: 6874
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: IPAddressGadget() Back Color

Post by infratec »

Hi,

no bug :!:

It's a feature request.

Because in the help of SetGadgetColor() IPAdressGadget() is not listed.

Bernd
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: IPAddressGadget() Back Color

Post by Dude »

+1 for this request. If any Windows API experts know a way in meantime, feel free to drop me a hint. :)
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: IPAddressGadget()/DateGadget() Back Color

Post by chi »

IPAddressGadget hint :wink:

Code: Select all

Global oldIpProc

Procedure ipCallback(hWnd, Msg, wParam, lParam)
  Select Msg
      
    Case #WM_PAINT
      DefWindowProc_(hWnd, Msg, wParam, lParam)
      hdc = GetDC_(hWnd)
      SetBkMode_(hdc, #TRANSPARENT)
      SelectObject_(hdc, GetStockObject_(#DEFAULT_GUI_FONT))
      TextOut_(hdc, 30, 3, "-", 1)
      TextOut_(hdc, 62, 3, "-", 1)
      TextOut_(hdc, 94, 3, "-", 1)
      TextOut_(hdc, 30, 3, "-", 1)
      ReleaseDC_(hWnd, hdc)
      ProcedureReturn 0
      
    Case #WM_CTLCOLOREDIT
      SetBkMode_(wParam, #TRANSPARENT)
      SetTextColor_(wParam, #Red)
      ProcedureReturn GetStockObject_(#DKGRAY_BRUSH)
      
    Case #WM_NCDESTROY
      SetWindowLongPtr_(hWnd, #GWL_WNDPROC, oldIpProc)
      ProcedureReturn 0
      
  EndSelect
  ProcedureReturn CallWindowProc_(oldIpProc, hWnd, Msg, wParam, lParam)
EndProcedure

OpenWindow(0, 0, 0, 147, 40, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
SetClassLongPtr_(WindowID(0), #GCL_HBRBACKGROUND, GetStockObject_(#DKGRAY_BRUSH))

IPAddressGadget(0, 10, 10, 127, 19)
SetGadgetState(0, MakeIPAddress(127, 0, 0, 1))

; reposition edit controls
Edit4 = GetWindow_(GadgetID(0), #GW_CHILD)
Edit3 = GetWindow_(Edit4, #GW_HWNDNEXT)
Edit2 = GetWindow_(Edit3, #GW_HWNDNEXT)
Edit1 = GetWindow_(Edit2, #GW_HWNDNEXT)
SetWindowPos_(Edit1, 0, 3, 3, 25, 13, #SWP_NOZORDER)
SetWindowPos_(Edit2, 0, 35, 3, 25, 13, #SWP_NOZORDER)
SetWindowPos_(Edit3, 0, 67, 3, 25, 13, #SWP_NOZORDER)
SetWindowPos_(Edit4, 0, 99, 3, 25, 13, #SWP_NOZORDER)

; set background brush
SetClassLongPtr_(GadgetID(0), #GCL_HBRBACKGROUND, GetStockObject_(#LTGRAY_BRUSH))

; remove border
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE)&~#WS_EX_CLIENTEDGE)
SetWindowPos_(GadgetID(0), 0, 0, 0, 0, 0, #SWP_NOSIZE|#SWP_NOMOVE|#SWP_NOZORDER|#SWP_FRAMECHANGED)

; set callback
oldIpProc = SetWindowLongPtr_(GadgetID(0), #GWL_WNDPROC, @ipCallback())

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend

Et cetera is my worst enemy
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: IPAddressGadget()/DateGadget() Back Color

Post by Dude »

Thanks Chi, and for your other post where you helped me today. ;)
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: IPAddressGadget()/DateGadget() Back Color

Post by RSBasic »

Nice code
Image
Image
Post Reply