Sign in to follow this  
Followers 0
UEZ

[Solved] How to make it without using child GUI?

13 posts in this topic

#1 ·  Posted (edited)

Any idea how to create this GUI example without using a child GUI?

#include <constants.au3>
#include <guirebar.au3>
#include <guiscrollbars.au3>
#include <guitoolbar.au3>
#include <screencapture.au3>
#include <scrollbarconstants.au3>
#include <windowsconstants.au3>

Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp
Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight
Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH)
Global Const $iW = 800, $iH = 600

Global Const $hGUI = GUICreate("Test", $iW, $iH)
Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI)
Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

Global Const $height_delta = 38
Global Const $hGUI_Child = GUICreate("", $iW, $iH - $height_delta, 0, $height_delta, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
Global Const $idPic = GUICtrlCreatePic("", 0, 0, $iImageW, $iImageH)

_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

_GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2)
Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3)
Global Const $iYCaption = _WinAPI_GetSystemMetrics(4)
Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8)
Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7)

Global Const $iMetricsSumX = $iVSscroll  + $iXFixedFrame * 2
Global Const $iMetricsSumY = $iHSscroll +  $iYCaption + $iYFixedFrame

_GUIScrollBars_Init($hGUI_Child)
_GUIScrollBars_SetScrollInfoMin($hGUI_Child, $SB_HORZ, 0)
_GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX)
_GUIScrollBars_SetScrollInfoMin($hGUI_Child, $SB_VERT, 0)
_GUIScrollBars_SetScrollInfoMax($hGUI_Child, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1)

GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hGUI_Child)

Global Const $STM_SETIMAGE = 0x0172
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture))
_WinAPI_DeleteObject($hBMP_ScreenCapture)

Global $IE_offset_x = 0, $IE_offset_y = 0

GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE")

Do
Until GUIGetMsg() = -3

GUIRegisterMsg($WM_HSCROLL, "")
GUIRegisterMsg($WM_VSCROLL, "")

Exit

Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $Min, $Max, $Page, $TrackPos

    ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $Min = DllStructGetData($tSCROLLINFO_X, "nMin")
    $Max = DllStructGetData($tSCROLLINFO_X, "nMax")
    $Page = DllStructGetData($tSCROLLINFO_X, "nPage")

    ; Save the position for comparison later on
    $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos")
    $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos")
    #forceref $Min, $Max
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Switch $nScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos)
    EndSwitch

;~  // Set the position and then retrieve it.  Due to adjustments
;~  //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X)

    $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos")
    ControlMove("", "", $idPic, -$IE_offset_x, -$IE_offset_y)

    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_HSCROLL_IE

Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Local $Min, $Max, $Page, $TrackPos

;~  ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO_Y, "nMin")
    $Max = DllStructGetData($tSCROLLINFO_Y, "nMax")
    $Page = DllStructGetData($tSCROLLINFO_Y, "nPage")
    ; Save the position for comparison later on
    $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos")
    $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos")
    #forceref $Min, $Max
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Switch $nScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos)
    EndSwitch

;~  // Set the position and then retrieve it.  Due to adjustments
;~  //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y)

    $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos")

    ControlMove("", "", $idPic, -$IE_offset_x, -$IE_offset_y)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_VSCROLL_IE

The important part is that I need scrollbars if the image is larger than the GUI to draw via GDI+ onto the image.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Recreated an example from help-file:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Example()
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp
Func Example()
    Local $oIE, $GUI_Button_Back, $GUI_Button_Forward
    Local $GUI_Button_Home, $GUI_Button_Stop, $msg
    $oIE = ObjCreate("Shell.Explorer.2")
    ; Create a simple GUI for our output
    GUICreate("Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
    GUICtrlCreateObj($oIE, 10, 40, 600, 360)
    $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
    $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
    $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
    $GUI_Button_Stop = GUICtrlCreateButton("Stop", 330, 420, 100, 30)
    GUISetState() ;Show GUI
    $oIE.navigate(@WINDOWSDIR & "\Web\Wallpaper\Autumn.jpg")
    ; Waiting for user to close the window
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $GUI_Button_Home
                $oIE.navigate("http://www.autoitscript.com")
            Case $msg = $GUI_Button_Back
                $oIE.GoBack
            Case $msg = $GUI_Button_Forward
                $oIE.GoForward
            Case $msg = $GUI_Button_Stop
                $oIE.Stop
        EndSelect
    WEnd
    GUIDelete()
EndFunc   ;==>Example

Doesn't seem to work for BMP files (on my PC) though.

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Nice idea but I need a control id / handle where I can draw via GDI+. It is not only for displaying an image!

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

UEZ,

The problem is that the toolbar is considered part of the client area and so gets scrolled along with the other controls. All my Googling suggests that the DWM API (in particular DwmExtendFrameIntoClientArea) might be the solution to keeping the toolbar out of the client area - but it seems to be limited to Vista+ and also needs Aero enabled. ;)

I hope this is of some help - personally I think that a child GUI is simpler, and certainly more general in application! :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@M23: thank you very much for your effort. I already implemented what I want with parent/child gui but I don't like the situation that the focus is changing depending which GUI is currently active -> see "Basic Image Editor" in Windows Screenshooter.

There are several applications like screen captures (e.g. Snipping Tool) which are using only one GUI:

Snipping Tool:

>>>> Control <<<<

Class: ToolbarWindow32

Instance: 1

ClassnameNN: ToolbarWindow321

Name:

Advanced (Class): [CLASS:ToolbarWindow32; INSTANCE:1]

>>>> Control <<<<

Class: Microsoft-Windows-Tablet-SnipperEditorPanel

Instance: 1

ClassnameNN: Microsoft-Windows-Tablet-SnipperEditorPanel1

Name:

Advanced (Class): [CLASS:Microsoft-Windows-Tablet-SnipperEditorPanel; INSTANCE:1]

The windows handle stays the same on both controls.

The hint to exclude an area on GUI sounds interesting...

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Hello UEZ, someone posted a similar solution in c++ at codeproject. Take a look: http://www.codeproject.com/Articles/3175/Displaying-Bitmap-with-Scrolling


----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

Nice idea, not scrolling the control but copying a portion from the image to the control according to the scrollbar values.

Thanks,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

All I could do so far was this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Func SetBitmapResourceToPicCtrl($hwnd,$ctrl,$file,$resource)
    Local Const $STM_SETIMAGE = 0x0172
    Local Const $IMAGE_BITMAP = 0
    Local Const $LR_LOADFROMFILE = 0x00000010
    Local $A = ControlGetHandle($hwnd,"",$ctrl)
    Local $DLLinst = DLLCall("kernel32.dll","hwnd","LoadLibrary","str",$file)
    $DLLinst = $DLLinst[0]
    Local $hBitmap = DLLCall("user32.dll","hwnd","LoadImage","hwnd",$DLLinst,"short",$resource, _
            "int",$IMAGE_BITMAP,"int",401,"int",225,"int",0)
    $hBitmap = $hBitmap[0]
    _SendMessage($A,$STM_SETIMAGE,$IMAGE_BITMAP,$hBitmap)
    DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst)
EndFunc

$Form1 = GUICreate("Form1", 633, 391, 481, 220)
$Pic1 = GUICtrlCreatePic("", 88, 56, 401, 225, BitOR($SS_NOTIFY,$WS_GROUP,$WS_HSCROLL,$WS_VSCROLL,$WS_CLIPSIBLINGS))
SetBitmapResourceToPicCtrl($Form1, $Pic1, @scriptdir & "IrRes.dll", 97)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Please, once you finish your example, do post it here. It will be a great help to me... like using WM_HSCROLL and WM_VSCROLL.

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

This might be one solution:

;coded by UEZ 2012
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <GuiReBar.au3>
#include <GuiScrollBars.au3>
#include <GuiToolbar.au3>
#include <ScreenCapture.au3>
#include <ScrollBarConstants.au3>
#include <WindowsConstants.au3>

_GDIPlus_Startup()
Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper
Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight
Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False)
Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture)

Sleep(50)
Global Const $iW = 800, $iH = 600

Global Const $hGUI = GUICreate("Test", $iW, $iH)
Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI)
Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

Global Const $height_delta = 37
Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH)
Global $hBitmap_tmp, $hHBitmap_tmp
$hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp)

_GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

_GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
_GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
_GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
_GUICtrlToolbar_AddButtonSep($hToolbar)
_GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP)

_GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2)
Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3)
Global Const $iYCaption = _WinAPI_GetSystemMetrics(4)
Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8)
Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7)

Global Const $iMetricsSumX = $iVSscroll  + $iXFixedFrame * 2
Global Const $iMetricsSumY = $iHSscroll +  $iYCaption + $iYFixedFrame

_GUIScrollBars_Init($hGUI)
_GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0)
_GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX)
_GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0)
_GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1)

GUISetState(@SW_SHOW, $hGUI)

Global Const $STM_SETIMAGE = 0x0172
_WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture))

Global $IE_offset_x = 0, $IE_offset_y = 0

DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH)

GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE")


Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
Until False

GUIRegisterMsg($WM_HSCROLL, "")
GUIRegisterMsg($WM_VSCROLL, "")

_WinAPI_DeleteObject($hBMP_ScreenCapture)
_GDIPlus_BitmapDispose($hBitmap_tmp)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGfx_Context)
_GDIPlus_Shutdown()
Exit

Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam
    Local $Min, $Max, $Page, $TrackPos

    ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $Min = DllStructGetData($tSCROLLINFO_X, "nMin")
    $Max = DllStructGetData($tSCROLLINFO_X, "nMax")
    $Page = DllStructGetData($tSCROLLINFO_X, "nPage")

    ; Save the position for comparison later on
    $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos")
    $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos")
    #forceref $Min, $Max
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Switch $nScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos)
    EndSwitch

;~    // Set the position and then retrieve it.  Due to adjustments
;~    //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X)

    $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos")

    DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH)
    $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp))
    _WinAPI_DeleteObject($hHBitmap_tmp)

    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_HSCROLL_IE

Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $lParam

    Local $Min, $Max, $Page, $TrackPos

;~  ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO_Y, "nMin")
    $Max = DllStructGetData($tSCROLLINFO_Y, "nMax")
    $Page = DllStructGetData($tSCROLLINFO_Y, "nPage")
    ; Save the position for comparison later on
    $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos")
    $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos")
    #forceref $Min, $Max
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Switch $nScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos)
    EndSwitch

;~    // Set the position and then retrieve it.  Due to adjustments
;~    //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y)

    $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos")

    DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH)
    Return "GUI_RUNDEFMSG"
EndFunc   ;==>WM_VSCROLL_IE

Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH)
    _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH)
    $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp)
    _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp))
    _WinAPI_DeleteObject($hHBitmap_tmp)
EndFunc

Thanks MKISH for the hint!

Any other solutions or ideas?

Br,

UEZ

Edited by UEZ
made it runable with v3.3.14.2

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

UEZ,

Clever stuff! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

You can exclude part of the client area from scrolling with ScrollWindow and ScrollWindowEx.

Unfinished example with painting issues.

http://msdn.microsoft.com/en-us/library/...=vs.85%29.aspx#scrolling_the_c

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <guirebar.au3>
#include <guitoolbar.au3>
#include <constants.au3>


Global Const $SW_ERASE = 0x4
Global Const $SW_INVALIDATE = 0x2
Global Const $SW_SCROLLCHILDREN = 0x1

_Main()

Func _Main()
    Local $nFileMenu, $nExititem, $GUIMsg, $hGUI, $h_cGUI, $h_cGUI2
    Local $listview, $button

    $hGUI = GUICreate("ScrollBar Example", 400, 400)
    GUISetBkColor(0x88AABB)

    Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp
    Local $hToolbar = _GUICtrlToolbar_Create($hGUI)
    Local $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)
    _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    Global $tRect = _WinAPI_GetClientRect($hToolbar)
    $iOffset = DllStructGetData($tRect, 4)
    DllStructSetData($tRect, 2, $iOffset+2)
    DllStructSetData($tRect, 4, DllStructGetData($tRect, 3)-$iOffset+2)


    $listview = GUICtrlCreateListView("col1  |col2|col3  ", 10, $iOffset+4, 200, 150);, BitOr($GUI_SS_DEFAULT_LISTVIEW, $WS_CHILD, $WS_CLIPCHILDREN))
    For $x = 1 To 30
        GUICtrlCreateListViewItem("item" & $x & "|col2|col3", $listview)
    Next
    $h_cGUI = GUICreate("Child GUI", 200, 150, 10, 200, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI)
    GUISetState()
    GUISwitch($hGUI)

    _GUIScrollBars_Init($h_cGUI2)
    _GUIScrollBars_ShowScrollBar($h_cGUI2, $SB_HORZ, False)

    GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
    GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL")

    GUISetState()

    _GUIScrollBars_Init($hGUI)
    _GUIScrollBars_Init($h_cGUI)

    While 1
        $GUIMsg = GUIGetMsg()

        Switch $GUIMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd

    Exit
EndFunc   ;==>_Main


Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)

    Local $index = -1, $xChar, $xPos
    Local $Min, $Max, $Page, $Pos, $TrackPos

    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $xChar = $aSB_WindowInfo[$index][2]
            ExitLoop
        EndIf
    Next
    If $index = -1 Then Return 0

;~   ; Get all the horizontal scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $xPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $xPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
    #forceref $Min, $Max
    Switch $nScrollCode

        Case $SB_LINELEFT ; user clicked left arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

        Case $SB_LINERIGHT ; user clicked right arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

        Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

        Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
    EndSwitch

;~  // Set the position and then retrieve it.  Due to adjustments
;~  //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($Pos <> $xPos) Then _GUIScrollBars_ScrollWindowEx($hWnd, $xChar * ($xPos - $Pos), 0, $tRect, $tRect, 0, 0, BitOR($SW_SCROLLCHILDREN,$SW_INVALIDATE,$SW_ERASE))

    _WinAPI_UpdateWindow($hWnd)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_HSCROLL

Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
    #forceref $Msg, $wParam, $lParam
    Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
    Local $index = -1, $yChar, $yPos
    Local $Min, $Max, $Page, $Pos, $TrackPos

    For $x = 0 To UBound($aSB_WindowInfo) - 1
        If $aSB_WindowInfo[$x][0] = $hWnd Then
            $index = $x
            $yChar = $aSB_WindowInfo[$index][3]
            ExitLoop
        EndIf
    Next
    If $index = -1 Then Return 0


    ; Get all the vertial scroll bar information
    Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
    $Min = DllStructGetData($tSCROLLINFO, "nMin")
    $Max = DllStructGetData($tSCROLLINFO, "nMax")
    $Page = DllStructGetData($tSCROLLINFO, "nPage")
    ; Save the position for comparison later on
    $yPos = DllStructGetData($tSCROLLINFO, "nPos")
    $Pos = $yPos
    $TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")

    Switch $nScrollCode
        Case $SB_TOP ; user clicked the HOME keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $Min)

        Case $SB_BOTTOM ; user clicked the END keyboard key
            DllStructSetData($tSCROLLINFO, "nPos", $Max)

        Case $SB_LINEUP ; user clicked the top arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)

        Case $SB_LINEDOWN ; user clicked the bottom arrow
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)

        Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)

        Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)

        Case $SB_THUMBTRACK ; user dragged the scroll box
            DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
    EndSwitch

;~  // Set the position and then retrieve it.  Due to adjustments
;~  //   by Windows it may not be the same as the value set.

    DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
    _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    _GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
    ;// If the position has changed, scroll the window and update it
    $Pos = DllStructGetData($tSCROLLINFO, "nPos")

    If ($Pos <> $yPos) Then _GUIScrollBars_ScrollWindowEx($hWnd, 0, $yChar * ($yPos - $Pos), $tRect, $tRect, 0, 0, BitOR($SW_SCROLLCHILDREN,$SW_INVALIDATE,$SW_ERASE))

    _WinAPI_UpdateWindow($hWnd)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>WM_VSCROLL


Func _GUIScrollBars_ScrollWindowEx($hWnd, $iXAmount = 0, $iYAmount = 0, $tScroll = 0, $tClip = 0, $hUpdate = 0, $tUpdate = 0, $iFlags = 0)
    ;rover
    If Not IsHWnd($hWnd) Then Return SetError(-2, -1, False)
    Local $aResult = DllCall("user32.dll", "int", "ScrollWindowEx", "hwnd", $hWnd, _
    "int", $iXAmount, "int", $iYAmount, "struct*", $tScroll, "struct*", $tClip , _
    "handle", $hUpdate, "struct*", $tUpdate, "uint", $iFlags)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc

I see fascists...

Share this post


Link to post
Share on other sites

rover,

I very nearly PMed you to see if you had a solution. Glad to see my confidence in your abilities was well placed! ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

@rover: nice example Mr. GUI ;)

That was also one of my ideas to exclude an area of the gui but had no idea how to do it.

Thanks for sharing it!

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • drapdv
      By drapdv
      I have a GUI with a parent window that has a menu and shortcut buttons at the top, and a child window which displays a list which is scrolled vertically.
      When the list is relatively small, like no more than 100 or so lines then it scrolls fine.  As the list gets larger, scrolling begins to slow, and if you start mixing up the scroll method (mousewheel, left-clicking the scrollbar box, etc) then it begins to hang.  When it hangs, dwm.exe CPU usage maxes out, and I can't even switch to another window.  Each line in the list is 1000px wide X 30px tall, and the lines alternate between a gray background and a white background, in case that matters.
      When a non-Aero theme is active, everything works fine.  So, I could disable DWM every time someone fires it up, but changing a client's color scheme is not ideal.
      I tried to utilize _WinAPI_DwmSetWindowAttribute($oGui_Parent,  $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED), and although it succeeds in disabling DWM for that window, it doesn't seem to make any difference as far as the scrolling lag is concerned.
      The code is several thousand lines long and contains proprietary information, so I'm trying to avoid posting that, but these are the lines which are creating the GUIs.  Is there anything that anyone can think of off the top of their heads, or is there anything jumping out at you from this snippet of code?  Any help is appreciated!
      $oGui_Parent = GUICreate("Data Viewer", 700, 500, Default, Default, BitOR($WS_CAPTION, $WS_MINIMIZEBOX, $WS_POPUPWINDOW)) WinSetTrans($oGui_Parent, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Parent, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF) $oGui_Child = GUICreate("", 700, 400, 0, 100, $WS_POPUP, $WS_EX_MDICHILD, $oGui_Parent) WinSetTrans($oGui_Child, "", 255) _WinAPI_DwmSetWindowAttribute($oGui_Child, $DWMWA_NCRENDERING_POLICY, $DWMNCRP_DISABLED) GUISetFont(9, 500, 0, "Calibri") GUISetBkColor(0xFFFFFF)