Software caret win32 C

Started by
3 comments, last by szecs 14 years, 1 month ago
Hi all! I have an event (windows messages) based program, with an openGL GUI. Since it's openGL, I can't use the hardware caret in an edit box widget, and I have problem with its blinking. Is there a win32 message that is sent, when the caret would "blink", or I have to re-implement the blinking with WM_TIMER for example? Or is there a simpler way for that thing? I hope that's clear, and thanks in advance!
Advertisement
I haven't tried but I still don't see what's keeping you from using the win32 caret functions? You can even specify your own bmp shape via:


// Load the application-defined caret resource.
hCaret = LoadBitmap(hinst, MAKEINTRESOURCE(120));

// Create a bitmap caret.
CreateCaret(hwnd, hCaret, 0, 0);

(See http://msdn.microsoft.com/en-us/library/ms648398(VS.85).aspx)

Is it not interacting well with OpenGL? (Maybe after a swap you may need to call ShowCaret() or something...?)

If not, I'm pretty sure you'll need to implement a timer yourself to know when to blink your home-brewed caret.
I'm not sure, I will try to place and show a caret somewhere, but you see, there are no edit boxes/whatever, just my own GUI, but I will try. (but I guess placing needs text coordinates, so I don't see how I can do that, if there aren't any text widgets)
Do you update your GUI constantly (like 60 FPS or whatever), or just when you receive messages?
If you have constant updates just increase a time every frame and invert the caret whenever more than 0.5 sec has passed or similar, and otherwise a WM_TIMER sounds good. If you want to mimic the Win32 caret, try the GetCaretBlinkTime Function, and SPI_GETCARETWIDTH from SystemParametersInfo.
Just on messages. that's the problem. I made the caret work on a constantly updating system, it's straightforward.
I can make it work in this case too by using WM_TIMER, but I was hoping there's a simpler method too, I don't want to re-implement everything, if there's a method for that.
But I guess I will go the timer way (should be 15 mins to implement anyway).

Thanks for your ideas guys!

EDIT: Yup, 15 minutes... (next time I should implement it first, then ask for alternative, because the solution couldn't be simpler that the one I have with timers).

[Edited by - szecs on March 9, 2010 2:10:54 AM]

This topic is closed to new replies.

Advertisement