Restored from previous forum. Originally posted by dmoc.
Anyone? I have tried various combo's of styles but it appears that #ES_AUTOHSCROLL is always set.
Multiline String Gadget *with* wrapping?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
You want to remove the #ES_AUTOHSCROLL Style from the Gadget, is that right?
Try this:
Where #String is the Gadget Number of your String Gadget.
Hope this helps...
Timo
You want to remove the #ES_AUTOHSCROLL Style from the Gadget, is that right?
Try this:
Code: Select all
Styles.l = GetWindowLong_( GadgetID(#String) ,#GWL_STYLE)
Styles = Styles & (~#ES_AUTOHSCROLL)
SetWindowLong_( GadgetID(#String) ,#GWL_STYLE, Styles)
Hope this helps...
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by dmoc.
Yep, already tried this. I also pasted your code in with minimal changes (see below) but no luck. Getting frustrated now, been on it for a couple of hours, grrrrr.
#WINDOW_Main = 0
#WindowWidth = 256
#WindowHeight = 192
Declare ChangeStatus(Text$)
If OpenWindow(0, 400, 200, #WindowWidth, #WindowHeight, #PB_Window_MinimizeGadget, "MetaNotes")
*MainWindow = WindowID(#WINDOW_Main)
If CreateGadgetList(WindowID())
StringGadget(0, 10, 15, 100, 140, "", #PB_String_Multiline)
Styles.l = GetWindowLong_( GadgetID(0) ,#GWL_STYLE)
Styles = Styles & (~#ES_AUTOHSCROLL)
SetWindowLong_( GadgetID(0) ,#GWL_STYLE, Styles)
If CreateStatusBar(0, *MainWindow)
AddStatusBarField(#WindowWidth)
ChangeStatus("Hello!")
EndIf
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
ChangeStatus("Main Window Event: "+Str(EventType()))
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
Procedure ChangeStatus(Text$)
If Text$
StatusBarText(0, 0, Text$, 4)
EndIf
EndProcedure
Yep, already tried this. I also pasted your code in with minimal changes (see below) but no luck. Getting frustrated now, been on it for a couple of hours, grrrrr.
#WINDOW_Main = 0
#WindowWidth = 256
#WindowHeight = 192
Declare ChangeStatus(Text$)
If OpenWindow(0, 400, 200, #WindowWidth, #WindowHeight, #PB_Window_MinimizeGadget, "MetaNotes")
*MainWindow = WindowID(#WINDOW_Main)
If CreateGadgetList(WindowID())
StringGadget(0, 10, 15, 100, 140, "", #PB_String_Multiline)
Styles.l = GetWindowLong_( GadgetID(0) ,#GWL_STYLE)
Styles = Styles & (~#ES_AUTOHSCROLL)
SetWindowLong_( GadgetID(0) ,#GWL_STYLE, Styles)
If CreateStatusBar(0, *MainWindow)
AddStatusBarField(#WindowWidth)
ChangeStatus("Hello!")
EndIf
EndIf
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0
ChangeStatus("Main Window Event: "+Str(EventType()))
EndSelect
EndIf
Until EventID = #PB_EventCloseWindow
EndIf
Procedure ChangeStatus(Text$)
If Text$
StatusBarText(0, 0, Text$, 4)
EndIf
EndProcedure
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
I've got bad news four you.
Timo
I've got bad news four you.
#ES_AUTOHSCROLL is one of the Styles you can't change after the creation of a StringGadget, sorry.From Microsoft Platform SDK
After the control has been created, these styles cannot be modified, except as noted.
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
You must create it, it can't be changed with SetWindowLong_():
EDIT: Corrected and 'generalized'.
UPDATE: Added GadgetToolTipEx().
Bye,
El_Choni
You must create it, it can't be changed with SetWindowLong_():
EDIT: Corrected and 'generalized'.
UPDATE: Added GadgetToolTipEx().
Code: Select all
Declare.l ActivateGadgetEx(Gadget)
Declare.l DisableGadgetEx(Gadget, State)
Declare.l FreeGadgetEx(Gadget)
Declare.l GadgetHeightEx(Gadget)
Declare.l GadgetIDEx(Gadget)
Declare.l GadgetToolTipEx(Gadget, Text$)
Declare.l GadgetWidthEx(Gadget)
Declare.l GadgetXEx(Gadget)
Declare.l GadgetYEx(Gadget)
Declare.s GetGadgetTextEx(Gadget)
Declare.l HideGadgetEx(Gadget, State)
Declare.l SetGadgetFontEx(FontID)
Declare.l SetGadgetTextEx(Gadget, Text$)
Declare.l WrapStringGadget(Gadget, x, y, width, height, text.s, flags)
Procedure Error(message$, fatal.b)
FormatMessage_(#FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError_(), 0, AllocateMemory(0, 256, 0), 256, 0)
MessageRequester("Error", message$+Chr(10)+Chr(10)+PeekS(MemoryID()), 0)
FreeMemory(0)
If fatal
End
EndIf
EndProcedure
; To process events we don't want WaitEventWindow() to catch
Procedure WndProc(hWnd, uMsg, wParam, lParam)
result = 0
Select uMsg
Case #WM_COMMAND
EditClass.s = Space(4)
If GetClassName_(hWnd, EditClass, 5)=4
If (GetWindowLong_(hWnd, #GWL_STYLE)#ES_AUTOHSCROLL)=0 And EditClass="Edit"
Select wParam>>16
Case #EN_CHANGE
result = #PB_ProcessPureBasicEvents
Case #EN_KILLFOCUS
result = #PB_ProcessPureBasicEvents
Case #EN_SETFOCUS
result = #PB_ProcessPureBasicEvents
EndSelect
Else
result = #PB_ProcessPureBasicEvents
EndIf
Else
result = #PB_ProcessPureBasicEvents
EndIf
Default
result = #PB_ProcessPureBasicEvents
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 220, 120, #PB_Window_SystemMenu, "Wrap string gadget example")
WindowID = WindowID()
If CreateGadgetList(WindowID)
SetGadgetFontEx(LoadFont(0, "Courier New", 10))
If WrapStringGadget(0, 10, 10, 200, 100, "", #PB_String_Multiline|#ES_AUTOVSCROLL|#WS_VSCROLL)
SetGadgetTextEx(0, "Wrap string gadget example: let's get wrapped until we scroll down and down!")
Debug "GadgetIDEx: "+Str(GadgetIDEx(0))
Debug "GadgetXEx: "+Str(GadgetXEx(0))
Debug "GadgetYEx: "+Str(GadgetYEx(0))
Debug "GadgetWidthEx: "+Str(GadgetWidthEx(0))
Debug "GadgetHeightEx: "+Str(GadgetHeightEx(0))
Debug "GadgetIDEx: "+GetGadgetTextEx(0)
SetWindowCallback(@WndProc())
If GadgetToolTipEx(0, "WrapEditGadget tooltip")=0
Error("GadgetToolTipEx() failed", 0)
EndIf
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadgetID()
Case 0
Debug "WrapStringGadget event type processed:"+Str(EventType())
EndSelect
EndSelect
Until EventID=#PB_Event_CloseWindow
DeleteObject_(hFont)
Else
Error("WrapStringGadget() failed:", 1)
EndIf
Else
Error("CreateGadgetList() failed:", 1)
EndIf
Else
Error("OpenWindow() failed:", 1)
EndIf
End
Global hFont
Procedure WrapStringGadget(Gadget, x, y, width, height, text$, flags)
WrapStringGadget = CreateWindowEx_(#WS_EX_CLIENTEDGE, "EDIT", text$, flags|#WS_CHILDWINDOW|#WS_MAXIMIZEBOX|#WS_MINIMIZEBOX|#WS_VISIBLE, x, y, width, height, WindowID(), Gadget, GetModuleHandle_(0), 0)
If WrapStringGadget
If hFont
SendMessage_(WrapStringGadget, #WM_SETFONT, hFont, 1)
Else
SendMessage_(WrapStringGadget, #WM_SETFONT, GetStockObject_(#DEFAULT_GUI_FONT), 1)
EndIf
UpdateWindow_(WrapStringGadget)
ShowWindow_(WrapStringGadget, #SW_SHOWNORMAL)
Else
Error("CreateWindowEx_() failed:", 1)
EndIf
ProcedureReturn WrapStringGadget
EndProcedure
Procedure.s GetGadgetTextEx(Gadget)
TextLength = SendMessage_(GadgetIDEx(Gadget), #WM_GETTEXTLENGTH, 0, 0)+1
Buffer = AllocateMemory(0, TextLength, 0)
SendMessage_(GadgetIDEx(Gadget), #WM_GETTEXT, TextLength, Buffer)
result.s = PeekS(Buffer)
FreeMemory(0)
ProcedureReturn result
EndProcedure
Global GadgetIDEx
Procedure EnumChildProc(hWnd, lParam)
ID = GetWindowLong_(hWnd, #GWL_ID)
If ID=lParam
GadgetIDEx = hWnd
result = #FALSE
Else
result = #TRUE
EndIf
ProcedureReturn result
EndProcedure
Procedure GadgetIDEx(Gadget)
EnumChildWindows_(WindowID(), @EnumChildProc(), Gadget)
ProcedureReturn GadgetIDEx
EndProcedure
Procedure DisableGadgetEx(Gadget, State)
result = EnableWindow_(GadgetIDEx(Gadget), State)
ProcedureReturn result
EndProcedure
Procedure FreeGadgetEx(Gadget)
result = DestroyWindow_(GadgetIDEx(Gadget))
ProcedureReturn result
EndProcedure
Procedure HideGadgetEx(Gadget, State)
If State
result = ShowWindow_(GadgetIDEx(Gadget), #SW_HIDE)
Else
result = ShowWindow_(GadgetIDEx(Gadget), #SW_SHOW)
EndIf
ProcedureReturn result
EndProcedure
Procedure GadgetWidthEx(Gadget)
GetWindowRect_(GadgetIDEx(Gadget), rc.RECT)
result = rc\right-rc\left
ProcedureReturn result
EndProcedure
Procedure GadgetHeightEx(Gadget)
GetWindowRect_(GadgetIDEx(Gadget), rc.RECT)
result = rc\bottom-rc\top
ProcedureReturn result
EndProcedure
Procedure GadgetXEx(Gadget)
GetWindowRect_(GadgetIDEx(Gadget), rc.RECT)
result = rc\left
ProcedureReturn result
EndProcedure
Procedure GadgetYEx(Gadget)
GetWindowRect_(GadgetIDEx(Gadget), rc.RECT)
result = rc\top
ProcedureReturn result
EndProcedure
Procedure ActivateGadgetEx(Gadget)
result = SetFocus_(GadgetIDEx(Gadget))
ProcedureReturn result
EndProcedure
Procedure SetGadgetTextEx(Gadget, Text$)
result = SendMessage_(GadgetIDEx(Gadget), #WM_SETTEXT, 0, Text$)
ProcedureReturn result
EndProcedure
Procedure SetGadgetFontEx(FontID)
If FontID=#PB_Font_Default
hFont = GetStockObject_(#DEFAULT_GUI_FONT)
Else
hFont = FontID
EndIf
ProcedureReturn hFont
EndProcedure
Procedure GadgetToolTipEx(Gadget, Text$)
#TTF_DI_SETITEM = $8000
hToolTip = CreateWindowEx_(0, "Tooltips_class32", 0, 0, 0, 0, 0, 0, WindowID(), 0, GetModuleHandle_(0), 0)
If hToolTip
ti.TOOLINFO
ti\cbSize = SizeOf(TOOLINFO)
ti\uFlags = #TTF_SUBCLASS|#TTF_IDISHWND
ti\hWnd = GadgetIDEx(Gadget)
ti\uId = GadgetIDEx(Gadget)
ti\hinst = 0
ti\lpszText = @Text$
result = SendMessage_(hToolTip, #TTM_ADDTOOL, 0, ti)
Else
result = 0
EndIf
ProcedureReturn result
EndProcedure
El_Choni
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by dmoc.
Gulp! Thanks both. Would be nice if PB supported this natively. @El_Choni: you've saved my day! I'm now busy generalising your code because I probably need a few of these. Spotted one error in GetGadgetTextEx(), "text = PeekS(Buffer)" needs to be "text.s = PeekS(Buffer)". Thanks again.
Gulp! Thanks both. Would be nice if PB supported this natively. @El_Choni: you've saved my day! I'm now busy generalising your code because I probably need a few of these. Spotted one error in GetGadgetTextEx(), "text = PeekS(Buffer)" needs to be "text.s = PeekS(Buffer)". Thanks again.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
, and I wanted to learn some more about the Windows API. The GadgetToolTipEx() was a tough one for me! So you don't have to feel guilty for making me code, coding is fun XD
El_Choni
You're absolutely right, the only reason I've made all those commands is because I'm unemployed right now, so I have enough spare time (not enough spare money, of courseseems a lot of code for what could be solved by a small(?) change to the stringgadget() command, unless I'm over simplifying things. Fred? Any comment?
El_Choni
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by dmoc.
I split your code into 2 files, one the main routine, the other "WrapStringGadget.pbi", and tested it with 2 gadgets. The only thing I had to change was a typo in WndProc() as shown below. Works a dream. I also commented out the SetWindowCallback(@WndProc()) because I don't need those events, but it's a good example for anyone who does.
Sorry to hear you are unemployed and I hope you find work soon. I'm in the same boat. Are you coding anything specific or just tinkering?
- In Procedure WndProc(hWnd, uMsg, wParam, lParam)...
If (GetWindowLong_(hWnd, #GWL_STYLE)#ES_AUTOHSCROLL)=0 And EditClass="Edit"
...changed to...
If (GetWindowLong_(hWnd, #GWL_STYLE) & #ES_AUTOHSCROLL)=0 And EditClass="Edit"
I split your code into 2 files, one the main routine, the other "WrapStringGadget.pbi", and tested it with 2 gadgets. The only thing I had to change was a typo in WndProc() as shown below. Works a dream. I also commented out the SetWindowCallback(@WndProc()) because I don't need those events, but it's a good example for anyone who does.
Sorry to hear you are unemployed and I hope you find work soon. I'm in the same boat. Are you coding anything specific or just tinkering?
- In Procedure WndProc(hWnd, uMsg, wParam, lParam)...
If (GetWindowLong_(hWnd, #GWL_STYLE)#ES_AUTOHSCROLL)=0 And EditClass="Edit"
...changed to...
If (GetWindowLong_(hWnd, #GWL_STYLE) & #ES_AUTOHSCROLL)=0 And EditClass="Edit"