1. What am I doing wrong?
- Posted by Louis at cwshop.com Sep 29, 2003
- 640 views
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 =3D create(Window, "Window Title", 0, {0.5,-150}, {0.5, -220}, 300, 220, 0) --constant -- Done =3D 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] =3D 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 Virtual B <behaviorself at netzero.net> Sep 29, 2003
- 605 views
Hi Louis, I'm not sure about why this is happening, and I don't have time right now to check into it. But if you just want to put text into a window you might want to consider putting an LText where you want the text, and then use setText() to add your text. I'm not sure if this is the "proper" way to do what you want to do, but it works fine for me. Virtual B ----- Original Message ----- From: <Louis at cwshop.com> Subject: What am I doing wrong? > > > 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. > > --^---------------------------------------------------------------- > This email was sent to: behaviorself at netzero.net > > > TOPICA - Start your own email discussion group. FREE! > >
3. Re: What am I doing wrong?
- Posted by Elliott Sales de Andrade <quantum_analyst at hotmail.com> Sep 29, 2003
- 581 views
The problem is, you are mixing setHandler() and the onXXX events. Any use of setHandler() turns off the onXXX events. I think adding a tooltip to the button might indirectly call setHandler(). Either way, you should be using setHandler and not onXXX. onXXX events are deprecated. Your code should be re-written like this: include win32lib.ew 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 self, integer event, sequence params) --params is {x1, y1, x2, y2} wPuts(Win, "This is some text") end procedure setHandler(Win, w32HPaint, routine_id("onPaint_Win")) WinMain(Win, Normal) >From: Louis at cwshop.com >Reply-To: EUforum at topica.com >To: EUforum <EUforum at topica.com> >Subject: What am I doing wrong? >Date: Mon, 29 Sep 2003 13:24:48 -0400 > > >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. > > > >TOPICA - Start your own email discussion group. FREE! > >
4. Re: What am I doing wrong?
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 29, 2003
- 674 views
----- Original Message ----- From: <Louis at cwshop.com> To: "EUforum" <EUforum at topica.com> Subject: What am I doing wrong? > > > Although an experienced programmer, I know nothing about Windows programming > except what is in the Win32Lib documentation. Yes, well.... Those docs can do with a bit of 'rounding out' I suppose> 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? The other comments regarding this are all correct. My advice would be to use the LText control if you have static text to display. Just to tantalize you, in the next release of win32lib, you will be able to code your test program thus ... createForm ({ "Window, Window Title, left=Center, top=Center," & "width=300, height=220", "Text,This is some text", "Button, Exit, tooltip=Close window and exit," & "left=150, top=160,flag=AUTOCLOSE" }) startApp(w32NoCallBack) The documentation is almost completed for the next release, and some testing is still to be completed. -- Derek