why: has #PB_Event_Repaint when Angle from 90 To 360

Just starting out? Need help? Post your questions and find answers here.
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

why: has #PB_Event_Repaint when Angle from 90 To 360

Post by gurj »

why: has #PB_Event_Repaint when Angle from 90 To 360

Code: Select all

;why: has #PB_Event_Repaint when Angle from 90 To 360
Global hDC,pen,hPen,fs=$ddddff,fsd=7;辅助色
Procedure lineG(Image,Gadget,x1,y1,x2,y2,lineWidth)
 If lineWidth<fsd:lw0=lineWidth:lineWidth=fsd:EndIf
 lw2=lineWidth/2+1:lw22=lineWidth+4
 If x1<x2:x1_=x1-lw2:xx2=x2+lw2-x1:xx1=lw2:Width=xx2+lw22:Else
 xx1=x1+lw2-x2:xx2=lw2:x1_=x2-lw2:Width=xx1+lw22:EndIf
 If y1<y2:y1_=y1-lw2:yy2=y2+lw2-y1:yy1=lw2:Height=yy2+lw22
  Else:yy1=y1+lw2-y2:yy2=lw2:y1_=y2-lw2:Height=yy1+lw22:EndIf
 If IsImage(Image):ResizeImage(Image,Width,Height)
  box=1:Else:CreateImage(Image,Width,Height,24,$6f6f6f):EndIf
 hdc=StartDrawing(ImageOutput(Image))
 If box=1:Box(0,0,Width,Height,$6f6f6f):EndIf
 MoveToEx_(hDC,xx1,yy1,0)
 If lw0>0:pen=CreatePen_(#PS_SOLID,lineWidth,fs)
  hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx2,yy2)
  MoveToEx_(hDC,xx1,yy1,0):pen=CreatePen_(#PS_SOLID,lw0,$0000ff)
 hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx2,yy2):Else
  pen=CreatePen_(#PS_SOLID,lineWidth,$0000ff)
  hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx2,yy2)
 EndIf
 StopDrawing()
 If IsGadget(Gadget)
  ;SetGadgetState(Gadget,ImageID(10));for clear residues shadow ,or use HideGadget(Gadget,1)
  ResizeGadget(Gadget,x1_,y1_,Width,Height)
  SetGadgetState(Gadget,ImageID(Image));:HideGadget(Gadget,0)
  Else:ImageGadget(Gadget,x1_,y1_,Width,Height,ImageID(Image)):EndIf
EndProcedure

OpenWindow(0, 0, 0, 550, 550, "dynamic Drawing", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered)

gx0=328:gy0=228:gx_=228:gy_=228:lineWidth=20
lineG(0,11,gx0,gy0,gx_,gy_,lineWidth)

AddWindowTimer(0,9,252)

Repeat:Event=WaitWindowEvent()
 If Event:Select Event
    ;******************
   Case #PB_Event_Repaint;why: has Repaint when Angle from 90 To 360
    Beep_(1400,200)
   Case #PB_Event_Timer
    gx0=228+Cos(Radian(Angle))*100:gy0=228+Sin(Radian(Angle))*100
    lineG(0,11,gx0,gy0,gx_,gy_,lineWidth);:WaitWindowEvent():WaitWindowEvent():WaitWindowEvent()
    Angle+10
    If Angle=360:Angle=0:EndIf
    ;******************
   Case #PB_Event_CloseWindow:appQuit = 1
 EndSelect:EndIf
Until appQuit = 1
DeleteObject_(pen)
DeleteObject_(hPen)
DeleteDC_(hdc)

End
my pb for chinese:
http://ataorj.ys168.com
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: why: has #PB_Event_Repaint when Angle from 90 To 360

Post by netmaestro »

I don't understand the question. #PB_Event_Repaint will be triggered by the SetGadgetState command on the image gadget at every angle, and that's what is happening here.
BERESHEIT
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why: has #PB_Event_Repaint when Angle from 90 To 360

Post by gurj »

here
ResizeGadget(),then has #PB_Event_Repaint (almost),isn't because SetGadgetState()
certainly,maybe,SetGadgetState() also can make ResizeGadget() for size on ImageGadget
but,if only for size,then SetGadgetState() can't make #PB_Event_Repaint,--try please use ';' For line34
(has Repaint) And (has flash As blink) when Angle >90 (almost)
has #WM_PAINT when Angle <90 (almost),but not flash,this normalization
winxp 86 pb5.6b1

Code: Select all

;why: has #PB_Event_Repaint when Angle >90

Global x,y,Angle,hDC,pen,hPen,fs=$ddddff,fsd=7;辅助色
Procedure lineG(Image,Gadget,x1,y1,x2,y2,lineWidth)
 If lineWidth<fsd:lw0=lineWidth:lineWidth=fsd:EndIf
 lw2=lineWidth/2+1:lw22=lineWidth+4
 If x1<x2:x1_=x1-lw2:xx2=x2+lw2-x1:xx1=lw2:Width=xx2+lw22:Else
 xx1=x1+lw2-x2:xx2=lw2:x1_=x2-lw2:Width=xx1+lw22:EndIf
 If y1<y2:y1_=y1-lw2:yy2=y2+lw2-y1:yy1=lw2:Height=yy2+lw22
  Else:yy1=y1+lw2-y2:yy2=lw2:y1_=y2-lw2:Height=yy1+lw22:EndIf
 If IsImage(Image):ResizeImage(Image,Width,Height)
  box=1:Else:CreateImage(Image,Width,Height,24,$6f6f6f):EndIf
 hdc=StartDrawing(ImageOutput(Image))
 If box=1:Box(0,0,Width,Height,$6f6f6f):EndIf
 MoveToEx_(hDC,xx1,yy1,0)
 If lw0>0:pen=CreatePen_(#PS_SOLID,lineWidth,fs)
  hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx2,yy2)
  pen=CreatePen_(#PS_SOLID,lw0,$0000ff)
 hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx1,yy1):Else
  pen=CreatePen_(#PS_SOLID,lineWidth,$0000ff)
  hPen=SelectObject_(hDC,pen):LineTo_(hDC,xx2,yy2)
 EndIf
 StopDrawing()
 If IsGadget(Gadget)
  ;-my1 ***********
  If x<>x1_ Or y<>y1_:x=x1_:y=y1_
   ResizeGadget(Gadget,x1_,y1_,Width,Height)
   SetGadgetText(7,Str(Angle)+":ResizeGadget")
   ;ResizeGadget(),then has #PB_Event_Repaint (almost),isn't because SetGadgetState()
   ;certainly,maybe,SetGadgetState() also can make ResizeGadget() only for size on ImageGadget
   ;but,if only for size,then SetGadgetState() can't make #PB_Event_Repaint,--try please use ";" for line34
   ;(has Repaint) And (has flash As blink) when Angle >90 (almost)
  EndIf
  SetGadgetState(Gadget,ImageID(Image))
  Else:ImageGadget(Gadget,x1_,y1_,Width,Height,ImageID(Image)):EndIf
EndProcedure

OpenWindow(0, 0, 0, 550, 550, "dynamic Drawing", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered)
EditorGadget(5,2,370,550,180,#PB_Editor_WordWrap)
SetGadgetText(5,~"here\nResizeGadget(),then has #PB_Event_Repaint (almost),isn't because SetGadgetState()\n"+
                ~"certainly,maybe,SetGadgetState() also can make ResizeGadget() for size on ImageGadget\n"+
                ~"but,if only for size,then SetGadgetState() can't make #PB_Event_Repaint,--try please use ';' For line34\n"+
                ~"(has Repaint) And (has flash As blink) when Angle >90 (almost)\n"+
                ~"has #WM_PAINT when Angle <90 (almost),but not flash,this normalization\nwinxp 86 pb5.6b1")
TextGadget(6,220,40,122,20,""):TextGadget(7,220,60,122,20,""):TextGadget(8,220,80,122,20,"")
SetGadgetColor(7,#PB_Gadget_BackColor,$ffff00)
gx0=328:gy0=228:gx_=228:gy_=228:lineWidth=20
lineG(0,11,gx0,gy0,gx_,gy_,lineWidth)

AddWindowTimer(0,9,888)

Repeat:Event=WaitWindowEvent()
 If Event:Select Event
  ;-my2 ***********
   Case #PB_Event_Repaint;why: (has Repaint) and (has flash as blink) when Angle >90 (almost)
    ;also see:   ;-my1 
    Beep_(1400,200)
    SetGadgetText(8,Str(Angle)+":#PB_Event_Repaint")
   Case #WM_PAINT;why: has paint when Angle <90 (almost),but not flash,this normalization
    SetGadgetText(8,Str(Angle)+":#WM_PAINT")
   Case #PB_Event_Timer
    Angle+5:If Angle=360:Angle=0:EndIf
    SetGadgetText(6,Str(Angle)+"=current Angle")
    gx0=228+Cos(Radian(Angle))*100:gy0=228+Sin(Radian(Angle))*100
    lineG(0,11,gx0,gy0,gx_,gy_,lineWidth);:WaitWindowEvent():WaitWindowEvent():WaitWindowEvent()
    ;******************
   Case #PB_Event_CloseWindow:appQuit = 1
 EndSelect:EndIf
Until appQuit = 1
DeleteObject_(pen)
DeleteObject_(hPen)
DeleteDC_(hdc)

End
other,please try this bug/?:

Code: Select all

;other,please try this bug/?:
If OpenWindow(0,0,0,800,500,"",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CreateImage(0,200,55,24,#Red)
ImageGadget(0,0,0,200,55,ImageID(0))
AddWindowTimer(0,9,888)
b=22
Repeat:Event=WaitWindowEvent()
 If Event:Select Event
  ; ***********
   Case #PB_Event_Repaint;only one time
    Debug a:a!1
   Case #WM_PAINT
;Beep_(1400,200)
   Case #PB_Event_Timer
    x+b
    ResizeGadget(0,x,x,200, 20)
    If x>100 Or x<Abs(b):b=-b:EndIf
   Case #PB_Event_CloseWindow:appQuit = 1
 EndSelect:EndIf
Until appQuit = 1:EndIf
my pb for chinese:
http://ataorj.ys168.com
User avatar
gurj
Enthusiast
Enthusiast
Posts: 664
Joined: Thu Jan 22, 2009 3:48 am
Location: china
Contact:

Re: why: has #PB_Event_Repaint when Angle from 90 To 360

Post by gurj »

Remarks:
For line33 add WaitWindowEvent() can filtering this #PB_Event_Repaint message,but can't avoiding Event_Repaint.

Code: Select all

  If x<>x1_ Or y<>y1_:x=x1_:y=y1_
   ResizeGadget(Gadget,x1_,y1_,Width,Height)
   SetGadgetText(7,Str(Angle)+":ResizeGadget")
   ;...
  WaitWindowEvent():EndIf;line33
my pb for chinese:
http://ataorj.ys168.com
Post Reply