Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Scrollbars Made Easy - New version 9 Aug 14


  • Please log in to reply
131 replies to this topic

#1 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 29 April 2010 - 03:50 PM

[New Version] - 9 Aug 14

Added: Ability to use the cursor keys to scroll if required.

Fixed: Links to variables in the underlying GUIScrollbars UDF.

New UDFs, examples and zip file below. smile.png

Previous changes: Attached File  Changelog.txt   1.53KB   32 downloads
 
Are you bemused by scrollbars? sad.png
Do you find them too difficult to use? sad.png

Then you need the GUIScrollbars_Ex UDF! smile.png

Just download the zip at the end of the post and run this short script with the UDF in the same folder. No tricky calculations, no complicated functions to master - just easy to use, accurate scrollbars with one command!



AutoIt         
[size=5]#include <guiconstantsex.au3> #include "GUIScrollbars_Ex.au3" ; Create GUI with red background $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFF0000, $hGUI) ; Create a 1000x1000 green label GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() ; Generate scrollbars - Yes, this is all you need to do!!!!!!!!!!!!!!!!!!!! _GUIScrollbars_Generate($hGUI, 1000, 1000) While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd[/size]
Try it today and see how easy it is!

I have been trying for some time to understand how scrollbars work and how to get them closely to match the area I want to display. After much research and headscratching I have come up with 2 UDFs which I hope will be of use to others. Apologies for the length of this post, but scrollbars are complex beasts and as I did this mainly for the less experienced user I want to make sure that they understand what is going on.

The 2 UDFs are:

GUIScrollbars_Ex.au3 - This gives you scrollbars sized to your GUI in one simple command - with no other includes or commands needed. The UDF is designed for those who would not normally use scrollbars because the whole process looks too complicated. It also includes a command to enable you to scroll page by page, thus making it easy to scroll to anywhere on the GUI with only simple calulations based on the values you used to create the GUIs. [New] Additional commands allow you to restore the scrollbar position after minimizing and restoring the GUI

GUIScrollbars_Size.au3 - This calculates the Page and Max numbers for the user to feed into the _GUIScrollbar_SetScrollInfoPage/Max commands. The UDF is aimed at the more experienced user and is particularly useful when you have a GUI with a dynamic scroll size (i.e. adding or subtracting controls to the scrollable area as the script runs). [New] Addtional command to restore the scrollbar position after a minimize/restore cycle.

First, a short tutorial for those who are interested in how the scrollbars affect your GUI and what it is that the UDFs calculate:
Spoiler

All the files mentioned here are in a downloadable zip file at the end of the post.

GUIScroll_Size.au3

As mentioned previously, the GUIScroll_Size.au3 UDF is aimed at the more experienced user who wants to use the full range of _GUIScrollbar comands, but would like a quick way of getting the required Page and Max values. It uses no other include files so you will need to include GUIScrollbars.au3 yourself, as well as the necessary GUIRegisterMsg and procedures for WM_VSCROLL and WM_HSCROLL. The syntax is simple - the size of the scrollable GUI and either the handle of the GUI you have created to hold the scrollbars or the size of the one you are going to create. It returns a 6-element array including the Page and Max values for the scrollbars and factors to compensate for the "shrinkage" of the GUI if you had already drawn some controls and wished to add others. Of interest, the returned Max value is biased not to clip the edges of the GUI - reducing it by 1 makes a tighter fit but can lead to some clipping. (If that does not make sense, please see the tutorial above for more details)

The Size_Example_1 script to show the UDF in action - the "Pass Size" button shows the effect of creating the scrollbars BEFORE the controls, the "Pass Handle" button shows what happens if the scrollbars are created AFTER the controls. If you do not understand why there is a difference - go and read the tutorial above wink.png ! You will need to have the GUIScroll_Size.au3 UDF in the same folder.

Where this UDF really helps is if you have a scrollable GUI of variable size - if the number of controls varies with user selections for example. All you need to do is to rerun the UDF with the new size of the scrollable GUI and it produces a new Max value for you to use. The Size_Example_2 script shows how the function enables you to dynamically size your scrollbars depending on the number of controls required. As before it requires the GUIScroll_Size.au3 UDF in the same folder.

--------

Now the "simple" GUIScrollbars_Ex.au3 (which is actually the more complex internally as you would expect).

