seres

image scrolling

8 posts in this topic

hello, im currently creating an image viewer, i got re-sizing good, but when i want to display the full size picture the scrolling doesn't respond, here is my code:

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#Include <Math.au3>


$AreaWidth = 1224
$AreaHeight = 768
$centerximg = 0
$centeryimg = 0
$NewImageWidth = 0
$NewImageHeight = 0
$idPic = ""
$centerx=$AreaWidth / 2
$centery= $AreaHeight / 2


Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("Hello World", $AreaWidth, $AreaHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_HSCROLL, $WS_VSCROLL ))
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "resize")
GUISetOnEvent($GUI_EVENT_RESIZED, "resize")
GUISetOnEvent($GUI_EVENT_RESTORE, "resize")

_GDIPlus_Startup()
$ImgLoad = @ScriptDir & "\3.jpg"
$IMG = _GDIPlus_ImageLoadFromFile($ImgLoad)
; Calculate the ratio of the image
$ImageWidth = _GDIPlus_ImageGetWidth($IMG)
$ImageHeight = _GDIPlus_ImageGetHeight($IMG)
_GDIPlus_ImageDispose($IMG)
 _GDIPlus_Shutdown()
;$ratio = $ImageWidth/$ImageHeight
; set dimensions
; The width is calculated from the Height
;$GuiH = 600


WinWaitActive("Hello World")
;resize()

;$idPic = GUICtrlCreatePic($ImgLoad, 0, 0, $GuiH*$ratio, $GuiH)
;$idPic = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $NewImageWidth, $NewImageHeight)
$idPic2 = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $ImageWidth, $ImageHeight)


;ConsoleWrite(Round($NewImageWidth) & 'x' & Round($NewImageHeight) & @CR)




While 1
  Sleep(1000)  ; Idle around
WEnd

 

Share this post


Link to post
Share on other sites



Does this help? 

 


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

seres,

Or you could use my Scrollbars UDF - the link is in my sig.

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
7 hours ago, Melba23 said:

seres,

Or you could use my Scrollbars UDF - the link is in my sig.

M23

wow thanks it was really simple to use, but i have one question, once i activate the scrolling window, what is the best way to disable it, so the scrolling bars disappeared

 

Share this post


Link to post
Share on other sites

seres,

Why would you want to disable the scrollbars? Let me see the script you have been using and explain exactly what you want to happen.

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
1 hour ago, Melba23 said:

seres,

Why would you want to disable the scrollbars? Let me see the script you have been using and explain exactly what you want to happen.

M23

 

it's just for visual style, im trying to create an image viewer with modifying options(bicubic, etc), i already make it resizable for the window width and heigh, but i needed an option to use actual size with scrolling(im planning to use a button for this), but once it is activated the scrolling bars won't disappear even when i make the image resizable again

right now im in school, i dont have the full code, only the one i posted

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#Include <Math.au3>
#include "GUIScrollbars_Ex.au3"



$AreaWidth = 600
$AreaHeight = 468
$centerximg = 0
$centeryimg = 0
$NewImageWidth = 0
$NewImageHeight = 0
$idPic = ""
$centerx=$AreaWidth / 2
$centery= $AreaHeight / 2


Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("Hello World", $AreaWidth, $AreaHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX ))
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "disable")
;GUISetOnEvent($GUI_EVENT_RESIZED, "resize")
;GUISetOnEvent($GUI_EVENT_RESTORE, "resize")

_GDIPlus_Startup()
$ImgLoad = @ScriptDir & "\3.jpg"
$IMG = _GDIPlus_ImageLoadFromFile($ImgLoad)
; Calculate the ratio of the image
$ImageWidth = _GDIPlus_ImageGetWidth($IMG)
$ImageHeight = _GDIPlus_ImageGetHeight($IMG)
_GDIPlus_ImageDispose($IMG)
 _GDIPlus_Shutdown()
;$ratio = $ImageWidth/$ImageHeight
; set dimensions
; The width is calculated from the Height
;$GuiH = 600


WinWaitActive("Hello World")
;resize()

;$idPic = GUICtrlCreatePic($ImgLoad, 0, 0, $GuiH*$ratio, $GuiH)
;$idPic = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $NewImageWidth, $NewImageHeight)
$idPic2 = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $ImageWidth, $ImageHeight)

_GUIScrollbars_Generate($mainwindow, $ImageWidth, $ImageHeight, 0, 0, Default, 7)
;ConsoleWrite(Round($NewImageWidth) & 'x' & Round($NewImageHeight) & @CR)




While 1
  Sleep(1000)  ; Idle around
WEnd

Func disable()
    _GUIScrollbars_Generate($mainwindow, 0, 0, 0, 0, Default, 7)
EndFunc

Func CLOSEClicked()
    Exit
EndFunc

 

Share this post


Link to post
Share on other sites

seres,

I understand the requirement now.

Quote

right now im in school, i dont have the full code

No problem - just post it when you can.

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
2 hours ago, Melba23 said:

seres,

I understand the requirement now.

No problem - just post it when you can.

M23

hello, here is my full code

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#Include <Math.au3>

#include <GUIConstantsEx.au3>
#include "GUIScrollbars_Ex.au3"

$AreaWidth = 1224
$AreaHeight = 768
$centerximg = 0
$centeryimg = 0
$NewImageWidth = 0
$NewImageHeight = 0
$idPic = ""
$centerx=$AreaWidth / 2
$centery= $AreaHeight / 2


Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode
$mainwindow = GUICreate("Hello World", $AreaWidth, $AreaHeight, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX ))
$hButton_1 = GUICtrlCreateButton("full size enab/disab", 0, 0, 200, 30)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "resize")
GUISetOnEvent($GUI_EVENT_RESIZED, "resize")
GUISetOnEvent($GUI_EVENT_RESTORE, "resize")

_GDIPlus_Startup()
$ImgLoad = @ScriptDir & "\3.jpg"
$IMG = _GDIPlus_ImageLoadFromFile($ImgLoad)
; Calculate the ratio of the image
$ImageWidth = _GDIPlus_ImageGetWidth($IMG)
$ImageHeight = _GDIPlus_ImageGetHeight($IMG)
_GDIPlus_ImageDispose($IMG)
 _GDIPlus_Shutdown()
;$ratio = $ImageWidth/$ImageHeight
; set dimensions
; The width is calculated from the Height
;$GuiH = 600


WinWaitActive("Hello World")
resize()

;$idPic = GUICtrlCreatePic($ImgLoad, 0, 0, $GuiH*$ratio, $GuiH)
$idPic = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $NewImageWidth, $NewImageHeight)
;$idPic2 = GUICtrlCreatePic($ImgLoad, $centerximg, $centeryimg, $ImageWidth, $ImageHeight)



;_GUIScrollbars_Generate($mainwindow, $ImageWidth, $ImageHeight, 0, 0, Default, 7)



While 1
  Sleep(1000)  ; Idle around
WEnd


Func resize()

    $aPos = WinGetPos("[ACTIVE]")

    $Scale = _Min($aPos[2] / $ImageWidth, $aPos[3] / $ImageHeight)
    $NewImageWidth = $ImageWidth * $Scale
    $NewImageHeight = $ImageHeight * $Scale

    $centerximg = ($aPos[2] / 2) - ($NewImageWidth / 2)
    $centeryimg = ($aPos[3] / 2) - ($NewImageHeight / 2)

    ;$idPic = GUICtrlCreatePic($ImgLoad, 0, 0, $GuiH*$ratio, $GuiH)
    If $idPic <> "" Then
        GUICtrlSetPos($idPic, $centerximg, $centeryimg, $NewImageWidth, $NewImageHeight)
    EndIf
EndFunc




Func CLOSEClicked()
  Exit
EndFunc

 

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