Posted: Sat Dec 15, 2007 5:30 am
*** Edited to remove global var ***
Not fully tested and not sure if it meets your standards for elegance...
Not fully tested and not sure if it meets your standards for elegance...
Code: Select all
Procedure SringProc(hwnd, msg, wParam, lParam)
oldproc = GetProp_(hwnd, "_oldProc")
Select msg
Case #WM_CHAR
;...Remove ding sound and press button
If wParam = #VK_RETURN
SendMessage_(GadgetID(1), #BM_CLICK, 0, 0)
ProcedureReturn 0
EndIf
EndSelect
ProcedureReturn CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 300, 200, "Silent StringGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
StringGadget(0, 10, 10, 280, 25, "Normal StringGadget")
ButtonGadget(1, 10, 40, 280, 25, "Click me or press Enter in StringGadget")
EditorGadget(2, 10, 70, 280, 125)
oldproc = GetWindowLong_(GadgetID(0), #GWL_WNDPROC)
SetProp_(GadgetID(0), "_oldproc", oldproc)
SetWindowLong_(GadgetID(0), #GWL_WNDPROC, @SringProc())
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget And EventGadget() = 1
AddGadgetItem(2, -1, "Current string text is: " + GetGadgetText(0))
EndIf
Until event = #PB_Event_CloseWindow
RemoveProp_(GadgetID(0), "_oldproc")
EndIf