鱼C论坛

 找回密码
 立即注册
查看: 6087|回复: 6

求助大神!如何让窗口高亮显示!.....

[复制链接]
发表于 2013-8-2 21:10:18 | 显示全部楼层 |阅读模式
5鱼币
请告诉小弟方法!

最佳答案

查看完整内容

BOOL WINAPI FlashWindow( _In_ HWND hWnd, _In_ BOOL bInvert ); BOOL WINAPI FlashWindow( _In_ HWND hWnd, _In_ BOOL bInvert ); Parameters hWnd A handle to the window to be flashed. The window can be either open or minimized. bInvert If this parameter is TRUE, the window is flashed from one state to the other. If it is FALSE, the window is returned to its ...

评分

参与人数 1鱼币 +1 收起 理由
メ㊣逆ご帅☆ + 1 你想让窗口发光么。。

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-8-2 21:10:19 | 显示全部楼层
本帖最后由 565123 于 2013-8-4 13:50 编辑

BOOL WINAPI FlashWindow(
  _In_  HWND hWnd,
  _In_  BOOL bInvert
);

BOOL WINAPI FlashWindow(
  _In_  HWND hWnd,
  _In_  BOOL bInvert
);







Parameters
hWnd [in]
A handle to the window to be flashed. The window can be either open or minimized.

bInvert [in]
If this parameter is TRUE, the window is flashed from one state to the other. If it is FALSE, the window is returned to its original state (either active or inactive).

When an application is minimized and this parameter is TRUE, the taskbar window button flashes active/inactive. If it is FALSE, the taskbar window button flashes inactive, meaning that it does not change colors. It flashes, as if it were being redrawn, but it does not provide the visual invert clue to the user.

Return value
The return value specifies the window's state before the call to the FlashWindow function. If the window caption was drawn as active before the call, the return value is nonzero. Otherwise, the return value is zero.

Remarks
Flashing a window means changing the appearance of its caption bar as if the window were changing from inactive to active status, or vice versa. (An inactive caption bar changes to an active caption bar; an active caption bar changes to an inactive caption bar.)

Typically, a window is flashed to inform the user that the window requires attention but that it does not currently have the keyboard focus.

The FlashWindow function flashes the window only once; for repeated flashing, the application should create a system timer.
第一个参数是窗口的句柄,第二个参数必须为真,如果要闪烁多次,要使用timer

  1. #define UNICODE
  2. #include <Windows.h>
  3. #include <tchar.h>
  4. #include <Shlwapi.h>
  5. #define TIMER_ID 10

  6. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

  7. union A
  8. {
  9.         WNDCLASSEX * wndClass;
  10.         HWND hWnd;
  11.         MSG *msg;
  12. };

  13. static HWND hWnd;

  14. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, int nCmdShow)
  15. {
  16.         A a;
  17.         a.wndClass = new WNDCLASSEX;
  18.         a.wndClass->cbSize = sizeof(WNDCLASSEX);
  19.         a.wndClass->cbWndExtra = 0;
  20.         a.wndClass->cbClsExtra = 0;
  21.         a.wndClass->hbrBackground = (HBRUSH) COLOR_BACKGROUND + 1;
  22.         a.wndClass->hCursor = LoadCursor(nullptr, IDC_ARROW);
  23.         a.wndClass->hIcon = LoadIcon(nullptr, IDI_APPLICATION);
  24.         a.wndClass->hIconSm = a.wndClass->hIcon;
  25.         a.wndClass->hInstance = hInstance;
  26.         a.wndClass->lpfnWndProc = WndProc;
  27.         a.wndClass->lpszClassName = L"Test";
  28.         a.wndClass->lpszMenuName = nullptr;
  29.         a.wndClass->style = CS_HREDRAW | CS_VREDRAW;
  30.         RegisterClassEx(a.wndClass);
  31.         delete a.wndClass;

  32.         a.hWnd = CreateWindow(L"Test", L"Class", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, 0);
  33.         hWnd = a.hWnd;
  34.         ShowWindow(a.hWnd, SW_SHOWNORMAL);

  35.         a.msg = new MSG;
  36.         while (GetMessage(a.msg, nullptr, 0, 0))
  37.         {
  38.                 TranslateMessage(a.msg);
  39.                 DispatchMessage(a.msg);
  40.         }

  41.         delete a.msg;
  42.         a.msg = 0;

  43.         return 0;
  44. }

  45. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  46. {
  47.         static int count;
  48.         switch (uMsg)
  49.         {
  50.         case WM_DESTROY:
  51.                 PostQuitMessage(0);
  52.                 break;
  53.         case WM_CREATE:
  54.                 if (StrCmp(((CREATESTRUCT*) lParam)->lpszClass, L"Test") == 0)
  55.                         CreateWindow(L"button", L"闪烁", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 50, 50, 100, 20, hWnd, 0, GetModuleHandle(nullptr), 0);
  56.                 break;
  57.         case WM_COMMAND:
  58.                 SetTimer(hWnd, TIMER_ID, 2000, nullptr);
  59.                 break;
  60.         case WM_TIMER:
  61.                 if (wParam == TIMER_ID && count < 5)
  62.                 {
  63.                         FlashWindow(hWnd, true);
  64.                         count++;
  65.                 }
  66.                 break;
  67.         default:
  68.                 return DefWindowProc(hWnd, uMsg, wParam, lParam);
  69.                 break;
  70.         }

  71.         return 0;
  72. }
复制代码
点击按钮让窗口闪烁五次

评分

参与人数 1荣誉 +10 鱼币 +10 贡献 +5 收起 理由
怡静 + 10 + 10 + 5 感谢楼主无私奉献!

查看全部评分

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-8-2 21:47:48 | 显示全部楼层
不知道你在问什么???详细一点,什么窗口???
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-8-3 10:21:03 | 显示全部楼层
真的不知道你想问什么诶
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-8-3 18:09:00 | 显示全部楼层
- - 就是问有木有让任何窗口高亮显示 的API
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2013-8-5 12:06:45 | 显示全部楼层
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2013-8-5 17:56:38 | 显示全部楼层
他问的是高难度的,,
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-11 13:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表