找回密码
 加入
搜索
查看: 1175|回复: 1

还是edit编辑框右键问题

[复制链接]
发表于 2009-6-24 20:24:53 | 显示全部楼层 |阅读模式
本帖最后由 gto250 于 2009-6-25 20:31 编辑

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <Constants.au3>
#include <WinAPI.au3>

Opt('GUIResizeMode', 802)


Dim $Version = "v1.0.2"
If WinExists($Version) Then Exit
AutoItWinSetTitle($Version)

Dim $d[41] ;40个档距
Dim $fs[8], $duqu_1[8], $duqu_2[8]
Dim $buttonitem[41], $buttoncontext[41]
$Form1 = GUICreate("", 622, 230 + 50, 195, 229)
$Group1 = GUICtrlCreateGroup("汇总", 0, 0, 276, 201)
$d[1] = GUICtrlCreateInput("", 8, 16, 49, 21)
$d[2] = GUICtrlCreateInput("", 60, 16, 49, 21)
$d[3] = GUICtrlCreateInput("", 113, 16, 49, 21)
$d[4] = GUICtrlCreateInput("", 166, 16, 49, 21)
$d[5] = GUICtrlCreateInput("", 218, 16, 49, 21)
$d[6] = GUICtrlCreateInput("", 8, 38, 49, 21)
$d[7] = GUICtrlCreateInput("", 60, 38, 49, 21)
$d[8] = GUICtrlCreateInput("", 113, 38, 49, 21)
$d[9] = GUICtrlCreateInput("", 166, 38, 49, 21)
$d[10] = GUICtrlCreateInput("", 218, 38, 49, 21)
$d[11] = GUICtrlCreateInput("", 8, 61, 49, 21)
$d[12] = GUICtrlCreateInput("", 60, 61, 49, 21)
$d[13] = GUICtrlCreateInput("", 113, 61, 49, 21)
$d[14] = GUICtrlCreateInput("", 166, 61, 49, 21)
$d[15] = GUICtrlCreateInput("", 218, 61, 49, 21)
$d[16] = GUICtrlCreateInput("", 8, 83, 49, 21)
$d[17] = GUICtrlCreateInput("", 60, 83, 49, 21)
$d[18] = GUICtrlCreateInput("", 113, 83, 49, 21)
$d[19] = GUICtrlCreateInput("", 166, 83, 49, 21)
$d[20] = GUICtrlCreateInput("", 218, 83, 49, 21)
$d[21] = GUICtrlCreateInput("", 8, 105, 49, 21)
$d[22] = GUICtrlCreateInput("", 60, 105, 49, 21)
$d[23] = GUICtrlCreateInput("", 113, 105, 49, 21)
$d[24] = GUICtrlCreateInput("", 166, 105, 49, 21)
$d[25] = GUICtrlCreateInput("", 218, 105, 49, 21)
$d[26] = GUICtrlCreateInput("", 8, 127, 49, 21)
$d[27] = GUICtrlCreateInput("", 60, 127, 49, 21)
$d[28] = GUICtrlCreateInput("", 113, 127, 49, 21)
$d[29] = GUICtrlCreateInput("", 166, 127, 49, 21)
$d[30] = GUICtrlCreateInput("", 218, 127, 49, 21)
$d[31] = GUICtrlCreateInput("", 8, 150, 49, 21)
$d[32] = GUICtrlCreateInput("", 60, 150, 49, 21)
$d[33] = GUICtrlCreateInput("", 113, 150, 49, 21)
$d[34] = GUICtrlCreateInput("", 166, 150, 49, 21)
$d[35] = GUICtrlCreateInput("", 218, 150, 49, 21)
$d[36] = GUICtrlCreateInput("", 8, 172, 49, 21)
$d[37] = GUICtrlCreateInput("", 60, 172, 49, 21)
$d[38] = GUICtrlCreateInput("", 113, 172, 49, 21)
$d[39] = GUICtrlCreateInput("", 166, 172, 49, 21)
$d[40] = GUICtrlCreateInput("", 218, 172, 49, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlSetState(-1, $GUI_DISABLE)
$Group2 = GUICtrlCreateGroup("计算", 274, 0, 345, 201)
$jisuan1 = GUICtrlCreateButton("分步-1", 280, 16, 75, 25, 0)
$jisuan2 = GUICtrlCreateButton("分步-2", 361, 16, 75, 25, 0)
$quanbujisuan = GUICtrlCreateButton("全步计算", 442, 16, 75, 25, 0)
$buttoncontext = GUICtrlCreateContextMenu($quanbujisuan)
$buttonitem = GUICtrlCreateMenuItem("About button", $buttoncontext)
$Label2 = GUICtrlCreateLabel("观测档距", 280, 56, 52, 17)
$guancedj = GUICtrlCreateInput("", 334, 48, 49, 21)
$Label3 = GUICtrlCreateLabel("代表档距", 387, 56, 52, 17)
$daibiaodj = GUICtrlCreateInput("", 440, 48, 49, 21)
$Label4 = GUICtrlCreateLabel("总档距", 496, 56, 40, 17)
$zongdj = GUICtrlCreateInput("", 536, 48, 49, 21)
$Group3 = GUICtrlCreateGroup("相应温度下观测档距的弧垂值", 274, 120, 345, 81)
$t_010 = GUICtrlCreateInput("", 286, 164, 49, 21, $ES_READONLY)
$t_0 = GUICtrlCreateInput("", 340, 164, 49, 21, $ES_READONLY)
$t_10 = GUICtrlCreateInput("", 395, 164, 49, 21, $ES_READONLY)
$t_20 = GUICtrlCreateInput("", 449, 164, 49, 21, $ES_READONLY)
$t_30 = GUICtrlCreateInput("", 504, 164, 49, 21, $ES_READONLY)
$t_40 = GUICtrlCreateInput("", 558, 164, 49, 21, $ES_READONLY)
$Label5 = GUICtrlCreateLabel("-10℃", 296, 144, 31, 17)
$Label6 = GUICtrlCreateLabel("0℃", 358, 144, 22, 17)
$Label7 = GUICtrlCreateLabel("10℃", 412, 144, 28, 17)
$Label8 = GUICtrlCreateLabel("20℃", 465, 144, 28, 17)
$Label9 = GUICtrlCreateLabel("30℃", 519, 144, 28, 17)
$Label10 = GUICtrlCreateLabel("40℃", 573, 144, 28, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Label14 = GUICtrlCreateLabel("导线规格", 281, 88, 52, 17)
$Combo1 = GUICtrlCreateCombo("", 334, 80, 145, 25)
GUICtrlSetData(-1, "LGJ-35|LGJ-50|LGJ-70/10|LGJ-95/15|LGJ-120/20|LGJ-150/25|LGJ-185/30|LGJ-240/30|LJ-50|LJ-70|LJ-95|LJ-120|LJ-150|LJ-185|LJ-240|JKLYJ-10-50|JKLYJ-10-70|JKLYJ-10-95|JKLYJ-10-120|JKLYJ-10-150|JKLYJ-10-185|JKLYJ-10-240", "LGJ-35")
$clear = GUICtrlCreateButton("全部清除", 527, 16, 75, 25, 0)
$shuoming = GUICtrlCreateLabel("关于计算说明", 515, 83, 76, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
GUICtrlSetCursor(-1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)


GUICtrlCreateGroup("辅助功能", 0, 202, 617, 75)
GUICtrlCreateLabel("选择你需要复制的弧垂温度", 5, 227, 150, 17)
$checkCN = GUICtrlCreateCombo("", 156, 224, 120, 20)
GUICtrlSetData(-1, "-10℃~0℃|0℃~10℃|10℃~20℃|20℃~30℃|30℃~40℃|-5℃~5℃|5℃~15℃|15℃~25℃|25℃~35℃|0℃-10℃-20℃|10℃-20℃-30℃|20℃-30℃-40℃|", "10℃-20℃-30℃")
$pause = GUICtrlCreateButton("复制", 279, 222, 75, 24, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Group4 = GUICtrlCreateGroup("数据复算", 0, 248 + 35, 617, 113)
GUICtrlCreateLabel("-10℃", 111, 260 + 35, 31, 17)
GUICtrlCreateLabel("0℃", 173, 260 + 35, 22, 17)
GUICtrlCreateLabel("10℃", 227, 260 + 35, 28, 17)
GUICtrlCreateLabel("20℃", 280, 260 + 35, 28, 17)
GUICtrlCreateLabel("30℃", 334, 260 + 35, 28, 17)
GUICtrlCreateLabel("40℃", 388, 260 + 35, 28, 17)
$duqu_1[1] = GUICtrlCreateInput("", 49, 280 + 35, 49, 21)
$duqu_1[2] = GUICtrlCreateInput("", 101, 280 + 35, 49, 21)
$duqu_1[3] = GUICtrlCreateInput("", 155, 280 + 35, 49, 21)
$duqu_1[4] = GUICtrlCreateInput("", 207, 280 + 35, 49, 21)
$duqu_1[5] = GUICtrlCreateInput("", 261, 280 + 35, 49, 21)
$duqu_1[6] = GUICtrlCreateInput("", 316, 280 + 35, 49, 21)
$duqu_1[7] = GUICtrlCreateInput("", 370, 280 + 35, 49, 21)
$duqu_2[1] = GUICtrlCreateInput("", 49, 306 + 35, 49, 21)
$duqu_2[2] = GUICtrlCreateInput("", 101, 306 + 35, 49, 21)
$duqu_2[3] = GUICtrlCreateInput("", 155, 306 + 35, 49, 21)
$duqu_2[4] = GUICtrlCreateInput("", 207, 306 + 35, 49, 21)
$duqu_2[5] = GUICtrlCreateInput("", 261, 306 + 35, 49, 21)
$duqu_2[6] = GUICtrlCreateInput("", 316, 306 + 35, 49, 21)
$duqu_2[7] = GUICtrlCreateInput("", 370, 306 + 35, 49, 21)
$fs[1] = GUICtrlCreateInput("", 49, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[2] = GUICtrlCreateInput("", 101, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[3] = GUICtrlCreateInput("", 155, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[4] = GUICtrlCreateInput("", 207, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[5] = GUICtrlCreateInput("", 261, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[6] = GUICtrlCreateInput("", 316, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
$fs[7] = GUICtrlCreateInput("", 370, 333 + 35, 49, 21, BitOR($ES_AUTOHSCROLL, $ES_READONLY))
GUICtrlCreateLabel("代表1", 8, 283 + 35, 34, 17)
GUICtrlCreateLabel("代表2", 8, 311 + 35, 34, 17)
GUICtrlCreateLabel("GC/DB", 8, 338 + 35, 34, 17)
$fuan = GUICtrlCreateButton("复  算", 432, 304 + 35, 75, 25, 0)
$clear_fs = GUICtrlCreateButton("清除复算", 512, 304 + 35, 75, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$zhiding = GUICtrlCreateCheckbox("界面置顶", 410, 205 + 21, 97, 17)
$shensuo_shujutianjia = GUICtrlCreateButton("数据复算↓", 513, 222, 91, 24, $BS_FLAT)
$Label15 = GUICtrlCreateLabel("10KV导线弧垂计算 V1.0 B_2_1版  雷 (内置数据库)", 240, 208 + 45, 368, 20)
GUICtrlSetFont(-1, 12, 400, 0, "楷体_GB2312")
GUICtrlSetState(-1, $GUI_DISABLE)
$DummyMenu      = GUICtrlCreateDummy()
$ContextMenu    = GUICtrlCreateContextMenu($DummyMenu)
$MenuItem1 = GUICtrlCreateMenuItem("菜单1", $ContextMenu)
$MenuItem2   = GUICtrlCreateMenuItem("菜单2", $ContextMenu)
GUICtrlCreateMenuItem("", $ContextMenu)
$ExitMenuItem   = GUICtrlCreateMenuItem("退出", $ContextMenu)
GUICtrlSetState($d[1], $GUI_FOCUS)
GUISetState(@SW_SHOW)

While 1

        $CurInfo = GUIGetCursorInfo($Form1)
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $CurInfo[3] = 1 And $CurInfo[4] = $d[15]
            ShowMenu($Form1, $ContextMenu)
                Case $jisuan1 ;第一步计算代表档距,总档距
                       

                Case $jisuan2 ;第二步计算弧垂
               

                Case $quanbujisuan ;一次性计算弧垂
               


                Case $clear ;全部清除
                       
                Case $clear_fs
                       
                Case $shensuo_shujutianjia ;界面伸缩
                        _myext()

                Case $fuan
                       

                Case $zhiding
                        If GUICtrlRead($zhiding) = 1 Then
                                WinSetOnTop($Form1, "", 1)
                        ElseIf GUICtrlRead($zhiding) = 4 Then
                                WinSetOnTop($Form1, "", 0)
                        EndIf
                Case $pause
                       
        EndSwitch
WEnd









Func clear()
        For $nn = 1 To 40
                GUICtrlSetData($d[$nn], "")
        Next
        For $nnn = 1 To 7
                GUICtrlSetData($duqu_1[$nnn], "")
                GUICtrlSetData($duqu_2[$nnn], "")
                GUICtrlSetData($fs[$nnn], "")
        Next
        GUICtrlSetData($t_010, "")
        GUICtrlSetData($t_0, "")
        GUICtrlSetData($t_10, "")
        GUICtrlSetData($t_20, "")
        GUICtrlSetData($t_30, "")
        GUICtrlSetData($t_40, "")
        GUICtrlSetData($guancedj, "")
        GUICtrlSetData($daibiaodj, "")
        GUICtrlSetData($zongdj, "")

        GUICtrlSetState($d[1], $GUI_FOCUS)
EndFunc   ;==>clear

Func clear_fs()

        For $nnn = 1 To 7
                GUICtrlSetData($duqu_1[$nnn], "")
                GUICtrlSetData($duqu_2[$nnn], "")
                GUICtrlSetData($fs[$nnn], "")
        Next
        GUICtrlSetState($d[1], $GUI_FOCUS)
EndFunc   ;==>clear_fs

Func _myext() ;数据添加的伸缩

        If GUICtrlRead($shensuo_shujutianjia) = "数据复算↓" Then
                WinMove($Form1, "", Default, Default, Default, 395 + 35)
                GUICtrlSetData($shensuo_shujutianjia, "数据复算↑")
        ElseIf GUICtrlRead($shensuo_shujutianjia) = "数据复算↑" Then
                WinMove($Form1, "", Default, Default, Default, 260 + 50)
                GUICtrlSetData($shensuo_shujutianjia, "数据复算↓")
        EndIf
EndFunc   ;==>_myext









Func ShowMenu($hWnd, $nContextID)
    Local $hMenu = GUICtrlGetHandle($nContextID)
    $arPos = MouseGetPos()
    Local $x = $arPos[0]
    Local $y = $arPos[1]
    DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc

;==============================================================================

昨天pc同学教的自定义编辑框右键的东东给我,但是今天试了试还是失败了,不知道错在哪里,为什么一运行就直接出现右键菜单呢?

我想实现的是在1—40的编辑框中点击右键就出现自定义右键菜单,在其他的编辑框上点击右键却不出现

望各位兄弟姐妹们大施援手
发表于 2009-6-24 21:00:07 | 显示全部楼层
$CurInfo = GUIGetCursorInfo($Form1)
if  $CurInfo[3] = 1 And  $CurInfo[4] = $d[1] then          ShowMenu($Form1, $ContextMenu)
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                       
                Case $jisuan1 ;第一步计算代表档距,总档距
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-10 04:52 , Processed in 0.071633 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表