1. RE: What am I doing wrong?
- Posted by Brian Broker <bkb at cnw.com> Sep 29, 2003
- 470 views
Hi Louis, First, avoid using the onXXX method of handling events and definitely don't mix it with setHandler because setHandler will disable the onXXX method. You are correct in using the paint event to show your text... Unless you use a label control for your text, you will need to wPuts it every time you need to repaint the window. The following code works fine: -------------------- include win32lib.ew without warning constant -- Win32 Setup Win = create(Window, "Window Title", 0, {0.5,-150}, {0.5, -220}, 300, 220, 0), Done = create(PushButton, {"Exit","Close window and exit."}, Win, 150, 160, 60, 25, w32AUTOCLOSE) procedure onPaint_Win(integer self, integer event, sequence parms) wPuts(Win, "This is some text") end procedure setHandler(Win,w32HPaint,routine_id("onPaint_Win")) WinMain(Win, Normal) ---------------------------------------- -- alternatively, using a Label control... -- ---------------------------------------- include win32lib.ew without warning constant -- Win32 Setup Win = create(Window, "Window Title", 0, {0.5,-150}, {0.5, -220}, 300, 220, 0), Done = create(PushButton, {"Exit","Close window and exit."}, Win, 150, 160, 60, 25, w32AUTOCLOSE), Label = create(LText, "This is some text", Win, 5, 5, 80, 15, 0) WinMain(Win, Normal) -------------------- -- Brian Louis wrote: > > > Although an experienced programmer, I know nothing about Windows > programming except what is in the Win32Lib documentation. > > I am trying to put text into a window that also has a button in it. > This is my test program: > > constant -- Win32 Setup > Win = create(Window, "Window Title", 0, > {0.5,-150}, {0.5, -220}, 300, 220, 0) > > --constant > -- Done = create(PushButton, {"Exit","Close window and exit."}, > -- Win, 150, 160, 60, 25, w32AUTOCLOSE) > > procedure onPaint_Win(integer x1, integer y1, integer x2, integer y2) > wPuts(Win, "This is some text") > end procedure > > onPaint[Win] = routine_id("onPaint_Win") > > WinMain(Win, Normal) > > This displays the text OK, but if I uncomment the lines to create a > button, the text disappears. Why? > > I tried putting the wPuts in "Load_Win" which is called as: > > setHandler(Win, w32HActivate, routine_id("Load_Win")) > > And that worked, except if I minimize the window then bring it back, the > text is gone. Why? > > I tried changing "W32HActivate" to "W32HOpen", but that never worked at > all. Why? Because the window had not opened yet? > > Louis. > >
2. RE: What am I doing wrong?
- Posted by Louis at cwshop.com Sep 29, 2003
- 482 views
Thanks, Brian. I think your label control approach is cleaner. However, who would have= guessed that the words "Left-justified label control." means "Write text= into a window." I guess I need a secret decoder ring to understand this= documentation. Avoid the onXXX functions? I guess that is why the onPaint was left= undocumented, though it was mentioned in forPaint and it appears in an= example. Somehow, I get the idea that I need a Windows Programming reference.= Although it will probably be written for the C programmer, I suspect it= would be a great help to me. Any suggestions? Did O'Reilly publish a= Nutshell book? Louis. *********** REPLY SEPARATOR *********** On 9/29/2003 at 6:30 PM Brian Broker wrote: > > >Hi Louis, > >First, avoid using the onXXX method of handling events and definitely >don't mix it with setHandler because setHandler will disable the onXXX >method. > >You are correct in using the paint event to show your text... Unless >you use a label control for your text, you will need to wPuts it every >time you need to repaint the window. > >The following code works fine: >-------------------- >include win32lib.ew >without warning > >constant -- Win32 Setup > Win =3D create(Window, "Window Title", 0, {0.5,-150}, {0.5, -220}, 300,= >220, 0), > Done =3D create(PushButton, {"Exit","Close window and exit."}, Win, >150, 160, 60, 25, w32AUTOCLOSE) > >procedure onPaint_Win(integer self, integer event, sequence parms) > wPuts(Win, "This is some text") >end procedure >setHandler(Win,w32HPaint,routine_id("onPaint_Win")) > >WinMain(Win, Normal) >include win32lib.ew >without warning > >constant -- Win32 Setup > Win =3D create(Window, "Window Title", 0, {0.5,-150}, {0.5, -220}, 300,= >220, 0), > Done =3D create(PushButton, {"Exit","Close window and exit."}, Win, >150, 160, 60, 25, w32AUTOCLOSE), > Label =3D create(LText, "This is some text", Win, 5, 5, 80, 15, 0) > >WinMain(Win, Normal) >-------------------- >-- Brian