Scale thumbnail clone to always fit GUI Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Scale thumbnail clone to always fit GUI

19 May 2017, 10:27

I have been finding it very tricky scaling these thumbnails to always fit inside gui. Even when source gets resized. Also trying to keep aspect ratio since source is a TV app. I think coco has a script dealing with this but its very advanced and Im having a hard time to follow what is happening. Perhaps someone out there has experience with this before? The hardest parts with GUI stuff is positioning, no contest about that.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 12:57

Hi, zcooler.
I'm not really getting the issue, your gui seems to have the same aspect ratio as the source window, do you mean that you want to force resize of gui to keep ratio and still have thumbnail covering the gui?
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 14:00

Sorry, I was in a hurry writing that :oops:
Helgef wrote:Hi, zcooler.
I'm not really getting the issue, your gui seems to have the same aspect ratio as the source window, do you mean that you want to force resize of gui to keep ratio and still have thumbnail covering the gui?
Exactly spot on what Im after and the only way I can accomplish this effect is with Transparency and Transcolor, but since the thumbnail has clickable features I can not use that method because of the click fall-through. Havent found any working method to toggle that off.
Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 14:15

Ok, I don't get the connection to transparency though. I think you have most of what you need, you just need to put it together in the resize routine.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 14:28

Helgef wrote:Ok, I don't get the connection to transparency though.
Oh. crap...yeah I was in a hurry as said :oops: This is not my live script, in that im having a text control (to catch the mouse clicks) which im making transparent, which makes resizing the Gui obsolete. Thumb appears perfectly each time but its an illusion of course, which I cant use.

Helgef wrote:I think you have most of what you need, you just need to put it together in the resize routine.
Ok, I will go over it again.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 16:40

Helgef wrote:I think you have most of what you need, you just need to put it together in the resize routine.
No, this is simply not possible! I think you will have to bring your A-game solving this. As I see it windowWidth and windowHeight is not the Width and Height for the actual Thumbnail. It is the Width and Height for the Toolwindow. Thumbnail size and Toolwindow size does almost never correlate. I believe I need to be abled to query the thumbnail size in order to size the Toolwindow correctly and accordingly, but query the Thumbnail size is not possible with these thumbnail functions (only source window).

If I am mistaken please would you be so kind to show me how you would go about with it. If Im right an additional function is needed where its possible to Thumbnail_GetTargetSize() (which unfortunately isnt an option reading the MSDN)

Also I will not be using any hotkeys or manual mouse resizing like the base script does (the full version of it). This must work upon first call.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

19 May 2017, 17:47

This is the coco script and he seems to be using ThumbPosGrid() to achive the thumbnail always correlate with toolwindow effect, but I cant get that to work when trying it though.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI  Topic is solved

19 May 2017, 17:51

Also I will not be using any hotkeys or manual mouse resizing like the base script does (the full version of it). This must work upon first call.

That just makes it easier I guess. Maybe somthing like this would do it.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


That is, call f() whenever you want to update the thumbnail window.

Edit: I'm not interested enough to look at all that code ;)
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 02:15

Helgef wrote:Edit: I'm not interested enough to look at all that code ;)
Yes, I figured you didnt test it. FYI
it goes wrong here:

WinGetPos,,, windowWidth, windowHeight, % "ahk_id " hDestination
msgbox % "W= " windowWidth "`nH= " windowHeight


windowWidth and windowHeight are empty and everything fails from there.
Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 04:57

If they are empty the handle to the destination window is invalid.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 05:18

@Helgef
After more testing I was abled to get it working. Had to apply some more padding to it. However there are still slim lines of Toolwindow showing at left, bottom and right border when resizing source to odd resolutions. Your solution is not perfect, but surley the best one out there so far. Many thanks for the lesson :wave:
Best regards
zcooler

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 13:11

I didn't see any such problems in my brief testing. Do not have that particular software though. One thing you could do, is to only use the client area of the source for the thumbnail. There is a flag to set in some of the functions handling the thumbnail properties, if I recall correctly. It might look better, it might also cause further inconvenience :lol: . You mentiond it being for some video/tv display, the ratio of the window might not be the same as that of the client area, which I would guess is only showing the video. Cheers.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 15:31

Helgef wrote:One thing you could do, is to only use the client area of the source for the thumbnail. There is a flag to set in some of the functions handling the thumbnail properties, if I recall correctly. It might look better, it might also cause further inconvenience :lol:
Very interesting lead there :) I applied the fSourceClientAreaOnly flag and removed my paddings and I actually get perfect aligning on the left side, but bottom and right are more spacious compared to before. Hmm...I wonder how I can get it perfect for bottom and right? Are there more fSourceClientAreaOnly NumGet dskThumbProps numbers to set to get it right all around?

Code: [Select all] [Download] GeSHi © Codebox Plus

Thumbnail_Show(hThumb) {
static dwFlags := 0x00000008 | 0x00000010, fVisible := 1, fSourceClientAreaOnly := 1

VarSetCapacity(dskThumbProps, 45, 0)
NumPut(dwFlags, dskThumbProps, 0, "UInt")
NumPut(fVisible, dskThumbProps, 37, "Int")
NumPut(fSourceClientAreaOnly, dskThumbProps, 41, "Int")

return DllCall("dwmapi.dll\DwmUpdateThumbnailProperties", "UInt", hThumb, "UInt", &dskThumbProps) ? false : true
}


Helgef wrote:You mentiond it being for some video/tv display, the ratio of the window might not be the same as that of the client area, which I would guess is only showing the video. Cheers.
Yes, the ratio of the TV app window is not the same as client area (when set oddly) but the ratio calculations handles it surpringsingly well. Im trying to keep the source at 16:9 ratio though. No, client area displays whole TV app window with title/statusbar and borders.
Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 15:54

No other flags related to that as far as I know. You might want to swap WinGetPos, RegionX, RegionY, RegionW, RegionH, ahk_class TfrmMain for GetClientRect(hSource,RegionW, RegionH) though. And make sure hSource is defined when calling GetClientRect, hSouce is currently assigned after the WinGetPoscall. Note, RegionX/Y aren't used so they can be omitted.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 16:49

Helgef wrote:No other flags related to that as far as I know. You might want to swap WinGetPos, RegionX, RegionY, RegionW, RegionH, ahk_class TfrmMain for GetClientRect(hSource,RegionW, RegionH) though. And make sure hSource is defined when calling GetClientRect, hSouce is currently assigned after the WinGetPoscall. Note, RegionX/Y aren't used so they can be omitted.
Oh la la...we are getting close now :mrgreen: These instructions fixed the right aligning which is spot on now. Thanks Helgef :D The remaining problem is the bottom part...much too spacious hmm :?
Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 16:55

zcooler wrote: hmm :?

Indeed :cry:
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 17:06

Must be something with the ratio calculations. I will go over it tomorrow. Many thanks for your support :wave:
Helgef
Posts: 2076
Joined: 17 Jul 2016, 01:02
Contact:

Re: Scale thumbnail clone to always fit GUI

20 May 2017, 17:32

Before I realised you didn't consider the manual (mouse drag) resizing of the gui, I wrote this, I do observe some of the right and bottom missing from the source thumbnail when the gui gets smaller.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


Make sure the OnMessage gets called, then the gui should scale when resized. Note, dw, dh isn't in this one, not sure they should though.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], eagerahk, liij, Rohwedder and 60 guests