客户区接收鼠标双击消息,在最大化、还原窗口之间切换(只为抛砖引玉)
#include <Windows.h>HINSTANCE g_hInstance;
BOOL b = 0;
LRESULT CALLBACK WndProc(HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch(uMsg)
{
case WM_LBUTTONDBLCLK:
{
b = !b;
if(TRUE == b)
{
ShowWindow(hWnd,SW_MAXIMIZE);
}
else
{
ShowWindow(hWnd,SW_RESTORE);
}
}
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
void RegisterWnd(LPCTSTR lpClassName)
{
WNDCLASSEX wce;
wce.style = CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
wce.lpfnWndProc = WndProc;
wce.cbSize = sizeof(WNDCLASSEX);
wce.cbClsExtra = 0;
wce.cbWndExtra = 0;
wce.hInstance = g_hInstance;
wce.hIcon= 0;
wce.hCursor = 0;
wce.hIconSm = 0;
wce.hbrBackground = HBRUSH(COLOR_BTNFACE);
wce.lpszClassName = lpClassName;
wce.lpszMenuName = 0;
if(!RegisterClassEx(&wce))
{
MessageBox(NULL,TEXT("注册失败"),TEXT("提示"),MB_OK);
}
}
HWND CreateWnd(LPCTSTR lpClassName)
{
HWND hWnd = CreateWindowEx(0,lpClassName,L"鱼C工作室",
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,
CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,g_hInstance,NULL);
return hWnd;
}
void DisplayWnd(HWND hWnd)
{
ShowWindow(hWnd,SW_SHOW);
UpdateWindow(hWnd);
}
void Message()
{
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
g_hInstance = hInstance;
RegisterWnd(L"hello");
HWND hWnd = CreateWnd(L"hello");
DisplayWnd(hWnd);
Message();
return 0;
}
小仙做为鱼友中笨到家的一位,都敢发帖,大侠们发出自己编写的程序吧,不管有没有用,请发出来,一起交流哦~ 小仙发帖只为抛砖引玉。连我这种技术的人都敢发,大家还有什么不敢发的? 前排学习了 {:7_146:} 是前排学习了
页:
[1]