(solved) AutoXYWH function - Y axis Resize bug [cause Tab3] Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

(solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

15 Sep 2018, 09:39

Hi guys,

I'm creating a Calculation table in a GUI and placing buttons where they need to be.
Then I use Auto XYWH function to act upon GUI SIZE: gLabel.

Problem is: When I have controls assigned to be positionned according to these two parameters: x + y, Resizing the GUI only Horizontally without touching the Y will drop the controls down and get out of the GUI window by a few pixels. The only it wont do it is to not make them affected by the Y resizing but I need it...

Any idea what in the function would be causing this issue?
PS: please tell me if need more precision on the context and script thanks

Thanks :)
Last edited by DRocks on 22 Oct 2018, 05:49, edited 3 times in total.
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: Auto XYWH function (x0.5 + y0.8) bugs Y axis Resizing

15 Sep 2018, 12:14

I can't reproduce the bug.

Code: Select all

Gui, +Resize
Gui, Margin, 100
Loop, 4
{
	Gui, Add, Text, xm, % "Key" A_Index
	Gui, Add, Text, x+100, % "Value" A_Index
}
Gui, Add, Button, xm w160, Test
Gui, Show
Return

GuiSize:
	AutoXYWH("x0.5 y0.8", "Static1", "Static2", "Static3", "Static4", "Static5", "Static6", "Static7", "Static8", "Button1")
return

GuiClose:
ExitApp
Could you post an example code?
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: Auto XYWH function (x0.5 + y0.8) bugs Y axis Resizing

15 Sep 2018, 12:27

Thanks for your reply!!
Ill do this and edit post :)

EDIT: I'm very sorry but I can't break down the gui because all variables are interdependant.
Before editing post I tried lots of other possibilities and nothing fixed it.

But you're perfectly right that your script example can't reproduce the bug! So its interesting.



heres is the overwelming script: seriously im sorry to have to post it all

- the function autoXYWH is at line 533
- the portion of the GUI that moves on Y incorrectly is between line 224-251
- the GuiSize Label is between 393-420 (where I call AutoXYWH
- The exact problematic lines is at 416

Code: Select all

#SingleInstance Force
#NoEnv
SendMode Input
SetTitleMatchMode, RegEx
SetWorkingDir %A_ScriptDir%
SetWinDelay, 80 ;100MS DEFAULT
SetControlDelay, -1 ; 20MS DEFAULT
SetMouseDelay, 10 ;-1 ; 10MS DEFAULT
SetDefaultMouseSpeed, 0 ; DEFAULT IS 2
ListLines, Off
;SetBatchLines, -1


;#[1.1-GUI Settings]
;=============================================================================================================================================
; Gui Dimensions related to user Screen
;=============================================================================================================================================
;SysGet, VirtualWidth, 16
;SysGet, VirtualHeight, 17
;GUI_WIDTH:= VirtualWidth * 0.55, GUI_HEIGHT:= VirtualHeight * 0.55 ; LARGER DEPENDING ON SCREEN WORKSPACE
GUI_WIDTH:= 854, GUI_HEIGHT:= 540 ; SMALL standard definition ~720p



;=============================================================================================================================================
; GUI Positionning Variables
;=============================================================================================================================================
GUI_X1_LEFT_ATTACH:= 7, GUI_Y1_TOP_ATTACH:= 40, GUI_X2_RIGHT_ATTACH:= GUI_WIDTH - 7, GUI_Y2_BOTTOM_ATTACH:= GUI_HEIGHT - 11, GUI_TEXT_H:=16, GUI_EDIT_H:=21, GUI_LINE_X:= 2, GUI_LINE_Y:= 20, GUI_LINE_W:= GUI_WIDTH-3, GUI_LINE_H:= 7, GUI_SPACER_X:= 5, GUI_SPACER_TABS:= 122, GUI_BUTTON_Y_TOP:=GUI_Y1_TOP_ATTACH - 5, GUI_BUTTON_Y_BOTTOM:=GUI_Y2_BOTTOM_ATTACH + 4, GUI_SEPARATORS_WIDTH:= GUI_WIDTH-1


Gui +Resize +MinSize%GUI_WIDTH%x%GUI_HEIGHT% +MaxSize%VirtualWidth%x%VirtualHeight% ;-Border -Caption -SysMenu +ToolWindow -MaximizeBox -MinimizeBox ; SETTINGS
;Gui Color, FFF5F5 ; rouge pale


;/*
;=============================================================================================================================================
;#[1.2-GUI OVERLAY TABS]
;=============================================================================================================================================
;=============================================================================================================================================
;TAB REVENUS
;=============================================================================================================================================
Gui, Add, Picture, vGUI_BACKGROUND_TAB_REVENUS_Unselected gGUI_BACKGROUND_TAB_REVENUS 	x0 y4 h21 BackgroundTrans, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_Unselected.png
Gui, Add, Picture, vGUI_BACKGROUND_TAB_REVENUS_LINE gGUI_BACKGROUND_TAB_REVENUS 		x%GUI_LINE_X% y%GUI_LINE_Y% w%GUI_LINE_W% h%GUI_LINE_H%, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_REVENUS_LINE.jpg ; hidden by the next picture
Gui, Add, Picture, vGUI_BACKGROUND_TAB_REVENUS gGUI_BACKGROUND_TAB_REVENUS 			x-1 y1 W135 h25, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_REVENUS.png
Gui Font, s12 bold q5
GUI_TEXT_TAB_REVENUS_X:= 21, GUI_TEXT_TAB_REVENUS_Y:= 3
Gui Add, Text, vGUI_TEXT_TAB_REVENUS gGUI_BACKGROUND_TAB_REVENUS 					x%GUI_TEXT_TAB_REVENUS_X% y%GUI_TEXT_TAB_REVENUS_Y% h%GUI_TEXT_H% BackgroundTrans, REVENUS 
Gui Font
;=============================================================================================================================================
;TAB DÉPENSES
;=============================================================================================================================================
Gui, Add, Picture, vGUI_BACKGROUND_TAB_DEPENSES_Unselected gGUI_BACKGROUND_TAB_DEPENSES 	x%GUI_SPACER_TABS% y4 h21 BackgroundTrans, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_Unselected.png ;hidden by the next picture
Gui, Add, Picture, +hidden vGUI_BACKGROUND_TAB_DEPENSES_LINE 						x%GUI_LINE_X% y%GUI_LINE_Y% w%GUI_LINE_W% h%GUI_LINE_H%, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_DEPENSES_LINE.jpg
Gui, Add, Picture, +hidden vGUI_BACKGROUND_TAB_DEPENSES gGUI_BACKGROUND_TAB_DEPENSES 	x%GUI_SPACER_TABS% y1 W135 h25, %A_ScriptDir%\Images\GUI_BACKGROUND_TAB_DEPENSES.png
GUI_TEXT_TAB_DEPENSES_X:= 173, GUI_TEXT_TAB_DEPENSES_Y:= 8
Gui Add, Text, +Disabled vGUI_TEXT_TAB_DEPENSES gGUI_BACKGROUND_TAB_DEPENSES 			x%GUI_TEXT_TAB_DEPENSES_X% y%GUI_TEXT_TAB_DEPENSES_Y% w120 h%GUI_TEXT_H% BackgroundTrans, Dépenses
;*/

;/*
;=============================================================================================================================================
;#[1.3-TAB CONTROLS set]
;=============================================================================================================================================
GUI_TABCONTROL_WIDTH:= GUI_WIDTH+1, GUI_TABCONTROL_HEIGHT:= GUI_HEIGHT-2
Gui Add, Tab3, vTabControl 		x0 y4 w%GUI_TABCONTROL_WIDTH% h%GUI_TABCONTROL_HEIGHT% -Wrap, REVENUS|DÉPENSES  ;-Background
Gui, Tab, DÉPENSES,, Exact ; Code below is owned by this tab NAME
;*/

/*
;=============================================================================================================================================
;#[2.1-DEPENSES-info paiement]
;=============================================================================================================================================
	Gui Font, s8 q5
	INFO_PAIEMENT_LAYER_WIDTH:= GUI_WIDTH - (GUI_X1_LEFT_ATTACH*2)
	INFO_PAIEMENT_CONTROLS_COUNT:= 6 ; NOMBRE DE TABLE SUR LA GRILLE DE CALCU
	
; PAIEMENT
	Gui Add, Text, vDEPENSES_Text_ModePaiement x%GUI_X1_LEFT_ATTACH% y%GUI_Y1_TOP_ATTACH% W111 h%GUI_TEXT_H% +Left BackgroundTrans, MODE DE PAIEMENT:
	Gui Add, DropDownList, vDEPENSES_ModePaiement gDEPENSES_ModePaiement x+%GUI_SPACER_X% y%GUI_BUTTON_Y_TOP% W124, Payer plus tard|Comptant/Débit|Virement Bancaire||Chèque|VISA|Mastercard  ;W97
	
	
; COMPTE BANCAIRE
	DEPENSES_COMPTE_BANCAIRE_TEXT_X:=260
	Gui Add, Text, vDEPENSES_CompteBancaire_Text x%DEPENSES_COMPTE_BANCAIRE_TEXT_X% y%GUI_Y1_TOP_ATTACH% w74 h%GUI_TEXT_H% +Left BackgroundTrans, SUR COMPTE:
	Gui Add, DropDownList, vDEPENSES_CompteBancaire x+%GUI_SPACER_X% y%GUI_BUTTON_Y_TOP% W200 BackgroundTrans, 1050 Fonds Non-Déposé|1055 Épargne|1060 Compte Courant Desjardins||    ; w177
	
	
; RÉFÉRENCE
	DEPENSES_Reference_EDIT_Width:=180
	DEPENSES_Reference_EDIT_X:= INFO_PAIEMENT_LAYER_WIDTH-DEPENSES_Reference_EDIT_Width
	DEPENSES_Reference_Text_X:= DEPENSES_Reference_EDIT_X-(146 + GUI_SPACER_X)
	Gui Add, Text, vDEPENSES_Reference_Text x%DEPENSES_Reference_Text_X% y%GUI_Y1_TOP_ATTACH% w146 h%GUI_TEXT_H% +Left BackgroundTrans, RÉFÉRENCE DU VIREMENT:
	Gui Add, Edit, vDEPENSES_Reference x%DEPENSES_Reference_EDIT_X% Y%GUI_BUTTON_Y_TOP% w%DEPENSES_Reference_EDIT_Width% h%GUI_EDIT_H% BackgroundTrans   ;75
	
 ;CHÈQUE / RÉFÉRENCE
	DEPENSES_Cheque_Text_X:= INFO_PAIEMENT_LAYER_WIDTH-DEPENSES_Reference_EDIT_Width-(47 + GUI_SPACER_X)
	Gui Add, Text, +Hidden vDEPENSES_Cheque_Text x%DEPENSES_Cheque_Text_X% y%GUI_Y1_TOP_ATTACH% W47 h%GUI_TEXT_H% +Left BackgroundTrans, CHÈQUE:
	Gui Add, Edit, +Hidden vDEPENSES_Cheque x%DEPENSES_Reference_EDIT_X% Y%GUI_BUTTON_Y_TOP% w%DEPENSES_Reference_EDIT_Width% h%GUI_EDIT_H% BackgroundTrans
	Gui Font
	
; SEPARATOR 1 _________________________________
	THIS_Y:= GUI_Y1_TOP_ATTACH + 16
	Gui Add, Text, vSEPARATOR_DEPENSES_1 x2 y%THIS_Y% w%GUI_SEPARATORS_WIDTH% h2 +0x10 ; SEPARATOR
*/



;=============================================================================================================================================
;#[2.2-DÉPENSES-info transaction]
;=============================================================================================================================================
INFO_TRANSACTION_WIDTH:= GUI_WIDTH - 50

; NOM DU FOURNISSEUR__________________________________________________________________________________________________________________________
Gui Font, s10 BOLD q5
Gui Add, Text, 									x48 y70 h%GUI_TEXT_H% +Left BackgroundTrans, NOM DU FOURNISSEUR:
Gui, Font
Gui Font, s10 q5
; ComboBox choix nom Fournisseur
Gui Add, ComboBox, 									x48 y+1 w300 h%GUI_EDIT_H% +Sort +Uppercase r10 BackgroundTrans +Disabled
, Gestion Daniel Desroches Inc||Test Inc|Test inc2|test inc3|test inc4|test inc5|test inc6|test inc7|test inc 8|test inc9|test inc 10 ; DÉPENSES
Gui Font
; Lock-Unlock Fournisseur
Gui Add, Picture, vLock_Fournisseur gLock_Fournisseur 		x20 y83 w20 h20 BackgroundTrans, %A_ScriptDir%\Images\GUI_Unlock.png
Gui Add, Picture, +hidden vUnLock_Fournisseur gLock_Fournisseur	x20 y83 w20 h20 BackgroundTrans, %A_ScriptDir%\Images\GUI_lock.png

; No FACTURE__________________________________________________________________________________________________________________________________
DEPENSES_NoFacture_EDIT_WIDTH:= 160, DEPENSES_NoFacture_Edit_X:= INFO_TRANSACTION_WIDTH - DEPENSES_NoFacture_EDIT_WIDTH, DEPENSES_NoFacture_Text_X:= DEPENSES_NoFacture_Edit_X - 91
Gui Font, s10 BOLD q5
Gui Add, Text, vDEPENSES_NoFacture_Text 				x%DEPENSES_NoFacture_Text_X% y45 w100 h%GUI_TEXT_H% BackgroundTrans, # FACTURE:
Gui, Font
Gui Font, s10  q5
Gui Add, Edit, vDEPENSES_NoFacture_Edit 				x%DEPENSES_NoFacture_Edit_X% yp-2 w%DEPENSES_NoFacture_EDIT_WIDTH% h%GUI_EDIT_H% BackgroundTrans +Limit22 +Disabled, max22caractères
Gui Font

; DATE_______________________________________________________________________________________________________________________________________
DEPENSES_Date_EDIT_WIDTH:= 110, DEPENSES_Date_EDIT_X:= INFO_TRANSACTION_WIDTH - (DEPENSES_Date_EDIT_WIDTH ), DEPENSES_Date_Text_X:= DEPENSES_Date_EDIT_X - (44 + GUI_X1_LEFT_ATTACH)
Gui Font, s10 bold q5
Gui Add, Text, vDEPENSES_Date_Text 					x%DEPENSES_Date_Text_X% y+7 w46 h%GUI_TEXT_H% +Right BackgroundTrans, DATE:
Gui Font
Gui Font, s10 q5
Gui Add, DateTime, vDEPENSES_Date_Edit 					x%DEPENSES_Date_EDIT_X% yp-4 w%DEPENSES_Date_EDIT_WIDTH% h24 +Left BackgroundTrans   +Disabled, ;-0x800000


;=============================================================================================================================================
;=============================================================================================================================================
;=============================================================================================================================================
;#[2.3-!!!DÉPENSES!!!-TABLE TRANSACTION]
;=============================================================================================================================================
;=============================================================================================================================================
;=============================================================================================================================================

; MAIN TRANSACTION CALCULATION TABLE
TABLE_X_START:=25  ; CONTROLS THE OFFSET OF EVERYTHING IN THE CALCULATION TABLE
TABLE_X_INCREMENT:=-1, THIS_PREVIOUS_CONTROL_X:=0, TABLE_TITLES_Y:=168, TABLE_TITLES_H:=31, TABLE_EDIT_H_INCREMENT:=-1, TABLE_WIDTH:= GUI_WIDTH - (TABLE_X_START*2), TABLE_TABS_COUNT:= 6

; MONTANT_________________________________________________________________________________________________________________________________________________________________________________
DEPENSES_MONTANT_X:= TABLE_X_START + THIS_PREVIOUS_CONTROL_X, DEPENSES_MONTANT_W:= ROUND((( TABLE_WIDTH/ TABLE_TABS_COUNT ) * 1.1 ) -1)
Gui Font
Gui Font, s10 q5
Gui Add, Text, vDEPENSES_MONTANT_TABLE_0_TITLE 			x%DEPENSES_MONTANT_X% Y%TABLE_TITLES_Y% w%DEPENSES_MONTANT_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, MONTANT
Gui Add, Edit, vDEPENSES_MONTANT_TABLE_1 gForceNumber 		x%DEPENSES_MONTANT_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_MONTANT_W% h%GUI_EDIT_H% +limit9 +Right 	
Gui Add, Edit, vDEPENSES_MONTANT_TABLE_2 gForceNumber 		x%DEPENSES_MONTANT_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_MONTANT_W% h%GUI_EDIT_H% +limit9 +Right 	;+Disabled
Gui Add, Edit, vDEPENSES_MONTANT_TABLE_3 gForceNumber 		x%DEPENSES_MONTANT_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_MONTANT_W% h%GUI_EDIT_H% +limit9 +Right 	;+Disabled
Gui Add, Edit, vDEPENSES_MONTANT_TABLE_4 gForceNumber 		x%DEPENSES_MONTANT_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_MONTANT_W% h%GUI_EDIT_H% +limit9 +Right 	;+Disabled
Gui Add, Edit, vDEPENSES_MONTANT_TABLE_5 gForceNumber 		x%DEPENSES_MONTANT_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_MONTANT_W% h%GUI_EDIT_H% +limit9 +Right 	;+Disabled
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_MONTANT_W + TABLE_X_INCREMENT

; CODE TAXE_______________________________________________________________________________________________________________________________________________________________________________
DEPENSES_CODETAXE_X:= TABLE_X_START + THIS_PREVIOUS_CONTROL_X, DEPENSES_CODETAXE_W:= ROUND((( TABLE_WIDTH/ TABLE_TABS_COUNT ) * 0.4 ) -1) + 1
Gui Add, Text, vDEPENSES_CODETAXE_TABLE_0_TITLE 			X%DEPENSES_CODETAXE_X% Y%TABLE_TITLES_Y% w%DEPENSES_CODETAXE_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, TAXE
Gui Font
Gui Font, s8 q5
Gui Add, ComboBox, vDEPENSES_CODETAXE_TABLE_1 gCalculate 	X%DEPENSES_CODETAXE_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_CODETAXE_W% R4	+Disabled	, -|GQ||G|Ti
Gui Add, ComboBox, vDEPENSES_CODETAXE_TABLE_2 			X%DEPENSES_CODETAXE_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_CODETAXE_W% R4 	+Disabled	, -|GQ|G|Ti
Gui Add, ComboBox, vDEPENSES_CODETAXE_TABLE_3 			X%DEPENSES_CODETAXE_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_CODETAXE_W% R4 	+Disabled	, -|GQ|G|Ti
Gui Add, ComboBox, vDEPENSES_CODETAXE_TABLE_4 			X%DEPENSES_CODETAXE_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_CODETAXE_W% R4 	+Disabled	, -|GQ|G|Ti
Gui Add, ComboBox, vDEPENSES_CODETAXE_TABLE_5 			X%DEPENSES_CODETAXE_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_CODETAXE_W% R4 	+Disabled	, -|GQ|G|Ti
Gui, font
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_CODETAXE_W + TABLE_X_INCREMENT ;(TABLE_X_INCREMENT*2)

; TPS/TVQ LINKED___________________________________________________________________________________________________________________________________________________________________________
DEPENSES_TPS_TVQ_W:= ROUND((( TABLE_WIDTH/ TABLE_TABS_COUNT ) * 0.7 ) -1) ;79
Gui Font, s10 q5
; TPS
DEPENSES_TPS_X:= TABLE_X_START + THIS_PREVIOUS_CONTROL_X ;176
Gui Add, Text, vDEPENSES_TPS_TABLE_0_TITLE 				x%DEPENSES_TPS_X% Y%TABLE_TITLES_Y% w%DEPENSES_TPS_TVQ_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, TPS/TVH
Gui Add, Edit, vDEPENSES_TPS_TABLE_1 					x%DEPENSES_TPS_X% y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number	+Disabled
Gui Add, Edit, vDEPENSES_TPS_TABLE_2 					x%DEPENSES_TPS_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TPS_TABLE_3 					x%DEPENSES_TPS_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TPS_TABLE_4 					x%DEPENSES_TPS_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TPS_TABLE_5 					x%DEPENSES_TPS_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_TPS_TVQ_W + TABLE_X_INCREMENT, DEPENSE_TPS_TVQ_LINK_X:= THIS_PREVIOUS_CONTROL_X
; TVQ
DEPENSES_TVQ_X:= TABLE_X_START + DEPENSE_TPS_TVQ_LINK_X ;255
Gui Add, Text, vDEPENSES_TVQ_TABLE_0_TITLE 				X%DEPENSES_TVQ_X% Y%TABLE_TITLES_Y% w%DEPENSES_TPS_TVQ_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, TVQ
Gui Add, Edit, vDEPENSES_TVQ_TABLE_1 					X%DEPENSES_TVQ_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TVQ_TABLE_2 					X%DEPENSES_TVQ_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TVQ_TABLE_3 					X%DEPENSES_TVQ_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TVQ_TABLE_4 					X%DEPENSES_TVQ_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
Gui Add, Edit, vDEPENSES_TVQ_TABLE_5 					X%DEPENSES_TVQ_X% Y+%TABLE_EDIT_H_INCREMENT% w%DEPENSES_TPS_TVQ_W% h%GUI_EDIT_H% +Number +Disabled
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_TPS_TVQ_W + TABLE_X_INCREMENT

; DESCRIPTION_______________________________________________________________________________________________________________________________________________________________________________
DEPENSES_DESCRIPTION_X:= TABLE_X_START + THIS_PREVIOUS_CONTROL_X, DEPENSES_DESCRIPTION_W:= ROUND((( TABLE_WIDTH/ TABLE_TABS_COUNT ) * 1.75 ) -1) + 1
Gui Add, Text, vDEPENSES_DESCRIPTION_TABLE_0_TITLE 		x%DEPENSES_DESCRIPTION_X% Y%TABLE_TITLES_Y% W%DEPENSES_DESCRIPTION_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, DESCRIPTION
Gui Add, Edit, vDEPENSES_DESCRIPTION_TABLE_1 			x%DEPENSES_DESCRIPTION_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_DESCRIPTION_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_DESCRIPTION_TABLE_2 			x%DEPENSES_DESCRIPTION_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_DESCRIPTION_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_DESCRIPTION_TABLE_3 			x%DEPENSES_DESCRIPTION_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_DESCRIPTION_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_DESCRIPTION_TABLE_4 			x%DEPENSES_DESCRIPTION_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_DESCRIPTION_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_DESCRIPTION_TABLE_5 			x%DEPENSES_DESCRIPTION_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_DESCRIPTION_W% h%GUI_EDIT_H% +Disabled
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_DESCRIPTION_W + TABLE_X_INCREMENT

; COMPTE___________________________________________________________________________________________________________________________________________________________________________________
DEPENSES_COMPTE_X:= TABLE_X_START + THIS_PREVIOUS_CONTROL_X, DEPENSES_COMPTE_W:= ROUND((( TABLE_WIDTH/ TABLE_TABS_COUNT ) * 1.4 ) -1)
Gui Add, Text, vDEPENSES_COMPTE_TABLE_0_TITLE 			x%DEPENSES_COMPTE_X% Y%TABLE_TITLES_Y% W%DEPENSES_COMPTE_W% H%TABLE_TITLES_H% +0x200 +Center -Background +Border 0x4, COMPTE
Gui Add, Edit, vDEPENSES_COMPTE_TABLE_1 				x%DEPENSES_COMPTE_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_COMPTE_W% h%GUI_EDIT_H% +Disabled , 5700 fournitures de bureau
Gui Add, Edit, vDEPENSES_COMPTE_TABLE_2 				x%DEPENSES_COMPTE_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_COMPTE_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_COMPTE_TABLE_3 				x%DEPENSES_COMPTE_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_COMPTE_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_COMPTE_TABLE_4 				x%DEPENSES_COMPTE_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_COMPTE_W% h%GUI_EDIT_H% +Disabled
Gui Add, Edit, vDEPENSES_COMPTE_TABLE_5 				x%DEPENSES_COMPTE_X% Y+%TABLE_EDIT_H_INCREMENT% W%DEPENSES_COMPTE_W% h%GUI_EDIT_H% +Disabled
Gui Font
THIS_PREVIOUS_CONTROL_X:= THIS_PREVIOUS_CONTROL_X + DEPENSES_COMPTE_W + TABLE_X_INCREMENT


;=============================================================================================================================================
 ;#[2.4-DEPENSES-Totaux]
;=============================================================================================================================================
; Colonne de gauche
Gui Font, s10 q5
DEPENSES_SOUSTOTAL_text_X:= ROUND( (GUI_WIDTH/2) - ((90 + 100)/2), 2)
Gui Add, Text, vDEPENSES_SOUSTOTAL_text 	x%DEPENSES_SOUSTOTAL_text_X% y374 w90 h%GUI_TEXT_H% +Left BackgroundTrans, SOUS-TOTAL :
Gui Add, Text, vDEPENSES_TPS_text 			x%DEPENSES_SOUSTOTAL_text_X% y398 w90 h%GUI_TEXT_H% +Left BackgroundTrans, TPS/TVH :
Gui Add, Text, vDEPENSES_TVQ_text 			x%DEPENSES_SOUSTOTAL_text_X% y422 w90 h%GUI_TEXT_H% +Left BackgroundTrans, TVQ :
Gui Add, Text, vDEPENSES_TOTAL_text 		x%DEPENSES_SOUSTOTAL_text_X% y454 w90 h%GUI_TEXT_H% +Left BackgroundTrans, TOTAL :
; Colonne de droite
DEPENSES_SOUSTOTAL_X:= ROUND( DEPENSES_SOUSTOTAL_text_X + 100, 2)
Gui Add, Text, vDEPENSES_SOUSTOTAL 		x%DEPENSES_SOUSTOTAL_X% y374 w100 h%GUI_TEXT_H% +Right BackgroundTrans, 0.00
Gui Add, Text, vDEPENSES_TPS 				x%DEPENSES_SOUSTOTAL_X% y398 w100 h%GUI_TEXT_H% +Right BackgroundTrans, 0.00
Gui Add, Text, vDEPENSES_TVQ 				x%DEPENSES_SOUSTOTAL_X% y422 w100 h%GUI_TEXT_H% +Right BackgroundTrans, 0.00
Gui Font, s10 Bold q5
Gui Font, s10 w600 q5
Gui Add, Text, vDEPENSES_TOTAL 			x%DEPENSES_SOUSTOTAL_X% y454 w100 h%GUI_TEXT_H% +Right BackgroundTrans, 0.00
Gui Font
; SEPARATORS _________________________________
Gui Add, Text, vSEPARATOR_DEPENSES_2 		x2 Y479 w%GUI_SEPARATORS_WIDTH% h2 +0x10 
Gui Add, Text, VSEPARATOR_DEPENSES_3 		x2 Y445 w%GUI_SEPARATORS_WIDTH% h2 +0x10
;=============================================================================================================================================
 ;#[2.5-DEPENSES-CONFIRMER TRANSACTION]
;=============================================================================================================================================
Gui Font, q5
Gui Add, Button, vDEPENSES_CONFIRMER 		x%DEPENSES_SOUSTOTAL_text_X% y490 w205 h39 BackgroundTrans			+Disabled, CONFIRMER LA TRANSACTION
Gui Font




Calculate()
Gui Show, w%GUI_WIDTH% h%GUI_HEIGHT%, Finance D - Tenue de livres simplifiée
; enable-drag-for-a-gui-without-a-titlebar
OnMessage( 0x200, "WM_MOUSEMOVE" ) ; Serenity - https://autohotkey.com/board/topic/80594-how-to-enable-drag-for-a-gui-without-a-titlebar/
;=============================================================================================================================================
Return ; first return
;=============================================================================================================================================



WM_MOUSEMOVE( wparam, lparam, msg, hwnd ) ; enable-drag-for-a-gui-without-a-titlebar
{
	; Serenity - https://autohotkey.com/board/topic/80594-how-to-enable-drag-for-a-gui-without-a-titlebar/ 
	if wparam = 1 ; LButton
	{
		;MouseGetPos, OutputVarX
		;if (OutputVarX )
			;return
		;else 
		PostMessage, 0xA1, 2,,, A ; WM_NCLBUTTONDOWN
	}
}




/*	DEPENSES_ModePaiement:
	Gui,Submit,Nohide
;MsgBox %ModePaiement%
	if (DEPENSES_ModePaiement = "Payer plus tard")
	{
		GuiControl, Hide, DEPENSES_CompteBancaire_Text
		GuiControl, Hide, DEPENSES_CompteBancaire
		GuiControl, Hide, DEPENSES_Cheque_Text
		GuiControl, Hide, DEPENSES_Cheque
		GuiControl, Hide, DEPENSES_Reference_Text
		GuiControl, Hide, DEPENSES_Reference
		return
	}
	
	if (DEPENSES_ModePaiement = "Virement Bancaire")
	{
		GuiControl, Show, DEPENSES_CompteBancaire_Text
		GuiControl, Show, DEPENSES_CompteBancaire
		GuiControl, Hide, DEPENSES_Cheque_Text
		GuiControl, Hide, DEPENSES_Cheque
		GuiControl, Show, DEPENSES_Reference_Text
		GuiControl, Show, DEPENSES_Reference
		return
	}
	
	if (DEPENSES_ModePaiement = "Comptant")
	{
		GuiControl, Show, DEPENSES_CompteBancaire_Text
		GuiControl, Show, DEPENSES_CompteBancaire
		GuiControl, Hide, DEPENSES_Cheque_Text
		GuiControl, Hide, DEPENSES_Cheque
		GuiControl, Hide, DEPENSES_Reference_Text
		GuiControl, Hide, DEPENSES_Reference
		return
	}
	
	if (DEPENSES_ModePaiement = "Chèque")
	{
		GuiControl, Show, DEPENSES_CompteBancaire_Text
		GuiControl, Show, DEPENSES_CompteBancaire
		GuiControl, Show, DEPENSES_Cheque_Text
		GuiControl, Show, DEPENSES_Cheque
		GuiControl, Hide, DEPENSES_Reference_Text
		GuiControl, Hide, DEPENSES_Reference
		return
	}
	
	else
	{
		GuiControl, Show, DEPENSES_CompteBancaire_Text
		GuiControl, Show, DEPENSES_CompteBancaire
		GuiControl, Hide, DEPENSES_Cheque_Text
		GuiControl, Hide, DEPENSES_Cheque
		GuiControl, Hide, DEPENSES_Reference_Text
		GuiControl, Hide, DEPENSES_Reference
		return
	}
	return
*/ 


GUI_BACKGROUND_TAB_DEPENSES:
Gui,Submit,Nohide
;Gui,Color, FFF5F5
GuiControl, ChooseString, TabControl, DÉPENSES
Gui, Font, s12 bold q5  ; If desired, use a line like this to set a new default font for the window.
GuiControl, Font, GUI_TEXT_TAB_DEPENSES  ; Put the above font into effect for a control.
GuiControl, Move, GUI_TEXT_TAB_DEPENSES, % "x" GUI_TEXT_TAB_DEPENSES_X-32 "y" GUI_TEXT_TAB_DEPENSES_Y-4 ; Uses an expression via "% " prefix.
GuiControl, , GUI_TEXT_TAB_DEPENSES, DÉPENSES
Gui, Font
GuiControl, Enable, GUI_TEXT_TAB_DEPENSES
GuiControl, Show, GUI_BACKGROUND_TAB_DEPENSES
GuiControl, Show, GUI_BACKGROUND_TAB_DEPENSES_LINE
GuiControl, Hide, GUI_BACKGROUND_TAB_REVENUS
GuiControl, Hide, GUI_BACKGROUND_TAB_REVENUS_LINE
GuiControl, Disable, GUI_TEXT_TAB_REVENUS
Gui, Font, s8 q5 ; If desired, use a line like this to set a new default font for the window.
GuiControl, Font, GUI_TEXT_TAB_REVENUS  ; Put the above font into effect for a control.
GuiControl, Move, GUI_TEXT_TAB_REVENUS, % "x" GUI_TEXT_TAB_REVENUS_X+8 "y" GUI_TEXT_TAB_REVENUS_Y+4 ; Uses an expression via "% " prefix.
GuiControl, , GUI_TEXT_TAB_REVENUS, Revenus ; Uses an expression via "% " prefix.
Gui, Font
return


GUI_BACKGROUND_TAB_REVENUS:
Gui,Submit,Nohide
;Gui Color, 0xF2FDF2 ; vert pale
GuiControl, ChooseString, TabControl, REVENUS
GuiControl, Enable, GUI_TEXT_TAB_REVENUS
Gui, Font, s12 bold q5  ; If desired, use a line like this to set a new default font for the window.
GuiControl, Font, GUI_TEXT_TAB_REVENUS  ; Put the above font into effect for a control.
GuiControl, Move, GUI_TEXT_TAB_REVENUS, % "x" GUI_TEXT_TAB_REVENUS_X "y" GUI_TEXT_TAB_REVENUS_Y ; Uses an expression via "% " prefix.
GuiControl, , GUI_TEXT_TAB_REVENUS, REVENUS ; Uses an expression via "% " prefix.
Gui, Font
GuiControl, Show, GUI_BACKGROUND_TAB_REVENUS
GuiControl, Show, GUI_BACKGROUND_TAB_REVENUS_LINE
Gui, Font, s8 q5  ; If desired, use a line like this to set a new default font for the window.
GuiControl, Font, GUI_TEXT_TAB_DEPENSES  ; Put the above font into effect for a control.
GuiControl, Move, GUI_TEXT_TAB_DEPENSES, % "x" GUI_TEXT_TAB_DEPENSES_X "y" GUI_TEXT_TAB_DEPENSES_Y ; Uses an expression via "% " prefix.
GuiControl, Disable, GUI_TEXT_TAB_DEPENSES
GuiControl, , GUI_TEXT_TAB_DEPENSES, Dépenses
Gui, Font
GuiControl, Hide, GUI_BACKGROUND_TAB_DEPENSES
GuiControl, Hide, GUI_BACKGROUND_TAB_DEPENSES_LINE
return



GuiSize:

If (A_EventInfo == 1) {
	Return
}
AutoXYWH("*w h", "TabControl") ; The Underlying Tab Selector 

; Background Tabs LINE overlay TOP LAYER
AutoXYWH("w", "GUI_BACKGROUND_TAB_DEPENSES_LINE", "GUI_BACKGROUND_TAB_REVENUS_LINE", "SEPARATOR_DEPENSES_1")

;AutoXYWH("X", "DEPENSES_Reference_Text", "DEPENSES_Reference", "DEPENSES_Cheque_Text", "DEPENSES_Cheque")
;AutoXYWH("X0.5", "DEPENSES_CompteBancaire_Text", "DEPENSES_CompteBancaire")

AutoXYWH("*X", "DEPENSES_NoFacture_Text", "DEPENSES_NoFacture_Edit", "DEPENSES_Date_Text", "DEPENSES_Date_Edit")

; x + w variation = next value EX: x0.06 + w0.1 NextX will be: x0.16
AutoXYWH("*x0.09 y0.4 w0.15", "DEPENSES_MONTANT_TABLE_0_TITLE", "DEPENSES_MONTANT_TABLE_1", "DEPENSES_MONTANT_TABLE_2", "DEPENSES_MONTANT_TABLE_3", "DEPENSES_MONTANT_TABLE_4", "DEPENSES_MONTANT_TABLE_5")
AutoXYWH("*x0.24 y0.4 w0.04", "DEPENSES_CODETAXE_TABLE_0_TITLE", "DEPENSES_CODETAXE_TABLE_1", "DEPENSES_CODETAXE_TABLE_2", "DEPENSES_CODETAXE_TABLE_3", "DEPENSES_CODETAXE_TABLE_4", "DEPENSES_CODETAXE_TABLE_5")
AutoXYWH("*X0.28 y0.4 w0.07", "DEPENSES_TPS_TABLE_0_TITLE", "DEPENSES_TPS_TABLE_1", "DEPENSES_TPS_TABLE_2", "DEPENSES_TPS_TABLE_3", "DEPENSES_TPS_TABLE_4", "DEPENSES_TPS_TABLE_5")
AutoXYWH("*X0.35 y0.4 w0.07", "DEPENSES_TVQ_TABLE_0_TITLE", "DEPENSES_TVQ_TABLE_1", "DEPENSES_TVQ_TABLE_2", "DEPENSES_TVQ_TABLE_3", "DEPENSES_TVQ_TABLE_4", "DEPENSES_TVQ_TABLE_5")
AutoXYWH("*x0.42 y0.4 w0.4", "DEPENSES_DESCRIPTION_TABLE_0_TITLE", "DEPENSES_DESCRIPTION_TABLE_1", "DEPENSES_DESCRIPTION_TABLE_2", "DEPENSES_DESCRIPTION_TABLE_3", "DEPENSES_DESCRIPTION_TABLE_4", "DEPENSES_DESCRIPTION_TABLE_5")
AutoXYWH("*X0.82 y0.4 w0.085", "DEPENSES_COMPTE_TABLE_0_TITLE", "DEPENSES_COMPTE_TABLE_1", "DEPENSES_COMPTE_TABLE_2", "DEPENSES_COMPTE_TABLE_3", "DEPENSES_COMPTE_TABLE_4", "DEPENSES_COMPTE_TABLE_5")

; Sous-total + CONFIRMER lines
AutoXYWH("*x0.5 y0.8", "DEPENSES_SOUSTOTAL_text", "DEPENSES_SOUSTOTAL", "DEPENSES_TPS_text", "DEPENSES_TPS", "DEPENSES_TVQ_text", "DEPENSES_TVQ", "DEPENSES_TOTAL", "DEPENSES_TOTAL_text", "DEPENSES_CONFIRMER")
;
; SEPARATOR lines
AutoXYWH("w y0.8", "SEPARATOR_DEPENSES_2", "SEPARATOR_DEPENSES_3")
Return


Lock_Fournisseur:
MsgBox % "Vérouiller le fournisseur actif"
;if ()
GuiControl, Hide, Lock_Fournisseur
;else
GuiControl, Show, UnLock_Fournisseur
return




GuiEscape:
GuiClose:
ExitApp




Calculate() { ;Calculate table values
	;global   
	LOOP_Strings:= "MONTANT,CODETAXE,TPS,TVQ" ; column names that hold each variables
	MONTANT:="DEPENSES_MONTANT_TABLE_1,DEPENSES_MONTANT_TABLE_2,DEPENSES_MONTANT_TABLE_3,DEPENSES_MONTANT_TABLE_4,DEPENSES_MONTANT_TABLE_5"
	CODETAXE:="DEPENSES_CODETAXE_TABLE_1,DEPENSES_CODETAXE_TABLE_2,DEPENSES_CODETAXE_TABLE_3,DEPENSES_CODETAXE_TABLE_4,DEPENSES_CODETAXE_TABLE_5"
	TPS:="DEPENSES_TPS_TABLE_1,DEPENSES_TPS_TABLE_2,DEPENSES_TPS_TABLE_3,DEPENSES_TPS_TABLE_4,DEPENSES_TPS_TABLE_5"
	TVQ:="DEPENSES_TVQ_TABLE_1,DEPENSES_TVQ_TABLE_2,DEPENSES_TVQ_TABLE_3,DEPENSES_TVQ_TABLE_4,DEPENSES_TVQ_TABLE_5"
	
	;MsgBox % LOOP_Strings ; LOOP_Strings contains the name of Variables holding each column strings
	loop, Parse, % LOOP_Strings, CSV ; Parse This String at "," and ignore "  or "spaces" 
	{
		VirtualOutput .=  "`n"A_LoopField " :"
		VirtualOutput .=  "`n"%A_LoopField% "`n"
	}
	;MsgBox % VirtualOutput
	
	Loop, Parse, % MONTANT, CSV ; Parse This String at "," and ignore "  or "spaces" 
	{
		;GuiControlGet, DEPENSES_MONTANT_TABLE_%A_Index% ; retrieve the value of each variable (1 per loop): 1, 2, 3, 4, 5
		;MsgBox % "DEPENSES_MONTANT_TABLE"A_Index " = " DEPENSES_MONTANT_TABLE_%A_Index% ; Force expression to show value of current index
		;if % DEPENSES_MONTANT_TABLE_%A_Index% = ""
		GuiControlGet, %A_LoopField%
		if (%A_LoopField% = "")
		{
			;MsgBox empty
			;need to evitate having empty strings
			;DEPENSES_MONTANT_TABLE_%A_Index% := 0 ; ATTRIBUTES "0" rather than empty/VOID/NUL
			%A_LoopField% := 0 ; ATTRIBUTES "0" rather than empty/VOID/NUL
			;MsgBox % "DEPENSES_MONTANT_TABLE"A_Index " = " DEPENSES_MONTANT_TABLE_%A_Index% ; Force expression to show value of current index
		}
	}
	Calculated_Depenses_SousTotal:= (Round((DEPENSES_MONTANT_TABLE_1 + DEPENSES_MONTANT_TABLE_2 + DEPENSES_MONTANT_TABLE_3 + DEPENSES_MONTANT_TABLE_4 + DEPENSES_MONTANT_TABLE_5), 2))
	GuiControl,, DEPENSES_SOUSTOTAL, %Calculated_Depenses_SousTotal%
	
	Calculated_Depenses_Total:= Calculated_Depenses_SOUSTOTAL ;+ Calculated_Depenses_TPS + Calculated_Depenses_TVQ
	GuiControl,, DEPENSES_TOTAL, %Calculated_Depenses_Total%
	Gui, Submit, NoHide
}




;-------------------------------------------------------------------------------
ForceNumber(hThisActiveControl) { ; allow only numbers up to 2 decimals
;-------------------------------------------------------------------------------
	;global
	local
	static Warning := "Entrez un nombre ayant un maximum de deux décimales"
        , BadNeedle := "[^\d\.-]|^.+-|^-0\d|^0\d", maxDecimals := 2, PrevNumber := []
	
    ; start dirty
	GuiControlGet, dirtyInput,, %hThisActiveControl%
	ControlGet, Pos, CurrentCol,,, ahk_id %hThisActiveControl%
	Converted := StrReplace(dirtyInput, ",", ".")
	AbsValue := StrReplace(Converted, "-",, NegCount)
	
	
    ; clean
	NewNumber := (NegCount=1 ? "-" : "") AbsValue
	Decimals := StrLen(StrSplit(NewNumber, ".").2)
	StrReplace(NewNumber, ".",, DotCount)
	
    ; with clean data we can tell which is BAD, it's one or more of these cases:
	BAD := (NewNumber ~= BadNeedle)
        Or (Decimals > maxDecimals)
        Or (DotCount > 1)
	
	If (BAD) { ; => complain and reject
		ControlGetPos, myX, myY,,,, ahk_id %hThisActiveControl%
		ToolTip, %Warning%, myX, myY - 20
		SetTimer, ForceNumber_ToolTipOff, -2000
		NewNumber := PrevNumber[hThisActiveControl], Pos -= 2
	}
	
	Else { ; GOOD, accept and remember input
		PrevNumber[hThisActiveControl] := NewNumber
		Pos -= (NegCount=2 ? 3 : 1)
	}
	
    ; talking to hThisActiveControl
	GuiControl,, %hThisActiveControl%, %NewNumber%
	SendMessage, 0xB1, %Pos%, %Pos%,, ahk_id %hThisActiveControl%
	
	Calculate()
	
	Return ; end of function
	
	ForceNumber_ToolTipOff:
	ToolTip ; off
	Return
}



; =================================================================================
; Function: AutoXYWH
;   Move and resize control automatically when GUI resizes.
; Parameters:
;   DimSize - Can be one or more of x/y/w/h  optional followed by a fraction
;             add a '*' to DimSize to 'MoveDraw' the controls rather then just 'Move', this is recommended for Groupboxes
;   cList   - variadic list of ControlIDs
;             ControlID can be a control HWND, associated variable name, ClassNN or displayed text.
;             The later (displayed text) is possible but not recommend since not very reliable 
; Examples:
;   AutoXYWH("xy", "Btn1", "Btn2")
;   AutoXYWH("w0.5 h 0.75", hEdit, "displayed text", "vLabel", "Button1")
;   AutoXYWH("*w0.5 h 0.75", hGroupbox1, "GrbChoices")
; ---------------------------------------------------------------------------------
; Version: 2015-5-29 / Added 'reset' option (by tmplinshi)
;          2014-7-03 / toralf
;          2014-1-2  / tmplinshi
; requires AHK version : 1.1.13.01+
; =================================================================================
AutoXYWH(DimSize, cList*) {       ; http://ahkscript.org/boards/viewtopic.php?t=1079
	Global
	Static cInfo := {}
	
	If (DimSize = "reset") {
		Return cInfo := {}
	}
	
	For i, ctrl in cList {
		ctrlID := A_Gui ":" ctrl
		If (cInfo[ctrlID].x = "") {
			GuiControlGet i, %A_Gui%: Pos, %ctrl%
			MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
			fx := fy := fw := fh := 0
			For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]"))) {
				If (!RegExMatch(DimSize, "i)" . dim . "\s*\K[\d.-]+", f%dim%)) {
					f%dim% := 1
				}
			}
			cInfo[ctrlID] := {x: ix, fx: fx, y: iy, fy: fy, w: iw, fw: fw, h: ih, fh: fh, gw: A_GuiWidth, gh: A_GuiHeight, a: a, m: MMD}
		} Else If (cInfo[ctrlID].a.1) {
			dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw, dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
			Options := ""
			For i, dim in cInfo[ctrlID]["a"] {
				Options .= dim . (dg%dim% * cInfo[ctrlID]["f" . dim] + cInfo[ctrlID][dim]) . A_Space
			}
			GuiControl, % A_Gui ":" cInfo[ctrlID].m, % ctrl, % Options
		}
	}
}
Sorry this is a script in progress and very noob GUI coded
You might not see the included images for the top layer

thanks alot man
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: Auto XYWH function (x0.5 + y0.8) bugs Y axis Resizing

15 Sep 2018, 13:10

I found it!!

The problem resolves when I De-activate the Tab3 Control that the controls are dependent on! Damn it whats this lol


EDIT: Tab1 and Tab2 models dont have a background and they don't introduce the problem but Tab3 has a background and bugs
if the Tab3 is activated but the controls are not atribbuted to BELONG to any tabs, it will not bug

Should I just get rid of a Tab anyway??
I only need swaping controls when I click on the pictures I use as custom Tab Selectors. But I thought I could only do this easily by using Tabs and making controls belong to one of these


EDIT: Btw thanks for your Gui example... it just showed me how more intelligently I can create identical increments with loops! :)
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: Auto XYWH function (x0.5 + y0.8) bugs Y axis Resizing  Topic is solved

15 Sep 2018, 15:29

I found the reason. The controls under Tab3 need to use relative positions for repositioning. @lexikos Is this a bug?

Code: Select all

Gui, Add, Tab3, w300 h150 Section vTabCtrl, aaa|bbb
Gui, Add, Text, x+10 y+30 Section, Hello
Gui, Add, Text, y+5, ------------------- 
Gui, Show
Return

F12::
	; Get the original position
	GuiControlGet, i, Pos, Static1
	MsgBox,, Before, % iX "," iY ; 23,58
	
	; Moving with its original position
	GuiControl, Move, Static1, x%iX% y%iY%

	; But after that, the position changed
	GuiControlGet, ii, Pos, Static1
	MsgBox,, After, % iiX "," iiY ; 36,86

	; Moving with position relative to Tab3 control
	relativeX := iX - (iiX - iX)
	relativeY := iY - (iiY - iY)
	MsgBox,, Relative Positon, % relativeX "," relativeY ; 10,30
	GuiControl, Move, Static1, x%relativeX% y%relativeY%
return
I added a ! symbo option to AutoXYWH to fix the problems with Tab3 control.

Code: Select all

Gui, +Resize
Gui, Add, Tab3, x50 w300 h200 Section vTabCtrl, aaa|bbb
Gui, Add, Text, x+10 y+30 Section, Hello
Gui, Add, Text, x+50 cRed, World
Gui, Add, Text, xs y+5 0x10 w270
Gui, Show, w400
Return

GuiSize:
	AutoXYWH("! x0.5 y0.8", "Static1") ; This one moving correctly
	AutoXYWH("  x0.5 y0.8", "Static2") ; Incorrect
return

GuiClose:
ExitApp

AutoXYWH(DimSize, cList*) {       ; http://ahkscript.org/boards/viewtopic.php?t=1079
	Global
	Static cInfo := {}
	
	If (DimSize = "reset") {
		Return cInfo := {}
	}
	
	For i, ctrl in cList {
		ctrlID := A_Gui ":" ctrl
		If (cInfo[ctrlID].x = "") {
			GuiControlGet i, %A_Gui%: Pos, %ctrl%

			if InStr(DimSize, "!") {
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
				GuiControlGet, _i, %A_Gui%: Pos, %ctrl%
				iX := iX - (_iX - iX), iY := iY - (_iY - iY)
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
			}

			MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
			fx := fy := fw := fh := 0
			For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]"))) {
				If (!RegExMatch(DimSize, "i)" . dim . "\s*\K[\d.-]+", f%dim%)) {
					f%dim% := 1
				}
			}
			cInfo[ctrlID] := {x: ix, fx: fx, y: iy, fy: fy, w: iw, fw: fw, h: ih, fh: fh, gw: A_GuiWidth, gh: A_GuiHeight, a: a, m: MMD}
		} Else If (cInfo[ctrlID].a.1) {
			dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw, dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
			Options := ""
			For i, dim in cInfo[ctrlID]["a"] {
				Options .= dim . (dg%dim% * cInfo[ctrlID]["f" . dim] + cInfo[ctrlID][dim]) . A_Space
			}
			GuiControl, % A_Gui ":" cInfo[ctrlID].m, % ctrl, % Options
		}
	}
}
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: AutoXYWH function - Y axis Resize bug [cause found Tab3]

15 Sep 2018, 16:07

Wow.

This is what I call impressive knowledge. Seriously how can you be so smart as to fix this and make it so simple that only ! fix it :D
Im exagerating a bit but this is genious. One of my most impressive tool cause I know how complex calculating manually all the proportions is!

thanks man!

On the same topic: Do you have a clue how we could reduce flickering apart from introducing a sleep before refreshing?

Edit: typos
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: AutoXYWH function - Y axis Resize bug [cause found Tab3]

16 Sep 2018, 12:53

DRocks wrote:Do you have a clue how we could reduce flickering apart from introducing a sleep before refreshing?
Maybe use Tab2 instead? You can set w0 h0 to Tab2 control, and set the GUI color to white.

Code: Select all

Gui, Color, White

Gui, Add, Text,    w100 h40 0x201 Border gSwitchTab, REVENUS
Gui, Add, Text, ys w100 h40 0x201 Border gSwitchTab, Dépenses

Gui, Add, Tab2, xm w0 h0 vTabCtrl, REVENUS|Dépenses
	Gui, Tab, 1
		Gui, Add, Text, xp+20 yp+20, Hello
	Gui, Tab, 2
		Gui, Add, Text, xp+20 yp+20, World
		
Gui, Show, w400 h200
Return

SwitchTab:
	GuiControl, Choose, TabCtrl, |%A_GuiControl%
return

GuiClose:
ExitApp
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

16 Sep 2018, 14:10

thanks. In your example if I add AutoXYWH you're right it doesnt flicker at all. But it will start doing so when you add buttons and edits.

I have noticed in my script that your trick will reduce like 20% of the flicker but the real problem is redrawing. It doesnt flicker when theres no redrawing, but the end result will mess up the GUI positions. Some overlay, some need total redrawing, etc.

So its kind of a downside of redrawing the controls. The refresh rate is visible. We can reduce the flickering intensity by adding like 200ms of sleep for each GuiSize request but it makes it feel laggy when you resize. I dont think its better than the flickering.

Let me know if you think of something else, in the mean time its not a major problem.
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

17 Sep 2018, 12:28

Adding WS_CLIPCHILDREN style to the control's parent window seems fixes a lot of flickering.

Tab2 Demo:

Code: Select all

#NoEnv
SetBatchLines -1

Gui, +Resize +0x02000000 ; WS_CLIPCHILDREN := 0x02000000

Gui, Add, Radio, y20 h24 gSwitchTab Checked, Page1
Gui, Add, Radio, x+50 h24 gSwitchTab, Page2

Gui, Add, Tab2, xm w0 h0 vTabCtrl +HWNDhTab, Page1|Page2
	Gui, Tab, 1
		Gui, Add, Text, xm Section Disabled, This is Tab2
		Gui, Add, Edit, xs w374 h50 +HWNDhEdit, 
		Gui, Add, Button, xs w374 h50, Test Button
		Gui, Add, Text, xs+302 y+20, Bottom Text
	Gui, Tab, 2
		Gui, Add, Button, xs+50 ys+50, This is page 2
	Gui, Tab

Gui, Show
Return

SwitchTab:
	GuiControl, Choose, %hTab%, |%A_GuiControl%
	DllCall("RedrawWindow", "ptr", hGUI, "ptr", 0, "ptr", 0, "uint", 131) ; 131 = RDW_INTERNALPAINT | RDW_ALLCHILDREN | RDW_INVALIDATE
return

GuiSize:
	AutoXYWH("y0.5 x", "Bottom Text", "This is page 2")
	AutoXYWH("w", hEdit, "Test Button")
return

GuiClose:
ExitApp

AutoXYWH(DimSize, cList*) {       ; http://ahkscript.org/boards/viewtopic.php?t=1079
	Static cInfo := {}
	
	If (DimSize = "reset") {
		Return cInfo := {}
	}
	
	For i, ctrl in cList {
		ctrlID := A_Gui ":" ctrl
		If (cInfo[ctrlID].x = "") {
			GuiControlGet i, %A_Gui%: Pos, %ctrl%

			if InStr(DimSize, "!") {
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
				GuiControlGet, _i, %A_Gui%: Pos, %ctrl%
				iX := iX - (_iX - iX), iY := iY - (_iY - iY)
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
			}

			MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
			fx := fy := fw := fh := 0
			For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]"))) {
				If (!RegExMatch(DimSize, "i)" . dim . "\s*\K[\d.-]+", f%dim%)) {
					f%dim% := 1
				}
			}
			cInfo[ctrlID] := {x: ix, fx: fx, y: iy, fy: fy, w: iw, fw: fw, h: ih, fh: fh, gw: A_GuiWidth, gh: A_GuiHeight, a: a, m: MMD}
		} Else If (cInfo[ctrlID].a.1) {
			dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw, dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
			Options := ""
			For i, dim in cInfo[ctrlID]["a"] {
				Options .= dim . (dg%dim% * cInfo[ctrlID]["f" . dim] + cInfo[ctrlID][dim]) . A_Space
			}
			GuiControl, % A_Gui ":" cInfo[ctrlID].m, % ctrl, % Options
		}
	}
}
Tab3 Demo:
For Tab3 control, is kind of tricky.
  • You can hide the Tab3 header, by using WinHide. (Note: GuiControl, Hide Will hide the entire Tab3 area)
  • Unlike Tab2 control, the Tab3 control has a container for its child controls (Screenshot). You'll need adding WS_CLIPCHILDREN style to this container.

Code: Select all

#NoEnv
SetBatchLines -1

Gui, +Resize +0x02000000 ; WS_CLIPCHILDREN := 0x02000000

Gui, Add, Radio, y20 h24 gSwitchTab Checked, Page1
Gui, Add, Radio, x+50 h24 gSwitchTab, Page2

Gui, Add, Tab3, xm w400 h200 vTabCtrl +HWNDhTab, Page1|Page2
	Gui, Tab, 1
		Gui, Add, Text, x+10 y+10 Section Disabled, This is Tab3
		Gui, Add, Edit, xs w374 h50 +HWNDhEdit, 
		Gui, Add, Button, xs w374 h50, Test Button
		Gui, Add, Text, xs+302 y+20, Bottom Text
	Gui, Tab, 2
		Gui, Add, Button, x+10 y+40, This is page 2
	Gui, Tab

Gui, Add, Edit, xm w300 h40 vEditBottom
Gui, Show

tab3 := New Tab3Ex(hTab)
tab3.HideHdr()
tab3.ReduceFlickering( tab3.GetContainer(hEdit) )
Return

SwitchTab:
	tab3.Choose(A_GuiControl)
return

GuiSize:
	AutoXYWH("w h0.5", hTab)
	AutoXYWH("! y0.5 x", "Bottom Text", "This is page 2")
	AutoXYWH("w", hEdit, "Test Button", "Btn1")
	AutoXYWH("y0.5 w *", "EditBottom")
return

GuiClose:
ExitApp

class Tab3Ex
{
	__New(hTab) {
		this.hTab := hTab
	}

	HideHdr() {
		DllCall("ShowWindow", "ptr", this.hTab, "int", 0) ; SW_HIDE := 0
	}

	ShowHdr() {
		DllCall("ShowWindow", "ptr", this.hTab, "int", 5) ; SW_SHOW := 5
	}

	; hChild - The handle of one of the child controls of Tab3
	GetContainer(hChild) {
		return DllCall("GetParent", "ptr", hChild, "ptr")
	}

	ReduceFlickering(hContainer) {
		WinSet, Style, +0x02000000, ahk_id %hContainer% ; WS_CLIPCHILDREN := 0x02000000
	}

	Choose(TabName) {
		DllCall("LockWindowUpdate", "ptr", this.hTab)
		this.ShowHdr()
		GuiControl, Choose, % this.hTab, |%TabName%
		this.HideHdr()
		DllCall("LockWindowUpdate", "ptr", 0)
	}
}

AutoXYWH(DimSize, cList*) {       ; http://ahkscript.org/boards/viewtopic.php?t=1079
	Static cInfo := {}
	
	If (DimSize = "reset") {
		Return cInfo := {}
	}
	
	For i, ctrl in cList {
		ctrlID := A_Gui ":" ctrl
		If (cInfo[ctrlID].x = "") {
			GuiControlGet i, %A_Gui%: Pos, %ctrl%

			if InStr(DimSize, "!") {
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
				GuiControlGet, _i, %A_Gui%: Pos, %ctrl%
				iX := iX - (_iX - iX), iY := iY - (_iY - iY)
				GuiControl, % A_Gui ":Move", % ctrl, x%iX% y%iY%
			}

			MMD := InStr(DimSize, "*") ? "MoveDraw" : "Move"
			fx := fy := fw := fh := 0
			For i, dim in (a := StrSplit(RegExReplace(DimSize, "i)[^xywh]"))) {
				If (!RegExMatch(DimSize, "i)" . dim . "\s*\K[\d.-]+", f%dim%)) {
					f%dim% := 1
				}
			}
			cInfo[ctrlID] := {x: ix, fx: fx, y: iy, fy: fy, w: iw, fw: fw, h: ih, fh: fh, gw: A_GuiWidth, gh: A_GuiHeight, a: a, m: MMD}
		} Else If (cInfo[ctrlID].a.1) {
			dgx := dgw := A_GuiWidth - cInfo[ctrlID].gw, dgy := dgh := A_GuiHeight - cInfo[ctrlID].gh
			Options := ""
			For i, dim in cInfo[ctrlID]["a"] {
				Options .= dim . (dg%dim% * cInfo[ctrlID]["f" . dim] + cInfo[ctrlID][dim]) . A_Space
			}
			GuiControl, % A_Gui ":" cInfo[ctrlID].m, % ctrl, % Options
		}
	}
}
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

17 Sep 2018, 17:14

Dude, this is a nightmare for me when there are classes. But you make it so clear that I think I get classes a bit more.
This solution seems to work on the example script! If I am able to integrate \ rewrite my GUI I'll test it properly.

In the example of Tab3 it flickers I'd say like 80% less than without your solution

thanks so much for investing time in this topic.
I'll keep studying your class and try to figure out how to use something similar in my own GUI that is very messy. I get lost myself in it because I was working with variables for almost each controls so its really confusing. And I also did not use loops for repeats. anyways thank you :)
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

17 Sep 2018, 18:26

Code: Select all

+0x02000000
seems to mess up with the controls that have background transparency :(
And to be honest my script is too confusing to integrate a new thing I just get lost so I've stopped after 30 minutes of trial and error.
Thank you very much for everything :)
Last edited by DRocks on 22 Oct 2018, 05:56, edited 1 time in total.
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

21 Oct 2018, 15:14

Hello again @tmplinshi

I have discovered an exception with the function that I am wondering if you have a clue how this could be adressed.

Context:

Code: Select all

AutoXYWH(" * X0.09 y0.4 w0.815", "TableLine1")
is working fine until I have moved "TableLine1" with "GuiControl, Move" somehwere else in the script than GuiSize gLabel

Code: Select all

GuiControl, Move, TableLine1, % "y" 239+(20*NextRow)
What happens as soon as it was moved, is that the function does not remember the new position like it normally does. It still considers the orignal creation Position of TableLine1 when triggering GuiSize Label. So the result is that it goes back to original position then it moves according to the parameters passed to the function.

What do you think could communicate that Pos change to Auto XYWH() before or within the function?
tmplinshi
Posts: 1278
Joined: 01 Oct 2013, 14:57

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

21 Oct 2018, 21:39

Call AutoXYWH("reset") after GuiControl.
DRocks
Posts: 190
Joined: 08 May 2018, 10:20

Re: (solved) AutoXYWH function - Y axis Resize bug [cause Tab3]

22 Oct 2018, 06:02

Perfect! Thank you again!!
And sorry for my beginner mistakes, I realise this was probably written in the instructions but I've read over it.

have a good day,
Alex

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], jackdunning, Yugo and 50 guests