Page 1 of 1

[Solved] Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 9:07 am
by Michael Vogel
I'd like to set the position of a window before unhiding it, but this doesn't seem to be possible. Is this correct?

Re: Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 9:20 am
by RSBasic
What do you mean exactly?

Code: Select all

EnableExplicit

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_Invisible)
  ResizeWindow(0, 100, 100, #PB_Ignore, #PB_Ignore)
  HideWindow(0, 0)
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf

Re: Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 12:02 pm
by Michael Vogel
Good question, I've updated a source code* yesterday and saw, that the - more or less - empty window will be displayed immediate after the WinResize command and it takes some moments (my program fills some gadgets with contents etc.) before the window should be seen (by the command HideWindow).

I tried a lot of things (SetWindowPos,...) but nothing has changed. Implemented some other ideas today in the morning, no change. I took my notebook to my work, another try, same result - so I had to ask the experts :wink:

Now back home, I checked your example, it works fine :shock:
My source code from yesterday? The compiled exe from yesterday? Everything works as expected.

I did not make any reboot nor I opened or closed any programs on my notebook, I have no idea why it didn't work for many hours and now everything has changed. I will add [Solved] the topic name even when this miracle will never be solved.

Code: Select all

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_Invisible)
	ResizeWindow(0, 100, 100, 200,200)
	;SetWindowPos_(WnidowID(0),#HWND_NOTOPMOST,100,100,200,200,#SWP_NOREDRAW)
	Debug "hidden ?"
	Delay(1000)
	HideWindow(0, 0)
	Debug "visible"

	Repeat
		Select WaitWindowEvent()
		Case #PB_Event_CloseWindow
			End
		EndSelect
	ForEver
EndIf
___
*) if you are curious, here's the program I was working on: SpeedRename (german only)

Re: [Solved] Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 6:25 pm
by VB6_to_PBx

Code: Select all

;SetWindowPos_(WnidowID(0),#HWND_NOTOPMOST,100,100,200,200,#SWP_NOREDRAW)
you had WnidowID misspelled ...WindowID

Code: Select all

   SetWindowPos_(WindowID(0),#HWND_NOTOPMOST,100,100,200,200,#SWP_NOREDRAW)

Re: [Solved] Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 7:11 pm
by Michael Vogel
Yes, that happens, when you don't do copy and paste - in the original code there was no typo :lol:

Re: Resize and move window before unhiding?

Posted: Tue Apr 10, 2018 9:02 pm
by Dude
Michael Vogel wrote:I will add [Solved] the topic name even when this miracle will never be solved.
You can definitely resize and move a window before unhiding it, yes. I've been doing it for years.

Re: [Solved] Resize and move window before unhiding?

Posted: Wed Apr 11, 2018 5:58 am
by Michael Vogel
Yes, indeed.

Still have no idea, why windows has changed it's behaviour for some hours?! The result was a really ugly effect and made me extremly nervous. In my panik I even thought to create a thread to do the resizing with a delay... :oops: