Snipz Posted December 17, 2005 Share Posted December 17, 2005 (edited) Ive taken some of other peoples code and tried to put it together to help me get in the habit of making them. Can some one help me in telling me what im doing wrong and how I can fix it. Thanks, Snipz expandcollapse popup;#NoTrayIcon #include <GUIConstants.au3> $w = 200 $h = 200 $l = ( @DesktopWidth - $w ) / 2 $t = ( @DesktopHeight - $h ) / 2 $win = "Snipz Menu" $already = 0 $gui = GUICreate($win, $w, $h, $l, -1 * $h, $WS_MINIMIZEBOX + $WS_SYSMENU) $edit = GUICtrlCreateEdit("", 0, 0, $w - 5, $h - 51, $ES_WANTRETURN + $ES_MULTILINE + $WS_TABSTOP) $say1 = GUICtrlCreateButton("R u n", 0, $h - 51, ($w / 3) - 2, 20) $say2 = GUICtrlCreateButton("Options", ($w / 3) - 2, $h - 51, ($w / 3) - 2, 20) $exit = GUICtrlCreateButton("E x i t", ($w / 3 * 2) - 4, $h - 51, ($w / 3) - 2, 20) $filemenu = GuiCtrlCreateMenu ("File") $fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu) $recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu) $separator1 = GuiCtrlCreateMenuitem ("",$filemenu) $exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu) $helpmenu = GuiCtrlCreateMenu ("Help") $aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit outex() Case $msg = $fileitem $file = FileOpenDialog("Choose file...",@ScriptDir,"All (*.*)") If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu) Case $msg = $exititem ExitLoop Case $msg = $say1 MsgBox(0, "Click","You clicked Run!") Case $msg = $aboutitem Msgbox(0,"About","GUI Menu Test") EndSelect WEnd GUISetState() GUISetBkColor("0xFFFFFF", $gui) GUICtrlSetState($edit, $GUI_FOCUS) WinSetOnTop($win, "", 1) WinSetTrans($win, "", 100) Global $n_ot = 0 For $i = -1 * $h to $t step 10 $n_ot = $n_ot + 1 Next $n_st = 0 For $i = -1 * $h to $t step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", (255 * $n_st) / $n_ot) Next Func outex() $n_st = 0 For $i = $t to $t + $t + $h step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", 255 - ((255 * $n_st) / $n_ot)) Next EndFunc Edited December 17, 2005 by Snipz Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go? Link to comment Share on other sites More sharing options...
Sokko Posted December 17, 2005 Share Posted December 17, 2005 This line looks weird to me:$gui = GUICreate($win, $w, $h, $l, -1 * $h, $WS_MINIMIZEBOX + $WS_SYSMENU)You are placing the top of the window at a negative value, which is off the screen. Based on the variables you defined at the top of the script, I'm guessing you meant to put $t there, rather than -1*$h.GUISetState() GUISetBkColor("0xFFFFFF", $gui) GUICtrlSetState($edit, $GUI_FOCUS) WinSetOnTop($win, "", 1) WinSetTrans($win, "", 100)This should go above the While, otherwise it will never be executed until the loop breaks out. If you wanted the other two blocks of code below it to be executed when the program starts up, those should also go above the While. If you leave them below, they will execute only when the "exit" menu item is clicked.Also, why do different methods of exiting the program do different things? Link to comment Share on other sites More sharing options...
Snipz Posted December 17, 2005 Author Share Posted December 17, 2005 I dont know if it did anything it wont let me in the menu it says $n_ot not declared. Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go? Link to comment Share on other sites More sharing options...
Sokko Posted December 17, 2005 Share Posted December 17, 2005 It appears that you did mean to put that stuff above the While loop. This code works fine for me:expandcollapse popup;#NoTrayIcon #include <GUIConstants.au3> $w = 200 $h = 200 $l = ( @DesktopWidth - $w ) / 2 $t = ( @DesktopHeight - $h ) / 2 $win = "Snipz Menu" $already = 0 $gui = GUICreate($win, $w, $h, $l, -1 * $h, $WS_MINIMIZEBOX + $WS_SYSMENU) $edit = GUICtrlCreateEdit("", 0, 0, $w - 5, $h - 51, $ES_WANTRETURN + $ES_MULTILINE + $WS_TABSTOP) $say1 = GUICtrlCreateButton("R u n", 0, $h - 51, ($w / 3) - 2, 20) $say2 = GUICtrlCreateButton("Options", ($w / 3) - 2, $h - 51, ($w / 3) - 2, 20) $exit = GUICtrlCreateButton("E x i t", ($w / 3 * 2) - 4, $h - 51, ($w / 3) - 2, 20) $filemenu = GuiCtrlCreateMenu ("File") $fileitem = GuiCtrlCreateMenuitem ("Open...",$filemenu) $recentfilesmenu = GuiCtrlCreateMenu ("Recent Files",$filemenu) $separator1 = GuiCtrlCreateMenuitem ("",$filemenu) $exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu) $helpmenu = GuiCtrlCreateMenu ("Help") $aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu) GUISetState() GUISetBkColor("0xFFFFFF", $gui) GUICtrlSetState($edit, $GUI_FOCUS) WinSetOnTop($win, "", 1) WinSetTrans($win, "", 100) Global $n_ot = 0 For $i = -1 * $h to $t step 10 $n_ot = $n_ot + 1 Next $n_st = 0 For $i = -1 * $h to $t step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", (255 * $n_st) / $n_ot) Next While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exit outex() Case $msg = $fileitem $file = FileOpenDialog("Choose file...",@ScriptDir,"All (*.*)") If @error <> 1 Then GuiCtrlCreateMenuItem ($file,$recentfilesmenu) Case $msg = $exititem ExitLoop Case $msg = $say1 MsgBox(0, "Click","You clicked Run!") Case $msg = $aboutitem Msgbox(0,"About","GUI Menu Test") EndSelect WEnd Func outex() $n_st = 0 For $i = $t to $t + $t + $h step 10 $n_st = $n_st + 1 WinMove($win, "", $l, $i) WinSetTrans($win, "", 255 - ((255 * $n_st) / $n_ot)) Next EndFuncThere are still a few things about it that seem odd, though. Like the fact that the function outex never actually exits the program, it just leaves it running off the screen somewhere. Link to comment Share on other sites More sharing options...
Snipz Posted December 17, 2005 Author Share Posted December 17, 2005 Sokko what happened to to the buttons? Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go? Link to comment Share on other sites More sharing options...
Sokko Posted December 17, 2005 Share Posted December 17, 2005 The buttons were never visible in the first place, they're off the bottom of the window. Remember, if you create a GUI that's 200 pixels high, that doesn't mean you have 200 pixels of usable space to work with. The title bar and menu of the window take up some of it. Link to comment Share on other sites More sharing options...
Snipz Posted December 18, 2005 Author Share Posted December 18, 2005 Alright I got it to exit perfectly but how do I put buttons back on? Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now