Advertisement
AZJIO

Всплывающая панель

Jun 8th, 2012
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.08 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <WindowsConstants.au3>
  3. Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'
  4. Global $btn1, $btn2, $iMemo = 0, $Button1
  5.  
  6. $Gui = GUICreate('My Program', 250, 260)
  7. $Button1 = GUICtrlCreateButton('Start', 10, 10, 120, 22)
  8. $Label1 = GUICtrlCreateLabel('StatusBar', 5, 260 - 20, 150, 17)
  9. GUISetState()
  10. GUIRegisterMsg(0x004E, "WM_NOTIFY")
  11.  
  12. While 1
  13.     $msg = GUIGetMsg()
  14.     If $iMemo = 2 Then
  15.         $iMemo = 0
  16.         _MsgFile($Button1)
  17.     EndIf
  18.     Switch $msg
  19.         Case -3
  20.             Exit
  21.     EndSwitch
  22. WEnd
  23.  
  24. Func _MsgFile($ctrl)
  25.     $cgp = ControlGetPos($Gui, "", $ctrl)
  26.     $tpoint = DllStructCreate("int X;int Y")
  27.     _WinAPI_ClientToScreen($Gui, $tpoint)
  28.     $x = DllStructGetData($tpoint, "X") + $cgp[0]
  29.     $y = DllStructGetData($tpoint, "Y") + $cgp[1] + $cgp[3]
  30.    
  31.     Local $EditBut, $Gui1, $GuiPos, $msg, $StrBut
  32.     ; GUISetState(@SW_DISABLE, $Gui)
  33.    
  34.     $Gui1 = GUICreate('Сообщение', 22 * 7, 22 * 5, $x, $y, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST, $Gui)
  35.     $aWord = StringSplit('9999bb|aa99aa|cccc00|CCCCEE|b0b558|dadd4e|FF0000|FFCA42|E2B4B4|C04141|99CCFF|F06320|862D2D|F9E6E6|0000FF|FFFF00|72ADC0|71AE71|C738B9|AAA6DB|0080FF|FF46FF|FF8080|D29A6C|EA9515|F000FF|0080C0|7D8AE6|FFFFFF|cccccc|696969|CCCCEE|5d5d5d|AAAAAA|3F3F3F', '|')
  36.     Local $aBt[$aWord[0] + 1]
  37.     For $i = 1 To $aWord[0]
  38.         $gcm = Opt("GUICoordMode", 2)
  39.         Switch $i
  40.             Case 8, 15, 22, 29
  41.                 $aBt[$i] = GUICtrlCreateLabel('', -22 * 7, 0, 22, 22)
  42.                 GUICtrlSetBkColor(-1, Dec($aWord[$i]))
  43.             Case 1
  44.                 $aBt[$i] = GUICtrlCreateLabel('', 1, 2, 22, 22)
  45.                 GUICtrlSetBkColor(-1, Dec($aWord[$i]))
  46.             Case Else
  47.                 $aBt[$i] = GUICtrlCreateLabel('', 0, -1, 22, 22)
  48.                 GUICtrlSetBkColor(-1, Dec($aWord[$i]))
  49.         EndSwitch
  50.         Opt("GUICoordMode", $gcm)
  51.     Next
  52.     GUISetState(@SW_SHOW, $Gui1)
  53.  
  54.     While 1
  55.         $msg = GUIGetMsg()
  56.         For $i = 1 To $aWord[0]
  57.             If $msg = $aBt[$i] Then
  58.                 GUICtrlSetData($Button1, $aWord[$i])
  59.                 GUICtrlSetBkColor($Gui, Dec($aWord[$i]))
  60.                 GUISetBkColor(Dec($aWord[$i]), $Gui)
  61.                 ExitLoop 2
  62.             EndIf
  63.         Next
  64.         If $iMemo = 1 Then
  65.             $Gui1ci = GUIGetCursorInfo($Gui1)
  66.             ; GUICtrlSetData($Label1, $Gui1ci[0])
  67.             If $Gui1ci[0] < -2 Or $Gui1ci[1] < -5 Or $Gui1ci[0] > 154 Or $Gui1ci[1] > 110 Then
  68.                 $iMemo = 0
  69.                 ExitLoop
  70.             EndIf
  71.         EndIf
  72.     WEnd
  73.     ; GUISetState(@SW_ENABLE, $Gui)
  74.     GUIDelete($Gui1)
  75. EndFunc
  76.  
  77. Func WM_NOTIFY($hWnd, $msg, $wParam, $lParam)
  78.    
  79.     #forceref $hWnd, $Msg, $wParam
  80.     ; If $hWnd<>$Gui Then Return $GUI_RUNDEFMSG
  81.     Local Const $BCN_HOTITEMCHANGE = -1249
  82.     Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
  83.     Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
  84.     Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
  85.     Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
  86.     Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
  87.     Local $sText = ""
  88.  
  89.     If $nID = $Button1 Then
  90.         Switch $nNotifyCode
  91.             Case $BCN_HOTITEMCHANGE ; Win XP and Above
  92.                 If BitAND($dwFlags, 0x10) = 0x10 Then
  93.                     $iMemo = 2
  94.                 ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
  95.                     $iMemo = 1
  96.                 EndIf
  97.         EndSwitch
  98.     EndIf
  99.     Return $GUI_RUNDEFMSG
  100. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement