1. Key Press to have Window "reappear ??
- Posted by Selgor Feb 22, 2011
- 1701 views
Hello , Selgor here.
The programme is an application strip. The "strip" is set to "invisible" with setVisible(Win,0). I am trying to have the Window Strip "reappear" . Tried "lots" and the only "thing" that works is the for next loop which is not the most favourable. So, I would like to press a key e.g. ESCAPE to have the window strip "reappear". I have left all my "tries" as edited out code. Hope someone can help. Thnx.
Cheers. Selgor.
include win32lib.ew without warning include get.e -- global object endit endit = 0 constant Win = create(Window,"",0,220,150,690,45,{WS_POPUP,WS_DLGFRAME}), Icn1 = create( Icon, "", Win, 5, 5, 32, 32, 0 ), Icn2 = create( Icon, "", Win, 45, 5, 32, 32, 0 ), Icn3 = create( Icon, "", Win, 85, 5, 32, 32, 0 ), Icn4 = create( Icon, "", Win, 125, 5, 32, 32, 0 ), Icn5 = create( Icon, "", Win, 165, 5, 32, 32, 0 ), Icn6 = create( Icon, "", Win, 205, 5, 32, 32, 0 ), Icn7 = create( Icon, "", Win, 245, 5, 32, 32, 0 ), Icn8 = create( Icon, "", Win, 285, 5, 32, 32, 0 ), Icn9 = create( Icon, "", Win, 325, 5, 32, 32, 0 ), Icn10 = create( Icon, "", Win, 365, 5, 32, 32, 0 ) setWindowBackColor(Win,0027110 ) setIcon( Icn1, "c:\\im\\icos\\c.ico" ) setIcon( Icn2, "c:\\im\\icos\\cd.ico" ) setIcon( Icn3, "c:\\im\\icos\\dl.ico" ) setIcon( Icn4, "c:\\im\\icos\\ed.ico" ) setIcon( Icn5, "c:\\im\\icos\\f2p.ico" ) setIcon( Icn6, "c:\\im\\icos\\pif.ico" ) setIcon( Icn7, "c:\\im\\icos\\rm.ico" ) setIcon( Icn8, "c:\\im\\icos\\ts.ico" ) setIcon( Icn9, "c:\\im\\icos\\wfe.ico" ) setIcon( Icn10, "c:\\im\\icos\\wk.ico" ) setHint( Icn1 , "Control Panel" ) setHint( Icn2 , "Check Disk" ) setHint( Icn3 , "Dir Lister" ) setHint( Icn4 , "Erase CD-DVD" ) setHint( Icn5 , "Folder 2 My PC" ) setHint( Icn6 , "PastIconFlusher" ) setHint( Icn7 , "Ram Monitor" ) setHint( Icn8 , "Tree Size" ) setHint( Icn9 , "Fonts on PC" ) setHint( Icn10 , "Win Hot Key" ) --procedure appear() -- setVisible(Win,1) ---end procedure -- integer stopped --stopped = 0 --procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. -- if parms[1] = VK_ESCAPE then appear() --setVisible(Win,1) end if -- stopped = not stopped -- elsif parms[1] = VK_ENTER then -- init_vars() -- stopped = 0 -- end if --end procedure --setHandler(Win, w32HKeyDown, routine_id("WinKey")) procedure run_it ( integer self, integer event, sequence parms ) -- integer keyCode keyCode = 0 if self = Win then setVisible(Win,0) ------->>>>>>> for i = 1 to 1000000000 do end for ------->>>>>>> setVisible(Win,1) -- if event = keyCode then if keyCode = 27 then setVisible(Win,1) end if -- end if -- closeWindow(Win) closeApp() end if if self = Icn1 then shellExecute ("open","c:\\windows\\system32\\control.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn2 then shellExecute ("open","c:\\checkdisk\\checkDisk.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn3 then shellExecute ("open","C:\\Program Files\\Directory Lister\\DirLister.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if end procedure setHandler({Win,Icn1,Icn2,Icn3}, w32HClick, routine_id("run_it")) -- w32HKeyDown WinMain(Win, Normal)
2. Re: Key Press to have Window "reappear ??
- Posted by DerekParnell (admin) Feb 22, 2011
- 1652 views
So, I would like to press a key e.g. ESCAPE to have the window strip "reappear".
The problem is that keys only respond to the control that has focus at the time of keypress, and a Window almost never has focus ... especially if its invisible.
The solution is to set a keystroke handler for the Screen control. This is a special control that is always defined, so you don't have to create it. It gets every message from Windows for your application.
So you only have to do a minor chnage to your program; change the handler for Win to Screen and things should be better.
-- The changed code would be ... procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then setVisible(Win,1) elsif parms[1] = VK_ENTER then init_vars() end if end procedure setHandler( Screen , w32HKeyDown, routine_id("WinKey"))
3. Re: Key Press to have Window "reappear ??
- Posted by Selgor Feb 22, 2011
- 1636 views
Hello Derek, Put code in. No go. Still not having Window Strip reappear. Selgor.
4. Re: Key Press to have Window "reappear ??
- Posted by DerekParnell (admin) Feb 22, 2011
- 1637 views
Hello Derek, Put code in. No go. Still not having Window Strip reappear. Selgor.
Ok, when I get home, I'll try it out myself. I'm not at a computer with Euphoria installed right now.
5. Re: Key Press to have Window "reappear ??
- Posted by Selgor Feb 23, 2011
- 1629 views
Thank you Derek. The Code as it now is.
include win32lib.ew without warning constant Win = create(Window,"",0,220,150,690,45,{WS_POPUP,WS_DLGFRAME}), Icn1 = create( Icon, "", Win, 5, 5, 32, 32, 0 ), Icn2 = create( Icon, "", Win, 45, 5, 32, 32, 0 ), Icn3 = create( Icon, "", Win, 85, 5, 32, 32, 0 ), Icn4 = create( Icon, "", Win, 125, 5, 32, 32, 0 ), Icn5 = create( Icon, "", Win, 165, 5, 32, 32, 0 ), Icn6 = create( Icon, "", Win, 205, 5, 32, 32, 0 ), Icn7 = create( Icon, "", Win, 245, 5, 32, 32, 0 ), Icn8 = create( Icon, "", Win, 285, 5, 32, 32, 0 ), Icn9 = create( Icon, "", Win, 325, 5, 32, 32, 0 ), Icn10 = create( Icon, "", Win, 365, 5, 32, 32, 0 ) setWindowBackColor(Win,0027110 ) setIcon( Icn1, "c:\\im\\icos\\c.ico" ) setIcon( Icn2, "c:\\im\\icos\\cd.ico" ) setIcon( Icn3, "c:\\im\\icos\\dl.ico" ) setIcon( Icn4, "c:\\im\\icos\\ed.ico" ) setIcon( Icn5, "c:\\im\\icos\\f2p.ico" ) setIcon( Icn6, "c:\\im\\icos\\pif.ico" ) setIcon( Icn7, "c:\\im\\icos\\rm.ico" ) setIcon( Icn8, "c:\\im\\icos\\ts.ico" ) setIcon( Icn9, "c:\\im\\icos\\wfe.ico" ) setIcon( Icn10, "c:\\im\\icos\\wk.ico" ) setHint( Icn1 , "Control Panel" ) setHint( Icn2 , "Check Disk" ) setHint( Icn3 , "Dir Lister" ) setHint( Icn4 , "Erase CD-DVD" ) setHint( Icn5 , "Folder 2 My PC" ) setHint( Icn6 , "PastIconFlusher" ) setHint( Icn7 , "Ram Monitor" ) setHint( Icn8 , "Tree Size" ) setHint( Icn9 , "Fonts on PC" ) setHint( Icn10 , "Win Hot Key" ) -- The changed code would be ... procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then setVisible(Win,1) end if end procedure setHandler( Screen , w32HKeyDown, routine_id("WinKey")) procedure run_it ( integer self, integer event, sequence parms ) if self = Win then setVisible(Win,0) ------->>>>>>> for i = 1 to 1000000000 do end for << works ------->>>>>>> setVisible(Win,1) << but !! -- if self = Win then -- closeWindow(Win) closeApp() end if if self = Icn1 then shellExecute ("open","c:\\windows\\system32\\control.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn2 then shellExecute ("open","c:\\checkdisk\\checkDisk.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn3 then shellExecute ("open","C:\\Program Files\\Directory Lister\\DirLister.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if end procedure setHandler({Win,Icn1,Icn2,Icn3}, w32HClick, routine_id("run_it")) WinMain(Win, Normal)
6. Re: Key Press to have Window "reappear ??
- Posted by DerekParnell (admin) Feb 23, 2011
- 1596 views
Ok, the problem is that when the last (or only) Window is hidden, the library also closes it. And once it is closed, it no longer receives Windows messages.
So, to get around this, use these tricks-of-the-trade ...
-- To hide a window, move to somewhere off the screen. if self = Win then setCtlPosition(Win, -1000, -1000) -- Hide it end if -- To reshow it, move it back to the screen. if self = Win then setCtlPosition(Win, 220, 150) -- Display it end if -- Also, you might like to create the window with the 'palette' style. -- This prevents it showing up in the Start Bar. constant Win = createEx(Window,"",0,220,150,690,45, {WS_POPUP, WS_DLGFRAME},WS_EX_PALETTEWINDOW)
7. Re: Key Press to have Window "reappear ??
- Posted by Selgor Feb 23, 2011
- 1571 views
Thanks for staying with me.
I must be doing it all wrong. Still no joy.
Here is what code now looks like.
include win32lib.ew without warning constant Win = createEx(Window,"",0,220,150,690,45,{WS_POPUP,WS_DLGFRAME},WS_EX_PALETTEWINDOW), Icn1 = create( Icon, "", Win, 5, 5, 32, 32, 0 ), Icn2 = create( Icon, "", Win, 45, 5, 32, 32, 0 ), Icn3 = create( Icon, "", Win, 85, 5, 32, 32, 0 ), Icn4 = create( Icon, "", Win, 125, 5, 32, 32, 0 ), Icn5 = create( Icon, "", Win, 165, 5, 32, 32, 0 ), Icn6 = create( Icon, "", Win, 205, 5, 32, 32, 0 ), Icn7 = create( Icon, "", Win, 245, 5, 32, 32, 0 ), Icn8 = create( Icon, "", Win, 285, 5, 32, 32, 0 ), Icn9 = create( Icon, "", Win, 325, 5, 32, 32, 0 ), Icn10 = create( Icon, "", Win, 365, 5, 32, 32, 0 ) setWindowBackColor(Win,0027110 ) setIcon( Icn1, "c:\\im\\icos\\c.ico" ) setIcon( Icn2, "c:\\im\\icos\\cd.ico" ) setIcon( Icn3, "c:\\im\\icos\\dl.ico" ) setIcon( Icn4, "c:\\im\\icos\\ed.ico" ) setIcon( Icn5, "c:\\im\\icos\\f2p.ico" ) setIcon( Icn6, "c:\\im\\icos\\pif.ico" ) setIcon( Icn7, "c:\\im\\icos\\rm.ico" ) setIcon( Icn8, "c:\\im\\icos\\ts.ico" ) setIcon( Icn9, "c:\\im\\icos\\wfe.ico" ) setIcon( Icn10, "c:\\im\\icos\\wk.ico" ) setHint( Icn1 , "Control Panel" ) setHint( Icn2 , "Check Disk" ) setHint( Icn3 , "Dir Lister" ) setHint( Icn4 , "Erase CD-DVD" ) setHint( Icn5 , "Folder 2 My PC" ) setHint( Icn6 , "PastIconFlusher" ) setHint( Icn7 , "Ram Monitor" ) setHint( Icn8 , "Tree Size" ) setHint( Icn9 , "Fonts on PC" ) setHint( Icn10 , "Win Hot Key" ) procedure run_it ( integer self, integer event, sequence parms ) if self = Win then setCtlPosition(Win, -1000, -1000) -- Hide it end if -- To reshow it, move it back to the screen. if self = Win then setCtlPosition(Win, 220, 150) -- Display it end if ------->>>>>>> for i = 1 to 1000000000 do end for << works ------->>>>>>> setVisible(Win,1) << but !! -- if self = Win then -- closeWindow(Win) closeApp() -- end if if self = Icn1 then shellExecute ("open","c:\\windows\\system32\\control.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn2 then shellExecute ("open","c:\\checkdisk\\checkDisk.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn3 then shellExecute ("open","C:\\Program Files\\Directory Lister\\DirLister.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if end procedure setHandler({Win,Icn1,Icn2,Icn3}, w32HClick, routine_id("run_it")) WinMain(Win, Normal)
8. Re: Key Press to have Window "reappear ??
- Posted by DerekParnell (admin) Feb 23, 2011
- 1565 views
I must be doing it all wrong.
It seems you are not yet an experienced programmer because the reason your code is NOW not working is very obvious. I'm sorry that my example code was not clear enough.
Your code should be looking more like this ...
include win32lib.ew without warning constant Win = createEx(Window, "", 0, 220, 150, 690, 45, {WS_POPUP, WS_DLGFRAME}, WS_EX_PALETTEWINDOW) integer x sequence IconId IconId = {} sequence command_data command_data = { {"c:\\windows\\system32\\control.exe", "c:\\im\\icos\\c.ico" , "Control Panel"}, {"c:\\checkdisk\\checkDisk.exe", "c:\\im\\icos\\cd.ico", "Check Disk"}, {"c:\\Program Files\\Directory Lister\\DirLister.exe", "c:\\im\\icos\\dl.ico", "Dir Lister"}, { "", "c:\\im\\icos\\ed.ico", "Erase CD-DVD"}, { "", "c:\\im\\icos\\f2p.ico", "Folder 2 My PC"}, { "", "c:\\im\\icos\\pif.ico", "PastIconFlusher"}, { "", "c:\\im\\icos\\rm.ico", "Ram Monitor"}, { "", "c:\\im\\icos\\ts.ico", "Tree Size"}, { "", "c:\\im\\icos\\wfe.ico", "Fonts on PC"}, { "", "c:\\im\\icos\\wk.ico", "Win Hot Key"} } setWindowBackColor(Win, 0027110 ) x = 5 -- The X position of leftmost icon. for i = 1 to length(command_data) do IconId &= create( Icon, "", Win, x, 5, 32, 32, 0) x += 40 setIcon( IconId[$], command_data[i][2]) setHint( IconId[$], command_data[i][3]) end for procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then setCtlPosition(Win, 250, 150) -- Show it end if end procedure setHandler( Screen , w32HKeyDown, routine_id("WinKey")) procedure hide_window ( integer self, integer event, sequence parms ) setCtlPosition(Win, -1000, -1000) -- Hide it end procedure setHandler(Win, w32HClick, routine_id("hide_window")) procedure run_it ( integer self, integer event, sequence parms ) integer cmd cmd = find(self, IconId) if cmd != 0 and length(command_data[cmd][1]) > 0 then shellExecute ("open", command_data[cmd][1], SW_SHOWNORMAL) closeApp() end if end procedure setHandler(IconId, w32HClick, routine_id("run_it")) WinMain(Win, Normal)
9. Re: Key Press to have Window "reappear ??
- Posted by Selgor Feb 23, 2011
- 1546 views
Hello Derek.
I have ALWAYS told you I am a novice in .exw programming. And probably in programming as a whole I am a sort of " let's try this & hope it works" person. Most often "it" does work for me. But when "it" doesn't I ask for EXPERT advice. I thought "we" were or are "hobbyists". As such we learn as we go .
Now , taking your code previously ... I worked on it and came up with the following programme which I thought worked O.K. until I now read your magnificent code. And I thank you and will digest it for future reference. Isn't that how we all learn ?
This programme puts a little window in the left top of the screen. When "it" is clicked the main Strip reappears. I thought this is what you were trying to get me to do. Use the code you gave and "gel" it to mine. For what it is now worth (maybe worthless) I show you MY code. At least I got something that somewhat worked ! And as usual I learnt something new in doing it.
If you do not learn something new each day then ...... shame .
Thanks for your patience as usual.
By the way my .ex Kaleidoscope programme which you helped put into .exw gui window code took nearly 2 years to perfect. See, I keep tapping away and eventually I get there.
Remember all I needed was help to "window" it NOT write the Kaleidoscope code.
But, heaps of thanks for this LESSON. I have learnt a lot.
Cheers. Selgor.
include win32lib.ew without warning constant Win = createEx(Window,"",0,220,150,690,45,{WS_POPUP,WS_DLGFRAME},WS_EX_PALETTEWINDOW), Icn1 = create( Icon, "", Win, 5, 5, 32, 32, 0 ), Icn2 = create( Icon, "", Win, 45, 5, 32, 32, 0 ), Icn3 = create( Icon, "", Win, 85, 5, 32, 32, 0 ), Icn4 = create( Icon, "", Win, 125, 5, 32, 32, 0 ), Icn5 = create( Icon, "", Win, 165, 5, 32, 32, 0 ), Icn6 = create( Icon, "", Win, 205, 5, 32, 32, 0 ), Icn7 = create( Icon, "", Win, 245, 5, 32, 32, 0 ), Icn8 = create( Icon, "", Win, 285, 5, 32, 32, 0 ), Icn9 = create( Icon, "", Win, 325, 5, 32, 32, 0 ), Icn10 = create( Icon, "", Win, 365, 5, 32, 32, 0 ) setWindowBackColor(Win,0027110 ) setIcon( Icn1, "c:\\im\\icos\\c.ico" ) setIcon( Icn2, "c:\\im\\icos\\cd.ico" ) setIcon( Icn3, "c:\\im\\icos\\dl.ico" ) setIcon( Icn4, "c:\\im\\icos\\ed.ico" ) setIcon( Icn5, "c:\\im\\icos\\f2p.ico" ) setIcon( Icn6, "c:\\im\\icos\\pif.ico" ) setIcon( Icn7, "c:\\im\\icos\\rm.ico" ) setIcon( Icn8, "c:\\im\\icos\\ts.ico" ) setIcon( Icn9, "c:\\im\\icos\\wfe.ico" ) setIcon( Icn10, "c:\\im\\icos\\wk.ico" ) setHint( Icn1 , "Control Panel" ) setHint( Icn2 , "Check Disk" ) setHint( Icn3 , "Dir Lister" ) setHint( Icn4 , "Erase CD-DVD" ) setHint( Icn5 , "Folder 2 My PC" ) setHint( Icn6 , "PastIconFlusher" ) setHint( Icn7 , "Ram Monitor" ) setHint( Icn8 , "Tree Size" ) setHint( Icn9 , "Fonts on PC" ) setHint( Icn10 , "Win Hot Key" ) procedure run_it ( integer self, integer event, sequence parms ) -- if self = Win then -- setCtlPosition(Win, 0, 1) -- Hide it -- end if -- To reshow it, move it back to the screen. if self = Win then setCtlPosition(Win, 220, 150) -- Display it end if ------->>>>>>> for i = 1 to 1000000000 do end for << works ------->>>>>>> setVisible(Win,1) << but !! -- if self = Win then -- closeWindow(Win) closeApp() -- end if if self = Icn1 then shellExecute ("open","c:\\windows\\system32\\control.exe",SW_SHOWNORMAL) setCtlPosition(Win,-685, -30) -- closeWindow(Win) closeApp() end if if self = Icn2 then shellExecute ("open","c:\\checkdisk\\checkDisk.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if if self = Icn3 then shellExecute ("open","C:\\Program Files\\Directory Lister\\DirLister.exe",SW_SHOWNORMAL) closeWindow(Win) closeApp() end if end procedure setHandler({Win,Icn1,Icn2,Icn3}, w32HClick, routine_id("run_it")) WinMain(Win, Normal)
10. Re: Key Press to have Window "reappear ??
- Posted by Selgor Feb 24, 2011
- 1457 views
Hello to all EuForum readers.
I post this programme to show that the previous programme which shows a small window in the top left of screen can easily be modified and do what Derek was trying to show me. O.K. the penny finally dropped and this works . Window can be closed, hidden, reappear.
include win32lib.ew without warning constant Win = createEx(Window,"",0,220,150,690,45,{WS_POPUP,WS_DLGFRAME},WS_EX_PALETTEWINDOW), Icn1 = create( Icon, "", Win, 5, 5, 32, 32, 0 ), Icn2 = create( Icon, "", Win, 45, 5, 32, 32, 0 ), Icn3 = create( Icon, "", Win, 85, 5, 32, 32, 0 ), Icn4 = create( Icon, "", Win, 125, 5, 32, 32, 0 ), Icn5 = create( Icon, "", Win, 165, 5, 32, 32, 0 ), Icn6 = create( Icon, "", Win, 205, 5, 32, 32, 0 ), Icn7 = create( Icon, "", Win, 245, 5, 32, 32, 0 ), Icn8 = create( Icon, "", Win, 285, 5, 32, 32, 0 ), Icn9 = create( Icon, "", Win, 325, 5, 32, 32, 0 ), Icn10 = create( Icon, "", Win, 365, 5, 32, 32, 0 ) setWindowBackColor(Win,0027110 ) setIcon( Icn1, "c:\\im\\icos\\c.ico" ) setIcon( Icn2, "c:\\im\\icos\\cd.ico" ) setIcon( Icn3, "c:\\im\\icos\\dl.ico" ) setIcon( Icn4, "c:\\im\\icos\\ed.ico" ) setIcon( Icn5, "c:\\im\\icos\\f2p.ico" ) setIcon( Icn6, "c:\\im\\icos\\pif.ico" ) setIcon( Icn7, "c:\\im\\icos\\rm.ico" ) setIcon( Icn8, "c:\\im\\icos\\ts.ico" ) setIcon( Icn9, "c:\\im\\icos\\wfe.ico" ) setIcon( Icn10, "c:\\im\\icos\\wk.ico" ) setHint( Icn1 , "Control Panel" ) setHint( Icn2 , "Check Disk" ) setHint( Icn3 , "Dir Lister" ) setHint( Icn4 , "Erase CD-DVD" ) setHint( Icn5 , "Folder 2 My PC" ) setHint( Icn6 , "PastIconFlusher" ) setHint( Icn7 , "Ram Monitor" ) setHint( Icn8 , "Tree Size" ) setHint( Icn9 , "Fonts on PC" ) setHint( Icn10 , "Win Hot Key" ) procedure WinKey(integer self, integer event, sequence parms) -- Check for key presses. if parms[1] = VK_ESCAPE then setCtlPosition(Win, 250, 150) -- Show it end if end procedure setHandler( Screen , w32HKeyDown, routine_id("WinKey")) procedure run_it ( integer self, integer event, sequence parms ) if self = Win then closeWindow(Win) closeApp() end if if self = Icn1 then shellExecute ("open","c:\\windows\\system32\\control.exe",SW_SHOWNORMAL) setCtlPosition(Win,-1000, -1000) -- closeWindow(Win) closeApp() end if if self = Icn2 then shellExecute ("open","c:\\checkdisk\\checkDisk.exe",SW_SHOWNORMAL) setCtlPosition(Win,-1000, -1000) -- closeWindow(Win) closeApp() end if if self = Icn3 then shellExecute ("open","C:\\Program Files\\Directory Lister\\DirLister.exe",SW_SHOWNORMAL) setCtlPosition(Win,-1000, -1000) -- closeWindow(Win) closeApp() end if end procedure setHandler({Win,Icn1,Icn2,Icn3}, w32HClick, routine_id("run_it")) WinMain(Win, Normal)
Yes, this is the "hide' I asked for. Thanks again Derek. But, it will be your programme , Derek , that I will use. Learnt so much from it.
Cheers.
Selgor