1. caret cursor in a window
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 14, 2000
- 357 views
- Last edited Jan 15, 2000
All, Greg Harris sent me a nice little piece of code which does let me put a caret based cursor in a window; I modified it a little to what's below, in case it's of any use to anyone else. Dan Moyer --------------------start code----------------- include win32lib.ew constant SimpleWin = create( Window, "Simple Window", 0, Default, Default, 200, 100, 0 ) atom MyCursor atom result MyCursor = getHandle(SimpleWin) result = c_func( xCreateCaret,{MyCursor,NULL,2,20})-- NULL is for bmp? result = c_func( xSetCaretBlinkTime,{300}) result = c_func( xSetCaretPos,{100,25}) result = c_func( xShowCaret,{MyCursor}) WinMain( SimpleWin, Normal ) ---------------- end code -------------------
2. Re: caret cursor in a window
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 14, 2000
- 340 views
- Last edited Jan 15, 2000
oops! never mind! My "improvement" to the caret cursor example Greg sent me is anything but an improvement. I should have kept my mitts off. Info he found for me says the caret cursor apparently needs to be created EACH TIME a relevant control (like a window) is active or gets focus, AND needs to be destroyed whenever it's inactive or loses focus. I'll correct it here later if he doesn't. Dan (choking on a caret)
3. Re: caret cursor in a window
- Posted by Judith Evans <camping at FLASH.NET> Jan 15, 2000
- 340 views
Dan, If you can get the caret to work in a window with a control such as the vertical scrollbar, I would appreciate seeing the code. I had played around with the caret back when David had the routines in Win32lib but could never get them to work except in a bare window with no controls. Since we do not yet have WINDOW scrollbars, it didn't do me a whole lot of good! Thanks, Judith Evans
4. Re: caret cursor in a window
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 15, 2000
- 332 views
Judith, I'm not sure if this is what you mean? It's just a vert. scroll bar control added into a more nearly original example of how to use the caret cursor that Greg Harris sent to me. Note that in order to use "OldBlinkRate" to reset the original "system" blink rate, a SetCaretBlinkTime should probably be in an onClose the window instead of in onLostFocus. Thanks again to Greg for the example code! It's not obvious in this simple window, but his original example code as represented here will do what my earlier "improved" version would not, namely function in a child window that might be "closed" & then re-opened. Dan Moyer ------------- code starts ------------------ -- code generated by Win32Lib IDE v0.8 -- note: "caret" based cursor added in afterward include Win32Lib.ew without warning ---------------------------------------------------------------------------- ---- -- Window Window1 global constant Window1 = create( Window, "The Window", 0, Default, Default, 350, 250+ 19, 0 ) global constant VScroll1 = create( VScroll, "VScroll1", Window1, 257, 37, 20, 150, 0 ) ---------------------------------------------------------------------------- -- "caret" based cursor: integer OldBlinkRate -- to restore original system blink rate OldBlinkRate = c_func(xGetCaretBlinkTime,{}) procedure Window1GetFocus() atom MyCursor atom result MyCursor = getHandle(getSelf())-- could probably be getHandle(Window1) result = c_func( xCreateCaret,{MyCursor,NULL,2,20})-- null is for bmp? result = c_func( xSetCaretBlinkTime,{300}) result = c_func( xSetCaretPos,{100,25})-- use this to control cursor position result = c_func( xShowCaret,{MyCursor}) end procedure onGotFocus[Window1] = routine_id("Window1GetFocus") ---------------------------------------------------------------------- procedure Window1LostFocus() atom result result = c_func( xSetCaretBlinkTime,{OldBlinkRate}) result = c_func( xDestroyCaret,{}) end procedure onLostFocus[Window1] = routine_id("Window1LostFocus") ---------------------------------------------------------------------- WinMain( Window1, Normal ) ------------------ code ends ---------------------- -----Original Message----- From: Judith Evans <camping at FLASH.NET> To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU> Date: Saturday, January 15, 2000 2:23 AM Subject: Re: caret cursor in a window >Dan, > >If you can get the caret to work in a window with a control such as the >vertical scrollbar, I would appreciate seeing the code. I had played around >with the caret back when David had the routines in Win32lib but could never >get them to work except in a bare window with no controls. Since we do not >yet have WINDOW scrollbars, it didn't do me a whole lot of good! > >Thanks, >Judith Evans
5. Re: caret cursor in a window
- Posted by Judith Evans <camping at FLASH.NET> Jan 15, 2000
- 357 views
Dan, The code you posted is similar to what I was doing. BUT if I add an onKeyPress[Window1] routine it is never triggered. Are you doing that? Judith Evans
6. Re: caret cursor in a window
- Posted by Judith Evans <camping at FLASH.NET> Jan 15, 2000
- 350 views
Dan, I found out that I should be doing the onKeyPress for the Scrollbar. The Scrollbar grabs the window focus. My old program works now! Thanks for all your help, Judith Evans
7. Re: caret cursor in a window
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jan 15, 2000
- 358 views
Judith, I'm glad you got it working, 'cause I don't think I would have thought to do onKeyPress for the SCROLLBAR! I would have probably tried setting focus on the window before the onKeyPress. Dan Moyer >Dan, > >I found out that I should be doing the onKeyPress for the Scrollbar. The >Scrollbar grabs the window focus. > >My old program works now! > >Thanks for all your help, > >Judith Evans