Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

King

Redrawing a Window

This topic is 6647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was thinking of an idea for my final project in school, its very simple(but of course i don''t know how to do it) window which when i press tab changes the color, and the text. If someone can point me in the right direction i''d appreciate it. Thanks. - king171@hotmail.com
- http://www.cfxweb.net/mxf/

Share this post


Link to post
Share on other sites
Advertisement
Maybe I''m sleep depped again, but I''m not quite sure I understand what you want.... what needs to be IN the window, text wise? Just some text saying something like "King''s Wonderful Project", a text file, or are you wanting to change the colour of a different applications window?

For the first option, I''d recommend opening up Visual Basic, drawing a simple form with some static text, and writing code that changes the form''s background colour property and the text''s colour property.

For the second, you''d either want to take an existing VB text editor (I''m sure I''ve seen them around) and add colour changing, or use VC++ to quickly create an MFC app that resembles notepad but with trippy colours.

The last option is hard, and I''m not quite sure how I''d go about doing it. There are several window manager programs around that let you hack the way Windows looks - I''m sure that at least one of them must have source code available!

Hope that helps a bit.

Share this post


Link to post
Share on other sites
Bracket i program in C, with the WINDOWS API, but i want to have a window setup(nice and simple like the original "hellow, windows 95" application). Then when I press a button(like Tab) the background changes from white to black, and the text redraws onto the screen saying something different.

hope this clears it up.

- king171@hotmail.com
- http://www.cfxweb.net/mxf/

Share this post


Link to post
Share on other sites
King, since you''re using the windows api all you need to do is add a couple of message handlers WM_KEYDOWN, and WM_PAINT. For WM_KEYDOWN it''s simple just something like:

Share this post


Link to post
Share on other sites
(sorry bout the break (hit tab return, oops))
case WM_KEYDOWN:
switch(wParam){
case VK_TAB: //do something like change bkcolor
}
break;

and the paint function something like:
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
RECT rect;
BeginPaint(hWnd,&ps);
hDC = ps.hdc;
GetClientRect(hWnd,&rect);
FillRect(hDC,&rect,CreateSolidBrush(bkcolor));
//Draw text
ReleaseDC(hWnd,hDC);
EndPaint(hWnd,&ps);
break;

Share this post


Link to post
Share on other sites
Oh, yeah sorry, you do

InvalidateRect(hWnd,NULL,FALSE);

that will redraw the window, but before that you should change the background color and text

Share this post


Link to post
Share on other sites
And in case you don''t know about it, there''s a very useful function when drawing text :

SetBkMode(hDC, TRANSPARENT);

That way the window will only draw the actual text and not that annoying rectangle around it, hope that helps.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!