Blame client/Windows/wf_floatbar.c

Packit 1fb8d4
/**
Packit 1fb8d4
 * FreeRDP: A Remote Desktop Protocol Implementation
Packit 1fb8d4
 * Windows Float Bar
Packit 1fb8d4
 *
Packit 1fb8d4
 * Copyright 2013 Zhang Zhaolong <zhangzl2013@126.com>
Packit 1fb8d4
 *
Packit 1fb8d4
 * Licensed under the Apache License, Version 2.0 (the "License");
Packit 1fb8d4
 * you may not use this file except in compliance with the License.
Packit 1fb8d4
 * You may obtain a copy of the License at
Packit 1fb8d4
 *
Packit 1fb8d4
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 1fb8d4
 *
Packit 1fb8d4
 * Unless required by applicable law or agreed to in writing, software
Packit 1fb8d4
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 1fb8d4
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 1fb8d4
 * See the License for the specific language governing permissions and
Packit 1fb8d4
 * limitations under the License.
Packit 1fb8d4
 */
Packit 1fb8d4
Packit 1fb8d4
#include <winpr/crt.h>
Packit 1fb8d4
#include <winpr/windows.h>
Packit 1fb8d4
Packit 1fb8d4
#include "resource.h"
Packit 1fb8d4
Packit 1fb8d4
#include "wf_client.h"
Packit 1fb8d4
#include "wf_floatbar.h"
Packit 1fb8d4
#include "wf_gdi.h"
Packit 1fb8d4
Packit 1fb8d4
typedef struct _Button Button;
Packit 1fb8d4
Packit 1fb8d4
/* TIMERs */
Packit 1fb8d4
#define TIMER_HIDE          1
Packit 1fb8d4
#define TIMER_ANIMAT_SHOW   2
Packit 1fb8d4
#define TIMER_ANIMAT_HIDE   3
Packit 1fb8d4
Packit 1fb8d4
/* Button Type */
Packit 1fb8d4
#define BUTTON_LOCKPIN      0
Packit 1fb8d4
#define BUTTON_MINIMIZE     1
Packit 1fb8d4
#define BUTTON_RESTORE      2
Packit 1fb8d4
#define BUTTON_CLOSE        3
Packit 1fb8d4
#define BTN_MAX             4
Packit 1fb8d4
Packit 1fb8d4
/* bmp size */
Packit 1fb8d4
#define BACKGROUND_W        581
Packit 1fb8d4
#define BACKGROUND_H        29
Packit 1fb8d4
#define LOCK_X              13
Packit 1fb8d4
#define MINIMIZE_X          (BACKGROUND_W - 91)
Packit 1fb8d4
#define CLOSE_X             (BACKGROUND_W - 37)
Packit 1fb8d4
#define RESTORE_X           (BACKGROUND_W - 64)
Packit 1fb8d4
Packit 1fb8d4
#define BUTTON_Y            2
Packit 1fb8d4
#define BUTTON_WIDTH        24
Packit 1fb8d4
#define BUTTON_HEIGHT       24
Packit 1fb8d4
Packit 1fb8d4
struct _Button
Packit 1fb8d4
{
Packit 1fb8d4
	FloatBar* floatbar;
Packit 1fb8d4
	int type;
Packit 1fb8d4
	int x, y, h, w;
Packit 1fb8d4
	int active;
Packit 1fb8d4
	HBITMAP bmp;
Packit 1fb8d4
	HBITMAP bmp_act;
Packit 1fb8d4
Packit 1fb8d4
	/* Lock Specified */
Packit 1fb8d4
	HBITMAP locked_bmp;
Packit 1fb8d4
	HBITMAP locked_bmp_act;
Packit 1fb8d4
	HBITMAP unlocked_bmp;
Packit 1fb8d4
	HBITMAP unlocked_bmp_act;
Packit 1fb8d4
};
Packit 1fb8d4
Packit 1fb8d4
struct _FloatBar
Packit 1fb8d4
{
Packit 1fb8d4
	HWND parent;
Packit 1fb8d4
	HWND hwnd;
Packit 1fb8d4
	RECT rect;
Packit 1fb8d4
	LONG width;
Packit 1fb8d4
	LONG height;
Packit 1fb8d4
	wfContext* wfc;
Packit 1fb8d4
	Button* buttons[BTN_MAX];
Packit 1fb8d4
	BOOL shown;
Packit 1fb8d4
	BOOL locked;
Packit 1fb8d4
	HDC hdcmem;
Packit 1fb8d4
	HBITMAP background;
Packit 1fb8d4
};
Packit 1fb8d4
Packit 1fb8d4
static int button_hit(Button* button)
Packit 1fb8d4
{
Packit 1fb8d4
	FloatBar* floatbar = button->floatbar;
Packit 1fb8d4
Packit 1fb8d4
	switch (button->type)
Packit 1fb8d4
	{
Packit 1fb8d4
		case BUTTON_LOCKPIN:
Packit 1fb8d4
			if (!floatbar->locked)
Packit 1fb8d4
			{
Packit 1fb8d4
				button->bmp = button->locked_bmp;
Packit 1fb8d4
				button->bmp_act = button->locked_bmp_act;
Packit 1fb8d4
			}
Packit 1fb8d4
			else
Packit 1fb8d4
			{
Packit 1fb8d4
				button->bmp = button->unlocked_bmp;
Packit 1fb8d4
				button->bmp_act = button->unlocked_bmp_act;
Packit 1fb8d4
			}
Packit 1fb8d4
Packit 1fb8d4
			floatbar->locked = ~floatbar->locked;
Packit 1fb8d4
			InvalidateRect(button->floatbar->hwnd, NULL, FALSE);
Packit 1fb8d4
			UpdateWindow(button->floatbar->hwnd);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case BUTTON_MINIMIZE:
Packit 1fb8d4
			ShowWindow(floatbar->parent, SW_MINIMIZE);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case BUTTON_RESTORE:
Packit 1fb8d4
			wf_toggle_fullscreen(floatbar->wfc);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case BUTTON_CLOSE:
Packit 1fb8d4
			SendMessage(floatbar->parent, WM_DESTROY, 0 , 0);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		default:
Packit 1fb8d4
			return 0;
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static int button_paint(Button* button, HDC hdc)
Packit 1fb8d4
{
Packit 1fb8d4
	FloatBar* floatbar = button->floatbar;
Packit 1fb8d4
	SelectObject(floatbar->hdcmem, button->active ? button->bmp_act : button->bmp);
Packit 1fb8d4
	StretchBlt(hdc, button->x, button->y, button->w, button->h, floatbar->hdcmem, 0,
Packit 1fb8d4
	           0, button->w, button->h, SRCCOPY);
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static Button* floatbar_create_button(FloatBar* floatbar, int type, int resid,
Packit 1fb8d4
                                      int resid_act, int x, int y, int h, int w)
Packit 1fb8d4
{
Packit 1fb8d4
	Button* button;
Packit 1fb8d4
	button = (Button*)malloc(sizeof(Button));
Packit 1fb8d4
Packit 1fb8d4
	if (!button)
Packit 1fb8d4
		return NULL;
Packit 1fb8d4
Packit 1fb8d4
	button->floatbar = floatbar;
Packit 1fb8d4
	button->type = type;
Packit 1fb8d4
	button->x = x;
Packit 1fb8d4
	button->y = y;
Packit 1fb8d4
	button->w = w;
Packit 1fb8d4
	button->h = h;
Packit 1fb8d4
	button->active = FALSE;
Packit 1fb8d4
	button->bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
Packit 1fb8d4
	                                 MAKEINTRESOURCE(resid), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
Packit 1fb8d4
	button->bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
Packit 1fb8d4
	                                     MAKEINTRESOURCE(resid_act), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
Packit 1fb8d4
	return button;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static Button* floatbar_create_lock_button(FloatBar* floatbar,
Packit 1fb8d4
        int unlock_resid, int unlock_resid_act,
Packit 1fb8d4
        int lock_resid, int lock_resid_act,
Packit 1fb8d4
        int x, int y, int h, int w)
Packit 1fb8d4
{
Packit 1fb8d4
	Button* button;
Packit 1fb8d4
	button = floatbar_create_button(floatbar, BUTTON_LOCKPIN, unlock_resid,
Packit 1fb8d4
	                                unlock_resid_act, x, y, h, w);
Packit 1fb8d4
Packit 1fb8d4
	if (!button)
Packit 1fb8d4
		return NULL;
Packit 1fb8d4
Packit 1fb8d4
	button->unlocked_bmp = button->bmp;
Packit 1fb8d4
	button->unlocked_bmp_act = button->bmp_act;
Packit 1fb8d4
	button->locked_bmp = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
Packit 1fb8d4
	                                        MAKEINTRESOURCE(lock_resid), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
Packit 1fb8d4
	button->locked_bmp_act = (HBITMAP)LoadImage(floatbar->wfc->hInstance,
Packit 1fb8d4
	                         MAKEINTRESOURCE(lock_resid_act), IMAGE_BITMAP, w, h, LR_DEFAULTCOLOR);
Packit 1fb8d4
	return button;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static Button* floatbar_get_button(FloatBar* floatbar, int x, int y)
Packit 1fb8d4
{
Packit 1fb8d4
	int i;
Packit 1fb8d4
Packit 1fb8d4
	if (y > BUTTON_Y && y < BUTTON_Y + BUTTON_HEIGHT)
Packit 1fb8d4
		for (i = 0; i < BTN_MAX; i++)
Packit 1fb8d4
			if (x > floatbar->buttons[i]->x
Packit 1fb8d4
			    && x < floatbar->buttons[i]->x + floatbar->buttons[i]->w)
Packit 1fb8d4
				return floatbar->buttons[i];
Packit 1fb8d4
Packit 1fb8d4
	return NULL;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static int floatbar_paint(FloatBar* floatbar, HDC hdc)
Packit 1fb8d4
{
Packit 1fb8d4
	int i;
Packit 1fb8d4
	/* paint background */
Packit 1fb8d4
	SelectObject(floatbar->hdcmem, floatbar->background);
Packit 1fb8d4
	StretchBlt(hdc, 0, 0, BACKGROUND_W, BACKGROUND_H, floatbar->hdcmem, 0, 0,
Packit 1fb8d4
	           BACKGROUND_W, BACKGROUND_H, SRCCOPY);
Packit 1fb8d4
Packit 1fb8d4
	/* paint buttons */
Packit 1fb8d4
	for (i = 0; i < BTN_MAX; i++)
Packit 1fb8d4
		button_paint(floatbar->buttons[i], hdc);
Packit 1fb8d4
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static int floatbar_animation(FloatBar* floatbar, BOOL show)
Packit 1fb8d4
{
Packit 1fb8d4
	SetTimer(floatbar->hwnd, show ? TIMER_ANIMAT_SHOW : TIMER_ANIMAT_HIDE, 10,
Packit 1fb8d4
	         NULL);
Packit 1fb8d4
	floatbar->shown = show;
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
LRESULT CALLBACK floatbar_proc(HWND hWnd, UINT Msg, WPARAM wParam,
Packit 1fb8d4
                               LPARAM lParam)
Packit 1fb8d4
{
Packit 1fb8d4
	static int dragging = FALSE;
Packit 1fb8d4
	static int lbtn_dwn = FALSE;
Packit 1fb8d4
	static int btn_dwn_x = 0;
Packit 1fb8d4
	static FloatBar* floatbar;
Packit 1fb8d4
	static TRACKMOUSEEVENT tme;
Packit 1fb8d4
	PAINTSTRUCT ps;
Packit 1fb8d4
	Button* button;
Packit 1fb8d4
	HDC hdc;
Packit 1fb8d4
	int pos_x;
Packit 1fb8d4
	int pos_y;
Packit 1fb8d4
	int xScreen = GetSystemMetrics(SM_CXSCREEN);
Packit 1fb8d4
Packit 1fb8d4
	switch (Msg)
Packit 1fb8d4
	{
Packit 1fb8d4
		case WM_CREATE:
Packit 1fb8d4
			floatbar = (FloatBar*)((CREATESTRUCT*)lParam)->lpCreateParams;
Packit 1fb8d4
			floatbar->hwnd = hWnd;
Packit 1fb8d4
			floatbar->parent = GetParent(hWnd);
Packit 1fb8d4
			GetWindowRect(floatbar->hwnd, &floatbar->rect);
Packit 1fb8d4
			floatbar->width = floatbar->rect.right - floatbar->rect.left;
Packit 1fb8d4
			floatbar->height = floatbar->rect.bottom - floatbar->rect.top;
Packit 1fb8d4
			hdc = GetDC(hWnd);
Packit 1fb8d4
			floatbar->hdcmem = CreateCompatibleDC(hdc);
Packit 1fb8d4
			ReleaseDC(hWnd, hdc);
Packit 1fb8d4
			tme.cbSize = sizeof(TRACKMOUSEEVENT);
Packit 1fb8d4
			tme.dwFlags = TME_LEAVE;
Packit 1fb8d4
			tme.hwndTrack = hWnd;
Packit 1fb8d4
			tme.dwHoverTime = HOVER_DEFAULT;
Packit 1fb8d4
			SetTimer(hWnd, TIMER_HIDE, 3000, NULL);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_PAINT:
Packit 1fb8d4
			hdc = BeginPaint(hWnd, &ps);
Packit 1fb8d4
			floatbar_paint(floatbar, hdc);
Packit 1fb8d4
			EndPaint(hWnd, &ps);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_LBUTTONDOWN:
Packit 1fb8d4
			pos_x = lParam & 0xffff;
Packit 1fb8d4
			pos_y = (lParam >> 16) & 0xffff;
Packit 1fb8d4
			button = floatbar_get_button(floatbar, pos_x, pos_y);
Packit 1fb8d4
Packit 1fb8d4
			if (!button)
Packit 1fb8d4
			{
Packit 1fb8d4
				SetCapture(hWnd);
Packit 1fb8d4
				dragging = TRUE;
Packit 1fb8d4
				btn_dwn_x = lParam & 0xffff;
Packit 1fb8d4
			}
Packit 1fb8d4
			else
Packit 1fb8d4
				lbtn_dwn = TRUE;
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_LBUTTONUP:
Packit 1fb8d4
			pos_x = lParam & 0xffff;
Packit 1fb8d4
			pos_y = (lParam >> 16) & 0xffff;
Packit 1fb8d4
			ReleaseCapture();
Packit 1fb8d4
			dragging = FALSE;
Packit 1fb8d4
Packit 1fb8d4
			if (lbtn_dwn)
Packit 1fb8d4
			{
Packit 1fb8d4
				button = floatbar_get_button(floatbar, pos_x, pos_y);
Packit 1fb8d4
Packit 1fb8d4
				if (button)
Packit 1fb8d4
					button_hit(button);
Packit 1fb8d4
Packit 1fb8d4
				lbtn_dwn = FALSE;
Packit 1fb8d4
			}
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_MOUSEMOVE:
Packit 1fb8d4
			KillTimer(hWnd, TIMER_HIDE);
Packit 1fb8d4
			pos_x = lParam & 0xffff;
Packit 1fb8d4
			pos_y = (lParam >> 16) & 0xffff;
Packit 1fb8d4
Packit 1fb8d4
			if (!floatbar->shown)
Packit 1fb8d4
				floatbar_animation(floatbar, TRUE);
Packit 1fb8d4
Packit 1fb8d4
			if (dragging)
Packit 1fb8d4
			{
Packit 1fb8d4
				floatbar->rect.left = floatbar->rect.left + (lParam & 0xffff) - btn_dwn_x;
Packit 1fb8d4
Packit 1fb8d4
				if (floatbar->rect.left < 0)
Packit 1fb8d4
					floatbar->rect.left = 0;
Packit 1fb8d4
				else if (floatbar->rect.left > xScreen - floatbar->width)
Packit 1fb8d4
					floatbar->rect.left = xScreen - floatbar->width;
Packit 1fb8d4
Packit 1fb8d4
				MoveWindow(hWnd, floatbar->rect.left, floatbar->rect.top, floatbar->width,
Packit 1fb8d4
				           floatbar->height, TRUE);
Packit 1fb8d4
			}
Packit 1fb8d4
			else
Packit 1fb8d4
			{
Packit 1fb8d4
				int i;
Packit 1fb8d4
Packit 1fb8d4
				for (i = 0; i < BTN_MAX; i++)
Packit 1fb8d4
					floatbar->buttons[i]->active = FALSE;
Packit 1fb8d4
Packit 1fb8d4
				button = floatbar_get_button(floatbar, pos_x, pos_y);
Packit 1fb8d4
Packit 1fb8d4
				if (button)
Packit 1fb8d4
					button->active = TRUE;
Packit 1fb8d4
Packit 1fb8d4
				InvalidateRect(hWnd, NULL, FALSE);
Packit 1fb8d4
				UpdateWindow(hWnd);
Packit 1fb8d4
			}
Packit 1fb8d4
Packit 1fb8d4
			TrackMouseEvent(&tme);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_CAPTURECHANGED:
Packit 1fb8d4
			dragging = FALSE;
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_MOUSELEAVE:
Packit 1fb8d4
			{
Packit 1fb8d4
				int i;
Packit 1fb8d4
Packit 1fb8d4
				for (i = 0; i < BTN_MAX; i++)
Packit 1fb8d4
					floatbar->buttons[i]->active = FALSE;
Packit 1fb8d4
Packit 1fb8d4
				InvalidateRect(hWnd, NULL, FALSE);
Packit 1fb8d4
				UpdateWindow(hWnd);
Packit 1fb8d4
				SetTimer(hWnd, TIMER_HIDE, 3000, NULL);
Packit 1fb8d4
				break;
Packit 1fb8d4
			}
Packit 1fb8d4
Packit 1fb8d4
		case WM_TIMER:
Packit 1fb8d4
			switch (wParam)
Packit 1fb8d4
			{
Packit 1fb8d4
				case TIMER_HIDE:
Packit 1fb8d4
					{
Packit 1fb8d4
						KillTimer(hWnd, TIMER_HIDE);
Packit 1fb8d4
Packit 1fb8d4
						if (!floatbar->locked)
Packit 1fb8d4
							floatbar_animation(floatbar, FALSE);
Packit 1fb8d4
Packit 1fb8d4
						break;
Packit 1fb8d4
					}
Packit 1fb8d4
Packit 1fb8d4
				case TIMER_ANIMAT_SHOW:
Packit 1fb8d4
					{
Packit 1fb8d4
						static int y = 0;
Packit 1fb8d4
						MoveWindow(floatbar->hwnd, floatbar->rect.left, (y++ - floatbar->height),
Packit 1fb8d4
						           floatbar->width, floatbar->height, TRUE);
Packit 1fb8d4
Packit 1fb8d4
						if (y == floatbar->height)
Packit 1fb8d4
						{
Packit 1fb8d4
							y = 0;
Packit 1fb8d4
							KillTimer(hWnd, wParam);
Packit 1fb8d4
						}
Packit 1fb8d4
Packit 1fb8d4
						break;
Packit 1fb8d4
					}
Packit 1fb8d4
Packit 1fb8d4
				case TIMER_ANIMAT_HIDE:
Packit 1fb8d4
					{
Packit 1fb8d4
						static int y = 0;
Packit 1fb8d4
						MoveWindow(floatbar->hwnd, floatbar->rect.left, -y++, floatbar->width,
Packit 1fb8d4
						           floatbar->height, TRUE);
Packit 1fb8d4
Packit 1fb8d4
						if (y == floatbar->height)
Packit 1fb8d4
						{
Packit 1fb8d4
							y = 0;
Packit 1fb8d4
							KillTimer(hWnd, wParam);
Packit 1fb8d4
						}
Packit 1fb8d4
Packit 1fb8d4
						break;
Packit 1fb8d4
					}
Packit 1fb8d4
Packit 1fb8d4
				default:
Packit 1fb8d4
					break;
Packit 1fb8d4
			}
Packit 1fb8d4
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		case WM_DESTROY:
Packit 1fb8d4
			DeleteDC(floatbar->hdcmem);
Packit 1fb8d4
			PostQuitMessage(0);
Packit 1fb8d4
			break;
Packit 1fb8d4
Packit 1fb8d4
		default:
Packit 1fb8d4
			return DefWindowProc(hWnd, Msg, wParam, lParam);
Packit 1fb8d4
	}
Packit 1fb8d4
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
static FloatBar* floatbar_create(wfContext* wfc)
Packit 1fb8d4
{
Packit 1fb8d4
	FloatBar* floatbar;
Packit 1fb8d4
	floatbar = (FloatBar*)malloc(sizeof(FloatBar));
Packit 1fb8d4
Packit 1fb8d4
	if (!floatbar)
Packit 1fb8d4
		return NULL;
Packit 1fb8d4
Packit 1fb8d4
	floatbar->locked = FALSE;
Packit 1fb8d4
	floatbar->shown = TRUE;
Packit 1fb8d4
	floatbar->hwnd = NULL;
Packit 1fb8d4
	floatbar->parent = wfc->hwnd;
Packit 1fb8d4
	floatbar->wfc = wfc;
Packit 1fb8d4
	floatbar->hdcmem = NULL;
Packit 1fb8d4
	floatbar->background = (HBITMAP)LoadImage(wfc->hInstance,
Packit 1fb8d4
	                       MAKEINTRESOURCE(IDB_BACKGROUND), IMAGE_BITMAP, BACKGROUND_W, BACKGROUND_H,
Packit 1fb8d4
	                       LR_DEFAULTCOLOR);
Packit 1fb8d4
	floatbar->buttons[0] = floatbar_create_button(floatbar, BUTTON_MINIMIZE,
Packit 1fb8d4
	                       IDB_MINIMIZE, IDB_MINIMIZE_ACT, MINIMIZE_X, BUTTON_Y, BUTTON_HEIGHT,
Packit 1fb8d4
	                       BUTTON_WIDTH);
Packit 1fb8d4
	floatbar->buttons[1] = floatbar_create_button(floatbar, BUTTON_RESTORE,
Packit 1fb8d4
	                       IDB_RESTORE, IDB_RESTORE_ACT, RESTORE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
Packit 1fb8d4
	floatbar->buttons[2] = floatbar_create_button(floatbar, BUTTON_CLOSE, IDB_CLOSE,
Packit 1fb8d4
	                       IDB_CLOSE_ACT, CLOSE_X, BUTTON_Y, BUTTON_HEIGHT, BUTTON_WIDTH);
Packit 1fb8d4
	floatbar->buttons[3] = floatbar_create_lock_button(floatbar, IDB_UNLOCK,
Packit 1fb8d4
	                       IDB_UNLOCK_ACT, IDB_LOCK, IDB_LOCK_ACT, LOCK_X, BUTTON_Y, BUTTON_HEIGHT,
Packit 1fb8d4
	                       BUTTON_WIDTH);
Packit 1fb8d4
	return floatbar;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
int floatbar_hide(FloatBar* floatbar)
Packit 1fb8d4
{
Packit 1fb8d4
	KillTimer(floatbar->hwnd, TIMER_HIDE);
Packit 1fb8d4
	MoveWindow(floatbar->hwnd, floatbar->rect.left, -floatbar->height,
Packit 1fb8d4
	           floatbar->width, floatbar->height, TRUE);
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
int floatbar_show(FloatBar* floatbar)
Packit 1fb8d4
{
Packit 1fb8d4
	SetTimer(floatbar->hwnd, TIMER_HIDE, 3000, NULL);
Packit 1fb8d4
	MoveWindow(floatbar->hwnd, floatbar->rect.left, floatbar->rect.top,
Packit 1fb8d4
	           floatbar->width, floatbar->height, TRUE);
Packit 1fb8d4
	return 0;
Packit 1fb8d4
}
Packit 1fb8d4
Packit 1fb8d4
void floatbar_window_create(wfContext* wfc)
Packit 1fb8d4
{
Packit 1fb8d4
	WNDCLASSEX wnd_cls;
Packit 1fb8d4
	HWND barWnd;
Packit 1fb8d4
	int x = (GetSystemMetrics(SM_CXSCREEN) - BACKGROUND_W) / 2;
Packit 1fb8d4
	wnd_cls.cbSize        = sizeof(WNDCLASSEX);
Packit 1fb8d4
	wnd_cls.style         = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
Packit 1fb8d4
	wnd_cls.lpfnWndProc   = floatbar_proc;
Packit 1fb8d4
	wnd_cls.cbClsExtra    = 0;
Packit 1fb8d4
	wnd_cls.cbWndExtra    = 0;
Packit 1fb8d4
	wnd_cls.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
Packit 1fb8d4
	wnd_cls.hCursor       = LoadCursor(wfc->hInstance, IDC_ARROW);
Packit 1fb8d4
	wnd_cls.hbrBackground = NULL;
Packit 1fb8d4
	wnd_cls.lpszMenuName  = NULL;
Packit 1fb8d4
	wnd_cls.lpszClassName = L"floatbar";
Packit 1fb8d4
	wnd_cls.hInstance     = wfc->hInstance;
Packit 1fb8d4
	wnd_cls.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
Packit 1fb8d4
	RegisterClassEx(&wnd_cls);
Packit 1fb8d4
	wfc->floatbar = floatbar_create(wfc);
Packit 1fb8d4
	barWnd = CreateWindowEx(WS_EX_TOPMOST, L"floatbar", L"floatbar", WS_CHILD, x, 0,
Packit 1fb8d4
	                        BACKGROUND_W, BACKGROUND_H, wfc->hwnd, NULL, wfc->hInstance, wfc->floatbar);
Packit 1fb8d4
Packit 1fb8d4
	if (barWnd == NULL)
Packit 1fb8d4
		return;
Packit 1fb8d4
Packit 1fb8d4
	ShowWindow(barWnd, SW_SHOWNORMAL);
Packit 1fb8d4
}