No FrontColour With SetParent_

Just starting out? Need help? Post your questions and find answers here.
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

No FrontColour With SetParent_

Post 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?
Coding's men's knitwork.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post by Danilo »

SetParent_() is not a supported/recognized PB command. Are you on Linux or is it a question specific to Windows OS?
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: No FrontColour With SetParent_

Post 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).
Last edited by staringfrog on Thu Jul 03, 2014 11:37 am, edited 3 times in total.
Coding's men's knitwork.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post by Danilo »

RASHAD will answer Windows only hacks, just be patient. ;)
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5032
Joined: Sun Apr 12, 2009 6:27 am

Re: No FrontColour With SetParent_

Post 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
Egypt my love
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: No FrontColour With SetParent_

Post 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.
Coding's men's knitwork.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post 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. ;)
User_Russian
Addict
Addict
Posts: 1623
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: No FrontColour With SetParent_

Post 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 
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post by Danilo »

RASHAD wrote:Do think Germany will win the Soccer World Cup ?
What do you think? Will Germany smash France today? :)
staringfrog
User
User
Posts: 58
Joined: Wed Feb 27, 2013 9:36 am

Re: No FrontColour With SetParent_

Post 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!
Coding's men's knitwork.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5032
Joined: Sun Apr 12, 2009 6:27 am

Re: No FrontColour With SetParent_

Post 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
Egypt my love
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post 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. :D
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 5032
Joined: Sun Apr 12, 2009 6:27 am

Re: No FrontColour With SetParent_

Post 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
Egypt my love
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post by Danilo »

I don't think a vertebral fracture is tactic, but I just heard the news after returning from nightshift work.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: No FrontColour With SetParent_

Post by Danilo »

RASHAD wrote:Well ,for sure this tournament is much much better than the last one in South Africa
For sure. :D
Post Reply