How to Set Background Color of Window After I Have Registered It

How to set background color of window after I have registered it?

From Window Background comes:

...The system paints the background for a
window or gives the window the
opportunity to do so by sending it a
WM_ERASEBKGND message when the
application calls BeginPaint. If an
application does not process the
message but passes it to
DefWindowProc, the system erases the
background by filling it with the
pattern in the background brush
specified by the window's class.....

...... An application can process the
WM_ERASEBKGND message even though a
class background brush is defined.
This is typical in applications that
enable the user to change the window
background color or pattern for a
specified window without affecting
other windows in the class. In such
cases, the application must not pass
the message to DefWindowProc. .....

So, use the WM_ERASEBKGND message's wParam to get the DC and paint the background.

After createwindow(...), how to give the window a color?

Create a brush of the desired color and then pass it in the hbrBackground member of the WNDCLASS struct when calling RegisterClass to register your window class.

The system will delete this brush automatically when you call UnregisterClass so once you have passed this brush to RegisterClass you can forget all about it and must not attempt to delete it yourself.

Set background color of a specific control

Check lParam matches the handle to the child that you want to change the colour of.

How to set background color of a View

You made your button transparent. The first byte is the alpha.

Try v.setBackgroundColor(0xFF00FF00);

How to change or set background color in 8086 assembly?

You can change the background and foreground color for all the screen by using BIOS function 06h

MOV AH, 06h    ; Scroll up function
XOR AL, AL ; Clear entire screen
XOR CX, CX ; Upper left corner CH=row, CL=column
MOV DX, 184FH ; lower right corner DH=row, DL=column
MOV BH, 1Eh ; YellowOnBlue
INT 10H

The numbers suit the text video mode of 80x25.

One of the best sources of information on BIOS and DOS Interrupts for the IBM PC is Ralf Brown's Interrupt List. INT 10h is the general BIOS interrupt for video routines. A complete list of the INT 10h routines can be found here. I have used the BIOS routine INT 10h/AH=06 which is documented as:

VIDEO - SCROLL UP WINDOW

AH = 06h
AL = number of lines by which to scroll up (00h = clear entire window)
BH = attribute used to write blank lines at bottom of window
CH,CL = row,column of window's upper left corner
DH,DL = row,column of window's lower right corner

Return:
Nothing


Related Topics



Leave a reply



Submit