It seems that I have about the same kind of problem as Poshu...
http://purebasic.fr/english/viewtopic.php?f=13&t=57156
RASHAD's last code works perfectly on Windows 8.1!
But I still had problems. Hard problems, the EditorGadget refused to be displayed!
I searched all day for the reason, and finally found it:
AnimateWindow_() !
Here is my test code:
Code: Select all
ExamineDesktops()
Global _DW.i=DesktopWidth(0)
Global _DH.i=DesktopHeight(0)
Procedure.i zBaseImage(Array ImX.i(1),X.i,Y.i,W.i,H.i)
Dim ImX.i(1)
ImCre=CreateImage(#PB_Any,W,H)
ImGad=ImageGadget(#PB_Any,X,Y,W,H,ImageID(ImCre))
DisableGadget(ImGad,1)
InvalidateRect_(GadgetID(ImGad),0,1)
ImX(0)=ImCre; #Image
ImX(1)=ImGad; #Gadget
ProcedureReturn ImGad
EndProcedure
Procedure zGradient(Array Im.i(1),Dir.i,X.i,Y.i,W.i,H.i,Color1.i,Color2.i,Update.i=1)
StartDrawing(ImageOutput(Im(0)))
DrawingMode(#PB_2DDrawing_Gradient)
BackColor(Color1)
FrontColor(Color2)
LinearGradient(W/2,0+Y,W/2,H+Y)
Box(X,Y,W,H)
StopDrawing()
If Update
SetGadgetState(Im(1),ImageID(Im(0)))
EndIf
DisableGadget(Im(1),1); no click on it
;InvalidateRect_(GadgetID(Im(1)),0,1)
EndProcedure
Procedure.i zEdit(Array ImX.i(1),X.i,Y.i,W.i,H.i,StrValue.s)
BkColor=$004000
Color=$FFFFFF
Label=EditorGadget(#PB_Any,X,Y,W,H,#PB_Editor_WordWrap)
SetGadgetColor(Label,#PB_Gadget_BackColor,BkColor)
SetGadgetColor(Label,#PB_Gadget_FrontColor,Color)
AddGadgetItem(Label,0,StrValue.s)
SetGadgetState(ImX(1),ImageID(ImX(0)))
;DisableGadget(ImX(1),1); no click on it
;InvalidateRect_(GadgetID(ImX(1)),0,1)
ProcedureReturn Label
EndProcedure
; =======================================================================================================================
Win=OpenWindow(#PB_Any,0,0,_DW,_DH,"",#PB_Window_BorderLess|#PB_Window_Invisible)
Dim ImA(0)
zBaseImage(ImA(),0,0,_DW,_DH)
zGradient(ImA(),1,0,0,_DW,_DH,$000000,$D419FF,0)
HideWindow(Win,0)
; =======================================================================================================================
Dim ImB(0)
DisableWindow(Win,1)
Win2=OpenWindow(#PB_Any,50,50,_DW-100,_DH-100,"",#PB_Window_BorderLess|#PB_Window_Invisible,WindowID(Win))
zBaseImage(ImB(),0,0,_DW-100,_DH-100)
zGradient(ImB(),1,0,0,_DW-100,_DH-100,$000000,$D4194A,0)
Btn2=ButtonGadget(#PB_Any,350,100,100,30,"Exit")
E2=zEdit(ImB(),100,100,200,200,"This is an EditorGadget")
SetWindowLongPtr_(GadgetID(ImB(1)), #GWL_STYLE, GetWindowLongPtr_(GadgetID(ImB(1)), #GWL_STYLE) | #WS_CLIPSIBLINGS )
SetWindowPos_(GadgetID(ImB(1)),#HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOSIZE | #SWP_NOMOVE)
SetActiveGadget(E2)
; The problem is that the API AnimateWindow_() works differently than HideWindow()!
; Try first with HideWindow(), it will work correctly,
; then try with AnimateWindow_(), nothing will be visible (Press Alt+F4 to exit!)
; AnimateWindow_(WindowID(Win2.i),Speed.i,#AW_ACTIVATE|#AW_BLEND)
HideWindow(Win2,0)
Repeat
Event=WaitWindowEvent(5)
Select Event
Case #PB_Event_CloseWindow
Quit=1
Case #PB_Event_Gadget
Gadget=EventGadget()
Select Gadget
Case Btn2
Quit=1
EndSelect
EndSelect
Until Quit
CloseWindow(Win2)
DisableWindow(Win,0)
First try it as coded: it will work.
Then, activate line 68 and deactivate line 69, and run it. Empty!!
Press Alt+F4 to exit...
I am using AnimateWindow_() because it is softer than HideWindow().
So, in my code, I do not change AnimateWindow_() for HideWindow(), but then I cannot use EditorGadget().
However, I have found an alternative in the CodeArchive4:
Code: Select all
; English forum: http://www.purebasic.fr/english/viewtopic.php?t=6507
; Author: PB (updated for PB4.00 by blbltheworm)
; Date: 12. June 2003
; OS: Windows
; Demo: Yes
If OpenWindow(0,200,200,300,200,"test",#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
t$="This text goes inside a multiline StringGadget."+Chr(13)+Chr(10)
For r=1 To 10 : t$+Str(r)+Chr(13)+Chr(10) : Next
StringGadget(0,10,10,200,100,t$,#ES_MULTILINE|#ES_AUTOVSCROLL|#WS_VSCROLL|#WS_HSCROLL|#ESB_DISABLE_LEFT|#ESB_DISABLE_RIGHT)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
and this works with AnimatedWindow_() and background images
Cheers