Advertisement

Redrawing a Window

Started by March 15, 2000 03:03 PM
10 comments, last by King 24 years, 9 months ago
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/
I would love to stretch... Any help would be appreciated,

- king171@hotmail.com
- http://www.cfxweb.net/mxf/
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.
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/
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:
Chris
(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,▭);
FillRect(hDC,▭,CreateSolidBrush(bkcolor));
//Draw text
ReleaseDC(hWnd,hDC);
EndPaint(hWnd,&ps);
break;

Chris
Advertisement
what do i do the the:

case VK_TAB:
what do i do to redraw right here?
break;

- king171@hotmail.com
- http://www.cfxweb.net/mxf/
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
Chris
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.
Chris
ok bravezeus, how do i change them is the question from the beginning, I want it to redraw it different

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

This topic is closed to new replies.

Advertisement