Inputting text while in DirectDraw
Hey all,
Just wanna say that this place is great :)
But anyway, I've made a couple of DirectDraw programs, and I also am learning winsock, it's going really well. The next thing that I wanted to try is inputting some text, while in DirectDraw...
But.. How am I going to do that? I can't use a text-box or something, right? Do I need to check for a pressed key, and then make a function for my own text-box in directdraw or something ?
BTW, I am using c++..
Thanks alot :)
That's exactly what you will need to do. You can use the WM_KEYDOWN/WM_CHAR messages to detect key presses. Then you will need a function to display text. In DirectDraw, you can use the GDI text functions (somewhat slow), or you can write your own functions and use a font drawn in a bitmap, treating the letters as sprites, and display the appropriate letter as the keys are pressed.
Have you looked into DirectInput? Your other option is handling input via windows, as Dave Hunt has suggested.
Not neccesarily, it depends on why he's taking input. He has mentioned text though, and your advice is excellent for that situation.
Quote:Then you will need a function to display text.
Not neccesarily, it depends on why he's taking input. He has mentioned text though, and your advice is excellent for that situation.
Quote:Original post by Dave Hunt
In DirectDraw, you can use the GDI text functions (somewhat slow), or you can write your own functions and use a font drawn in a bitmap, treating the letters as sprites, and display the appropriate letter as the keys are pressed.
Hmm.. yes, I know what you mean,.. I think that I need to program some sort of GUI function, that I can create windows as classes, and link textboxes and buttons to it, and then check everything on what is the active textbox / map / button, etc.. and then use the inputs from directinput/windows...
Thx for the answer, just wanted to make sure there wasn't another way :)
But do you suggest I make my own font bitmap, or use GDI text?
To start out, I would use the GDI functions, since they already work. You can switch to using your own font routines after you get everything working.
Your welcome. And good luck with it!
Just another note, if you decide to use DirectInput, you will want to use buffered mode while collecting user input. Otherwise, you won't have any way of knowing in what order the user pressed the keys. Again, for starting out, you can stick with Windows messages and switch to DirectInput once everything works.
Just another note, if you decide to use DirectInput, you will want to use buffered mode while collecting user input. Otherwise, you won't have any way of knowing in what order the user pressed the keys. Again, for starting out, you can stick with Windows messages and switch to DirectInput once everything works.
I've used the mouse earlier with buffering, with directinput, I will look deeper in how to use the keyboard with directinput..
Thanks for the tips :)
Thanks for the tips :)
I think DirectInput has problems with alternate keyboard layouts (like dvorak), as well. Directinput is good for game-controls, but I made a (very basic) text-input system using DirectInput, and if I were to make another one I'd probably just use window messages.
Okay, inputting things works great, but another question I have is, how to use the windows system mouse ?? Because if the user clicks on a text box, it needs to become active, and then the user can type things.. But how do I know the coordinates the user has ?
I am using windowed mode, so if the user change the window's position, I presume I must calculate some things.. But I don't have a clue where to get the info on the coordinates of the mouse..
Anyone know some good tutorial on that ?
Thx,
Padschild
I am using windowed mode, so if the user change the window's position, I presume I must calculate some things.. But I don't have a clue where to get the info on the coordinates of the mouse..
Anyone know some good tutorial on that ?
Thx,
Padschild
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement