Jump to content

taietel

Active Members
  • Posts

    726
  • Joined

  • Last visited

  • Days Won

    2

Community Answers

  1. taietel's post in Window in slide format was marked as the answer   
    JScript, try now:
    #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> ;coded by taietel _SlideWindow() Func _SlideWindow() Local $iW = 600, $iFont = 12, $iH = $iFont + 4 + 20, $bExpand = True, $iNoIcnsExpand = 3, $w = $iNoIcnsExpand * ($iFont + 4 + 10), $p = 25, $r = 25, $iDelay = 2 Local $iIcnExit = "r", $iIcnCfg = "@", $iIcnInfo = "i", $iIcnUp = "5", $iIcnDown = "6", $iIcnSep = "|", $iIcnChk = "a", $iIcnFull = "1" ; Create GUI Local $hForm = GUICreate("Test", $iW, $iH + $p, (@DesktopWidth - $iW + $w + $r) / 2, -$iH, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0xdedede) ;------- Put some stuff on GUI ---------- Local $hExit = GUICtrlCreateLabel($iIcnExit, 5, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x505050) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Exit") GUICtrlCreateLabel($iIcnSep, 5 + $iFont + 4, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x909090) Local $hSomeStuff = GUICtrlCreateLabel($iIcnCfg, 5 + 2 * ($iFont + 4), $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x505050) Local $hSomeStuff_l = GUICtrlCreateLabel("Some stuff", 5 + 3 * ($iFont + 4), $iH - ($iFont + 4) - 10, 80, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Arial", 5) GUICtrlSetColor(-1, 0x505050) GUICtrlSetTip(-1, "Click for menu") GUICtrlSetCursor(-1, 0) Local $hSomeStuffA = GUICtrlCreateLabel($iIcnDown, 5 + 3 * ($iFont + 4) + 80, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont - 2, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x505050) GUICtrlSetTip(-1, "Click for menu") GUICtrlSetCursor(-1, 0) Local $DummyMenu = GUICtrlCreateDummy() Local $hContextMenu = GUICtrlCreateContextMenu($DummyMenu) Local $mnuSomeStuff = GUICtrlCreateMenuItem("Some Item", $hContextMenu) Local $mnuExit = GUICtrlCreateMenuItem("Exit", $hContextMenu) GUICtrlCreateLabel($iIcnSep, 5 + 4 * ($iFont + 4) + 80 - 5, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x909090) GUICtrlCreateLabel($iIcnInfo, 5 + 5 * ($iFont + 4) + 80, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x505050) Local $hAbout = GUICtrlCreateLabel("About", 5 + 6 * ($iFont + 4) + 80, $iH - ($iFont + 4) - 10, 60, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Arial", 5) GUICtrlSetColor(-1, 0x505050) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "About this program...") GUICtrlCreateLabel($iIcnSep, 5 + 6 * ($iFont + 4) + 80 + 60, $iH - ($iFont + 4) - 10, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x909090) ;------- end some stuff on GUI ---------- Local $hExpand = GUICtrlCreateLabel($iIcnDown, $iW - $r - $w / 4 - ($iFont + 4) / 2, $iH + ($p - ($iFont + 4)) / 2, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x505050) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Expand") GUICtrlCreateLabel($iIcnSep, $iW - $r - 2 * $w / 4 - ($iFont + 4) / 2, $iH + ($p - ($iFont + 4)) / 2, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetColor(-1, 0x909090) Local $hFullScreen = GUICtrlCreateLabel($iIcnFull, $iW - $r - 3 * $w / 4 - ($iFont + 4) / 2, $iH + ($p - ($iFont + 4)) / 2, $iFont + 4, $iFont + 4, BitOR($SS_CENTER, $SS_CENTERIMAGE)) GUICtrlSetFont(-1, $iFont, 400, 0, "Webdings", 5) GUICtrlSetCursor(-1, 0) GUICtrlSetTip(-1, "Full Screen") GUICtrlSetColor(-1, 0x505050) Local $hRgn = _WinAPI_CreateRectRgn(0, 0, $iW - 1, $iH / 2) Local $hRgn1 = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, 7, 7) Local $hRgn2 = _WinAPI_CreateRoundRectRgn($iW - $r - $w, 2, $iW - $r, $iH + $p, 7, 7) Local $hRgn3 = _WinAPI_CreateRectRgn($iW - $r - $w - 5, 2, $iW - $r - $w, $iH + $p) Local $aPointl[3][2] = [[$iW - $r - $w - 5, $iH - 1], [$iW - $r - $w, $iH + $p], [$iW - $r - $w, $iH - 1]] Local $hRgn3 = _WinAPI_CreatePolygonRgn($aPointl) Local $aPointr[3][2] = [[$iW - $r + 5, $iH - 1], [$iW - $r - 2, $iH + $p - 1], [$iW - $r - 1, $iH - 1]] Local $hRgn4 = _WinAPI_CreatePolygonRgn($aPointr) _WinAPI_CombineRgn($hRgn, $hRgn, $hRgn1, $RGN_OR) _WinAPI_CombineRgn($hRgn, $hRgn, $hRgn2, $RGN_OR) _WinAPI_CombineRgn($hRgn, $hRgn, $hRgn3, $RGN_OR) _WinAPI_CombineRgn($hRgn, $hRgn, $hRgn4, $RGN_OR) _WinAPI_DeleteObject($hRgn1) _WinAPI_DeleteObject($hRgn2) _WinAPI_DeleteObject($hRgn3) _WinAPI_DeleteObject($hRgn4) _WinAPI_SetWindowRgn($hForm, $hRgn, 1) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $hExit, $mnuExit Exit Case $hFullScreen MsgBox(0, "", "Here you'll have to put the code for full screen mode.") Case $mnuSomeStuff MsgBox(0,"","stuff...") Case $hAbout MsgBox(0, "", "Here you'll have to put the code for About message.") Case $hExpand If $bExpand Then GUICtrlSetData($hExpand, $iIcnUp) WinMove($hForm, "", (@DesktopWidth - $iW + $w + $r) / 2, 0, $iW, $iH + $p, $iDelay) GUICtrlSetTip($hExpand, "Retract") $bExpand = False Else GUICtrlSetData($hExpand, $iIcnDown) WinMove($hForm, "", (@DesktopWidth - $iW + $w + $r) / 2, -$iH, $iW, $iH + $p, $iDelay) GUICtrlSetTip($hExpand, "Expand") $bExpand = True EndIf Case $hSomeStuffA, $hSomeStuff_l ShowMenu($hForm, $hContextMenu, $hSomeStuff) EndSwitch WEnd EndFunc ;==>_test Func ShowMenu($hWnd, $nContextID, $nContextControlID, $iMouse = 0) Local $hMenu = GUICtrlGetHandle($nContextID) Local $iCtrlPos = ControlGetPos($hWnd, "", $nContextControlID) Local $X = $iCtrlPos[0] Local $Y = $iCtrlPos[1] + $iCtrlPos[3] ClientToScreen($hWnd, $X, $Y) If $iMouse Then $X = MouseGetPos(0) $Y = MouseGetPos(1) EndIf DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $X, "int", $Y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $X, ByRef $Y) Local $stPoint = DllStructCreate("int;int") DllStructSetData($stPoint, 1, $X) DllStructSetData($stPoint, 2, $Y) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint)) $X = DllStructGetData($stPoint, 1) $Y = DllStructGetData($stPoint, 2) ; release Struct not really needed as it is a local $stPoint = 0 EndFunc ;==>ClientToScreen
×
×
  • Create New...