Jump to content



Photo

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


  • Please log in to reply
12 replies to this topic

#1 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 14 May 2012 - 09:12 PM

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

AutoIt         
#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, 17 May 2012 - 10:11 AM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯






#2 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 15 May 2012 - 04:25 AM

Recreated an example from help-file:

AutoIt         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() ; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI ; ; See also: <a href='http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp' class='bbc_url' title='External link' rel='nofollow external'>http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp</a> 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("<a href='http://www.autoitscript.com' class='bbc_url' title=''>http://www.autoitscript.com"</a>)             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, 15 May 2012 - 04:26 AM.

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::


#3 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 15 May 2012 - 08:17 AM

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

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#4 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,374 posts

Posted 15 May 2012 - 09:07 AM

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
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

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#5 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 15 May 2012 - 09:31 AM

@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

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#6 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 15 May 2012 - 09:52 AM

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

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::


#7 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 15 May 2012 - 10:06 AM

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

Thanks,
UEZ

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#8 MKISH

MKISH

    EXAM Time...

  • Active Members
  • PipPipPipPipPipPip
  • 534 posts

Posted 15 May 2012 - 10:14 AM

All I could do so far was this:

AutoIt         
#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, 15 May 2012 - 10:16 AM.

Get DROPBOX - simplify your life...

:::::Dear LOL and Hmmmm... thank you for always being there, when I have nothing else to say... - great words by the author of this post:::::


#9 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 15 May 2012 - 11:32 AM

This might be one solution:

AutoIt         
#include <Constants.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, $idHelp 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 Global $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) $hBitmap_tmp = $aResult[6] 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, $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) _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 GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Do Until GUIGetMsg() = -3 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")     _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)     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")     _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)     Return "GUI_RUNDEFMSG" EndFunc   ;==>WM_VSCROLL_IE


Thanks MKISH for the hint!

Any other solutions or ideas?

Br,
UEZ

Edited by UEZ, 15 May 2012 - 02:48 PM.

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯


#10 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,374 posts

Posted 15 May 2012 - 11:36 AM

UEZ,

Clever stuff! ;)

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

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#11 rover

rover

    unmutual

  • Active Members
  • PipPipPipPipPipPip
  • 825 posts

Posted 16 May 2012 - 05:26 PM

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


AutoIt         
#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...

#12 Melba23

Melba23

    Yes, me!

  • Moderators
  • 15,374 posts

Posted 16 May 2012 - 07:45 PM

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
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

RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options

GUIListViewEx - Insert, delete, move, drag and sort ListView items


#13 UEZ

UEZ

    Never say never

  • MVPs
  • 3,610 posts

Posted 16 May 2012 - 11:15 PM

@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

 
The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users