Page 1 of 2
No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 10:54 am
by staringfrog
Recently I've encountered quite a strange behaviour of a StringGadget tagged on the EditorGadget as its child with SetParent_. Thus, I can change its font properties (with some font initialized) but I can't change its fore color. The situation is modelled below, with 2 StringGadgets, one of them is a child control to EditorGadget, and the other isn't.
Code: Select all
If OpenWindow(0, 0, 0, 300, 200, "Editor With String Overlay", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 10, 10, 275, 170,#PB_Editor_WordWrap|#WS_CLIPCHILDREN)
StringGadget(2,20,20,100,30,"Child")
StringGadget(3,30,70,100,30,"Orphan")
SetParent_(GadgetID(2),GadgetID(1))
SetGadgetColor(2,#PB_Gadget_FrontColor,8421376)
SetGadgetColor(3,#PB_Gadget_FrontColor,8421376)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
So far, I can't make anything of this. Do you know what's going wrong here and/or how such behaviour can be mended?
Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 11:16 am
by Danilo
SetParent_() is not a supported/recognized PB command. Are you on Linux or is it a question specific to Windows OS?
Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 11:22 am
by staringfrog
Yeah, but this function's used quite often in various scripts, all the same. I realize it has something to do with SetParent_ (though I still can control this StringGadget in all respects except for colorizing). Then, is there an equivalent to SetParent_ in PB, or is there any other way to tag a StringGadget on the EditorGadget (in a fixed position and always in the foreground of the EditorGadget)?
P.S. So, SetParent API func is Windows specific, but my question isn't, as I don't mind doing the same tagging thing with pure PB code (if I only knew how).
Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 11:23 am
by Danilo
RASHAD will answer Windows only hacks, just be patient.

Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 1:37 pm
by RASHAD
Hi Danilo
Do think Germany will win the Soccer World Cup ?
@staringfrog
SetGadgetColor() use the window callback
If you insist to use SetParent_() you have to SubClass the EditorGadget
to respond to the StringGadget calls
Code: Select all
Global OldCallback
Procedure EditCallback(hwnd, msg, wparam, lparam)
result = CallWindowProc_(OldCallback, hwnd, msg, wparam, lparam)
Select msg
Case #WM_CTLCOLOREDIT
hdc = wParam
SetTextColor_(hdc, 8421376)
SetBkMode_(hdc, #TRANSPARENT)
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 300, 200, "Editor With String Overlay", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 10, 10, 275, 170,#PB_Editor_WordWrap|#WS_CLIPCHILDREN)
StringGadget(2,20,20,100,30,"Child")
StringGadget(3,30,70,100,30,"Orphan")
SetGadgetColor(3,#PB_Gadget_FrontColor,8421376)
SetParent_(GadgetID(2),GadgetID(1))
OldCallback = SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @EditCallback())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Or if it is a matter of Z-Order then
Code: Select all
If OpenWindow(0, 0, 0, 300, 200, "Editor With String Overlay", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
StringGadget(2,30,30,100,30,"Child")
StringGadget(3,30,70,100,30,"Orphan")
EditorGadget(1, 10, 10, 275, 170,#PB_Editor_WordWrap|#WS_CLIPSIBLINGS)
SetGadgetColor(2,#PB_Gadget_FrontColor,8421376)
SetGadgetColor(3,#PB_Gadget_FrontColor,8421376)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 2:05 pm
by staringfrog
Rashad,
thank you for your exhaustive explanation. Right, the second way is preferable and quite sufficient, and #WS_CLIPSIBLINGS flag seems to do the trick perfectly. I have to test it furthermore, though.
Re: No FrontColour With SetParent_
Posted: Thu Jul 03, 2014 6:25 pm
by Danilo
RASHAD wrote:Hi Danilo
Do think Germany will win the Soccer World Cup ?
From what I've seen so far, I don't think so. Let's see tomorrow, France : Germany could get interesting.

Re: No FrontColour With SetParent_
Posted: Fri Jul 04, 2014 7:29 am
by User_Russian
Danilo wrote:SetParent_() is not a supported/recognized PB command. Are you on Linux or is it a question specific to Windows OS?
Function UseGadgetList() supported and recommended for use?
But she also does not support color.
Code: Select all
If OpenWindow(0, 0, 0, 300, 200, "Editor With String Overlay", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 10, 10, 275, 170,#PB_Editor_WordWrap|#WS_CLIPCHILDREN)
Old=UseGadgetList(GadgetID(1))
StringGadget(2,20,20,100,30,"Child")
UseGadgetList(Old)
StringGadget(3,30,70,100,30,"Orphan")
SetGadgetColor(2,#PB_Gadget_FrontColor,8421376)
SetGadgetColor(3,#PB_Gadget_FrontColor,8421376)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: No FrontColour With SetParent_
Posted: Fri Jul 04, 2014 7:32 am
by Danilo
RASHAD wrote:Do think Germany will win the Soccer World Cup ?
What do you think? Will Germany smash France today?

Re: No FrontColour With SetParent_
Posted: Fri Jul 04, 2014 7:27 pm
by staringfrog
User_Russian wrote:Function UseGadgetList() supported and recommended for use?
But she also does not support color.
A nice one, thanks for underpinning my point. Is it probable that UseGadgetList() refers internally to SetParent function on Windows? Nonetheless, I think Rashad's explanation (given in the first snippet) is pretty clear, and we can use SetParent_ here as well but not without further editor control's subclassing. To think, there are tons of intrinsic things to learn about Windows before one can freely code for it in basic languages ))
P.S.
Danilo, congrats!
Re: No FrontColour With SetParent_
Posted: Fri Jul 04, 2014 10:13 pm
by RASHAD
Hi Danilo
The German team is much better than today but the time of the game(Afternoon in Brazil)
A kind of a degree in Hell
Re: No FrontColour With SetParent_
Posted: Sat Jul 05, 2014 5:37 am
by Danilo
RASHAD wrote:The German team is much better than today
The french team was fighting hard to the last second, so I think it wasn't that easy.
In my opinion it was 50%/50% chance. Just one can win. I also think it will be 50/50
with all the next matches. What we see is already the best of the world.
My congrats and respect goes to the french team. Nice match to watch and nice to see
how they were fighting. They just didn't give up.
Colombia destroyed Neymar, it makes it little bit easier for us - Brazil : Germany next Tuesday.

Re: No FrontColour With SetParent_
Posted: Sat Jul 05, 2014 5:51 am
by RASHAD
Colombia destroyed Neymar
I have a doubt about such news
It could be just a tactic from Brazil trainer
Well ,for sure this tournament is much much better than the last one in South Africa
Re: No FrontColour With SetParent_
Posted: Sat Jul 05, 2014 5:58 am
by Danilo
I don't think a vertebral fracture is tactic, but I just heard the news after returning from nightshift work.
Re: No FrontColour With SetParent_
Posted: Tue Jul 08, 2014 9:41 pm
by Danilo
RASHAD wrote:Well ,for sure this tournament is much much better than the last one in South Africa
For sure.
