String Gadget Background Transparent?
Posted: Sun Dec 02, 2007 10:45 pm
How can i do this?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
;===============================================================
; Program: A bunch of dirty hacks
; Author: netmaestro
; Date: December 2, 2007
; Target OS: Microsoft Windows all
; Target compiler: PureBasic 4.xx and later
; License: Free, unrestricted, use at your own risk
;===============================================================
Global stringpattern.l, bkswitch.l = 0
CreateImage(0,320,240,32)
StartDrawing(ImageOutput(0))
For i=0 To 231 Step 16
For j = 0 To 311 Step 16
Box(j,i,8,8,RGB(230,230,255))
Box(j+8,i,8,8,#White)
Box(j,i+8,8,8,#White)
Box(j+8,i+8,8,8,RGB(230,230,255))
Next
Next
StopDrawing()
Procedure WinProc(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLOREDIT
hdc = wParam
SetTextColor_(hdc, #Black)
SetBkMode_(hdc, #TRANSPARENT)
result = stringpattern
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ImageGadget(0,0,0,0,0,ImageID(0))
DisableGadget(0, #True)
StringGadget(1,10,10,200,20,"hello")
GrabImage(0, 1, GadgetX(1)+2,GadgetY(1)+2, GadgetWidth(1)-2,GadgetHeight(1)-2)
stringpattern = CreatePatternBrush_(ImageID(1))
SetWindowCallback(@WinProc())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
DeleteObject_(stringpattern)
Code: Select all
;===============================================================
; Program: A bunch of dirty hacks
; Author: netmaestro
; Date: December 2, 2007
; Target OS: Microsoft Windows all
; Target compiler: PureBasic 4.xx and later
; License: Free, unrestricted, use at your own risk
;===============================================================
CreateImage(0,320,240,32)
StartDrawing(ImageOutput(0))
For i=0 To 231 Step 16
For j = 0 To 311 Step 16
Box(j,i,8,8,RGB(230,230,255))
Box(j+8,i,8,8,#White)
Box(j,i+8,8,8,#White)
Box(j+8,i+8,8,8,RGB(230,230,255))
Next
Next
StopDrawing()
Procedure StringProc(hwnd, msg, wparam, lparam)
oldproc = GetProp_(hwnd, "oldproc")
Select msg
Case #WM_KEYDOWN
; Select wparam
; Case 8, 32
hdc = GetWindowDC_(#Null)
hdcout = GetDC_(hwnd)
hdcin = CreateCompatibleDC_(hdc)
SelectObject_(hdcin, ImageID(1))
BitBlt_(hdcout,0,0,200,20,hdcin,0,0,#SRCCOPY)
ReleaseDC_(0, hdc)
DeleteDC_(hdcin)
ReleaseDC_(hwnd, hdcout)
InvalidateRect_(hwnd, 0,1)
; EndSelect
Case #WM_NCDESTROY
RemoveProp_(hwnd, "oldproc")
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wparam, lparam)
EndProcedure
Procedure WinProc(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLOREDIT
hdc = wParam
SetTextColor_(hdc, #Black)
SetBkMode_(hdc, #TRANSPARENT)
result = GetStockObject_(#NULL_BRUSH)
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ImageGadget(0,0,0,0,0,ImageID(0))
DisableGadget(0, #True)
UpdateWindow_(WindowID(0))
StringGadget(1,10,10,200,20,"")
GrabImage(0, 1, 12,12, 200, 20)
SetGadgetText(1, "initial value"); Here is where you would set an initial text for the gadget
oldproc = SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @StringProc())
SetProp_(GadgetID(1), "oldproc", oldproc)
SetWindowCallback(@WinProc())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
Code: Select all
;===============================================================
; Program: A bunch of dirty hacks
; Author: netmaestro
; Date: December 2, 2007
; Target OS: Microsoft Windows all
; Target compiler: PureBasic 4.xx and later
; License: Free, unrestricted, use at your own risk
;===============================================================
Global stringpattern
CreateImage(0,320,240,32)
StartDrawing(ImageOutput(0))
For i=0 To 231 Step 16
For j = 0 To 311 Step 16
Box(j,i,8,8,RGB(230,230,255))
Box(j+8,i,8,8,#White)
Box(j,i+8,8,8,#White)
Box(j+8,i+8,8,8,RGB(230,230,255))
Next
Next
StopDrawing()
Procedure WinProc(hwnd, msg, wparam, lparam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLOREDIT
hdc = wParam
SetTextColor_(hdc, #Black)
SetBkMode_(hdc, #TRANSPARENT)
result = stringpattern
EndSelect
ProcedureReturn result
EndProcedure
OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
ImageGadget(0,0,0,0,0,ImageID(0))
DisableGadget(0, #True)
UpdateWindow_(WindowID(0))
StringGadget(1,10,10,200,20,"")
GrabImage(0, 1, 12,12, 200, 20)
stringpattern = CreatePatternBrush_(ImageID(1))
SetGadgetText(1, "initial value"); Here is where you would set an initial text for the gadget
SetWindowCallback(@WinProc())
Repeat:Until WaitWindowEvent()=#WM_CLOSE
I'm on my way!LuCiFeR[SD] wrote:Gentlemen, if either of you venture to sunny telford, I promise to buy you a beer or ten!