This UDF is intended to be the single point of call for creating scrollbars on a GUI - it will automatically add the GUIScrollbars UDF and the WM_VSCROLL and WM_HSCROLL GUIRegisterMsg commands and procedures to your script - so you need no commands other than those within the UDF itself. These commands are _GUIScrollbars_Generate and _GUIScrollbars_Scroll_Page.

As you might expect, _GUIScrollbars_Generate generates scrollbars for your GUI. It is usually called AFTER you have added all the controls and all you need to use it is the GUI handle and the size of the underlying GUI you want to scroll. If you so wish, you can also decide to generate the scrollbars BEFORE the controls on the scrollable GUI, and you can choose if you want to risk not quite reaching the edge of the GUI when the scrollbars are at the maximum position. So a basic call could be as simple as:

_GUIScrollbars_Generate ($hGUI, 1000, 1000)

which would put scrollbars on the $hGUI window allowing a 1000x1000 underlying GUI to be displayed.

_GUIScrollbars_Scroll_Page lets you scroll a page at a time. If your GUI was 200 pixels wide, you would have 1000/200 = 5 pages to scroll before reaching the edge - no need to know what the actual Page and Max values are, just use this simple division based on the number you use to draw the GUIs. So:

_GUIScrollbars_Scroll_Page ($hGUI, 3)

would scroll to the third page - it would display the area between 400 and 600 pixels of the full 1000 pixel width. If you ask for a page over the maximum available, you just scroll to the maximum position - asking for page 1 resets you to the origin.

_GUIScrollbars_Minimize and _GUIScrollbars_Restore allow you to reset the scrollbars to the correct position after a minimize/restore cycle.

Ex_Example_1 shows the UDF working. You can decide whether to have both or just one scrollbar, whether to create the scrollbars before or after the controls, and whether you want the maximum scroll to be tight to the edge or leave a border. Just select the options you want - the script selects a random width and height for both the scrollbar GUI and the underlying GUI - and press the "Scroll" button to show a single page scroll down and/or right followed by a scroll to the bottom right corner of the GUI. There are labels to let you see the size of the GUI and the accuracy of the page scrolls (please read the tutorial above to understand why these are almost certainly inaccurate). The script requires the GUIScrollbars_Ex.au3 UDF in the same folder.

Ex_Example_2 is a really simple example to show how easy generating scrollbars can now become! As you can see - no other includes, no GUIRegisterMsg commands, no WM_H/VSCROLL procedure functions. Just accurate scrolling and proportional thumb sizes.

Ex_Example_3 shows the automatic calculation of control positions.

[New] Ex_Example_4 shows how to initiate the cursor keys to scroll the GUI as well.

I hope these 2 UDFs are useful to AutoIt users - I certainly find them so.

Here is a zip file with the UDFs and examples: Attached File  Scrollbars.zip   16.66KB   235 downloads

My grateful thanks to the authors of the GUIScrollbars and WinAPI UDFs for their code, some of which I have plundered. And as always I welcome constructive criticism and/or effusive congratulations. smile.png

M23

Edited by Melba23, 09 August 2014 - 11:48 AM.

  • Xandy and 232showtime like this
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items







#2 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,510 posts

Posted 29 April 2010 - 06:31 PM

I was looking at something like this a couple of days back and found this (a post by you) and now you release this, awesome! Thanks.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#3 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 29 April 2010 - 06:34 PM

Very good, but if i am a “less experienced user”, then i will have a difficulties to save all these scripts to correct files and make it work. Why you guys don't post an attached zip-file with all needed UDFs/Examples, so lazy users as my self could just download the archive, unpack it and check the great stuff you have there :idea:
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#4 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 29 April 2010 - 07:19 PM

MrCreatoR,

post an attached zip-file

Done - see first post. :idea:

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#5 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 29 April 2010 - 08:33 PM

Done - see first post

Thank you!
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#6 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 29 April 2010 - 09:20 PM

Melba23,

Posted Image AWESOME! A very nice implementation and a job well done!

I needed something like this for one of my projects so this will be of much use.

James

#7 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 30 April 2010 - 07:46 AM

Hi,

I realised that there was not a really simple example to show how easy GUIScrollbars_Ex is to use - so here it is:
AutoIt         
#include <GUIConstantsEx.au3> #include <GUIScrollbars_Ex.au3> ; Create GUI with red background $hGUI = GUICreate("Test", 500, 500) GUISetBkColor(0xFF0000, $hGUI) ; Create a 1000x1000 green label GUICtrlCreateLabel("", 0, 0, 1000, 1000) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState() ; Generate scrollbars - yes this is all you have to do!!!!!!!!!!!!!! _GUIScrollbars_Generate($hGUI, 1000, 1000) While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd

I have added it to the zip above and amended the first post. :idea:

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#8 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 30 April 2010 - 03:56 PM

I realised that there was not a really simple example to show how easy GUIScrollbars_Ex is to use - so here it is:

Nice, but i think that you can make more usefull example. Many users need the scrollable GUI for the settings window, so this window could include more options in one place (reachable by the scroll).
Here is the example:

AutoIt         
#include <GUIConstantsEx.au3> #include <GUIScrollbars_Ex.au3> ; Create GUI $hGUI = GUICreate("_GUIScrollbars_Generate Demo", 500, 500) $iTop = 20 For $i = 1 To 100     GUICtrlCreateCheckbox("Option " & $i & "-a", 20, $iTop)     GUICtrlCreateCheckbox("Option " & $i & "-b", 500, $iTop)         $iTop += 20 Next ; Generate scrollbars _GUIScrollbars_Generate($hGUI, 600, $iTop) GUISetState() While 1     Switch GUIGetMsg()         Case $GUI_EVENT_CLOSE             Exit     EndSwitch WEnd


P.S
I have one small(?) feature request: Add an ability to scroll the window by mouse wheel.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#9 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 30 April 2010 - 04:28 PM

MrCreatoR,

Add an ability to scroll the window by mouse wheel

I have never been able to get my mouse to scroll an AutoIt scrollbar. And yes I have tried your MouseOnEvent UDF. :idea: Everything works except the scroll wheel.

So if you would like to work at it, be my guest. :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#10 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 30 April 2010 - 04:52 PM

Hi Melba,

I'm drawing custom window, at least the title bar is custom. However I'm unable to make the scrollbars ignore the top region and only scroll an area beneath it.

AutoIt         
#NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #include <WinApi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include "../GUIScrollbars_Size.au3" Global Const $SC_DRAGMOVE = 0xF012 Opt("MouseCoordMode", 2) Local $tMsg Opt("TrayMenuMode", 1) $frmMain = GUICreate("frmMain", 333, 441, -1, -1, $WS_POPUP, 0) GUISetState(@SW_SHOW) GUISetBkColor(0xe9eff5, $frmMain) ; Scrollbars $aRet = _GUIScrollbars_Size(0, 500, 1, 441) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($frmMain) _GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3]) $rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3) _WinAPI_SetWindowRgn($frmMain, $rgn) DrawBar() While 1     $tMsg = TrayGetMsg()     Switch $tMsg         Case $TRAY_EVENT_PRIMARYDOWN             GUISetState(@SW_SHOW)             DrawBar()             WinSetState("frmMain", "", @SW_RESTORE)             Opt("TrayIconHide", 1)     EndSwitch     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $GUI_EVENT_PRIMARYDOWN             $mPos = MouseGetPos()             If $mPos[1] <= 20 Then                 If $mPos[0] >= 295 And $mPos[0] <= 316 Then                     GUISetState(@SW_HIDE)                     Opt("TrayIconHide", 0)                 ElseIf $mPos[0] >= 313 And $mPos[0] <= 322 Then                     Exit                 Else                     _SendMessage($frmMain, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)                 EndIf             EndIf     EndSwitch WEnd Func DrawBar()     Local $aDim = WinGetClientSize($frmMain)     Local $hDC = _WinAPI_GetDC($frmMain)     ; Bar     Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5     Local $hRect = DllStructCreate($tagRECT)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 0)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Bar text     Local $sTitle = WinGetTitle($frmMain)     Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5     DllStructSetData($hRect, "Left", 4)     DllStructSetData($hRect, "Top", 2)     DllStructSetData($hRect, "Right", $aDim[0] - 40)     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_SetBkMode($hDC, $TRANSPARENT)     _WinAPI_SetTextColor($hDC, 0xFFFFFF)     _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)     _WinAPI_DeleteObject($hBrush)     ; Minimize     $hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", $aDim[0] - 37)     DllStructSetData($hRect, "Top", 12)     DllStructSetData($hRect, "Right", $aDim[0] - 28)     DllStructSetData($hRect, "Bottom", 14)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Close     Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)     Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)     _WinAPI_SelectObject($hDC, $hSelected)     _WinAPI_DeleteObject($hPen)     $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)     ; Frame Edge     ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", 1)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", $aDim[0] - 2)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", $aDim[1] - 2)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     _WinAPI_ReleaseDC($frmMain, $hDC)     AdlibRegister("DrawBar") EndFunc   ;==>DrawBar Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)     #forceref $Msg, $wParam, $lParam     Local $nScrollCode = BitAND($wParam, 0x0000FFFF)     Local $iIndex = -1, $yChar, $yPos     Local $Min, $Max, $Page, $Pos, $TrackPos     For $x = 0 To UBound($aSB_WindowInfo) - 1         If $aSB_WindowInfo[$x][0] = $hWnd Then             $iIndex = $x             $yChar = $aSB_WindowInfo[$iIndex][3]             ExitLoop         EndIf     Next     If $iIndex = -1 Then Return 0     Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)     $Min = DllStructGetData($tSCROLLINFO, "nMin")     $Max = DllStructGetData($tSCROLLINFO, "nMax")     $Page = DllStructGetData($tSCROLLINFO, "nPage")     $yPos = DllStructGetData($tSCROLLINFO, "nPos")     $Pos = $yPos     $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")     Switch $nScrollCode         Case $SB_TOP             DllStructSetData($tSCROLLINFO, "nPos", $Min)         Case $SB_BOTTOM             DllStructSetData($tSCROLLINFO, "nPos", $Max)         Case $SB_LINEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)         Case $SB_LINEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)         Case $SB_PAGEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)         Case $SB_PAGEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)         Case $SB_THUMBTRACK             DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)     EndSwitch     DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)     _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     $Pos = DllStructGetData($tSCROLLINFO, "nPos")     If ($Pos <> $yPos) Then         _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))         $yPos = $Pos     EndIf     Return $GUI_RUNDEFMSG EndFunc   ;==>_Scrollbars_WM_VSCROLL

James

#11 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 30 April 2010 - 05:15 PM

james,

As far as I know Windows draws the scrollbars to fill the client area - which is what is happening here. :)

However, nothing is impossible: :(
AutoIt         
#NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #include <WinApi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <GUIScrollbars_Size.au3> Global Const $SC_DRAGMOVE = 0xF012 Opt("MouseCoordMode", 2) Local $tMsg Opt("TrayMenuMode", 1) $frmMain = GUICreate("frmMain", 333, 421, -1, -1, $WS_POPUP, 0) GUISetState(@SW_SHOW) GUISetBkColor(0xe9eff5, $frmMain) $frmBar = GUICreate("frmBar", 333, 20, -1, -1, $WS_POPUP, 0) GUISetState(@SW_SHOW) $aPos = WinGetPos($frmMain) WinMove($frmBar, "", $aPos[0], $aPos[1] - 20) GUIRegisterMsg($WM_MOVE, "StickTogether") ; Scrollbars $aRet = _GUIScrollbars_Size(0, 500, 1, 441) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($frmMain) _GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3]) $rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3) _WinAPI_SetWindowRgn($frmMain, $rgn) DrawBar() While 1     $tMsg = TrayGetMsg()     Switch $tMsg         Case $TRAY_EVENT_PRIMARYDOWN             GUISetState(@SW_SHOW)             DrawBar()             WinSetState("frmMain", "", @SW_RESTORE)             Opt("TrayIconHide", 1)     EndSwitch     $nMsg = GUIGetMsg()     Switch $nMsg         Case $GUI_EVENT_CLOSE             Exit         Case $GUI_EVENT_PRIMARYDOWN             $mPos = MouseGetPos()             If $mPos[1] <= 20 Then                 If $mPos[0] >= 295 And $mPos[0] <= 316 Then                     GUISetState(@SW_HIDE)                     Opt("TrayIconHide", 0)                 ElseIf $mPos[0] >= 313 And $mPos[0] <= 322 Then                     Exit                 Else                     _SendMessage($frmBar, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)                 EndIf             EndIf     EndSwitch WEnd Func StickTogether($hWnd, $iMsg, $wParam, $lParam)     #forceref $iMsg, $wParam, $lParam     Switch $hWnd         Case $frmBar             Local $aPos = WinGetPos($frmBar)             WinMove($frmMain, "", $aPos[0], $aPos[1] + 20)     EndSwitch EndFunc Func DrawBar()     Local $aDim = WinGetClientSize($frmBar)     Local $hDC = _WinAPI_GetDC($frmBar)     ; Bar     Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5     Local $hRect = DllStructCreate($tagRECT)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 0)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Bar text     Local $sTitle = WinGetTitle($frmBar)     Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5     DllStructSetData($hRect, "Left", 4)     DllStructSetData($hRect, "Top", 2)     DllStructSetData($hRect, "Right", $aDim[0] - 40)     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_SetBkMode($hDC, $TRANSPARENT)     _WinAPI_SetTextColor($hDC, 0xFFFFFF)     _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)     _WinAPI_DeleteObject($hBrush)     ; Minimize     $hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", $aDim[0] - 37)     DllStructSetData($hRect, "Top", 12)     DllStructSetData($hRect, "Right", $aDim[0] - 28)     DllStructSetData($hRect, "Bottom", 14)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Close     Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)     Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)     _WinAPI_SelectObject($hDC, $hSelected)     _WinAPI_DeleteObject($hPen)     $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)     ; Frame Edge     ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", 1)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", $aDim[0] - 2)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", $aDim[1] - 2)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     _WinAPI_ReleaseDC($frmBar, $hDC)     AdlibRegister("DrawBar") EndFunc   ;==>DrawBar Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)     #forceref $Msg, $wParam, $lParam     Local $nScrollCode = BitAND($wParam, 0x0000FFFF)     Local $iIndex = -1, $yChar, $yPos     Local $Min, $Max, $Page, $Pos, $TrackPos     For $x = 0 To UBound($aSB_WindowInfo) - 1         If $aSB_WindowInfo[$x][0] = $hWnd Then             $iIndex = $x             $yChar = $aSB_WindowInfo[$iIndex][3]             ExitLoop         EndIf     Next     If $iIndex = -1 Then Return 0     Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)     $Min = DllStructGetData($tSCROLLINFO, "nMin")     $Max = DllStructGetData($tSCROLLINFO, "nMax")     $Page = DllStructGetData($tSCROLLINFO, "nPage")     $yPos = DllStructGetData($tSCROLLINFO, "nPos")     $Pos = $yPos     $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")     Switch $nScrollCode         Case $SB_TOP             DllStructSetData($tSCROLLINFO, "nPos", $Min)         Case $SB_BOTTOM             DllStructSetData($tSCROLLINFO, "nPos", $Max)         Case $SB_LINEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)         Case $SB_LINEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)         Case $SB_PAGEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)         Case $SB_PAGEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)         Case $SB_THUMBTRACK             DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)     EndSwitch     DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)     _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     $Pos = DllStructGetData($tSCROLLINFO, "nPos")     If ($Pos <> $yPos) Then         _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))         $yPos = $Pos     EndIf     Return $GUI_RUNDEFMSG EndFunc   ;==>_Scrollbars_WM_VSCROLL

You work out how I did it! :idea:

M23

P.S. There is some work to do still, I have only done the bare minimum. After all it is nothing to do with my UDF! :)
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#12 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 30 April 2010 - 05:45 PM

