个人比较喜欢windows消息模式
这代码中午给他写好了,楼主自己都不积极回复,本都不打算给他答案了。
。。。。。。 本帖最后由 tubaba 于 2021-11-23 22:29 编辑
更新版,左键和右键双击均可弹出新窗口
#include <WinAPIConstants.au3>
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("左键或者右键双击Edit修改内容", 615, 437, -1, -1)
$Edit1 = GUICtrlCreateEdit("", 120, 112, 345, 121)
Global $hEdit1_CallBack = DllCallbackRegister("Edit_CallBackFunc", "int", "hWnd;uint;wparam;lparam")
Global $pEdit1_CallBack = DllCallbackGetPtr($hEdit1_CallBack)
Global $hOEdit1_CallBack = _WinAPI_SetWindowLong(GUICtrlGetHandle($Edit1), $GWL_WNDPROC, $pEdit1_CallBack)
$Form2 = GUICreate("请在Edit中输入修改后的内容", 615, 437, 627, 422)
$Edit2 = GUICtrlCreateEdit("", 120, 112, 345, 121)
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg
Case $GUI_EVENT_CLOSE
Switch $nMsg
Case $Form1
Exit
Case $Form2
GUISetState(@SW_HIDE, $Form2)
GUICtrlSetData($Edit1, GUICtrlRead($Edit2))
EndSwitch
EndSwitch
WEnd
Func Edit_CallBackFunc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_LBUTTONDBLCLK
GUISetState(@SW_SHOW, $Form2)
Case $WM_RBUTTONUP
Local Static $ClicksStartTime,$OneClick = False
If TimerDiff($ClicksStartTime) > 500 Then
$ClicksStartTime = TimerInit()
$OneClick = True
Return 1
EndIf
If $OneClick Then
GUISetState(@SW_SHOW, $Form2)
EndIf
Return 1
EndSwitch
Return _WinAPI_CallWindowProc($hOEdit1_CallBack, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>Edit_CallBackFunc
haijie1223 发表于 2021-11-23 21:02
这代码中午给他写好了,楼主自己都不积极回复,本都不打算给他答案了。
。。。。。。
看他语言习惯,可能不是大陆同胞吧,可能有时差:face (1): haijie1223 发表于 2021-11-23 21:02
这代码中午给他写好了,楼主自己都不积极回复,本都不打算给他答案了。
。。。。。。
抱歉抱歉,因白天還有在上班,所以來論壇都是半夜,論壇如果有登入紀錄,應該可以查到我都是晚上才出沒的說,謝謝您了。 tubaba 发表于 2021-11-23 22:03
看他语言习惯,可能不是大陆同胞吧,可能有时差
:face (24):對對,有時差,我這邊半夜,地球的另一邊剛好吃午飯了 tubaba 发表于 2021-11-23 22:00
更新版,左键和右键双击均可弹出新窗口
感謝回覆,目前初步測試是我想要的功能,我會重新改寫我要的函數,感謝您的幫忙。 tubaba 发表于 2021-11-23 20:47
个人比较喜欢windows消息模式
winapi 模式,我對他不熟,我再分析源碼看看怎麼運作,這功能也是我想要的,謝謝協助。 本帖最后由 yohoboy 于 2021-11-24 02:08 编辑
#include <WinAPIConstants.au3>
#include <WinAPI.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $SIZE = 30 ,$Edit_Number =1
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("左键或者右键双击Edit修改内容", 415, 437, -1, -1)
Global $Edit1 = GUICtrlCreateEdit("Edit1", 10, 10, 345, 121)
Global $Edit2 = GUICtrlCreateEdit("Edit2", 10, 140, 345, 121)
Global $Edit3 = GUICtrlCreateEdit("Edit3", 10, 270, 345, 121)
Global $hEdit1_CallBack = DllCallbackRegister("Edit_CallBackFunc1", "int", "hWnd;uint;wparam;lparam")
Global $pEdit1_CallBack = DllCallbackGetPtr($hEdit1_CallBack)
Global $hOEdit1_CallBack = _WinAPI_SetWindowLong(GUICtrlGetHandle($Edit1), $GWL_WNDPROC, $pEdit1_CallBack)
Global $hEdit2_CallBack = DllCallbackRegister("Edit_CallBackFunc2", "int", "hWnd;uint;wparam;lparam")
Global $pEdit2_CallBack = DllCallbackGetPtr($hEdit2_CallBack)
Global $hOEdit2_CallBack = _WinAPI_SetWindowLong(GUICtrlGetHandle($Edit2), $GWL_WNDPROC, $pEdit2_CallBack)
Global $hEdit3_CallBack = DllCallbackRegister("Edit_CallBackFunc3", "int", "hWnd;uint;wparam;lparam")
Global $pEdit3_CallBack = DllCallbackGetPtr($hEdit3_CallBack)
Global $hOEdit3_CallBack = _WinAPI_SetWindowLong(GUICtrlGetHandle($Edit3), $GWL_WNDPROC, $pEdit3_CallBack)
$Form2 = GUICreate("请在Edit中输入修改后的内容", 600, 200, 627, 422)
$Edit4 = GUICtrlCreateEdit("Edit4", 10, 10, 580, 190)
GUICtrlSetFont($Edit4, $SIZE)
GUISetState(@SW_SHOW, $Form1)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg(1)
Switch $nMsg
Case $GUI_EVENT_CLOSE
Switch $nMsg
Case $Form1
Exit
Case $Form2
GUISetState(@SW_HIDE, $Form2)
If $Edit_Number = 1 Then
GUICtrlSetData($Edit1, GUICtrlRead($Edit4))
ElseIf $Edit_Number = 2 Then
GUICtrlSetData($Edit2, GUICtrlRead($Edit4))
ElseIf $Edit_Number = 3 Then
GUICtrlSetData($Edit3, GUICtrlRead($Edit4))
EndIf
EndSwitch
EndSwitch
WEnd
Func Edit_CallBackFunc1($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_LBUTTONDBLCLK
$Edit_Number = 1
GUICtrlSetData($Edit4, GUICtrlRead($Edit1))
GUISetState(@SW_SHOW, $Form2)
Case $WM_RBUTTONUP
Local Static $ClicksStartTime,$OneClick = False
If TimerDiff($ClicksStartTime) > 500 Then
$ClicksStartTime = TimerInit()
$OneClick = True
Return 1
EndIf
If $OneClick Then
$Edit_Number = 1
GUICtrlSetData($Edit4, GUICtrlRead($Edit1))
GUISetState(@SW_SHOW, $Form2)
EndIf
Return 1
EndSwitch
Return _WinAPI_CallWindowProc($hOEdit1_CallBack, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>Edit_CallBackFunc
Func Edit_CallBackFunc2($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_LBUTTONDBLCLK
$Edit_Number = 2
GUICtrlSetData($Edit4, GUICtrlRead($Edit2))
GUISetState(@SW_SHOW, $Form2)
Case $WM_RBUTTONUP
Local Static $ClicksStartTime,$OneClick = False
If TimerDiff($ClicksStartTime) > 500 Then
$ClicksStartTime = TimerInit()
$OneClick = True
Return 1
EndIf
If $OneClick Then
$Edit_Number = 2
GUICtrlSetData($Edit4, GUICtrlRead($Edit2))
GUISetState(@SW_SHOW, $Form2)
EndIf
Return 1
EndSwitch
Return _WinAPI_CallWindowProc($hOEdit2_CallBack, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>Edit_CallBackFunc
Func Edit_CallBackFunc3($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_LBUTTONDBLCLK
$Edit_Number = 3
GUICtrlSetData($Edit4, GUICtrlRead($Edit3))
GUISetState(@SW_SHOW, $Form2)
Case $WM_RBUTTONUP
Local Static $ClicksStartTime,$OneClick = False
If TimerDiff($ClicksStartTime) > 500 Then
$ClicksStartTime = TimerInit()
$OneClick = True
Return 1
EndIf
If $OneClick Then
$Edit_Number = 3
GUICtrlSetData($Edit4, GUICtrlRead($Edit3))
GUISetState(@SW_SHOW, $Form2)
EndIf
Return 1
EndSwitch
Return _WinAPI_CallWindowProc($hOEdit3_CallBack, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>Edit_CallBackFunc
;用於將主視窗的edit控件透過鼠標左右鍵呼叫函數,創新GUI並放大字體,讓老花眼(老視眼)的使用者可以順利編輯文本 可以简化些,所有的callback写在同一个函数里
Func Edit_CallBackFunc($hWnd, $iMsg, $wParam, $lParam) ;$hWnd->来自callback的呼叫方,$iMsg->发生的消息
Local $iCtrl = _WinAPI_GetDlgCtrlID($hWnd)
Switch $iCtrl
Case $Edit1
Switch $iMsg
Case $WM_LBUTTONDBLCLK
GUISetState(@SW_SHOW, $Form2)
Case $WM_RBUTTONUP
;do something
EndSwitch
Return _WinAPI_CallWindowProc($hOEdit1_CallBack, $hWnd, $iMsg, $wParam, $lParam)
Case $Edit2
;do something
Return _WinAPI_CallWindowProc($hOEdit2_CallBack, $hWnd, $iMsg, $wParam, $lParam)
Case $Edit3
;do something
Return _WinAPI_CallWindowProc($hOEdit3_CallBack, $hWnd, $iMsg, $wParam, $lParam)
EndSwitch
EndFunc
tubaba 发表于 2021-11-24 09:03
可以简化些,所有的callback写在同一个函数里
謝謝回覆,我再來測試看看。 用事件模式更简捷 把右键单击弹出菜单阉割了?_ _||
页:
1
[2]