PhilipG Posted January 26, 2010 Share Posted January 26, 2010 I've encountered something I don't really understand my self. i have a function to create a new gui Func edit() $winopen= GUICreate("Redigera text", 145, 173, -1, -1, BitOR ($WS_POPUP, $WS_BORDER), -1) GUISetState(@sw_show, $winopen) $myedit = GUICtrlCreateEdit("Text", 5, 5, 135, 135) $save = GUICtrlCreateButton("Spara", 5, 145) $abort = GUICtrlCreateButton("Avbryt", 50, 145) While 1 $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $abort Then GUIdelete($winopen) ;GUISwitch ($main) $msg2 = 0 ExitLoop EndIf wend EndFunc before I added the while 1 loop the gui where written as it should but now it stops right after it has created the gui window. the controls in the window are never written! Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 Try changing While 1 to While WinExists($winopen). Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 no difference. Still stops responding Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 Do you have other functions being called before this or is it the only GUI you have? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 (edited) yes this function is called from within an other function. all the other functions look like this: expandcollapse popupFunc WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen case $idRed edit() Case $idSet settings() EndSwitch EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup () _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Ny...", $idOpen) _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Redigera Text", $idRed) _GUICtrlMenu_InsertMenuItem ($hMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Inställningar", $idSet) _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu ($hMenu) Return True EndFunc Func settings() $font = _ChooseFont() GUICtrlSetFont ($load , $font[3], $font[4], $font[1], $font[2]) $data = "0=" & $font[0] & @lf &"1=" & $font[1] & @lf &"2=" & $font[2] & @lf &"3=" & $font[3] & @lf &"4=" & $font[4] & @lf &"5=" & $font[5] & @lf &"6=" & $font[6] & @lf &"7=" & $font[7] & @lf ;IniWriteSection (@ScriptDir & "\notes\" & @year & @mon & @mday & @HOUR & @min & @sec & @msec & ".note", "FONT", $data, 0) IniWriteSection ($notename, "FONT", $data, 0) ConsoleWriteError(@error) EndFunc Func edit() $winopen= GUICreate("Redigera text", 145, 173, -1, -1, BitOR ($WS_POPUP, $WS_BORDER), -1) GUISetState(@sw_show, $winopen) $myedit = GUICtrlCreateEdit("Text", 5, 5, 135, 135) $save = GUICtrlCreateButton("Spara", 5, 145) $abort = GUICtrlCreateButton("Avbryt", 50, 145) While WinExists($winopen) $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Then GUIdelete($winopen) ;GUISwitch ($main) $msg2 = 0 ExitLoop EndIf wend EndFunc GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") EDIT: Spelling Edited January 26, 2010 by PhilipG Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 And the constants? I could do with them. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 they are added through GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") so i dont have them... or did you mean something else? Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 they are added through GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") so i dont have them... or did you mean something else? The script does nothing for me. Even after adding: Dim $idOpen, $idRed, $idSet Dim $load, $notename You need to post these values. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 oh i see... i missed the following row: Global Enum $idOpen = 1000, $idSet, $idInfo, $idRed it's written in top Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 I really don't see what the heck is going on here. No context menu, on anything. No access to the settings window. How are you calling this? Post the whole script as you have it now. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 expandcollapse popup#include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <GuiMenu.au3> $notename = @ScriptDir & "\notes\20100126172830166.note" Global Enum $idOpen = 1000, $idSet, $idInfo, $idRed $abort = "nope" $winopen = "nope" Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen case $idRed edit() Case $idSet settings() EndSwitch EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup () _GUICtrlMenu_InsertMenuItem ($hMenu, 0, "Ny...", $idOpen) _GUICtrlMenu_InsertMenuItem ($hMenu, 1, "Redigera Text", $idRed) _GUICtrlMenu_InsertMenuItem ($hMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem ($hMenu, 3, "Inställningar", $idSet) _GUICtrlMenu_TrackPopupMenu ($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu ($hMenu) Return True EndFunc Func settings() $font = _ChooseFont() GUICtrlSetFont ($load , $font[3], $font[4], $font[1], $font[2]) $data = "0=" & $font[0] & @lf &"1=" & $font[1] & @lf &"2=" & $font[2] & @lf &"3=" & $font[3] & @lf &"4=" & $font[4] & @lf &"5=" & $font[5] & @lf &"6=" & $font[6] & @lf &"7=" & $font[7] & @lf ;IniWriteSection (@ScriptDir & "\notes\" & @year & @mon & @mday & @HOUR & @min & @sec & @msec & ".note", "FONT", $data, 0) IniWriteSection ($notename, "FONT", $data, 0) ConsoleWriteError(@error) EndFunc Func edit() $winopen= GUICreate("Redigera text", 145, 173, -1, -1, BitOR ($WS_POPUP, $WS_BORDER), -1) GUISetState(@sw_show, $winopen) $myedit = GUICtrlCreateEdit("Text", 5, 5, 135, 135) $save = GUICtrlCreateButton("Spara", 5, 145) $abort = GUICtrlCreateButton("Avbryt", 50, 145) While WinExists($winopen) $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Then GUIdelete($winopen) ;GUISwitch ($main) $msg2 = 0 ExitLoop EndIf wend EndFunc GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") $width=150 $height=150 ;$font = _ChooseFont() $picPath = @ScriptDir &"\Graphic\postit.gif" $gui = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) $ctrl = GUICtrlCreatePic($picPath, 0, 0, $width, $height) GuiCtrlSetState(-1,$GUI_DISABLE) $more = GUICTRLCreateIcon ( @ScriptDir &"\Graphic\more.ico", -1, 6, 3, 10, 10, $SS_NOTIFY) $close = GUICTRLCreateIcon ( @ScriptDir &"\Graphic\close.ico", -1, 133, 5, 12, 12, $SS_NOTIFY) $drag = GUICtrlCreateLabel("",20,0,110,20,-1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor($drag, $GUI_BKCOLOR_TRANSPARENT) $load = GUICtrlCreateLabel("Detta är starten" & @CRLF & @CRLF & "Fortsättning följer", 10, 20, 130, 130) GUICtrlSetBkColor($load, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor ( $load, 0x774000) ;GUICtrlSetFont ($load , $font[3], $font[4], $font[1], $font[2]) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Switch $msg[2] Case GUICtrlGetHandle($close) exitloop Case GUICtrlGetHandle($more) WM_CONTEXTMENU($gui, 0, $gui, 0) EndSwitch WEnd GUIDelete() Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 And now, just so we're finally on the same page, what bug do you get? On Win 7 32bit, the window flashes black, white then closes. Same for you? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 The function is called when you click the icon in the upper left corner that displays the context menu, and when you then select "Redigera text" Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 running win xp 32bit service pack 3. The first window displays as it should. The whole gui background is a pic looking like a post it. When you access the context menu and triggers edit() a new gui opens as it schould but the controls for that GUI doesn't load at all and the program halts. Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 running win xp 32bit service pack 3. The first window displays as it should. The whole gui background is a pic looking like a post it. When you access the context menu and triggers edit() a new gui opens as it schould but the controls for that GUI doesn't load at all and the program halts.I don't get any of this behaviour sorry Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 thats strange. Any suggiestions at all what to do? Link to comment Share on other sites More sharing options...
James Posted January 26, 2010 Share Posted January 26, 2010 thats strange. Any suggiestions at all what to do?Unfortunately, I don't. I can't understand why this happens, probably very simple, but I'm mis-reading it. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
PhilipG Posted January 26, 2010 Author Share Posted January 26, 2010 so do I Link to comment Share on other sites More sharing options...
jchd Posted January 26, 2010 Share Posted January 26, 2010 so do I The following version works, at least as you say you expect. I've simply reorganized he code somehow and added scope declarations (I'm a bit picky, I know) but what should make the difference is that I've added Sleep(50) in your tight loops. expandcollapse popup#include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <GuiMenu.au3> ;~ AutoItSetOption("TrayIconDebug", 1) Global Enum $idOpen = 1000, $idSet, $idInfo, $idRed Global $notename = @ScriptDir & "\notes\20100126172830166.note" Global $abort = "nope" Global $winopen = "nope" GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") Global $width = 150 Global $height = 150 ;$font = _ChooseFont() Global $picPath = @ScriptDir & "\Graphic\postit.gif" Global $gui = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) Global $ctrl = GUICtrlCreatePic($picPath, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) Global $more = GUICtrlCreateIcon(@ScriptDir & "\Graphic\more.ico", -1, 6, 3, 10, 10, $SS_NOTIFY) Global $close = GUICtrlCreateIcon(@ScriptDir & "\Graphic\close.ico", -1, 133, 5, 12, 12, $SS_NOTIFY) Global $drag = GUICtrlCreateLabel("", 20, 0, 110, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor($drag, $GUI_BKCOLOR_TRANSPARENT) Global $load = GUICtrlCreateLabel("Detta är starten" & @CRLF & @CRLF & "Fortsättning följer", 10, 20, 130, 130) GUICtrlSetBkColor($load, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor($load, 0x774000) ;GUICtrlSetFont ($load , $font[3], $font[4], $font[1], $font[2]) GUISetState(@SW_SHOW) Global $msg While 1 $msg = GUIGetMsg(1) Switch $msg[2] Case GUICtrlGetHandle($close) ExitLoop Case GUICtrlGetHandle($more) WM_CONTEXTMENU($gui, 0, $gui, 0) EndSwitch Sleep(50) WEnd GUIDelete() Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen Case $idRed edit() Case $idSet settings() EndSwitch EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Ny...", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Redigera Text", $idRed) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Inställningar", $idSet) _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Func settings() Local $font = _ChooseFont() GUICtrlSetFont($load, $font[3], $font[4], $font[1], $font[2]) Local $data = "0=" & $font[0] & @LF & "1=" & $font[1] & @LF & "2=" & $font[2] & @LF & "3=" & $font[3] & @LF & "4=" & $font[4] & @LF & "5=" & $font[5] & @LF & "6=" & $font[6] & @LF & "7=" & $font[7] & @LF ;IniWriteSection (@ScriptDir & "\notes\" & @year & @mon & @mday & @HOUR & @min & @sec & @msec & ".note", "FONT", $data, 0) IniWriteSection($notename, "FONT", $data, 0) ConsoleWriteError(@error) EndFunc ;==>settings Func edit() Local $winopen = GUICreate("Redigera text", 145, 173, -1, -1, BitOR($WS_POPUP, $WS_BORDER), -1) GUISetState(@SW_SHOW, $winopen) Local $myedit = GUICtrlCreateEdit("Text", 5, 5, 135, 135) Local $save = GUICtrlCreateButton("Spara", 5, 145) $abort = GUICtrlCreateButton("Avbryt", 50, 145) Local $msg2 While WinExists($winopen) $msg2 = GUIGetMsg() If $msg2 = $GUI_EVENT_CLOSE Then GUIDelete($winopen) ;GUISwitch ($main) $msg2 = 0 ExitLoop EndIf Sleep(50) WEnd EndFunc ;==>edit This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Skruge Posted January 26, 2010 Share Posted January 26, 2010 <br />thats strange. Any suggiestions at all what to do?<br /><br /><br /><br /> Those loops were doing way more than they needed to, which prevented other things from happening (like message handling and control drawing). There's no need to continually re-read the control handles, since they don't change. I added small sleeps to help keep the CPU idle and moved the functions to the bottom of the script. I also made the edit gui activate the main gui when it closes, since the main one doesn't appear on the taskbar, can't be alt-tabbed to, and is easily obscured by other windows. Try this out and see how it goes. expandcollapse popup#include <WindowsConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <Misc.au3> #include <GuiMenu.au3> $notename = @ScriptDir & "\notes\20100126172830166.note" Global Enum $idOpen = 1000, $idSet, $idInfo, $idRed $abort = "nope" $winopen = "nope" GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ;GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") $width = 150 $height = 150 ;$font = _ChooseFont() $picPath = @ScriptDir & "\Graphic\postit.gif" $gui = GUICreate("", $width, $height, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) $ctrl = GUICtrlCreatePic($picPath, 0, 0, $width, $height) GUICtrlSetState(-1, $GUI_DISABLE) $more = GUICtrlCreateIcon(@ScriptDir & "\Graphic\more.ico", -1, 6, 3, 10, 10, $SS_NOTIFY) $close = GUICtrlCreateIcon(@ScriptDir & "\Graphic\close.ico", -1, 133, 5, 12, 12, $SS_NOTIFY) $drag = GUICtrlCreateLabel("", 20, 0, 110, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetBkColor($drag, $GUI_BKCOLOR_TRANSPARENT) $load = GUICtrlCreateLabel("Detta är starten" & @CRLF & @CRLF & "Fortsättning följer", 10, 20, 130, 130) GUICtrlSetBkColor($load, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor($load, 0x774000) ;GUICtrlSetFont ($load , $font[3], $font[4], $font[1], $font[2]) GUISetState(@SW_SHOW) Local $hClose = ControlGetHandle($gui, "", $close) Local $hMore = ControlGetHandle($gui, "", $more) While True $msg = GUIGetMsg(1) Switch $msg[2] Case $hClose GUIDelete($gui) ExitLoop Case $hMore WM_CONTEXTMENU($gui, 0, $gui, 0) EndSwitch Sleep(10) WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch $iwParam Case $idOpen Case $idRed edit() Case $idSet settings() EndSwitch EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Ny...", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Redigera Text", $idRed) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Inställningar", $idSet) _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Func settings() $font = _ChooseFont() GUICtrlSetFont($load, $font[3], $font[4], $font[1], $font[2]) $data = "0=" & $font[0] & @LF & "1=" & $font[1] & @LF & "2=" & $font[2] & @LF & "3=" & $font[3] & @LF & "4=" & $font[4] & @LF & "5=" & $font[5] & @LF & "6=" & $font[6] & @LF & "7=" & $font[7] & @LF ;IniWriteSection (@ScriptDir & "\notes\" & @year & @mon & @mday & @HOUR & @min & @sec & @msec & ".note", "FONT", $data, 0) IniWriteSection($notename, "FONT", $data, 0) ConsoleWriteError(@error) EndFunc ;==>settings Func edit() $winopen = GUICreate("Redigera text", 145, 173, -1, -1, BitOR($WS_POPUP, $WS_BORDER), -1) $myedit = GUICtrlCreateEdit("Text", 5, 5, 135, 135) $save = GUICtrlCreateButton("Spara", 5, 145) $abort = GUICtrlCreateButton("Avbryt", 50, 145) $hSave = ControlGetHandle($winopen, "", $save) $hAbort = ControlGetHandle($winopen, "", $abort) GUISetState(@SW_SHOW, $winopen) While True $msg2 = GUIGetMsg(1) If $msg2[1] = $winopen Then Select Case $msg2[2] = $hSave MsgBox(0, "Test", "Save") Case $msg2[2] = $hAbort ContinueCase Case $msg2[0] = $GUI_EVENT_CLOSE GUIDelete($winopen) WinActivate($gui) ExitLoop EndSelect EndIf Sleep(10) WEnd EndFunc ;==>edit [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] 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