Jump to content

Recommended Posts

Posted

Hello :)

I got a GUI with a picture background the same size as the GUI and using the $WS_POPUP style (so there is no border on my GUI) so how can I move my GUI by by clicking on the picture and moving the picture to move my GUI. (Should this work on pictures $GUI_WS_EX_PARENTDRAG?)

I would also like to know how to put a picture on my GuiCtrlCreateInput box is this possible.

I have examples scripts but they do nothing I want them to do :)

Posted

#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

If Not IsDeclared('WM_LBUTTONDOWN') Then Global Const $WM_LBUTTONDOWN = $WM_LBUTTONUP-1

Global $hGUI = GUICreate('', 400, 400, -1, -1, $WS_POPUP)
GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN')
GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
Exit

Func WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    _SendMessage($hWnd, $WM_NCLBUTTONDOWN, $HTCAPTION, $ilParam)
    Return $GUI_RUNDEFMSG
EndFunc

About the input control with a picture I'm not sure but maybe it's possible.

Posted

#include <GUIConstantsEx.au3>
#include <SendMessage.au3>
#include <WindowsConstants.au3>

If Not IsDeclared('WM_LBUTTONDOWN') Then Global Const $WM_LBUTTONDOWN = $WM_LBUTTONUP-1

Global $hGUI = GUICreate('', 400, 400, -1, -1, $WS_POPUP)
GUIRegisterMsg($WM_LBUTTONDOWN, 'WM_LBUTTONDOWN')
GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
Exit

Func WM_LBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    _SendMessage($hWnd, $WM_NCLBUTTONDOWN, $HTCAPTION, $ilParam)
    Return $GUI_RUNDEFMSG
EndFunc

About the input control with a picture I'm not sure but maybe it's possible.

This works great for moving a GUI but can't get it to work with a picture.
Posted

Seems like you can put an image there but once the caret reaches the image the image gets deleted. You may want to handle the $WM_ERASEBKGND or the $WM_CHAR to repaint the image though it's just not necessary to put the image in first place because it's an edit control. :)

#include <Constants.au3>
#include <EditConstants.au3>
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()

Global Const $tagBITMAP = _
    'int bmType;' & _
    'int bmWidth;' & _
    'int bmHeight;' & _
    'int bmWidthBytes;' & _
    'ushort bmPlanes;' & _
    'ushort bmBitsPixel;' & _
    'ptr bmBits;'
    
Global Const $tagPAINTSTRUCT = _
    'hwnd hdc;' & _
    'int fErase;' & _
    $tagRECT & _
    ';int fRestore;' & _
    'int fIncUpdate;' & _
    'byte rgbReserved[32];'


Global $hGUI, $Edit
Global $hEdit, $hEditProc
Global $hFunc, $pFunc
Global $hImage, $hBitmap

$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\er.bmp')
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)

$hGUI = GUICreate('Test', 400, 400)
$Edit = GUICtrlCreateEdit('', 0, 0, 400, 400, $ES_WANTRETURN)
$hEdit = GUICtrlGetHandle($Edit)

$hFunc = DllCallbackRegister('EditProc', 'lresult', 'hwnd;uint;wparam;lparam')
$pFunc = DllCallbackGetPtr($hFunc)
$hEditProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $pFunc)
GUISetState()

Do
Until GUIGetMsg() = -3

GUIDelete()
DllCallbackFree($hFunc)
_GDIPlus_Shutdown()
Exit

Func EditProc($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hDC, $hMemDC
    Local $tPAINTSTRUCT, $pPAINTSTRUCT
    Local $tBmp, $pBmp, $ibmWidth, $ibmHeight
    Local $tRect, $iWidth, $iHeight
    
    If $iMsg = $WM_PAINT Then
        $tPAINTSTRUCT = DllStructCreate($tagPAINTSTRUCT)
        $pPAINTSTRUCT = DllStructGetPtr($tPAINTSTRUCT)
        $tRect = _WinAPI_GetClientRect($hWnd)
        $iWidth = DllStructGetData($tRect, 'Right')
        $iHeight = DllStructGetData($tRect, 'Bottom')
        
        $hDC = _WinAPI_BeginPaint($hWnd, $pPAINTSTRUCT)
        $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
        _WinAPI_SelectObject($hMemDC, $hBitmap)
        $tBmp = DllStructCreate($tagBITMAP)
        $pBmp = DllStructGetPtr($tBmp)
        
        _WinAPI_GetObject($hBitmap, DllStructGetSize($tBmp), $pBmp)
        $ibmWidth = DllStructGetData($tBmp, 'bmWidth')
        $ibmHeight = DllStructGetData($tBmp, 'bmHeight')
        _WinAPI_BitBlt($hDC, $iWidth/2-$ibmWidth/2, $iHeight/2-$ibmHeight/2, $ibmWidth, $ibmHeight, $hMemDC, 0, 0, $SRCCOPY)
        _WinAPI_DeleteDC($hMemDC)
        _WinAPI_EndPaint($hWnd, $pPAINTSTRUCT)
        Return 0
    EndIf
    
    Return _WinAPI_CallWindowProc($hEditProc, $hWnd, $iMsg, $iwParam, $ilParam)
EndFunc

Func _WinAPI_BeginPaint($hWnd, $pPS)
    Local $aResult
    
    $aResult = DllCall('user32.dll', 'hwnd', 'BeginPaint', 'hwnd', $hWnd, 'ptr', $pPS)
    If @error Then Return SetError(1, 0, 0)
    Return $aResult[0]
EndFunc

Func _WinAPI_EndPaint($hWnd, $pPS)
    Local $aResult
    
    $aResult = DllCall('user32.dll', 'hwnd', 'EndPaint', 'hwnd', $hWnd, 'ptr', $pPS)
    If @error Then Return SetError(1, 0, 0)
    Return $aResult[0]
EndFunc

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
×
×
  • Create New...