1. tiny little question about win32lib

There is something I don't understand.
A customer asked if I could modify euphoria program to display a page of text programmatically. Piece of cake. Create a window, add graphics and text to window (with win32lib graphics commands), voila! Works like a charm UNTIL one grabs the window and moves it to off the display edge(partially off screen). Return the window to the screen and any graphics that were moved off screen have been erased. Window and its controls return OK. Just the graphics disappear. BMP controls behave normally except that anything added to the BMP after the original creation behave similarly. It is as though there are multiple display frames (I'm talking memory frames here that the graphics processor uses) that behave like layers - some permanent and some temporary. No info in docs that I could find.

Anybody out there that can give me a clue?

thanks in advance for you help...

new topic     » topic index » view message » categorize

2. Re: tiny little question about win32lib

How are you drawing the graphics? Can we see a snippet of your code? Or better, a working sample to demonstrate the problem?

-Greg

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

3. Re: tiny little question about win32lib

Herewith follows a short example program

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008 
 
constant TheProgramType="exw"  
  
include Win32lib.ew 
without warning 
 
constant win = createEx( Window, "DEMONSTRATION WINDOW", 0, Default, Default, 474, 326, 0, 0 ) 
constant pb_2 = createEx( PushButton, "QUIT", win, 20, 232, 124, 28, 0, 0 ) 
setFont( pb_2,"Arial",14,Normal+Bold) 
constant pb_1 = createEx( PushButton, "generate", win, 268, 232, 124, 28, 0, 0 ) 
setFont( pb_1,"Arial",14,Normal+Bold) 
 
procedure pb_2_onClick (integer self, integer event, sequence params) 
closeApp () 
end procedure 
setHandler( pb_2, w32HClick, routine_id("pb_2_onClick")) 
 
procedure pb_1_onClick (integer self, integer event, sequence params) 
setFont (win, "Consolas",12,Normal) 
wPuts({win,15,20},"Hello to the world, yet Again!") 
wPuts({win,15,40},"Now that text is on screen grab Window") 
wPuts({win,15,55},"Top bar & Move it so part of text") 
wPuts({win,15,70},"Leaves the monitor (off the edge)") 
wPuts({win,15,85},"Now, move it back to starting position.") 
wPuts({win,15,120},"Notice vanishing text AND unaffected control...") 
end procedure 
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick")) 
 
WinMain( win,Normal ) 
new topic     » goto parent     » topic index » view message » categorize

4. Re: tiny little question about win32lib

jessedavis said...

Herewith follows a short example program

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008 
 
constant TheProgramType="exw"  
  
include Win32lib.ew 
without warning 
 
constant win = createEx( Window, "DEMONSTRATION WINDOW", 0, Default, Default, 474, 326, 0, 0 ) 
constant pb_2 = createEx( PushButton, "QUIT", win, 20, 232, 124, 28, 0, 0 ) 
setFont( pb_2,"Arial",14,Normal+Bold) 
constant pb_1 = createEx( PushButton, "generate", win, 268, 232, 124, 28, 0, 0 ) 
setFont( pb_1,"Arial",14,Normal+Bold) 
 
procedure pb_2_onClick (integer self, integer event, sequence params) 
closeApp () 
end procedure 
setHandler( pb_2, w32HClick, routine_id("pb_2_onClick")) 
 
procedure pb_1_onClick (integer self, integer event, sequence params) 
setFont (win, "Consolas",12,Normal) 
wPuts({win,15,20},"Hello to the world, yet Again!") 
wPuts({win,15,40},"Now that text is on screen grab Window") 
wPuts({win,15,55},"Top bar & Move it so part of text") 
wPuts({win,15,70},"Leaves the monitor (off the edge)") 
wPuts({win,15,85},"Now, move it back to starting position.") 
wPuts({win,15,120},"Notice vanishing text AND unaffected control...") 
end procedure 
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick")) 
 
WinMain( win,Normal ) 

procedure pb_1_onClick (integer self, integer event, sequence params) 
setFont (win, "Consolas",12,Normal) 
wPuts({win,15,20},"Hello to the world, yet Again!") 
wPuts({win,15,40},"Now that text is on screen grab Window") 
wPuts({win,15,55},"Top bar & Move it so part of text") 
wPuts({win,15,70},"Leaves the monitor (off the edge)") 
wPuts({win,15,85},"Now, move it back to starting position.") 
wPuts({win,15,120},"Notice vanishing text AND unaffected control...") 
end procedure 
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick")) 
 
--Add this (it might work) 
setHandler(pb_1,w32HPaint,routine_id("pb_1_onClick")) 

The w32HPaint will keep drawing graphics on screen. I've also had issues with win32lib when trying to draw text using CText, or LText, the text will not show up at all or will be cut-off or look weird. Not sure if the w32HPaint will work, but its worth a shot.

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

5. Re: tiny little question about win32lib

jessedavis said...

Herewith follows a short example program

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008 
 
constant TheProgramType="exw"  
  
include Win32lib.ew 
without warning 
 
constant win = createEx( Window, "DEMONSTRATION WINDOW", 0, Default, Default, 474, 326, 0, 0 ) 
constant pb_2 = createEx( PushButton, "QUIT", win, 20, 232, 124, 28, 0, 0 ) 
setFont( pb_2,"Arial",14,Normal+Bold) 
constant pb_1 = createEx( PushButton, "generate", win, 268, 232, 124, 28, 0, 0 ) 
setFont( pb_1,"Arial",14,Normal+Bold) 
 
procedure pb_2_onClick (integer self, integer event, sequence params) 
closeApp () 
end procedure 
setHandler( pb_2, w32HClick, routine_id("pb_2_onClick")) 
 
procedure pb_1_onClick (integer self, integer event, sequence params) 
setFont (win, "Consolas",12,Normal) 
wPuts({win,15,20},"Hello to the world, yet Again!") 
wPuts({win,15,40},"Now that text is on screen grab Window") 
wPuts({win,15,55},"Top bar & Move it so part of text") 
wPuts({win,15,70},"Leaves the monitor (off the edge)") 
wPuts({win,15,85},"Now, move it back to starting position.") 
wPuts({win,15,120},"Notice vanishing text AND unaffected control...") 
end procedure 
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick")) 
 
WinMain( win,Normal ) 

Persistent graphics are a common issue in GUI apps. A quick solution is to simply redraw the graphics during each onPaint event or, if it's just text, embed them in a label control [Disclaimer: I don't know if Win32lib actually has a label control..].

