Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

non client area buttons (maximize, minimize, close) do not glow

82 views
Skip to first unread message

Gernot Frisch

unread,
Feb 7, 2012, 4:37:28 PM2/7/12
to
Hi,

I have a very simple Win32 API program, but the top-right 3 buttons don't
show any animation when I hover the mouse over them.
They work, though.
What can this be? My WinProc does nothing fancy.

Here's how I create the window.

hwnd = ::CreateWindowExA(
WS_EX_COMPOSITED
|WS_EX_LAYERED // no flicker in aero
// |WS_EX_TRANSPARENT awfully slow!
, "GLBasicDialog", caption,
WS_THICKFRAME|WS_VISIBLE | WS_SYSMENU | WS_CAPTION | WS_OVERLAPPED
|WS_MAXIMIZEBOX|WS_MINIMIZEBOX
| WS_CLIPSIBLINGS
, x,y, w, h, NULL, 0, (HINSTANCE)::GetModuleHandleA(NULL), 0);

UpdateWindow(hwnd);
ShowWindow(hwnd, SW_SHOWNORMAL);


Alf P. Steinbach

unread,
Feb 8, 2012, 8:31:12 AM2/8/12
to
I can't see anything particularly wrong. Using the ANSI wrapper
functions is unusual but should work. If you still experience the
problem after removing WS_EX_COMPOSITED|WS_EX_LAYERED then you can be
more sure that the problem is elsewhere.

I recommend:

* Create a complete, shortest possible program that exhibits the problem.

* Post the complete source code of that here.

* Also post Windows version etc.

Cheers & hth.,

- Alf


Gernot Frisch

unread,
Feb 8, 2012, 9:00:40 AM2/8/12
to
This should be reproducable:

extern "C" LRESULT CALLBACK gui_wproc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}
int main()
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW|CS_VREDRAW; // sent WM_PAINT when size
gets changed
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = LoadIconA(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hIconSm = LoadIconA(NULL, IDI_APPLICATION);
wc.lpfnWndProc = (WNDPROC) gui_wproc;
wc.hInstance = (HINSTANCE)::GetModuleHandleA(NULL);
wc.lpszClassName = "GLBasicDialog";
wc.lpszMenuName = "GLBasicDialog";

RegisterClassExA(&wc);
HWND hwnd = ::CreateWindowExA(
WS_EX_COMPOSITED|WS_EX_LAYERED // no flicker in aero
, "GLBasicDialog", "Test",
WS_THICKFRAME|WS_VISIBLE | WS_SYSMENU | WS_CAPTION | WS_OVERLAPPED
|WS_MAXIMIZEBOX|WS_MINIMIZEBOX
| WS_CLIPSIBLINGS
, 0,0,400,200, NULL, 0, (HINSTANCE)::GetModuleHandleA(NULL), 0);

CreateWindowExA(0, "BUTTON", "Test", BS_PUSHLIKE|BS_AUTOCHECKBOX
|WS_CHILD|WS_VISIBLE|WS_TABSTOP,
0,0,64,32,hwnd, NULL,
(HINSTANCE)::GetModuleHandleA(NULL), 0);

UpdateWindow(hwnd);
ShowWindow(hwnd, SW_SHOWNORMAL);

MSG msg;
while(GetMessage(&msg, hwnd, 0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

Alf P. Steinbach

unread,
Feb 8, 2012, 11:49:12 AM2/8/12
to
Hm. I added include of <windows.h>, and in the window proc I added

if( uMsg == WM_CLOSE ) { PostQuitMessage( 0 ); }

(without it you should get an invisible hung process, undesirable),
plus, necessarily, changed your message loop head to

while(GetMessage(&msg, 0, 0,0))

(note second argument is 0, for all messages, instead of hwnd).

Then it works fine in Windows 7, at least when compiled by Visual C++ 10.0.

However, I did not test with menu resource.

If you're using a menu resource, please post also that.

---

Other stuff to know that might be helpful to you:

* You don't need to declare the window proc "extern "C"". In Windows
this affects only the name mangling.

* You can and should remove all the casts, e.g. (WNDPROC), except the
cast to HBRUSH.

* For the color value, add 1.

Gernot Frisch

unread,
Feb 9, 2012, 3:23:26 AM2/9/12
to

Very strange. I added a manifest for XP+ styled theme, but it doesn't work.
I'm not using Aero - just the "Windows 7 basic" theme.

#include <Windows.h>
#include <stdio.h>

extern "C" LRESULT CALLBACK gui_wproc(HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
if( uMsg == WM_CLOSE ) { PostQuitMessage( 0 ); }
return DefWindowProcA(hWnd, uMsg, wParam, lParam);
}


// ------------------------------------------------------------------------------------------
// *** MAIN ***
// ------------------------------------------------------------------------------------------
int main()
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW|CS_VREDRAW; // sent WM_PAINT when size
gets changed
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = LoadIconA(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.hIconSm = LoadIconA(NULL, IDI_APPLICATION);
wc.lpfnWndProc = (WNDPROC) gui_wproc;
wc.hInstance = (HINSTANCE)::GetModuleHandleA(NULL);
wc.lpszClassName = "GLBasicDialog";
wc.lpszMenuName = "GLBasicDialog";

RegisterClassExA(&wc);
HWND hwnd = ::CreateWindowExA(
WS_EX_COMPOSITED|WS_EX_LAYERED // no flicker in aero
// |WS_EX_TRANSPARENT awfully slow!
, "GLBasicDialog", "Test",
WS_THICKFRAME|WS_VISIBLE | WS_SYSMENU | WS_CAPTION | WS_OVERLAPPED
|WS_MAXIMIZEBOX|WS_MINIMIZEBOX
| WS_CLIPSIBLINGS
, 0,0,400,200, NULL, 0, (HINSTANCE)::GetModuleHandleA(NULL), 0);

CreateWindowExA(0, "BUTTON", "Test", BS_PUSHLIKE|BS_AUTOCHECKBOX
|WS_CHILD|WS_VISIBLE|WS_TABSTOP, 0,0,64,32,hwnd, NULL,
(HINSTANCE)::GetModuleHandleA(NULL), 0);

UpdateWindow(hwnd);
ShowWindow(hwnd, SW_SHOWNORMAL);

MSG msg;
while(GetMessage(&msg, NULL, 0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

0 new messages