Author Topic: How move Message window or Pause Window?  (Read 267 times)

pguild

  • Newbie
  • *
  • Posts: 43
  • The dog is always right!
    • MasteryLearning
How move Message window or Pause Window?
« on: April 24, 2021, 11:10:18 pm »
GRR! Third time trying to post this question.  >:(
How can I move the window created by the pause command or the message command?
If not possible is there a workaround?

kdmoyers

  • Sr. Member
  • ****
  • Posts: 411
Re: How move Message window or Pause Window?
« Reply #1 on: April 25, 2021, 09:15:07 am »
If your need is just functional, not cosmetic, then this is a cheap hack:
Code: Winbatch
  #definefunction askmessage(x,y,width,height,title,mess)

    ; this controls placement of certain AskXxxx functions
    intcontrol(63, x, y, x+width, y+height)

    AskTextBox( title, "", mess, 2, 0)

  #endfunction

  message("hey","there")

  askmessage(110,110,400,400,"hey","there")
The mind is everything; What you think, you become.

td

  • Tech Support
  • *****
  • Posts: 3752
    • WinBatch
Re: How move Message window or Pause Window?
« Reply #2 on: April 26, 2021, 06:59:07 am »
Or if you don't mind a little more work you could use the WIL Dialog function to create your own message box.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

kdmoyers

  • Sr. Member
  • ****
  • Posts: 411
Re: How move Message window or Pause Window?
« Reply #3 on: April 26, 2021, 09:07:49 am »
Attached is a cool bunch of code that demonstrates a number of techniques for making specialized message boxes.

it contains these functions:
Code: Winbatch
#DEFINESUBROUTINE MessageUdfProc(dlgMessageUdfHandle,dlgMessageUdfEvent,dlgMessageUdfEventControlID,dlgMessageUdfParam4,dlgMessageUdfParam5)

#DEFINEFUNCTION udfMessage(Title,Text,TextJust,Timeout,Buttons,PositionBox)

 
The mind is everything; What you think, you become.

cssyphus

  • Newbie
  • *
  • Posts: 35
Re: How move Message window or Pause Window?
« Reply #4 on: May 18, 2021, 09:10:32 am »
In addition to Sean Dorn's udfMessage() function that Kirby posted, do not miss IFICantBYTE's Rube-Goldberg-All-In-One-Super-Fragalistic Message Box, here:
https://forum.winbatch.com/index.php?topic=1556.0


It is also nice to know about this simple WSH messagebox implementation (although it doesn't help with repositioning the dialog window):

Code: [Select]
#DefineFunction udfWSHMessage(Timeout,TitleText,MessageText,DisplayFlags) ;-------------------
    oWSHShell = ObjectCreate("WScript.Shell")
    Ret = oWSHShell.popup(MessageText,Timeout,TitleText,DisplayFlags)
    oWSHShell = 0
    Return(Ret)

    ;EXAMPLES:
    ;Test1 = udfWSHMessage(5,"Test 1","5 second timeout with STOP icon and OK button.",16)
    ;Test2 = udfWSHMessage(7,"Test 2","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
    ;Test3 = udfWSHMessage(8,"Test 3","8 second timeout with EXCLAMATION icon and ABORT RETRY IGNORE buttons. IGNORE has been made the DEFAULT option.",48|2|512)
    ;Test4 = udfWSHMessage(4,"Test 4","4 second timeout with NO icon and just an OK button.",0)
    ;0==OK, 1==OK|Cancel, 2==Abort|Retry|Ignore, 4==Yes|No, 8==nothing, 16==RedX, 32==?mark, 64==info, 128==blank spot, 256==noIcon
    ;timeout= -1, OK==1, Cancel==2, abort==3, retry==4, yes==6, no==7
#EndFunction ;udfWSHMessage ------------------------------------------------------------------
Test2 = udfWSHMessage(7,"My Dlg Title","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
   

I would have thought that this would work, but sadly no:

Code: [Select]
Test2 = udfWSHMessage(7,"My Dlg Title","7 second timeout with QUESTION MARK icon and OK and CANCEL buttons.",32|1)
winPlace(50,50,100,300,`My Dlg Title`)

But the 20 minutes that you spend experimenting with IFICantBYTE's and Sean Dorn's udfMessage() functions will pay many future dividends.

rw_baker

  • Newbie
  • *
  • Posts: 24
Re: How move Message window or Pause Window?
« Reply #5 on: May 20, 2021, 10:02:20 am »
Place the bare-bones script below on the Desktop and run with:

run("C:\Users\user\Desktop\bare bones.WBT","'try it' 30 173 159 338")
pause("try it","")

;
win_title = param1
ok = WinWaitExist(win_title,3)
terminate(!ok,"Window did not show!",param1)
for i = 1 to 4
   j = i + 1
   coord%i% = param%j%
next
WinPlace(coord1,coord2,coord3,coord4,win_title)
exit
;
Generalize the script by using "WinPlaceGet" to find the original coordinates, adjust these to get the target
location and use "WinPlace" to finish.


RW Baker

cssyphus

  • Newbie
  • *
  • Posts: 35
Re: How move Message window or Pause Window?
« Reply #6 on: May 21, 2021, 08:57:26 am »
That's an interesting demo, RW, and it does work as advertised -- but it requires an external script to reposition the message() or pause() dialogs, which is not strictly what is being asked.

On the other hand, your example proves that one could spawn such an external app -- it needn't even pre-exist (one could filePut() it into existence, run() it, and fileDelete() it when done) -- and solve the problem that way.

Good idea, sir.

rw_baker

  • Newbie
  • *
  • Posts: 24
Re: How move Message window or Pause Window?
« Reply #7 on: May 21, 2021, 07:24:33 pm »
Thanks for your comments.  I have used the full script for many years, it is stored in my utilities directory.  The following gives the full script's comments and an example of its use:

;Script: Delayed WinPlace.WBT - A script to move a window on the screen.
;  param1:  is the partial window title.
;  param2:  if it has the format x-ulc,y-ulc,x-brc,y-brc then the window is moved to these coordinates,
;           example: 100,200,300,400
;           if its first character is + or - then the format should be: +/-xdisp,+/-ydisp, example: +100,-100
;           this example would move the window x-coord right 100 units and the y coord up 100 units.
;           In this format the window always remains the same size.

; Sample run to move the message window right 100 and up 100 units:
run("F:\WBT\Utilities\Delayed WinPlace.WBT",'"a test" +100,-100')
message("a test","")
exit

RW Baker