Spock

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

6. Re: tiny little question about win32lib

Try this..

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008  
  
constant TheProgramType="exw"   
   
include Win32lib.ew  
without warning  
  
constant win = createEx( Window, "DEMONSTRATION WINDOW", 0, Default, Default, 474, 326, 0, 0 )  
constant pb_2 = createEx( PushButton, "QUIT", win, 20, 232, 124, 28, 0, 0 )  
setFont( pb_2,"Arial",14,Normal+Bold)  
constant pb_1 = createEx( PushButton, "generate", win, 268, 232, 124, 28, 0, 0 )  
setFont( pb_1,"Arial",14,Normal+Bold)  
  
procedure pb_2_onClick (integer self, integer event, sequence params)  
closeApp ()  
end procedure  
setHandler( pb_2, w32HClick, routine_id("pb_2_onClick"))  
 
procedure draw (integer self, integer event, sequence params)  
setFont (win, "Consolas",12,Normal)  
wPuts({win,15,20},"Hello to the world, yet Again!")  
wPuts({win,15,40},"Now that text is on screen grab Window")  
wPuts({win,15,55},"Top bar & Move it so part of text")  
wPuts({win,15,70},"Leaves the monitor (off the edge)")  
wPuts({win,15,85},"Now, move it back to starting position.")  
wPuts({win,15,120},"Notice vanishing text AND unaffected control...")  
end procedure  
 
integer clicked = 0 
 
procedure pb_1_onClick (integer self, integer event, sequence params)  
	clicked = 1 
	draw(self, event, params) 
end procedure  
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick"))  
  
procedure win_1_onPaint (integer self, integer event, sequence params)  
	if clicked then 
		draw(self, event, params) 
	end if 
end procedure  
setHandler( win, w32HPaint, routine_id("win_1_onPaint"))  
  
WinMain( win,Normal )  
 
 
new topic     » goto parent     » topic index » view message » categorize

7. Re: tiny little question about win32lib

Spock said...

Persistent graphics are a common issue in GUI apps. A quick solution is to simply redraw the graphics during each onPaint event or, if it's just text, embed them in a label control [Disclaimer: I don't know if Win32lib actually has a label control..].

Spock

A multi line edit control can also work..

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

8. Re: tiny little question about win32lib

Spock said...

Persistent graphics are a common issue in GUI apps. A quick solution is to simply redraw the graphics during each onPaint event or, if it's just text, embed them in a label control [Disclaimer: I don't know if Win32lib actually has a label control..].

Spock

This is interesting...

Yes, your fix works well. redrawing is certainly an answer; however, I do not understand what Windows is doing. Anytime something is moved the entire screen needs to be repainted. w32hpaint is never fired unless a portion of the app window (win) goes off screen and then only if moved back on the screen. As the window moves back onto the screen multiple w32Paint events are triggered, Each time a narrow band of the window is redrawn (added to the complete image). I assume that Windows silently repainting the entire screen as the screen buffer is updated. w32Paint is reconstructing the screen buffer a narrow band at the time as the app window moves back onto the screen - Windows then updates the entire screen every time the buffer changes..

as Arte Johnson would say... VERRRRY interresting!

thanks for your help.

jd

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

9. Re: tiny little question about win32lib

Icy_Viking said...

The w32HPaint will keep drawing graphics on screen. I've also had issues with win32lib when trying to draw text using CText, or LText, the text will not show up at all or will be cut-off or look weird. Not sure if the w32HPaint will work, but its worth a shot.


See my comments above on w32Paint. I have not found problems with CText, LText & RText. As far as I know these are only label controls. The documentation is not correct. These controls WILL respond to click events.

regards & thanks,
jd

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

10. Re: tiny little question about win32lib

jessedavis said...

Yes, your fix works well. redrawing is certainly an answer; however, I do not understand what Windows is doing.

This isn't a fix. This is the answer.

jessedavis said...

Anytime something is moved the entire screen needs to be repainted. w32hpaint is never fired unless a portion of the app window (win) goes off screen and then only if moved back on the screen. As the window moves back onto the screen multiple w32Paint events are triggered, Each time a narrow band of the window is redrawn (added to the complete image). I assume that Windows silently repainting the entire screen as the screen buffer is updated. w32Paint is reconstructing the screen buffer a narrow band at the time as the app window moves back onto the screen - Windows then updates the entire screen every time the buffer changes..

Windows expects your application to know what it's doing when painting the window. Windows will not try to predict what you want to do. Most of the time you won't want Windows trying to perform these actions for you. So all Windows is going to do is tell you when and where to repaint. It will not hold a buffer for you. It will not redraw what you previously asked it to draw. This is the way the Win32 API is designed, so this is how your application should behave.

The correct solution is to use a buffer bitmap to hold your graphics and then copy that to the window whenever a repaint event is triggered. I've updated your example below.

--  code generated by Win32Lib IDE v1.0.4 Build July-06-2008 
 
constant TheProgramType="exw"  
  
include Win32lib.ew 
without warning 
 
constant win = createEx( Window, "DEMONSTRATION WINDOW", 0, Default, Default, 474, 326, 0, 0 ) 
constant pb_2 = createEx( PushButton, "QUIT", win, 20, 232, 124, 28, 0, 0 ) 
setFont( pb_2,"Arial",14,Normal+Bold) 
constant pb_1 = createEx( PushButton, "generate", win, 268, 232, 124, 28, 0, 0 ) 
setFont( pb_1,"Arial",14,Normal+Bold) 
 
integer buffer = 0 
 
-- copy the buffer to the screen 
procedure redrawBuffer() 
     
    if buffer then 
        copyBlt( win, 0, 0, buffer ) 
    end if 
     
end procedure 
 
-- create a new buffer of the correct size 
procedure updateBuffer( integer width, integer height ) 
     
    if buffer then 
        destroy( buffer ) 
    end if 
     
    buffer = createEx( Pixmap, "", win, 0, 0, width, height, 0, 0 ) 
     
    setFont (buffer, "Consolas",12,Normal) 
    wPuts({buffer,15,20},"Hello to the world, yet Again!") 
    wPuts({buffer,15,40},"Now that text is on screen grab Window") 
    wPuts({buffer,15,55},"Top bar & Move it so part of text") 
    wPuts({buffer,15,70},"Leaves the monitor (off the edge)") 
    wPuts({buffer,15,85},"Now, move it back to starting position.") 
    wPuts({buffer,15,120},"Notice vanishing text AND unaffected control...") 
     
end procedure 
 
procedure pb_2_onClick (integer self, integer event, sequence params) 
     
    closeApp() 
     
end procedure 
setHandler( pb_2, w32HClick, routine_id("pb_2_onClick")) 
 
procedure pb_1_onClick (integer self, integer event, sequence params) 
     
    sequence size = getClientSize( win ) 
     
    -- manually update the buffer 
    updateBuffer( size[3], size[4]-100 ) 
    redrawBuffer() 
     
end procedure 
setHandler( pb_1, w32HClick, routine_id("pb_1_onClick")) 
 
procedure win_onPaint (integer self, integer event, sequence params) 
     
    redrawBuffer() 
     
end procedure 
setHandler( win, w32HPaint, routine_id("win_onPaint")) 
 
procedure win_onResize (integer self, integer event, sequence params) 
     
    -- move the buttons around to keep them out of the text 
    setRect( pb_1, 20, params[3]-48, 124, 28, w32True ) 
    setRect( pb_2, params[2]-168, params[3]-48, 124, 28, w32True ) 
     
    -- update the buffer to the new window size 
    updateBuffer( params[2], params[3]-100 ) 
    redrawBuffer() 
     
end procedure 
setHandler( win, w32HResize, routine_id("win_onResize")) 
 
WinMain( win,Normal ) 

-Greg

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

11. Re: tiny little question about win32lib

GTK has a way to draw graphics (or controls) on an invisible offscreen window, which won't be affected when your program's window is moved or obscured. Then it's a matter of responding to the correct signals that happen when the window (or part of it) is un-obscured, or when the contents of the offscreen change. You "just" copy the contents to the real window.

I can say that, because I believe the GTK documentation. As for doing it myself - I'm just starting to figure it out. Might take a while.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu