I''ve had to do this same thing.
Everyone else, he ain''t looking for using the GDI. He''s looking for the actual code to make his own equivalent of a text-box, meaing how to handle input and such.
What I did...
1. Have a variable (CHAR or STRING) that holds the current input. This normally starts blank, but...
2. When there is a KeyDown event (or WM_KEYDOWN, or whatever), is look at what key it is. If it is an alphanumeric character (A-Z,a-z,0-9,Space), then I add it to the end of the variable. If it is the BACKSPACE key, I remove the last character in the variable. I do not allow for a "caret" system.
3. When I render, I first draw the text. You do this using your method of choice. Based on a timer variable, I might temporarily add the "_" character to the end of the string before rendering.
4. When the RETURN/ENTER key is pressed, I take this as an "accept", and either move on to the next box, or the next screen.
Just slam this system into the background of your main loop, and it should work fine.
Hope this helps!
write a text
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
I''ve had to do this same thing.
Everyone else, he ain''t looking for using the GDI. He''s looking for the actual code to make his own equivalent of a text-box, meaing how to handle input and such.
What I did...
1. Have a variable (CHAR or STRING) that holds the current input. This normally starts blank, but...
2. When there is a KeyDown event (or WM_KEYDOWN, or whatever), is look at what key it is. If it is an alphanumeric character (A-Z,a-z,0-9,Space), then I add it to the end of the variable. If it is the BACKSPACE key, I remove the last character in the variable. I do not allow for a "caret" system.
3. When I render, I first draw the text. You do this using your method of choice. Based on a timer variable, I might temporarily add the "_" character to the end of the string before rendering.
4. When the RETURN/ENTER key is pressed, I take this as an "accept", and either move on to the next box, or the next screen.
Just slam this system into the background of your main loop, and it should work fine.
Hope this helps!
Everyone else, he ain''t looking for using the GDI. He''s looking for the actual code to make his own equivalent of a text-box, meaing how to handle input and such.
What I did...
1. Have a variable (CHAR or STRING) that holds the current input. This normally starts blank, but...
2. When there is a KeyDown event (or WM_KEYDOWN, or whatever), is look at what key it is. If it is an alphanumeric character (A-Z,a-z,0-9,Space), then I add it to the end of the variable. If it is the BACKSPACE key, I remove the last character in the variable. I do not allow for a "caret" system.
3. When I render, I first draw the text. You do this using your method of choice. Based on a timer variable, I might temporarily add the "_" character to the end of the string before rendering.
4. When the RETURN/ENTER key is pressed, I take this as an "accept", and either move on to the next box, or the next screen.
Just slam this system into the background of your main loop, and it should work fine.
Hope this helps!
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement