1. Min-Max

After running the following code, then minimizing (or dragging partially off the screen) and recalling the window (or dragging it back on screen), the items that were drawn are gone.

How can it be made to remain as drawn?

Buzzo

-- FILE: test_Min_Max.exw 
include machine.e 
include misc.e 
include Win32Lib.ew 
include dll.e 
include wildcard.e 
 
constant 	win=createEx( Window,"Test Min Max",0,100,100,500,500,0,0), 
			But1 = createEx( PushButton, "Click To Draw", win,200,400, 100, 24, 0, 0 ) 
 
global	integer MainWinColor = #e2ffc9  
setWindowBackColor(win, MainWinColor)	 
 
procedure draw(integer win, integer Event, sequence Params) draw_something() end procedure  
setHandler(But1, w32HClick, routine_id("draw"))  
 
procedure draw_something() 
	sequence screeN  
	atom clientH, clientW 
	screeN=getClientRect(win)  
	clientH=screeN[4] clientW=screeN[3]			-- height and width of win, inside borders and top menu etc 
	setPenColor(win,Parchment) 	 
	drawRoundRect(win,w32True,10,10,100,100,8,8) 
	setPenColor(win,Black) 	 
	drawRoundRect(win,w32False,10,10,100,100,8,8) 
	setPenColor(win,Red) 
	drawLine(win,0,0,clientW,clientH)  
	drawLine(win,0,clientH,clientW,0) 
end procedure 
 
WinMain(win,Normal)  
  
 
new topic     » topic index » view message » categorize

2. Re: Min-Max

found the solution using w32HPaint... and w32HResize.. fickers a bit

new topic     » goto parent     » topic index » view message » categorize

3. Re: Min-Max

buzzo said...

found the solution using w32HPaint... and w32HResize.. fickers a bit

I've reworked your example to reduce flickering. The trick is to use a Pixmap to draw onto then copy the pixmap to the window's drawing surface. It is much faster than drawing directly onto a window.

-- FILE: test_Min_Max.exw  
include Win32Lib.ew  
  
constant 	win=createEx( Window,"Test Min Max",0,100,100,500,500,0,0),  
			But1 = createEx( PushButton, "Click To Draw", win,200,400, 100, 24, 0, 0 ), 
			pm = create(Pixmap, "", 0, 0, 0, 0, 0, 0)  
  
global	integer MainWinColor = #e2ffc9   
setWindowBackColor(pm, MainWinColor)	  
 
integer allow_drawing 
allow_drawing = 0 
procedure draw(integer win, integer Event, sequence Params)  
	allow_drawing = not allow_drawing 
	if allow_drawing then 
		setText(But1, "Click to Clear") 
	else 
		setText(But1, "Click to Draw") 
	end if 
	draw_something()  
end procedure   
setHandler(But1, w32HClick, routine_id("draw"))   
  
procedure onPaint(integer win, integer Event, sequence Params) 
    draw_something() 
end procedure   
setHandler(win, w32HPaint, routine_id("onPaint"))   
 
procedure onResize(integer win, integer Event, sequence Params) 
    draw_something() 
end procedure   
setHandler(win, w32HResize, routine_id("onResize"))   
 
procedure draw_something()  
	sequence screeN   
	sequence pmSize 
	atom clientH, clientW  
	screeN=getClientRect(win)   
	pmSize=getClientRect(pm)   
	clientH=screeN[4] clientW=screeN[3]			-- height and width of win, inside borders and top menu etc  
	if not equal(pmSize, screeN) then 
		setCtlSize(pm, clientW, clientH) 
	end if 
	clearWindow(pm) 
	if allow_drawing then 
		setPenColor(pm,Parchment) 	  
		drawRoundRect(pm,w32True,10,10,100,100,8,8)  
		setPenColor(pm,Black) 	  
		drawRoundRect(pm,w32False,10,10,100,100,8,8)  
		setPenColor(pm,Red)  
		drawLine(pm,0,0,clientW,clientH)   
		drawLine(pm,0,clientH,clientW,0)  
	end if 
	copyBlt(win, 0, 0, pm) 
	repaintWindow(But1) 
end procedure  
  
WinMain(win,Normal)   
new topic     » goto parent     » topic index » view message » categorize

4. Re: Min-Max

Derek,

Thanks.. it occurred to me the use a Pixmap.. but my use did not have any diagonal lines.. If is really faster, I may use the Pixmap any way.

Buzzo

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu