Jump to content

Disable Drag and Drop for RichEdit

Go to solution Solved by Danp2,

Recommended Posts

Hi Dan,

OK i made a short extract from my program, which contents the WindowEdit.

You can drag photos from internet pages into, which i want to disable.

Hope this helps

Cheers mike

#include <WinAPISys.au3>
#include <WinAPIsysinfoConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>


Func WindowEdit($sTitle)

    Global $hGlo_WE_Control, $hGlo_WE_GUI

    Global $idGlo_WE_Close, $idGlo_WE_Copy, $idGlo_WE_Cut, $idGlo_WE_Delete, $idGlo_WE_Find, $idGlo_WE_MenuEdit, $idGlo_WE_MenuFile, $idGlo_WE_New
    Global $idGlo_WE_Open, $idGlo_WE_Paste, $idGlo_WE_Play, $idGlo_WE_PlayHelp, $idGlo_WE_Save, $idGlo_WE_SaveAs, $idGlo_WE_SelectAll, $idGlo_WE_Undo

    Local $aClientSize, $hExStyle, $hStyle, $hWnd, $iHeight, $iLeft, $iTop, $iWidth, $sText

    $hWnd = GUICreate("")

    $iWidth = ScreenSizeAvailableGet()[0] - 6
    $iHeight = ScreenSizeAvailableGet()[1] - 25
    $iLeft = 0
    $iTop = 0

    $hStyle = BitOR($WS_CAPTION, $WS_SYSMENU)


    $hGlo_WE_GUI = GUICreate($sTitle, $iWidth , $iHeight, $iLeft, $iTop, $hStyle, $hExStyle, $hWnd)

    $hExStyle = $WS_EX_CLIENTEDGE

    $hGlo_WE_Control = _GUICtrlRichEdit_Create($hGlo_WE_GUI, "", 0, 0, $iWidth, $iHeight - 19, $hStyle, $hExStyle)

    ; File Menu

    $idGlo_WE_MenuFile = GUICtrlCreateMenu("File")
    $idGlo_WE_New = GUICtrlCreateMenuItem("New ..." & @TAB & "Strg+N", $idGlo_WE_MenuFile)
    $idGlo_WE_Open = GUICtrlCreateMenuItem("Open" & @TAB & "Strg+O", $idGlo_WE_MenuFile)
    $idGlo_WE_Save = GUICtrlCreateMenuItem("Save" & @TAB & "Strg+S", $idGlo_WE_MenuFile)
    $idGlo_WE_SaveAs = GUICtrlCreateMenuItem("Save As ...", $idGlo_WE_MenuFile)

    GUICtrlCreateMenuItem("", $idGlo_WE_MenuFile, 5)

    $idGlo_WE_Close = GUICtrlCreateMenuItem("Close" & @TAB & "Alt+F4", $idGlo_WE_MenuFile)

    ; File Menu End ----------------------------------------------------------------------------

    ; Edit Menu

    $idGlo_WE_MenuEdit = GUICtrlCreateMenu("Edit")
    $idGlo_WE_Undo = GUICtrlCreateMenuItem("Undo" & @TAB & "Strg+Z", $idGlo_WE_MenuEdit)

    GUICtrlCreateMenuItem("", $idGlo_WE_MenuEdit, 2)

    $idGlo_WE_Cut = GUICtrlCreateMenuItem("Cut" & @TAB & "Strg+X", $idGlo_WE_MenuEdit)
    $idGlo_WE_Copy = GUICtrlCreateMenuItem("Copy" & @TAB & "Strg+C", $idGlo_WE_MenuEdit)
    $idGlo_WE_Paste = GUICtrlCreateMenuItem("Paste" & @TAB & "Strg+V", $idGlo_WE_MenuEdit)
    $idGlo_WE_Delete = GUICtrlCreateMenuItem("Delete" & @TAB & "Del", $idGlo_WE_MenuEdit)

    GUICtrlCreateMenuItem("", $idGlo_WE_MenuEdit, 7)

    $idGlo_WE_Find = GUICtrlCreateMenuItem("Find" & @TAB & "Strg+F", $idGlo_WE_MenuEdit)

    GUICtrlCreateMenuItem("", $idGlo_WE_MenuEdit, 9)

    $idGlo_WE_SelectAll = GUICtrlCreateMenuItem("Select All" & @TAB & "Strg+A", $idGlo_WE_MenuEdit)

    ; Edit Menu End ----------------------------------------------------------------------------

    GUISetState(@SW_SHOW, $hGlo_WE_GUI)

    While 1
        Switch GUIGetMsg()

            Case $GUI_EVENT_CLOSE, $idGlo_WE_Close

EndFunc   ;==>WindowEdit

Func ScreenSizeAvailableGet()
    Local $tWorkArea
    Local $aResult[2]

    $tWorkArea = DllStructCreate($tagRECT)

    _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($tWorkArea))

    $aResult[0] = DllStructGetData($tWorkArea, "Right") - DllStructGetData($tWorkArea, "Left")
    $aResult[1] = DllStructGetData($tWorkArea, "Bottom") - DllStructGetData($tWorkArea, "Top")

    Return $aResult
EndFunc   ;==>ScreenSizeAvailableGet


Link to comment
Share on other sites

  • Solution

Unsure if there's a simple way to accomplish this. Found this earlier discussion --

Edit: Found a way using DragDropEvent_Revoke found here. Add this line immediately after the control is created --


The function looks like this --

Func DragDropEvent_Revoke($hWnd)
    DllCall("ole32.dll", "int", "RevokeDragDrop", "hwnd", $hWnd)


Edited by Danp2
Link to comment
Share on other sites

  • 9 months later...

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

  • Recently Browsing   0 members

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