Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Resize Controls on GUI, even procentual


  • Please log in to reply
25 replies to this topic
Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi,
sorry to boring you, but I have a new dll for AHK again :lol:

If you want to resize controls on a GUI, please have a look at the sample.

That is a simple GUI window.
Posted Image

If you want to enter long texts, it's better if the window is bigger. Thus, resize it and look at the result

Posted Image

You can specify, that controls will resize at factor of 1-0.001.
I.e. you can use it, if you have 4 editcontrols side by side and want that each will resize equally.
Use a factor of 0.25 for each control and they will grow equally.

Here's the DLL:
https://ahknet.autoh...sizeSupport.dll
Here's the Script:
https://ahknet.autoh...izeCtrlDemo.ahk

If you have problems to get the dll working, you will need new MS-Dlls (mfc80.dll, msvcr80.dll) please download the 2 Archives, unpack them and start the vcredist_x86.exe. It will install the needed dlls
https://ahknet.autoh...6.sfx.part1.exe
https://ahknet.autoh...6.sfx.part2.rar
There's a uploadlimit of 2 MB, thus I had to split the Archives

Have fun
Micha

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
I forgot to mention how to use it:
CtrlHWnd := GetChildHWND(WinID, "Button1")
nRC := DllCall("AHKResizeSupport\AddControl", DWORD, CtrlHWnd, int, 2, int, 1, int, 1, double, 0.5, double, 0.5, "Cdecl Int")

First you have to get the HWND of the Control. You will get it with the snippet of the help (look at the bottom of this message)

AddControl:
CtrlHWND: hwnd of the control
first int:

0 = no resize
1 = don't change the width
2 = dock left and stay there
3= stay left and don't resize
4 = Dock right
5 = dock right and don't resize
6 = dock left and right and change width


second int: Same as first int, but for the height

third int: Try to resize flickerfree. Controls within a static border can't be resized that way, because the bordercontrol would overdraw them. If you have a Static border (groupborder), use 0 as parameter for the border and the controls within

double 1&2: Resize by factor. 0.5 = 50%, 0.25 = 25%

Best tip: Try and fail :wink:


GetChildHWND(ParentHWND, ChildClassNN)
{
WinGetPos, ParentX, ParentY,,, ahk_id %ParentHWND%
if ParentX =
	return  ; Parent window not found (possibly due to DetectHiddenWindows).
ControlGetPos, ChildX, ChildY,,, %ChildClassNN%, ahk_id %ParentHWND%
if ChildX =
   return  ; Child window not found, so return a blank value.
return DllCall("WindowFromPoint", "int", ChildX + ParentX, "int", ChildY + ParentY)
}


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Looks like a very cool effect. As you said, this could be the inspiration for building in some similar feature someday.

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005

Best tip: Try and fail :wink:

I tried and failed ^^
I can not register the dlls where I have put them in or in system32 of XP. So I always get an error at starting the demo-applikation:

---------------------------
ResizeControlDemo.ahk
---------------------------
error while calling SetDlgParameters Errorlevel: -3
---------------------------
OK
---------------------------


The error-message on registering the dll is only in german available (something with wrong application-data). Also downloading the zip did not help me.

Maybe you could give me some tipps how to use it? Because this would be exactly what I need for a problem of mine with DPI!

Would be great!
Thx,
Thalon

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
Hi Thalon,

thanks for the info. I've tried to run it on a clean PC and failed with the same error.

The offline test with dependencywalker shows no error but when profiling AHK it says

00:00:00.581: Loaded "c:\dokumente und einstellungen\name\desktop\AHKRESIZESUPPORT.DLL" at address 0x10000000 by thread 1. Successfully hooked module.
00:00:00.591: LDR: LdrpWalkImportDescriptor() failed to probe C:\Dokumente und Einstellungen\Silke\Desktop\AHKResizeSupport.dll for its manifest, ntstatus 0xc0150002

and it wasn't able to load the MFC-Dlls

After breakfast I will immediately search the problem

Ciao
Micha

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
I've updated the links from the 1. post. Please download the VCREDIST-files, unpack them and start the vcredist_x86.exe. It will install the MFC-Files you need.
Sorry for any inconvenience.

Ciao
Micha

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
Now it works great!
Doesn't matter that it took a bit longer, I am still @ work ;)

Thalon

kapege.de
  • Members
  • 192 posts
  • Last active: Jan 16 2012 12:34 PM
  • Joined: 07 Feb 2005
I'm @ work @ the moment (with w2000). Is your DLL also running with w98?
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
I'm @ home (vacation) :p

I've installed W98 under VMWare. It's working 80% :?

The 2 editcontrols at the bottom aren't resizing at all.
Funny behavior. All other controls on the demoscript are working well.

Is it very important for you to get it work on W98?
(I'm not very enthusiastic to debug a dll remote under VMware :wink: )

Ciao
Micha

kapege.de
  • Members
  • 192 posts
  • Last active: Jan 16 2012 12:34 PM
  • Joined: 07 Feb 2005

Is it very important for you to get it work on W98?

Therefore my compi has only w98 it would be great. (Never change a running system.)
Could not test it yesterday. I'll try it today.
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)

kapege.de
  • Members
  • 192 posts
  • Last active: Jan 16 2012 12:34 PM
  • Joined: 07 Feb 2005
Now I'm @ home w/ Win98 aaaand:

It's working perfect!

Esp.: Your sample script works as it should. Thanks!

The only problem I see is: When I'm going to distribute a program with your DLL it's difficult to explain to others that they have to install that 2,6 MB large vcredist_x86.exe first.
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)

  • Guests
  • Last active:
  • Joined: --
@kapege

The only problem I see is: When I'm going to distribute a program with your DLL it's difficult to explain to others that they have to install that 2,6 MB large vcredist_x86.exe first.


I understand this. Most people have the "old" files already on their system (installed by other software). Thus compiling with an older compiler would help. If the files weren't installed by other software, they have to install the old 2 MB large redistributables from microsoft.

The redistributables are needed whether the old or the new ones.

It's only a matter of time, when almost all will have the new dlls on their system.

Ciao
Micha

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
You could use FileInstall and RunWait the exe within the program, so that the user doesn't have to do anything. You could use an INI file to remember the state, or just check if the DLLs/INI exist, if not, the software wasn't installed yet.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Thalon
  • Members
  • 641 posts
  • Last active: Jan 02 2017 12:17 PM
  • Joined: 12 Jul 2005
I would give a info at download-page that it might be necessary to install an environment-package.
The size of this exe is the only reason why I do not want to use this great feature at the moment..

Thalon

Micha
  • Members
  • 539 posts
  • Last active: Dec 31 2011 01:43 PM
  • Joined: 15 Nov 2005
@Thalon
**sigh**
I'll see.

I've deleted > 2GB files to make space for an Image to install VC7 again.
Installed the old compiler and created "old" VCprojs.

The compiled DLL waits for your download there:
https://ahknet.autoh...eSupportVC7.dll

Please rename the dll (*tVC7.dll -> *t.dll) or adjust the callings in your script.

But I will not keep both dlls up2date. All bugfixing and enhancments will only be included in the new dll.
Perhaps from time to time, I will update the old dll, but not as fast as the new one

Hope that helps :-)
Ciao
Micha