Jump to content

Creating a natural GUI window


aommaster
 Share

Recommended Posts

Hey guys!

I'm trying to get a GUI window to 'feel' natural in the sense that when you open a proper program like Microsoft Word, you have complete flexibility over what, where, how the GUI looks and feels.

I'm attempting to get that same effect with Autoit, and I'm pretty sure Autoit is capable of doing it. To start off, my process began on what makes a GUI feel natural. I came up with:

1.It should be resizable

2.Scrollbars should not be visible unless there is something that can't be seen because the GUI is small

3.The Menu bar should remain static regardless of size. If the GUI is resized to such an extent that parts of the menu bar are hidden, nothing should happen. Scrollbars should not be displayed (please correct me if this is inaccurate)

The current GUI layout I'm using is this:

$window= GUICreate($currenttitle, 500, 500, -1, -1, 0x94FF0000)

However, the problem with this is that the scrollbars are always displayed no matter what. Is there a way of achieving point #2? Unless there is the 'natural GUI' that I haven't seen?

Thanks again!

Link to comment
Share on other sites

Hi Zedna!

For setting control's resizing use GUICtrlSetResizing()

This feature is probably one of the features that I'll end up using in the program. However, it still doesn't solve my scrollbar problem.

So yes, I can have this control behave in this way, and this other control behave in this other way when resizing of the window occurs. However, how can I get scrollbars to pop out just when some element in the GUI gets hidden because the window has been resized too small?

Thanks

Link to comment
Share on other sites

Thanks for taking a look at the code for me Zedna!

So, a little bit of background. I intend on volunteering at Bleeping Computer's HijackThis team and have nearly halfway though my training. Canned speeches are used throughout ie. posts that are already pre-written to direct users to do various things such as run programs, etc.

This program will eventually end up as a database to store and preview all the canned speeches so that members can select which ones they want, add it to the program's preview, and send it.

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>


#region Create Window
Opt("GUIOnEventMode", 1)
$currenttitle="Canned Speech Assistant V0.1 by Aommaster"
$window= GUICreate($currenttitle, 500, 500, -1, -1, 0x94FF0000)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion

#region Tabs
$tab=GUICtrlCreateTab (10,10,490,470)
#Region Create Post Previewer
$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 40)
$message= GUICtrlCreateEdit("", 20, 55, 470, 100)

;$tab1=GUICtrlCreateTabitem ("Canned Speech Editor")
#endregion
#endregion

while 1
    sleep(100)
WEnd

func Closeclicked()
    Exit
Endfunc

Please pardon the regions, commenting, etc. I tend to have them as a scaffolding to base my program so I can navigate to stuff quickly.

Oh, and while you're looking at this, you'll notice that if you attempt to run the program, even though a GUI elements have been defined in the first tab, they don't seem to be displayed. What am I doing wrong?

Thanks again for your time Zedna!

Link to comment
Share on other sites

Here is version with some corrections.

But I don't know how to make "auto scrollbars".

There are some posts about "scroll GUI".

#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

$currenttitle="Canned Speech Assistant V0.1 by Aommaster"
$window= GUICreate($currenttitle, 500, 500, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) ;0x94FF0000)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$tab=GUICtrlCreateTab (10,10,490,470)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 40)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$message= GUICtrlCreateEdit("", 20, 55, 470, 100)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
$tab1=GUICtrlCreateTabitem ("Canned Speech Editor")
GUICtrlCreateLabel("Some Label:", 20, 40)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUISetState(@SW_SHOW)

while 1
    sleep(100)
WEnd

func Closeclicked()
    Exit
Endfunc

EDIT: you can replace $GUI_DOCKALL by $GUI_DOCKAUTO or any other

Edited by Zedna
Link to comment
Share on other sites

Hi Zedna!

Okay, so the code I have decided to use was this:

#region Create Window
Opt("GUIOnEventMode", 1)
$window= GUICreate("Canned Speech Assistant V0.1 by Aommaster", 500, 500, -1, -1, BitOr($WS_HSCROLL, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_VSCROLL)) 

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
#endregion

#region Tabs
$tab=GUICtrlCreateTab (10,10,480,440)
GUICtrlSetResizing(-1,102)
#Region Create Post Previewer
$tab0=GUICtrlCreateTabitem ("Post Previewer")
GUICtrlCreateLabel("Message:", 20, 40)
GUICtrlSetResizing ( -1, $GUI_DOCKALL)
$message= GUICtrlCreateEdit("", 20, 55, 460, 100)
GUICtrlSetResizing ( -1, 550)
GUISetState(@SW_SHOW)
;$tab1=GUICtrlCreateTabitem ("Canned Speech Editor")
#endregion
#endregion

For some reason, the code you gave me has its maximize box disabled, so I'm not too sure what's up with that.

Now, if you could actually try the code by replace the top part of the code, you'll notice that the scrollbars are still active even though the full window is displayed. Not sure if this is a vista thing, or something wrong with my coding. Care to shine a little light on it?

Also, if you try dragging the bottom of the window all the way up, you'll see that the edit box overlaps the tab area. Not a big problem, but looks unprofessional. Any ideas on how to fix it?

Edit:

Fixed my previous problem, came up with another :)

Edited by aommaster
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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