C++如何修改窗口背景颜色?或者添加背景图片?
#include<windows.h>LRESULTCALLBACKWndProc(HWND,UINT,WPARAM,LPARAM);intWINAPIWinMain(H...
#include<windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd ;
MSG Msg ;
WNDCLASS wc;
char szApplicationName[]= "Exam3_1Window";
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW) ;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName= szApplicationName;
RegisterClass( &wc);
hwnd=CreateWindow
(
szApplicationName,
szApplicationName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow( hwnd, nCmdShow) ;
UpdateWindow(hwnd);
while( GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage( &Msg) ;
DispatchMessage( &Msg) ;
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc ( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{ switch(message)
{ case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
} 展开
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HWND hwnd ;
MSG Msg ;
WNDCLASS wc;
char szApplicationName[]= "Exam3_1Window";
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor=LoadCursor(NULL,IDC_ARROW) ;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName=NULL;
wc.lpszClassName= szApplicationName;
RegisterClass( &wc);
hwnd=CreateWindow
(
szApplicationName,
szApplicationName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,,
NULL,
NULL,
hInstance,
NULL
);
ShowWindow( hwnd, nCmdShow) ;
UpdateWindow(hwnd);
while( GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage( &Msg) ;
DispatchMessage( &Msg) ;
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc ( HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
)
{ switch(message)
{ case WM_DESTROY:
PostQuitMessage(0);
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
} 展开
展开全部
修改一下窗口的BackColor属性,选折你想要的背景颜色即可
更多追问追答
追问
这个要怎么改啊,是在Background里?
追答
你的界面的属性里没有BackColor这个属性吗
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询