silvercover wrote:...everythings work fine except changing background color and text color of created StringGadgets...
Hi silvercover. Based on your code and the comments in it, I made a simple test routine, replacing ProcedureCDLL() with a standard procedure, and it seems to work:
Code: Select all
Global h.l, io$ ;<--- based on your comments
Global fColor.i ;<--- I added this for the front colour
Procedure.s SetEditBoxBGColor() ;<--- changed to standard procedure for testing
If (io$ <> "") ; io$ is passed parameters from host window and that is global.
UseGadgetList(h) ; h.l is destination window handle which is global.
Delimiter$ = "|"
ObjectID = Val(StringField(io$, 1, Delimiter$))
ColorRed.l = Val(StringField(io$, 2, Delimiter$))
ColorGreen.l = Val(StringField(io$, 3, Delimiter$))
ColorBlue.l = Val(StringField(io$, 4, Delimiter$))
Color = RGB(ColorRed, ColorGreen, ColorBlue)
StringGadget(1, 8, 35, 306, 20, "1234567", #PB_String_Numeric)
SetGadgetColor(1, #PB_Gadget_BackColor, Color)
SetGadgetColor(1, #PB_Gadget_FrontColor, fColor) ;<--- I added this
EndIf
EndProcedure
;my test routine to call the procedure
#MainWindow = 1
wFlags.i = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, 0, 0, 330, 100, "Set Gadget Color", wFlags)
h = WindowID(#MainWindow)
fColor = #Red
io$ = Str(1) + "|" + Str(Red(#Cyan)) + "|" + Str(Green(#Cyan)) + "|" + Str(Blue(#Cyan))
SetEditBoxBGColor()
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
However, I believe that the problem is in the use of Global variables, which are not accessible to external DLL procedures. You'd have to pass them as parameters when calling the function, something like this:
Code: Select all
Procedure.s SetEditBoxBGColor(h.l, io$, io2$) ;<--- data passed as parameters
If (io$ <> "")
UseGadgetList(h)
StringGadget(1, 8, 35, 306, 20, "1234567", #PB_String_Numeric)
Delimiter$ = "|"
gadgetColor.i = #PB_Gadget_BackColor
For L = 1 To 2
If L = 2
gadgetColor = #PB_Gadget_FrontColor
io$ = io2$
EndIf
ObjectID = Val(StringField(io$, 1, Delimiter$))
ColorRed.l = Val(StringField(io$, 2, Delimiter$))
ColorGreen.l = Val(StringField(io$, 3, Delimiter$))
ColorBlue.l = Val(StringField(io$, 4, Delimiter$))
Color = RGB(ColorRed, ColorGreen, ColorBlue)
SetGadgetColor(1, gadgetColor, Color)
Next L
EndIf
EndProcedure
#MainWindow = 1
wFlags.i = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(#MainWindow, 0, 0, 330, 100, "Set Gadget Color", wFlags)
h.l = WindowID(#MainWindow)
io$ = Str(1) + "|" + Str(Red(#Cyan)) + "|" + Str(Green(#Cyan)) + "|" + Str(Blue(#Cyan))
io2$ = Str(1) + "|" + Str(Red(#Red)) + "|" + Str(Green(#Red)) + "|" + Str(Blue(#Red))
SetEditBoxBGColor(h, io$, io2$) ;<--- local variables passed as function parameters
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
You'll notice that no Global variables are used, and the data is being passed as parameters to the function. I made some small changes to your code to accommodate this, and to set the front colour as well.
In any case, without more details on the rest of your code, it's really just a stab in the dark. If it still doesn't work from your DLL, please let me know.