a476879313 发表于 2013-8-2 21:10:18

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

请告诉小弟方法!{:5_107:}

565123 发表于 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
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 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
#define UNICODE
#include <Windows.h>
#include <tchar.h>
#include <Shlwapi.h>
#define TIMER_ID 10

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

union A
{
      WNDCLASSEX * wndClass;
      HWND hWnd;
      MSG *msg;
};

static HWND hWnd;

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdline, int nCmdShow)
{
      A a;
      a.wndClass = new WNDCLASSEX;
      a.wndClass->cbSize = sizeof(WNDCLASSEX);
      a.wndClass->cbWndExtra = 0;
      a.wndClass->cbClsExtra = 0;
      a.wndClass->hbrBackground = (HBRUSH) COLOR_BACKGROUND + 1;
      a.wndClass->hCursor = LoadCursor(nullptr, IDC_ARROW);
      a.wndClass->hIcon = LoadIcon(nullptr, IDI_APPLICATION);
      a.wndClass->hIconSm = a.wndClass->hIcon;
      a.wndClass->hInstance = hInstance;
      a.wndClass->lpfnWndProc = WndProc;
      a.wndClass->lpszClassName = L"Test";
      a.wndClass->lpszMenuName = nullptr;
      a.wndClass->style = CS_HREDRAW | CS_VREDRAW;
      RegisterClassEx(a.wndClass);
      delete a.wndClass;

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

      a.msg = new MSG;
      while (GetMessage(a.msg, nullptr, 0, 0))
      {
                TranslateMessage(a.msg);
                DispatchMessage(a.msg);
      }

      delete a.msg;
      a.msg = 0;

      return 0;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
      static int count;
      switch (uMsg)
      {
      case WM_DESTROY:
                PostQuitMessage(0);
                break;
      case WM_CREATE:
                if (StrCmp(((CREATESTRUCT*) lParam)->lpszClass, L"Test") == 0)
                        CreateWindow(L"button", L"闪烁", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 50, 50, 100, 20, hWnd, 0, GetModuleHandle(nullptr), 0);
                break;
      case WM_COMMAND:
                SetTimer(hWnd, TIMER_ID, 2000, nullptr);
                break;
      case WM_TIMER:
                if (wParam == TIMER_ID && count < 5)
                {
                        FlashWindow(hWnd, true);
                        count++;
                }
                break;
      default:
                return DefWindowProc(hWnd, uMsg, wParam, lParam);
                break;
      }

      return 0;
}
点击按钮让窗口闪烁五次

565123 发表于 2013-8-2 21:47:48

不知道你在问什么???详细一点,什么窗口???

牡丹花下死做鬼 发表于 2013-8-3 10:21:03

真的不知道你想问什么诶

a476879313 发表于 2013-8-3 18:09:00

- - 就是问有木有让任何窗口高亮显示 的API

a476879313 发表于 2013-8-5 12:06:45

565123 发表于 2013-8-3 21:48 static/image/common/back.gif
BOOL WINAPI FlashWindow(
_In_HWND hWnd,
_In_BOOL bInvert


无比感谢!

欠你的幸福 发表于 2013-8-5 17:56:38

他问的是高难度的,,
页: [1]
查看完整版本: 求助大神!如何让窗口高亮显示!.....