Melba,

Hmm I see. It's a little bit of a dirty method, but I'll work on it.

James

#13 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 30 April 2010 - 06:01 PM

James,

"dirty"? :idea:

"Inspired lateral thinking" would be my preferred comment! :)

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#14 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 30 April 2010 - 06:09 PM

"Inspired lateral thinking" would be my preferred comment! :idea:

M23

Posted Image

Two windows, one for title bar and one for client area? What were you inspired by, crack? :)

James

#15 James

James

    Universalist

  • MVPs
  • 10,337 posts

Posted 30 April 2010 - 06:09 PM

"Inspired lateral thinking" would be my preferred comment! :idea:

M23

Posted Image

Two windows, one for title bar and one for client area? What were you inspired by, crack? :)

James

#16 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,412 posts

Posted 30 April 2010 - 07:02 PM

Any reason not to make the content window an MDI child (WS_EX_MDICHILD)? Then moving the window takes care of itself. Here's an example. You might have to play with the window placement slightly, but it looks pretty good.
AutoIt         
#NoTrayIcon #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <Constants.au3> #include <WinApi.au3> #include <GUIScrollBars.au3> #include <ScrollBarConstants.au3> #include <GUIScrollbars_Size.au3> Global Const $SC_DRAGMOVE = 0xF012 Opt("MouseCoordMode", 2) Local $tMsg Opt("TrayMenuMode", 1) $frmBar = GUICreate("frmBar", 333, 441, -1, -1, $WS_POPUP, 0) GUISetState(@SW_SHOW) $frmMain = GUICreate("frmMain", 333, 421, 4, 24, $WS_POPUP, $WS_EX_MDICHILD, $frmBar) GUISetState(@SW_SHOW) ; Scrollbars $aRet = _GUIScrollbars_Size(0, 500, 1, 441) GUIRegisterMsg($WM_VSCROLL, "_Scrollbars_WM_VSCROLL") _GUIScrollBars_Init($frmMain) _GUIScrollBars_ShowScrollBar($frmMain, $SB_VERT, True) _GUIScrollBars_ShowScrollBar($frmMain, $SB_HORZ, False) _GUIScrollBars_SetScrollInfoPage($frmMain, $SB_VERT, $aRet[2]) _GUIScrollBars_SetScrollInfoMax($frmMain, $SB_VERT, $aRet[3]) $rgn = _WinAPI_CreateRoundRectRgn(0, 0, 333, 441, 3, 3) _WinAPI_SetWindowRgn($frmMain, $rgn) DrawBar() While 1     $tMsg = TrayGetMsg()     Switch $tMsg         Case $TRAY_EVENT_PRIMARYDOWN             GUISetState(@SW_SHOW, $frmBar)             GUISetState(@SW_SHOW, $frmMain)             WinActivate($frmBar)             DrawBar()             Opt("TrayIconHide", 1)     EndSwitch     $nMsg = GUIGetMsg(1)     Switch $nMsg[1] ; window         Case $frmBar             Switch $nMsg[0] ; event ID                 Case $GUI_EVENT_CLOSE                     Exit                 Case $GUI_EVENT_PRIMARYDOWN                     If $nMsg[4] <= 20 Then                         If $nMsg[3] >= 295 And $nMsg[3] <= 316 Then                             GUISetState(@SW_HIDE, $frmMain)                             GUISetState(@SW_HIDE, $frmBar)                             Opt("TrayIconHide", 0)                         ElseIf $nMsg[3] >= 313 And $nMsg[3] <= 322 Then                             Exit                         Else                             _SendMessage($frmBar, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)                         EndIf                     EndIf             EndSwitch     EndSwitch WEnd Func DrawBar()     Local $aDim = WinGetClientSize($frmBar)     Local $hDC = _WinAPI_GetDC($frmBar)     ; Bar     Local $hBrush = _WinAPI_CreateSolidBrush(0xf5d997) ; 0x97d9f5     Local $hRect = DllStructCreate($tagRECT)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 0)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Bar text     Local $sTitle = WinGetTitle($frmBar)     Local $hBrush = _WinAPI_CreateSolidBrush(0x000000) ; 0xe9eff5     DllStructSetData($hRect, "Left", 4)     DllStructSetData($hRect, "Top", 2)     DllStructSetData($hRect, "Right", $aDim[0] - 40)     DllStructSetData($hRect, "Bottom", 20)     _WinAPI_SetBkMode($hDC, $TRANSPARENT)     _WinAPI_SetTextColor($hDC, 0xFFFFFF)     _WinAPI_DrawText($hDC, $sTitle, $hRect, $DT_LEFT)     _WinAPI_DeleteObject($hBrush)     ; Minimize     $hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", $aDim[0] - 37)     DllStructSetData($hRect, "Top", 12)     DllStructSetData($hRect, "Right", $aDim[0] - 28)     DllStructSetData($hRect, "Bottom", 14)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     ; Close     Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, 0x000000)     Local $hSelected = _WinAPI_SelectObject($hDC, $hPen)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 5, $aDim[0] - 11, 14)     _WinAPI_DrawLine($hDC, $aDim[0] - 20, 14, $aDim[0] - 11, 5)     _WinAPI_SelectObject($hDC, $hSelected)     _WinAPI_DeleteObject($hPen)     $hBrush = _WinAPI_CreateSolidBrush(0xd8ded3)     ; Frame Edge     ;$hBrush = _WinAPI_CreateSolidBrush(0x000000)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", 1)     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", $aDim[0] - 2)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", 20)     DllStructSetData($hRect, "Right", 1)     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     DllStructSetData($hRect, "Left", 0)     DllStructSetData($hRect, "Top", $aDim[1] - 2)     DllStructSetData($hRect, "Right", $aDim[0])     DllStructSetData($hRect, "Bottom", $aDim[1])     _WinAPI_FillRect($hDC, DllStructGetPtr($hRect), $hBrush)     _WinAPI_DeleteObject($hBrush)     _WinAPI_ReleaseDC($frmBar, $hDC)     AdlibRegister("DrawBar") EndFunc   ;==>DrawBar Func _Scrollbars_WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)     #forceref $Msg, $wParam, $lParam     Local $nScrollCode = BitAND($wParam, 0x0000FFFF)     Local $iIndex = -1, $yChar, $yPos     Local $Min, $Max, $Page, $Pos, $TrackPos     For $x = 0 To UBound($aSB_WindowInfo) - 1         If $aSB_WindowInfo[$x][0] = $hWnd Then             $iIndex = $x             $yChar = $aSB_WindowInfo[$iIndex][3]             ExitLoop         EndIf     Next     If $iIndex = -1 Then Return 0     Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)     $Min = DllStructGetData($tSCROLLINFO, "nMin")     $Max = DllStructGetData($tSCROLLINFO, "nMax")     $Page = DllStructGetData($tSCROLLINFO, "nPage")     $yPos = DllStructGetData($tSCROLLINFO, "nPos")     $Pos = $yPos     $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")     Switch $nScrollCode         Case $SB_TOP             DllStructSetData($tSCROLLINFO, "nPos", $Min)         Case $SB_BOTTOM             DllStructSetData($tSCROLLINFO, "nPos", $Max)         Case $SB_LINEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)         Case $SB_LINEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)         Case $SB_PAGEUP             DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)         Case $SB_PAGEDOWN             DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)         Case $SB_THUMBTRACK             DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)     EndSwitch     DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)     _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)     $Pos = DllStructGetData($tSCROLLINFO, "nPos")     If ($Pos <> $yPos) Then         _GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))         $yPos = $Pos     EndIf     Return $GUI_RUNDEFMSG EndFunc   ;==>_Scrollbars_WM_VSCROLL


#17 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 21,743 posts

Posted 30 April 2010 - 07:25 PM

wraithdu,

I like a multi-brain solution to a problem! :idea:

M23
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items

#18 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 30 April 2010 - 08:06 PM

Posted Image

Two windows, one for title bar and one for client area? What were you inspired by, crack? :idea:

James

One of my favorite tricks for solving many GUI problems is to use multiple windows. It can save me having to create multiple controls for example and in some cases I even change the text for a button when a window is shown and then change it back when that Window is hidden and the original Child restored.
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#19 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 30 April 2010 - 11:52 PM

MrCreatoR,


I have never been able to get my mouse to scroll an AutoIt scrollbar. And yes I have tried your MouseOnEvent UDF. :idea: Everything works except the scroll wheel.

So if you would like to work at it, be my guest. :)

M23

It's easy, you just add this to the UDF:

#include <SendMessage.au3> .... GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") .... Func WM_MOUSEWHEEL($hWnd, $nMsg, $wParam, $lParam)     Local $nKeys = BitAnd($wParam, 0x0000FFFF)     Local $nDistance = BitShift($wParam, 16)         If $nDistance > 0 Then         _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEUP, 0)     Else         _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEDOWN, 0)     EndIf EndFunc


At least for the vertical scroll this is usefull.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#20 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 01 May 2010 - 12:03 AM

And this one will enable the horizontal scroll by holding Shift or Ctrl key:

Func _Scrollbars_WM_MOUSEWHEEL($hWnd, $nMsg, $wParam, $lParam)     Local $nKeys = BitAND($wParam, 0x0000FFFF)     Local $nDistance = BitShift($wParam, 16)         If $nKeys = 0 Then         If $nDistance > 0 Then             _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEUP, 0)         Else             _SendMessage($hWnd, $WM_VSCROLL, $SB_LINEDOWN, 0)         EndIf     Else         If $nDistance > 0 Then             _SendMessage($hWnd, $WM_HSCROLL, $SB_LINELEFT, 0)         Else             _SendMessage($hWnd, $WM_HSCROLL, $SB_LINERIGHT, 0)         EndIf     EndIf EndFunc

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: ATT - Application Translate Tool [new] | BlockIt - Block files & folders [new] | SIP - Selected Image Preview [new] | SISCABMAN - SciTE Abbreviations Manager [new] | AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramPosted Image UDFs: OnAutoItErrorRegister - Handle AutoIt critical errors [new] | AutoIt Syntax Highlight [new] | Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDFPosted Image Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users