Jump to content

math question


quickies
 Share

Go to solution Solved by jdelaney,

Recommended Posts

Gui Width = 800

Number of icons = 9

Icon width = 25

Space between Icons = 5

I have nine icons I am trying to center horizontally in the GUI and I stink at math. Would someone be so kind as to helping me with this equation. It is also noted that the gui size and icon size can change at anytime. Thank you in advance.

Edited by quickies
Link to comment
Share on other sites

  • Developers

What are you trying to figure out? The left margin for the first icon?

(800 - (9 * 25) - (8 * 5) ) / 2

Right ?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If math is a battlefield for you, it's a bad idea to write scripts.  ;)

But there is another way without calculating: Use Koda designer and let there arrange your controls automatically.

And if I lived under dogma such as yours perhaps I would end up stuck in the rat race.  Don't mistake a lack of knowledge in one particular aspect of life as a overall lack of knowledge in obtaining set information. This information is learned. I may say stink now because I do but give it a min. I can get there same as anyone else friend. I am as well familiar with Koda and ISN but I prefer good old notepad. I like the hard road, but then again if you knew me or had been sitting with me in this room for the last month programming and learning this language until the wee hours of the morning perhaps your tongue would have refrained from unleashing such rubbish. Look at me pot calling the kettle black. Sorry can't help but poke at peoples ignorance, but you kind of asked for it. Eye for an eye I suppose. Now lets be a little more inspirational and constructive shall we. World has enough damn self-destructive people in it.

@Jos

That is what I was looking for. Thank you sir.

Link to comment
Share on other sites

  • Solution

fun:

$iBuffer=5
$iIconWidth=25
$iIconHeight=25
$iCountIcon=9
Local $aIcons[$iCountIcon]
$iWidth = ($iIconWidth*$iCountIcon)+($iBuffer*($iCountIcon+1))
$iHeight = ($iIconHeight)+($iBuffer*(2))

GUICreate("My GUI Button", $iWidth, $iHeight) ; will create a dialog box that when displayed is centered

For $i = 0 To UBound($aIcons)-1
    $aIcons[$i]=GUICtrlCreateButton($i+1,($iIconWidth*$i)+($iBuffer*($i+1)),$iBuffer,$iIconWidth)
Next
GUISetState()
While True
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case _ArraySearch($aIcons,$msg) >= 0
            MsgBox(1,1,"ButtonText=[" & GUICtrlRead($msg) & "] was clicked")
    EndSelect
WEnd

Update any of the top 4 variables, and your gui will dynamically adjust...traded icons for buttons

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

And if I lived under dogma such as yours perhaps I would end up stuck in the rat race.  Don't mistake a lack of knowledge in one particular aspect of life as a overall lack of knowledge in obtaining set information. This information is learned. I may say stink now because I do but give it a min. I can get there same as anyone else friend. I am as well familiar with Koda and ISN but I prefer good old notepad. I like the hard road, but then again if you knew me or had been sitting with me in this room for the last month programming and learning this language until the wee hours of the morning perhaps your tongue would have refrained from unleashing such rubbish. Look at me pot calling the kettle black. Sorry can't help but poke at peoples ignorance, but you kind of asked for it. Eye for an eye I suppose. Now lets be a little more inspirational and constructive shall we. World has enough damn self-destructive people in it.

 

Hey, I have attacked you in any way? My remark was meant well. You will always encounter mathematical programming problems. Is the dogmatic?

Also my reference to Koda was serious. If you don't want to calculate by yourself, it gives you the desired options. That you does not use SciTE, I was not aware.

You should not always feel personally attacked. Rather, I could feel offended by your words.

To say it with Bobby McFerrin: Don't worry, be happy.

Best Regards BugFix  

Link to comment
Share on other sites

BugFix is super relaxed around here, he wasn't putting you down in anyway. Just making a little joke that was all.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Hey, I have attacked you in any way? My remark was meant well. You will always encounter mathematical programming problems. Is the dogmatic?

Also my reference to Koda was serious. If you don't want to calculate by yourself, it gives you the desired options. That you does not use SciTE, I was not aware.

You should not always feel personally attacked. Rather, I could feel offended by your words.

To say it with Bobby McFerrin: Don't worry, be happy.

Well then as Pat Benatar once said "love is a battlefield". Human interaction and communication should not be, nor math for that matter. I will only correct you one last time as you seem to like the defensive approach rather the other way around. Addressing your question as to did you attack me in any way? Well.......yeah you did. In fact I think your exact words were something along the lines of...."If math is a battlefield for you, it's a bad idea to write scripts" We will agree to disagree on this subject and call it a lost in interwebs translation as it could be taken both ways. Nothing new here. However in not knowing one another it is always best to take the offensive approach. A better response might have been something along the lines of. If math is problematic for you it might not be a bad idea to brush up on the subject matter. Here is an example of what you will be trying to accomplish and what you should research. This would have been much more conducive of polite social etiquette between two strangers. But, as we now both sit here assuming one another leading off the original question in some display of alpha superiority against one another, nothing has been accomplished outside of being less educated going out then coming in. In the future please shut your mouth when your talking to me. I could give a f less more than anyone in the room. Are you as bored as I am? Good times talking bout good times cause we moving on up to the easssssst side....

Link to comment
Share on other sites

What are you trying to figure out? The left margin for the first icon?

(800 - (9 * 25) - (8 * 5) ) / 2

Right ?

Jos

 

(800-(9×25))/10 think this would give you the size of the spaces between the icons

