|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
怎样创建一个透明的子窗口,使用createwindow和win32
窗口代码是这样的:
#include<windows.h>
#include<stdio.h>
WNDCLASS wndclass;
HWND hwnd;
MSG Msg;
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain
(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow
)
{
typedef struct_WNDCLASS;
{
wndclass.style=CS_VREDRAW|CS_HREDRAW;
wndclass.lpfnWndProc=WndProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance;
wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)(GetStockObject(WHITE_BRUSH));
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName=TEXT("HAHA");
}
RegisterClass(&wndclass);
hwnd=CreateWindow( TEXT("HAHA"),
TEXT("XIXI"),
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 0;
};
long CALLBACK WndProc(HWND hwnd,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,message,wParam,lParam);
}
return 0;
}
1.WS_EX_LAYERED可能没定义,我们可以直接取值0x80000
是不是就可以这样写
wndclass.style=CS_VREDRAW|CS_HREDRAW|0x80000
2.SetWindowLong(m_hWnd,GWL_EXSTYLE,GetWindowLong(this->GetSafeHwnd(),GWL_EXSTYLE)^0x80000);
为什么编译的时候会提示错误:error C2065: 'this' : undeclared identifier
3.BOOL SetLayeredWindowAttributes(HWND hwnd,COLORREF crKey,BYTE bAlpha,DWORD dwFlags);
会提示错误:error C2143: syntax error : missing ';' before 'type'
4.void CFloatWnd::OnUpdateTransparent(int iTransparent)
{
HINSTANCE hInst = LoadLibrary("User32.DLL");
if(hInst)
{
typedef BOOL (WINAPI *SLWA)(HWND,COLORREF,BYTE,DWORD);
SLWA pFun = NULL;
pFun = (SLWA)GetProcAddress(hInst,"SetLayeredWindowAttributes");
if(pFun)
{
pFun(m_hWnd,0,iTransparent,2);
}
FreeLibrary(hInst);
}
}
上述代码中的几个HWND分别指的是什么,还有上面这段代码上面意思帮注释下
5.以及上面那些代码我应该怎么插入到我原来的代码里面,就是放在上面位置
本人新手,请大神们讲的通俗点,谢谢!
|
|