LadyLong Posted January 27, 2005 Share Posted January 27, 2005 If I understand it correctly, WinGetClientSize should return the position on the desktop of the specified window in its first two parameters, right?I'm using SplashTextOn() to display a list of names on the user's screen. The text is pulled from a text file which updates from a database every nn minutes, so my script periodically refreshes the list onscreen to match. The size of the display window changes dynamically to fit its contents. That much is working fine.The problem is that I also want the user to be able to move the window to a different location on the desktop if desired. I'm using WinGetClientSize() to return the current location of the window before updating it so that it can (theoretically) be put back where the user left it.The problem is that no matter where the window happens to be on the desktop, WinGetClientSize is reporting that it's at X=216, Y=126 (or in that vicinity), while at the same time AutoItSpy is reporting the actual coordinates, for instance X=404, Y=321. So the window keeps popping over to (216, 126) when it gets resized.Can anyone tell me what I'm missing?If you want to wade through my code, here's the current iteration:expandcollapse popup;***Declarations Dim $fontface = "Arial", $fontsize = 9, $leading = 5 Dim $lineheight = $fontsize + $leading Dim $fontwidth = $fontsize * 0.8 Dim $title = "Recent Charts", $lastheight = 0, $lastwidth = 0 Dim $winpos[4] $winpos[0] = -1 $winpos[1] = -1 While 42 $line = "" $nextline = "" $height = $lineheight $width = StringLen($title) * $fontwidth ;***Open File and check for errors $file = FileOpen("test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ;***Read lines from file, adjust window dimensions if needed While 1 $nextline = FileReadLine($file) If @error = -1 Then ExitLoop $line = $line & $nextline & @LF $height = $height + $lineheight If $width < StringLen($nextline) * $fontwidth Then $width = StringLen($nextline) * $fontwidth EndIf Wend FileClose($file) If WinExists($title) Then $winpos = WinGetClientSize($title) Select ;***Update with resize Case $height <> $lastheight OR $width <> $lastwidth SplashTextOn($title, $line, $width, $height, $winpos[0], $winpos[1], 22, $fontface, $fontsize) ;***Update without resize Case Else ControlSetText($title, "", "Static1", $line) EndSelect MsgBox(0, "Coordinates", "X=" & $winpos[0] & " Y=" & $winpos[1]) $lastheight = $height $lastwidth = $width Sleep(8000);(short for testing) WEnd SplashOff()The test.txt file is just something like this:Engelbert Humperdink Fred Flintstone Laverne DeFazio Lucretia Borg BUSY Mary Poppins Pharquar P. Parkenfarker Richard Nixon Tom Cruise BUSYThis is a tool requested by a doctor I work for, so he can tell which electronic charts for the current day's patients are in use by another user and therefore locked for editing, and which are available so he can do his charting in them. Right now there's no way to know without just periodically opening the chart to see if it's free, which wastes a lot of his time. .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein Link to comment Share on other sites More sharing options...
MHz Posted January 27, 2005 Share Posted January 27, 2005 WinGetPos is what you want. Returns a 4-element array containing the following information: $array[0] = X position $array[1] = Y position $array[2] = Width $array[3] = Height WinGetClientSize gets the client size of a window. Not position. Link to comment Share on other sites More sharing options...
LadyLong Posted January 27, 2005 Author Share Posted January 27, 2005 WinGetPos is what you want.{snip}WinGetClientSize gets the client size of a window. Not position.Oh, duh. Maybe I should go to bed before I transpose any *more* function names. <sigh>Thanks for the quick reply! .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein Link to comment Share on other sites More sharing options...
MHz Posted January 27, 2005 Share Posted January 27, 2005 I am unsure fully of what you script actually will do, but... Consider having a good look at Control* functions. The position of the window may not be an issue for you, so long as it exists? Link to comment Share on other sites More sharing options...
LadyLong Posted January 27, 2005 Author Share Posted January 27, 2005 I am unsure fully of what you script actually will do, but...Actually the window position is an issue because the list it contains is dynamic, so the window is constantly being recreated. When that happens, it needs to be recreated where the user last left it, so as not to be annoying. Let me see if I can explain without writing a book. When a patient is seen in the office, an encounter is created in their electronic chart, and a minimum of three people will make one or more entries in it during the course of their visit -- the medical assistant does the patient's intake and vitals and records that information, then the doctor sees the patient and uses the exam room workstation to make notes and write instructions for referrals, order labs, generate prescriptions, etc. The MA does any in-house labs required and notes those in the chart, as well as any specimens to be sent out for analysis. Then the office assistant opens the chart to see what followup appointments need to be made, and to print out any prescriptions, etc. to give to the patient. And finally the doctor puts in his final chart notes and generates the billing and a letter to the patient's primary care physician (I work for a specialist). Then the office assistants open it again to print and fax the letter. (The billing, thank goodness, is transferred automatically to the billing software - I'd hate to have to mess with THAT!)It gets frustrating sometimes because only one person can edit a record at any given time, and you don't find out the chart is in use until you've actually selected and opened it. But the software runs off a MSSQL back end, so I poked around and found the fields that store the "in use" status of a chart, and created a stored procedure that generates a list of the current status of the charts for the day's patients. Then I created a job to run the stored procedure every 3 minutes during office hours, and write the list out to a file on the network. The final step was to find a way to display the list on an individual's desktop and have it automatically refresh every 3 minutes. Each person working on charts usually has several charts they need to work on, so this way they have a better idea which one they can actually get into at any given time. Hopefully it will eliminate some frustration and smooth the workflow a bit.And now that I got it working and emailed it to the doctor so he can test it, I really AM going to bed. Thanks again for your help! -LadyLong .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo"I came to realize that life lived to help others is the only one that matters. This is my highest and best use as a human." -- Ben Stein Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now