($guisize-($numberoficons×$iconsize))/$numberofspaces=$spacesize. I could be wrong tho

 

fun:

$iBuffer=5
$iIconWidth=25
$iIconHeight=25
$iCountIcon=9
Local $aIcons[$iCountIcon]
$iWidth = ($iIconWidth*$iCountIcon)+($iBuffer*($iCountIcon+1))
$iHeight = ($iIconHeight)+($iBuffer*(2))

GUICreate("My GUI Button", $iWidth, $iHeight) ; will create a dialog box that when displayed is centered

For $i = 0 To UBound($aIcons)-1
    $aIcons[$i]=GUICtrlCreateButton($i+1,($iIconWidth*$i)+($iBuffer*($i+1)),$iBuffer,$iIconWidth)
Next
GUISetState()
While True
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case _ArraySearch($aIcons,$msg) >= 0
            MsgBox(1,1,"ButtonText=[" & GUICtrlRead($msg) & "] was clicked")
    EndSelect
WEnd

Update any of the top 4 variables, and your gui will dynamically adjust...traded icons for buttons

 

With 3 responses on how to improve your knowledge the only remark you give is about the one you didn't like only impedes your concept of learning.  These 3 solutions should give you a better understanding of how to equate the output.  Jos shows how to start the equation. markyrocks shows how to use variables with the equation. Last but not least is an example jdelaney that show a gui created by the dimensions that could easily be altered to meet your needs.  

As you are new to AutoIt and its forums, I've came to notice that people here try to educate not humiliate others. Just because you don't get the answer you are looking for doesn't mean that you haven't been given the tools needed to acquire the task you request. As the saying goes "Give a man a fish he can eat for a day, show a man to fish, he can eat for a lifetime"

Link to comment
Share on other sites

With 3 responses on how to improve your knowledge the only remark you give is about the one you didn't like only impedes your concept of learning.  These 3 solutions should give you a better understanding of how to equate the output.  Jos shows how to start the equation. markyrocks shows how to use variables with the equation. Last but not least is an example jdelaney that show a gui created by the dimensions that could easily be altered to meet your needs.  

As you are new to AutoIt and its forums, I've came to notice that people here try to educate not humiliate others. Just because you don't get the answer you are looking for doesn't mean that you haven't been given the tools needed to acquire the task you request. As the saying goes "Give a man a fish he can eat for a day, show a man to fish, he can eat for a lifetime"

 

Ok Jesus slow your roll. You do not need to defend the stupidity. The intent of the last response I had given, well you pointed out the obvious there friend. I understand though. New poster old souls on the forum all stand up for each other. I get it. truthfully I was just a little bored and felt like asking some lazy questions. For that I do apologize, but the project is Autoit, so why not Autoit. Please refrain yourself from responding with some likeness of maybe next time you should take boredom to the boredom forums because we are here to teach. I also credited the author to whom I thought had the best answer. So, why on earth you are commenting on the individuals whom gave responses to some degree as to which I did not accredit them, only you know the answer to that. I imagine you read the bottom first and like every good human being of nature fired off based on emotion rather than logic. Go stand in front of the mirror for that one and say once out loud for me. I AM A SOFA KING STU PED. i took the help that was offered I poked back fun at those that poked fun at me, since it was stated that it was a small joke, but perhaps it is I? i don't know you seem witty and clever maybe you can tell me.

Anyways moving forward. I took the help I was given here and applied my logic and was able to figure out and apply a working solution. So, to those that constructively assisted me in accomplishing this answer. I thank you. For those of you with your heads so far stuffed up your own a$$es you can see the light of day when you smile. I thank you as well. Good day.

LOGIC

; GUI Size = 800
; Number of Items = 9
; Width of Items = 25
; Padding Between Items = 5
; Total Padding = Number of Items * Padding Between Items
; Total Width of Icons = Width of Items * Number of Items + Padding Between items
; -------------------------------------------------------------------------------
; Middle of GUI = GUI Size / 2
; Middle of Total Icon Width = Total Width of Icons / 2
; Middle Position = Middle of GUI - Middle of Total Icon Width
; -------------------------------------------------------------------------------
; = (325)
Link to comment
Share on other sites

  • Developers

 

Ok Jesus slow your roll. You do not need to defend the stupidity. The intent of the last response I had given, well you pointed out the obvious there friend. I understand though. New poster old souls on the forum all stand up for each other. I get it. truthfully I was just a little bored and felt like asking some lazy questions. For that I do apologize, but the project is Autoit, so why not Autoit. Please refrain yourself from responding with some likeness of maybe next time you should take boredom to the boredom forums because we are here to teach. I also credited the author to whom I thought had the best answer. So, why on earth you are commenting on the individuals whom gave responses to some degree as to which I did not accredit them, only you know the answer to that. I imagine you read the bottom first and like every good human being of nature fired off based on emotion rather than logic. Go stand in front of the mirror for that one and say once out loud for me. I AM A SOFA KING STU PED. i took the help that was offered I poked back fun at those that poked fun at me, since it was stated that it was a small joke, but perhaps it is I? i don't know you seem witty and clever maybe you can tell me.

Anyways moving forward. I took the help I was given here and applied my logic and was able to figure out and apply a working solution. So, to those that constructively assisted me in accomplishing this answer. I thank you. For those of you with your heads so far stuffed up your own a$$es you can see the light of day when you smile. I thank you as well. Good day.

Sigh ... Moving on too.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...