Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WinAPI.au3>
- #include <WindowsConstants.au3>
- Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG'
- Global $btn1, $btn2, $iMemo=0, $Button1, $aHSB[3]=[0,0,0]
- $Gui=GUICreate('My Program', 250, 260)
- $Button1=GUICtrlCreateButton('Start', 10, 10, 120, 22)
- $Label1=GUICtrlCreateLabel('StatusBar', 5, 260-20, 150, 17)
- GUISetState()
- GUIRegisterMsg(0x004E, "WM_NOTIFY")
- While 1
- $msg = GUIGetMsg()
- If $iMemo=2 Then
- $iMemo=0
- _MsgFile($Button1)
- EndIf
- Switch $msg
- Case -3
- Exit
- EndSwitch
- WEnd
- Func _MsgFile($ctrl)
- $cgp=ControlGetPos($Gui, "", $ctrl)
- $tpoint = DllStructCreate("int X;int Y")
- _WinAPI_ClientToScreen($Gui, $tpoint)
- $x=DllStructGetData($tpoint, "X")+$cgp[0]
- $y=DllStructGetData($tpoint, "Y")+$cgp[1]+$cgp[3]
- Local $EditBut, $Gui1, $GuiPos, $msg, $StrBut
- ; GUISetState(@SW_DISABLE, $Gui)
- $Gui1 = GUICreate('Сообщение', 22*7, 22*5,$x, $y, $WS_POPUP+$WS_DLGFRAME,-1,$Gui)
- Dim $aWord[36]
- $aWord[0]=35
- Local $aBt[$aWord[0]+1]
- $aHSB[1]=100
- $aHSB[2]=100
- For $i = 1 to $aWord[0]
- $aHSB[0]=$i*10
- $aRGB=_HSB_2_RGB($aHSB)
- $aWord[$i]=StringTrimLeft($aRGB[0], 6) & StringTrimLeft($aRGB[1], 6) & StringTrimLeft($aRGB[2], 6)
- $gcm=Opt("GUICoordMode", 2)
- Switch $i
- Case 8,15,22,29
- $aBt[$i]=GUICtrlCreateLabel('', -22*7, 0, 22, 22)
- GUICtrlSetBkColor(-1, Dec($aWord[$i]))
- Case 1
- $aBt[$i]=GUICtrlCreateLabel('', 1, 2, 22, 22)
- GUICtrlSetBkColor(-1, Dec($aWord[$i]))
- Case Else
- $aBt[$i]=GUICtrlCreateLabel('', 0, -1, 22, 22)
- GUICtrlSetBkColor(-1, Dec($aWord[$i]))
- EndSwitch
- Opt("GUICoordMode", $gcm)
- Next
- GUISetState(@SW_SHOW, $Gui1)
- While 1
- $msg = GUIGetMsg()
- For $i = 1 to $aWord[0]
- If $msg = $aBt[$i] Then
- GUICtrlSetData($Button1, $aWord[$i])
- GUICtrlSetBkColor($Gui, Dec($aWord[$i]))
- GUISetBkColor(Dec($aWord[$i]), $Gui)
- ExitLoop 2
- EndIf
- Next
- If $iMemo=1 Then
- $Gui1ci=GUIGetCursorInfo($Gui1)
- ; GUICtrlSetData($Label1, $Gui1ci[0])
- If $Gui1ci[0]<-2 Or $Gui1ci[1]<-5 Or $Gui1ci[0]>154 Or $Gui1ci[1]>110 Then
- $iMemo=0
- ExitLoop
- EndIf
- EndIf
- WEnd
- ; GUISetState(@SW_ENABLE, $Gui)
- GUIDelete($Gui1)
- EndFunc
- Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
- #forceref $hWnd, $Msg, $wParam
- ; If $hWnd<>$Gui Then Return $GUI_RUNDEFMSG
- Local Const $BCN_HOTITEMCHANGE = -1249
- Local $tNMBHOTITEM = DllStructCreate("hwnd hWndFrom;int IDFrom;int Code;dword dwFlags", $lParam)
- Local $nNotifyCode = DllStructGetData($tNMBHOTITEM, "Code")
- Local $nID = DllStructGetData($tNMBHOTITEM, "IDFrom")
- Local $hCtrl = DllStructGetData($tNMBHOTITEM, "hWndFrom")
- Local $dwFlags = DllStructGetData($tNMBHOTITEM, "dwFlags")
- Local $sText = ""
- If $nID = $Button1 Then
- Switch $nNotifyCode
- Case $BCN_HOTITEMCHANGE ; Win XP and Above
- If BitAND($dwFlags, 0x10) = 0x10 Then
- $iMemo=2
- ElseIf BitAND($dwFlags, 0x20) = 0x20 Then
- $iMemo=1
- EndIf
- EndSwitch
- EndIf
- Return $GUI_RUNDEFMSG
- EndFunc
- Func _HSB_2_RGB($aHSB)
- Local $min, $max, $aRGB[3]
- $aHSB[2]/=100
- If $aHSB[1] = 0 Then
- $aRGB[0]=Hex(Round($aHSB[2]*255))
- $aRGB[1]=$aRGB[0]
- $aRGB[2]=$aRGB[0]
- Return $aRGB
- EndIf
- While $aHSB[0]>=360
- $aHSB[0]-=360
- WEnd
- $aHSB[1]/=100
- $aHSB[0] /= 60
- $Sector=Int($aHSB[0])
- $f=$aHSB[0] - $Sector
- $p=$aHSB[2]*(1-$aHSB[1])
- $q=$aHSB[2]*(1-$aHSB[1]*$f)
- $t=$aHSB[2]*(1-$aHSB[1]*(1-$f))
- Switch $Sector
- Case 0
- $aRGB[0]=$aHSB[2]
- $aRGB[1]=$t
- $aRGB[2]=$p
- Case 1
- $aRGB[0]=$q
- $aRGB[1]=$aHSB[2]
- $aRGB[2]=$p
- Case 2
- $aRGB[0]=$p
- $aRGB[1]=$aHSB[2]
- $aRGB[2]=$t
- Case 3
- $aRGB[0]=$p
- $aRGB[1]=$q
- $aRGB[2]=$aHSB[2]
- Case 4
- $aRGB[0]=$t
- $aRGB[1]=$p
- $aRGB[2]=$aHSB[2]
- Case Else
- $aRGB[0]=$aHSB[2]
- $aRGB[1]=$p
- $aRGB[2]=$q
- EndSwitch
- $aRGB[0]=Hex(Round($aRGB[0]*255))
- $aRGB[1]=Hex(Round($aRGB[1]*255))
- $aRGB[2]=Hex(Round($aRGB[2]*255))
- Return $aRGB
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement