Jump to content

don't right move background png slide area


davidkim
 Share

Recommended Posts

Making main window draw...

i want mouse drag background png...

now it is moving to the left....

slide png is 50% making.....

Posted Image

mouse drag to icon area...move left.......

Posted Image

move to left....

Posted Image

not move right.. :idea:

right area blank area view.....

how can move right?

how can not blank backround?

this au3 source

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include
#include
#include
Global $thisXpos = Default
Global Const $tagBITMAP = 'long bmType;long bmWidth;long bmHeight;long bmWidthBytes;ushort bmPlanes;ushort bmBitsPixel;ptr bmBits;'

Global $back_png_witdh = 1680
Global $bUpdate_WM = False
Global $iAdjX_WM = 0
Global $now_xPos = 0

Global $x1 = 0, $x2 = 0, $x3 = 0
Global $np1 = 0, $np2 = 0, $np3 = 0
HotKeySet("{ESC}", "_exit_")

_GDIPlus_Startup()
$gui_png = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\phone_body.png")
$slide_png = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\phone_slide_pannel.png") ; 1680x337
$GUI = GUICreate("slide", 287, 553, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
$slide_area = GUICtrlCreateLabel("", 26, 85, 240, 337); if GUICtrlCreateButton is not scan $WM_LBUTTONUP ....
GUISetState()

GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR')

;~ Global $mouseevent, $timer

_First()

#cs
GUIGetCursorInfo
$aMPos[0] = X coord (horizontal)
$aMPos[1] = Y coord (vertical)
$aMPos[2] = Primary down (1 if pressed, 0 if not pressed)
$aMPos[3] = Secondary down (1 if pressed, 0 if not pressed)
$aMPos[4] = ID of the control that the mouse cursor is hovering over (or 0 if none)
#ce
While 1
Sleep(30)
$aMPos = GUIGetCursorInfo($GUI)
If $aMPos[4] = $slide_area Then
GUIRegisterMsg($WM_NCHITTEST, "") ;mouse slide area, disable move main form
If $aMPos[2] Then
$iAdjX_WM = $aMPos[0] ;this mouse x position
$bUpdate_WM = True
EndIf
Else
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST") ;mouse not slide area ,enable move main form
$bUpdate_WM = False
EndIf
If $bUpdate_WM Then _freeView($iAdjX_WM)
WEnd


Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam)
$iLParamhigh = BitShift($iLParam, 16) ;HiWord
$iLParamlow = BitAND($iLParam, 0x0000FFFF) ;LoWord
If $hWnd = $GUI And $iLParamlow = 1 And $iLParamhigh > 512 Then
Switch $iLParamhigh
Case $WM_LBUTTONDOWN
$np2 = $np3
ConsoleWrite('down np3:' & $np3 & @CRLF) ;last background x position
Case $WM_LBUTTONUP
$np3 = $np2
ConsoleWrite('up np2:' & $np3 & @CRLF) ;now background x position
EndSwitch
EndIf
EndFunc ;==>WM_SETCURSOR

Func WM_NCHITTEST($hWnd, $iMsg, $iWParam, $iLParam)
If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then
Return $HTCAPTION
EndIf
EndFunc ;==>WM_NCHITTEST

Func _First() ;GUICreate
Local $hGraphic, $hImage
$hImage = _GDIPlus_ImageClone($gui_png)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $slide_png, $np1, 0, 240, 337, 26, 85, 240, 337)
_WinAPI_UpdateLayeredWindowEx($GUI, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, 1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
EndFunc ;==>_First

Func _freeView($xPos)
If $xPos <> $thisXpos Then
$thisXpos = $xPos
Local $hGraphic, $hImage
$hImage = _GDIPlus_ImageClone($gui_png)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage)
If $x1 = 0 Then
$x1 = $xPos
ElseIf $x1 > $xPos Then
$gap = $x1 - $xPos
$x1 = $xPos
$np2 += $gap
ElseIf $x1 < $xPos Then
$gap = $xPos - $x1
$x1 = $xPos
$np2 -= $gap
EndIf
ConsoleWrite('before position scan $np2:' & $np2 & ' $now_xPos:' & $now_xPos & @CRLF)
If $now_xPos > $np2 Then
$np2 = $now_xPos
Else
$now_xPos = $np2
EndIf
ConsoleWrite('after positon scan $np2:' & $np2 & ' $now_xPos:' & $now_xPos & @CRLF)
_GDIPlus_GraphicsDrawImageRectRect($hGraphic, $slide_png, $np2, 0, 240, 337, 26, 85, 240, 337)
_WinAPI_UpdateLayeredWindowEx($GUI, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, 1)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_ImageDispose($hImage)
EndIf
EndFunc ;==>_freeView

Func _exit_()
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_exit_

Func _GDIPlus_ImageClone($hImage)
Local $aResult = DllCall($ghGDIPDll, 'uint', 'GdipCloneImage', 'ptr', $hImage, 'ptr*', 0)
If @error Then
Return SetError(1, 0, 0)
Else
If $aResult[0] Then
Return SetError($aResult[0], 0, 0)
EndIf
EndIf
Return $aResult[2]
EndFunc ;==>_GDIPlus_ImageClone

Func _WinAPI_UpdateLayeredWindowEx($hWnd, $hBitmap, $iOpacity = 255, $fDelete = 0)
Local $Ret, $tSIZE, $tPOINT, $tBLENDFUNCTION, $hDC, $hDestDC, $hDestSv
$Ret = DllCall('user32.dll', 'hwnd', 'GetDC', 'hwnd', $hWnd)
$hDC = $Ret[0]
$Ret = DllCall('gdi32.dll', 'hwnd', 'CreateCompatibleDC', 'hwnd', $hDC)
$hDestDC = $Ret[0]
$Ret = DllCall('gdi32.dll', 'hwnd', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hBitmap)
$hDestSv = $Ret[0]
$tSIZE = _WinAPI_GetBitmapDimension($hBitmap)
$tPOINT = DllStructCreate($tagPOINT)
$tBLENDFUNCTION = DllStructCreate($tagBLENDFUNCTION)
DllStructSetData($tBLENDFUNCTION, 'Alpha', $iOpacity)
DllStructSetData($tBLENDFUNCTION, 'Format', 1)
$Ret = DllCall('user32.dll', 'int', 'UpdateLayeredWindow', 'hwnd', $hWnd, 'hwnd', $hDC, 'ptr', 0, 'ptr', DllStructGetPtr($tSIZE), 'hwnd', $hDestDC, 'ptr', DllStructGetPtr($tPOINT), 'dword', 0, 'ptr', DllStructGetPtr($tBLENDFUNCTION), 'dword', 0x02)
DllCall('user32.dll', 'int', 'ReleaseDC', 'hwnd', $hWnd, 'hwnd', $hDC)
DllCall('gdi32.dll', 'ptr', 'SelectObject', 'hwnd', $hDestDC, 'ptr', $hDestSv)
DllCall('gdi32.dll', 'int', 'DeleteDC', 'hwnd', $hDestDC)
If Not $Ret[0] Then
Return SetError(1, 0, 0)
EndIf
If $fDelete Then
_WinAPI_DeleteObject($hBitmap)
EndIf
Return 1
EndFunc ;==>_WinAPI_UpdateLayeredWindowEx

Func _WinAPI_GetBitmapDimension($hBitmap)
Local $tObj = DllStructCreate($tagBITMAP)
Local $Ret = DllCall('gdi32.dll', 'int', 'GetObject', 'int', $hBitmap, 'int', DllStructGetSize($tObj), 'ptr', DllStructGetPtr($tObj))
If (@error) Or (Not $Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Local $tSIZE = DllStructCreate($tagSIZE)
DllStructSetData($tSIZE, 1, DllStructGetData($tObj, 'bmWidth'))
DllStructSetData($tSIZE, 2, DllStructGetData($tObj, 'bmHeight'))
Return $tSIZE
EndFunc ;==>_WinAPI_GetBitmapDimension

I interest am many quite in AutoitScript.From that is [http://cafe.naver.com/autoitscript[/color]] Korea of cafe(blog) to be operating, [size="2"][color="#ff00ff"]English cannot well[/size].Many help it requests.To read, it stands it thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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