Re: Dialog wanders when shown repeatedly

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tony Bohm wrote:
> 
> --Great first posting, huh?  Didn't mean to hit Send Now, previously.  Sorry
> for the incomplete post + double posting :(
> 
> Hello ;D  I'm trying to get into programming again after a very long hiatus,
> and am running into a problem too simple to wrap my head around XD
> 
> I've defined two windows with the create() function; one of which is intended
> to be the main window, and the other will be called in a button-click handler
> as the need arises.  Depending on the button clicked, setText is used to give
> this secondary window the appropriate title (works OK), and a text label is
> created to show whatever text is appropriate (works OK).  But, this window
> doesn't appear in a consistant (x,y) location relative to the screen corners
> or the primary window, and appears farther up (and usually, but not always,
> farther to the left) relative to its prior position every time it's shown
> after the first time it's displayed during a program run.
> 
> My code looks like this:
> 
> include win32lib.ew
> without warning
> 
> --Main program window
> constant MainWin = create(Window, "etS beta 0.0", 0, Default, Default, 100,
> 100, {WS_DLGFRAME, WS_SYSMENU, WS_MINIMIZEBOX})
> --Secondary message window/dialogue
> constant MsgWin = create(Window, "", MainWin, 200, 200, 100, 100,
> {WS_DLGFRAME,
> WS_SYSMENU})
> 
> --Button click handler
> procedure ButClick(integer self, integer event, sequence parms)
> 	atom hTemp
> 
> 	if self=hHistBut then
> 		setClientRect(MsgWin, 150, 150)
> 		setText(MsgWin, "History..")
> 		hTemp = create(CText, "Blahblahblah", MsgWin, 0, 0, 150, 150, 0)
> 		openDialog(MsgWin)
> 	elsif self=hAboutBut then
> 		setClientRect(MsgWin, 150, 150)
> 		setText(MsgWin, "About")
> 		hTemp = create(CText, "Blarghblargh", MsgWin, 0, 0, 150, 150, 0)
> 		openDialog(MsgWin)
> 	end if
> 
>         destroy(hTemp)
> end procedure
> 
> global procedure IntroScreen()
> 	atom hSplash, hTrim
> 
> 	hSplash = create(Bitmap, ImageSource & "starmap.bmp", MainWin, 0, 0, 668,
> 546, 0)
> 	hTrim = create(Bitmap, ImageSource & "startrim.bmp", MainWin, 668, 0, 60,
> 486, 0)
> 	hStoryBut = create(PictureButton, {"", "History"}, MainWin, 668, 486, 60, 30,
> ImageSource & "storybut.bmp")
> 	hAboutBut = create(PictureButton, {"", "About"}, MainWin, 668, 516, 60, 30,
> ImageSource
> & "aboutbut.bmp")
> 	setHandler({hHistBut, hAboutBut}, w32HClick, routine_id("ButClick"))
> 	setFocus(hStoryBut)
> end procedure
> 
> global procedure main()
> 	setClientRect(MainWin, 728, 546)
> 	IntroScreen()
> end procedure

Problem confirmed. This appears to be a very old bug.
Around line 19063 in win32lib.ew, find this line
posn = getPosition( id )

and change it to read
posn =
        getWindowInfo(id,{{WINDOWINFO_CRect,rectLeft},{WINDOWINFO_CRect,rectTop}})

The call to setClientRect() are redundant, but shouldn't cause the effect you
just reported. Fix will be in 70.4.

CChris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu