SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Oct 26, 2004 10:54 pm Post subject: Custom Caret |
|
|
This will change the caret(the blinking line in an editbox) of your edit control.
The example requires a 16x16 BMP(a sample is attached to this post, it's extension was changed to JPG so it could be attached), it looks in the path of your script for it. Caret colors are inverted, so make sure you save it as the inverse of the colors you actually want to show up.
Code: |
DIALOG CREATE,Custom Caret,-1,0,240,62
DIALOG ADD,EDIT,EDIT1,17,31,180,24
%%focused = 0
%%bmppath = @PATH(%0)cursor.bmp
%%caretwidth = 16
%%caretheight = 16
LOADLIB user32.dll
REM *** Load the cursor bitmap
REM *** $010 = LR_LOADFROMFILE
%%carethandle = @LIB(user32,LoadImageA,INT:,INT:0,STR:%%bmppath,INT:0,INT:%%caretwidth,INT:%%caretheight,INT:$010)
%%hwnd = @STRDEL(@WINEXISTS(~EDIT1),1,1)
DIALOG SHOW
:Timer
REM *** ReCreate the caret each time the edit receives focus, or else it reverts to the normal one.
%%focusedhwnd = @LIB(user32,GetFocus,INT:,NIL:)
if @EQUAL(%%focusedhwnd,%%hwnd)
REM *** Make sure we are "regaining" the focus, and didn't already have it
if @EQUAL(%%focused,0)
%%return = @LIB(user32,HideCaret,INT:,INT:%%hwnd)
%%return = @LIB(user32,CreateCaret,INT:,INT:%%hwnd,INT:%%carethandle,INT:%%caretwidth,INT:%%caretheight)
%%return = @LIB(user32,ShowCaret,INT:,INT:%%hwnd)
%%focused = 1
end
else
%%return = @LIB(user32,HideCaret,INT:,INT:%%hwnd)
%%return = @LIB(user32,DestroyCaret,INT:,NIL:)
%%focused = 0
end
:evloop
wait event,0.2
goto @event()
:Close
LOADLIB Gdi32.dll
%%return = @LIB(Gdi32,DeleteObject,INT:,INT:%%carethandle)
FREELIB Gdi32.dll
FREELIB user32.dll
exit
|
Description: |
|
Filesize: |
822 Bytes |
Viewed: |
15388 Time(s) |

|
_________________ -Sheep
My pockets hurt... |
|