Ejemplo n.º 1
0
void endPlugin(HINSTANCE hPluginInstance)
{
	// Stop the monitor...
	unsigned long exitcode;
	GetExitCodeThread(hThread_Time, &exitcode);
	TerminateThread(hThread_Time, exitcode);

	// Write the current plugin settings to the config file...
	WriteRCSettings();
	// Delete the main plugin menu if it exists (PLEASE NOTE that this takes care of submenus as well!)
	if (myMenu){ DelMenu(myMenu); myMenu = NULL;}

	// Make the window unsticky
	RemoveSticky(hwndPlugin);
	// Unregister Blackbox messages...
	SendMessage(hwndBlackbox, BB_UNREGISTERMESSAGE, (WPARAM)hwndPlugin, (LPARAM)msgs);

	if(inSlit && hSlit)
		SendMessage(hSlit, SLIT_REMOVE, NULL, (LPARAM)hwndPlugin);

	ClearToolTips();
  	DestroyWindow(hToolTips);
	// Destroy our window...
	DestroyWindow(hwndPlugin);
	// Unregister window class...
	UnregisterClass(szAppName, hPluginInstance);

	FreeLibrary(controlPlugin);
}
Ejemplo n.º 2
0
//===========================================================================
// Function: EditBox
// Purpose: Display a single line editcontrol
// In:
// Out:
//===========================================================================
BOOL CALLBACK dlgproc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static char *buffer;
	switch ( msg )
	{
	case WM_INITDIALOG:
		SetWindowText (hDlg, ((char**)lParam)[0]);
		SetDlgItemText(hDlg, 401, ((char**)lParam)[1]);
		SetDlgItemText(hDlg, 402, ((char**)lParam)[2]);
		buffer = ((char**)lParam)[3];
		MakeSticky(hDlg);
		{
			POINT p;
			GetCursorPos(&p);
			RECT m;
			GetMonitorRect(&p, &m, GETMON_WORKAREA|GETMON_FROM_POINT);
			RECT r;
			GetWindowRect(hDlg, &r);
#if 0
			// at cursor
			r.right -= r.left;
			r.bottom -= r.top;
			p.x = iminmax(p.x - r.right / 2,  m.left, m.right - r.right);
			p.y = iminmax(p.y - 10,  m.top, m.bottom - r.bottom);
#else
			// center screen
			p.x = (m.left + m.right - r.right + r.left) / 2;
			p.y = (m.top + m.bottom - r.bottom + r.top) / 2;
#endif
			SetWindowPos(hDlg, NULL, p.x, p.y, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
		}
		return 1;

	case WM_MOUSEMOVE:
	case WM_NCMOUSEMOVE:
		SetForegroundWindow(hDlg);
		break;

	case WM_COMMAND:
		switch ( LOWORD( wParam ))
		{
		case IDOK:
			GetDlgItemText (hDlg, 402, buffer, 256);
		case IDCANCEL:
			RemoveSticky(hDlg);
			EndDialog(hDlg, LOWORD(wParam));
			return 1;
		}

	default:
		break;
	}
	return 0;
}
Ejemplo n.º 3
0
ST LRESULT CALLBACK Desk_WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static UINT msgs [] = { BB_DRAGTODESKTOP, 0 };
    static bool button_down;
    int n = 0;
    int nDelta;
    switch (uMsg)
    {
        //====================
        case WM_CREATE:
            hDesktopWnd = hwnd;
            MakeSticky(hwnd);
            MessageManager_AddMessages(hwnd, msgs);
            Desk_SetPosition();
            init_DeskDropTarget(hwnd);
            break;

        //====================
        case WM_DESTROY:
            exit_DeskDropTarget(hwnd);
            MessageManager_RemoveMessages(hwnd, msgs);
            RemoveSticky(hwnd);
            break;

        case WM_USER:
            Desk_Clear();
            Root.bmp = (HBITMAP)lParam;
        case WM_NCPAINT:
            Desk_SetPosition();
            break;

        //====================
        case WM_CLOSE:
            break;

        //====================
        case WM_MOUSEACTIVATE:
            return MA_NOACTIVATE;

        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
            button_down = true;
            break;

        //====================
        case WM_LBUTTONUP: n = 0; goto post_click;
        case WM_RBUTTONUP: n = 1; goto post_click;
        case WM_MBUTTONUP: n = 2; goto post_click;
        case WM_XBUTTONUP:
            switch (HIWORD(wParam)) {
            case XBUTTON1: n = 3; goto post_click;
            case XBUTTON2: n = 4; goto post_click;
            case XBUTTON3: n = 5; goto post_click;
            } break;

        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK: n = 6;
            button_down = true;
            goto post_click;

        case WM_MOUSEWHEEL:
            nDelta = (short)HIWORD(wParam);
            if (nDelta > 0) n =  7; // Wheel UP
            if (nDelta < 0) n =  8; // Wheel Down
            button_down = true;
            goto post_click;

        post_click:
            if (button_down) PostMessage(BBhwnd, BB_DESKCLICK, 0, n);
            button_down = false;
//            PostMessage(BBhwnd, BB_DESKCLICK, 0, n);
            break;

        //====================
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc_scrn = BeginPaint(hwnd, &ps);
            if (Root.bmp)
            {
                HDC hdc_bmp = CreateCompatibleDC(hdc_scrn);
                HGDIOBJ other = SelectObject(hdc_bmp, Root.bmp);
                BitBltRect(hdc_scrn, hdc_bmp, &ps.rcPaint);
                SelectObject(hdc_bmp, other);
                DeleteDC(hdc_bmp);
            }
            else
            {
                PaintDesktop(hdc_scrn);
            }
            EndPaint(hwnd, &ps);
            break;
        }

        //====================
        case WM_ERASEBKGND:
            return TRUE;

        //====================
        case BB_DRAGTODESKTOP:
            return get_drop_command((const char *)lParam, wParam);

        //====================
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);

    }
    return 0;
}
Ejemplo n.º 4
0
LRESULT CALLBACK BBP_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static UINT msgs[] = { BB_RECONFIGURE, BB_BROADCAST, BB_DESKCLICK, 0};

    LRESULT Result = 0;
    plugin_info *PI  = (plugin_info *)GetWindowLongPtr(hwnd, 0);

    //dbg_printf("message %x", message);

    if (NULL == PI)
    {
        if (WM_NCCREATE == message)
        {
            // bind the window to the structure
            PI = (plugin_info *)((CREATESTRUCT*)lParam)->lpCreateParams;
            PI->hwnd = hwnd;
            SetWindowLongPtr(hwnd, 0, (LONG_PTR)PI);
        }
        return DefWindowProc(hwnd, message, wParam, lParam);
    }

    switch (message)
    {
        case WM_CREATE:
            SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            MakeSticky(hwnd);
            goto pass_nothing;

        case WM_DESTROY:
            SendMessage(GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            RemoveSticky(hwnd);
            goto pass_nothing;

        // ==========
        case BB_BROADCAST:
        {
            const char *temp = (LPCSTR)lParam;
            int f, len;

            if (0 == stricmp(temp, "@BBShowPlugins")) {
                PI->toggled_hidden = false;
                BBP_set_window_modes(PI);
                goto pass_result;
            }
            if (0 == stricmp(temp, "@BBHidePlugins")) {
                if (PI->pluginToggle) {
                    PI->toggled_hidden = true;
                    BBP_set_window_modes(PI);
                }
                goto pass_result;
            }

            if ('@' != *temp++)
                goto pass_nothing;

            len = PI->broam_key_len;
            if (len && 0 == memicmp(temp, PI->broam_key, len) && '.' == temp[len]) {
                f = 0;
                temp += len + 1;
                goto do_broam;
            }

            if (PI->next)
                goto pass_nothing;

            len = PI->broam_key_len_common;
            if (len && 0 == memicmp(temp, PI->broam_key, len)) {
                f = BBP_BROAM_COMMON;
                temp += len;
                goto do_broam;
            }

            goto pass_nothing;

        do_broam:
            f |= BBP_handle_broam(PI, temp);
            PI->process_broam(_THIS_ temp, f);
            goto pass_result;
        }

        // ==========

        case BB_DESKCLICK:
            if (lParam == 0
             && PI->clickRaise
             && false == PI->alwaysOnTop
             && false == PI->inSlit)
                SetWindowPos(hwnd, HWND_TOP,
                    0,0,0,0, SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
            goto pass_nothing;

        // ==========

        case WM_WINDOWPOSCHANGING:
            if (PI->is_moving) {
                if (false == PI->inSlit
                 && 0 == (0x8000 & GetAsyncKeyState(VK_SHIFT)))
				 SnapWindowToEdge((WINDOWPOS*)lParam, PI->snapWindow, true);
                if (PI->is_sizing) {
                    WINDOWPOS* wp = (WINDOWPOS*)lParam;
                    if (wp->cx < 12) wp->cx = 12;
                    if (wp->cy < 12) wp->cy = 12;
                }
            }
            goto pass_nothing;

        case WM_WINDOWPOSCHANGED:
            if (PI->is_sizing) {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                PI->width = wp->cx;
                PI->height = wp->cy;
                InvalidateRect(hwnd, NULL, FALSE);
            }
			SnapWindowToEdge((WINDOWPOS*)lParam, PI->snapWindow, true);
            goto pass_nothing;

        case WM_ENTERSIZEMOVE:
            PI->is_moving = true;
            goto pass_nothing;

        case WM_EXITSIZEMOVE:
            BBP_exit_moving(PI);
            BBP_set_autoHide(PI, PI->autoHide);
            if (PI->inSlit)
                SendMessage(PI->hSlit, SLIT_UPDATE, 0, (LPARAM)PI->hwnd);
            goto pass_nothing;

        // ==========
        case WM_LBUTTONDOWN:
            SetFocus(hwnd);
            UpdateWindow(hwnd);
            if (false == PI->inSlit && (MK_CONTROL & wParam)) {
                // start moving, when control-key is held down
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
                goto pass_result;
            }
            goto pass_nothing;

        case WM_MOUSEMOVE:
            if (false == PI->mouse_over)
            {
                PI->mouse_over = true;
                set_autohide_timer(PI, true);
            }

            if (PI->auto_hidden)
            {
                PI->auto_shown = true;
                BBP_set_window_modes(PI);
                goto pass_result;
            }

            goto pass_nothing;

        case WM_TIMER:
            if (AUTOHIDE_TIMER != wParam)
                goto pass_nothing;

            if (check_mouse(hwnd))
                goto pass_result;
#if 0
            {
                POINT pt;
                GetCursorPos(&pt);
                if (PI->hMon != GetMonitorRect(&pt, NULL, GETMON_FROM_POINT))
                    goto pass_result;
            }
#endif
            if (PI->mouse_over) {
                POINT pt;
                GetCursorPos(&pt);
                ScreenToClient(hwnd, &pt);
                PostMessage(hwnd, WM_MOUSELEAVE, 0, MAKELPARAM(pt.x, pt.y));
                PI->mouse_over = false;
            }

            if (PI->auto_shown) {
                if (PI->suspend_autohide && BBVERSION_LEAN)
                    goto pass_result;
                PI->auto_shown = false;
                BBP_set_window_modes(PI);
            }

            set_autohide_timer(PI, false);
            goto pass_result;


        case BB_AUTOHIDE:
            if (PI->inSlit)
                PostMessage(PI->hSlit, message, wParam, lParam);

            if (wParam)
                PI->suspend_autohide |= lParam;
            else
                PI->suspend_autohide &= ~lParam;

            if (PI->suspend_autohide && PI->auto_hidden) {
                PI->auto_shown = true;
                BBP_set_window_modes(PI);
            }

            set_autohide_timer(PI, true);
            goto pass_result;

        case WM_CLOSE:
            goto pass_result;

        case WM_ERASEBKGND:
            Result = TRUE;
            goto pass_result;

        default:
        pass_nothing:
            return PI->wnd_proc(_THIS_ hwnd, message, wParam, lParam, NULL);
    }
pass_result:
    return PI->wnd_proc(_THIS_ hwnd, message, wParam, lParam, &Result);
}
Ejemplo n.º 5
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    static int msgs[] = { BB_RECONFIGURE, BB_BROADCAST, 0};

    switch (message)
    {
        case WM_CREATE:
            /* Register to reveive these message */
            SendMessage(BBhwnd, BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            /* Make the window appear on all workspaces */
            MakeSticky(hwnd);
            break;

        case WM_DESTROY:
            /* as above, in reverse */
            RemoveSticky(hwnd);
            SendMessage(BBhwnd, BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends a "BB_RECONFIGURE" message on style changes etc. */

        case BB_RECONFIGURE:
            ReadRCSettings();
            GetStyleSettings();
            set_window_modes();
            break;

        /* ---------------------------------------------------------- */
        /* Painting directly on screen. Good enough for static plugins. */
#if 1
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* Setup the rectangle */
            r.left = r.top = 0;
            r.right = my.width;
            r.bottom =  my.height;

            /* and paint everything on it*/
            paint_window(hdc, &r);

            /* Done */
            EndPaint(hwnd, &ps);
            break;
        }

        /* ---------------------------------------------------------- */
        /* Painting with a cached double-buffer. If your plugin updates
           frequently, this avoids flicker */
#else
        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc, hdc_buffer;
            HGDIOBJ otherbmp;
            RECT r;

            /* get screen DC */
            hdc = BeginPaint(hwnd, &ps);

            /* create a DC for the buffer */
            hdc_buffer = CreateCompatibleDC(hdc);

            if (NULL == my.bufbmp) /* No bitmap yet? */
            {
                /* Make a bitmap ... */
                my.bufbmp = CreateCompatibleBitmap(hdc, my.width, my.height);

                /* ... and select it into the DC, saving the previous default. */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);

                /* Setup the rectangle */
                r.left = r.top = 0;
                r.right = my.width;
                r.bottom =  my.height;

                /* and paint everything on it*/
                paint_window(hdc_buffer, &r);
            }
            else
            {
                /* Otherwise it has been painted already,
                   so just select it into the DC */
                otherbmp = SelectObject(hdc_buffer, my.bufbmp);
            }

            /* Copy the buffer on the screen, within the invalid rectangle: */
            BitBltRect(hdc, hdc_buffer, &ps.rcPaint);

            /* Put back the previous default bitmap */
            SelectObject(hdc_buffer, otherbmp);
            /* clean up */
            DeleteDC(hdc_buffer);

            /* Done. */
            EndPaint(hwnd, &ps);
            break;
        }
#endif
        /* ---------------------------------------------------------- */
        /* Manually moving/sizing has been started */

        case WM_ENTERSIZEMOVE:
            my.is_moving = true;
            break;

        case WM_EXITSIZEMOVE:
            if (my.is_moving)
            {
                if (my.is_inslit)
                {
                    /* moving in the slit is not really supported but who
                       knows ... */
                    SendMessage(g_hSlit, SLIT_UPDATE, 0, (LPARAM)hwnd);
                }
                else
                {
                    /* if not in slit, record new position */
                    WriteInt(rcpath, RC_KEY("xpos"), my.xpos);
                    WriteInt(rcpath, RC_KEY("ypos"), my.ypos);
                }

                if (my.is_sizing)
                {
                    /* record new size */
                    WriteInt(rcpath, RC_KEY("width"), my.width);
                    WriteInt(rcpath, RC_KEY("height"), my.height);
                }
            }
            my.is_moving = my.is_sizing = false;
            set_window_modes();
            break;

        /* --------------------------------------------------- */
        /* snap to edges on moving */

        case WM_WINDOWPOSCHANGING:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.snapWindow && false == my.is_sizing)
                    SnapWindowToEdge(wp, 10, SNAP_FULLSCREEN);

                /* set a minimum size */
                if (wp->cx < 40)
                    wp->cx = 40;

                if (wp->cy < 20)
                    wp->cy = 20;
            }
            break;

        /* --------------------------------------------------- */
        /* record new position or size */

        case WM_WINDOWPOSCHANGED:
            if (my.is_moving)
            {
                WINDOWPOS* wp = (WINDOWPOS*)lParam;
                if (my.is_sizing)
                {
                    /* record sizes */
                    my.width = wp->cx;
                    my.height = wp->cy;

                    /* redraw window */
                    invalidate_window();
                }

                if (false == my.is_inslit)
                {
                    /* record position, if not in slit */
                    my.xpos = wp->x;
                    my.ypos = wp->y;
                }
            }
            break;

        /* ---------------------------------------------------------- */
        /* start moving or sizing accordingly to keys held down */

        case WM_LBUTTONDOWN:
            UpdateWindow(hwnd);
            if (GetAsyncKeyState(VK_MENU) & 0x8000)
            {
                /* start sizing, when alt-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf008, 0);
                my.is_sizing = true;
            }
            else
            if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
            {
                /* start moving, when control-key is held down */
                PostMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
            }
            break;

        /* ---------------------------------------------------------- */
        /* normal mouse clicks */

        case WM_LBUTTONUP:
            /* code goes here ... */
            break;

        case WM_RBUTTONUP:
            /* Show the user menu on right-click (might test for control-key
               held down if wanted */
            /* if (wParam & MK_CONTROL) */
            ShowMyMenu(true);
            break;

        case WM_LBUTTONDBLCLK:
            /* Do something here ... */
            about_box();
            break;

        /* ---------------------------------------------------------- */
        /* Blackbox sends Broams to all windows... */

        case BB_BROADCAST:
        {
            const char *msg = (LPCSTR)lParam;
            struct msg_test msg_test;

            /* check general broams */
            if (!stricmp(msg, "@BBShowPlugins"))
            {
                if (my.is_hidden)
                {
                    my.is_hidden = false;
                    ShowWindow(hwnd, SW_SHOWNA);
                }
                break;
            }

            if (!stricmp(msg, "@BBHidePlugins"))
            {
                if (my.pluginToggle && false == my.is_inslit)
                {
                    my.is_hidden = true;
                    ShowWindow(hwnd, SW_HIDE);
                }
                break;
            }

            /* if the broam is not for us, return now */
            if (0 != memicmp(msg, BROAM_PREFIX, sizeof BROAM_PREFIX - 1))
                break;

            msg_test.msg = msg + sizeof BROAM_PREFIX - 1;

            if (scan_broam(&msg_test, "useSlit"))
            {
                eval_broam(&msg_test, M_BOL, &my.useSlit);
                break;
            }

            if (scan_broam(&msg_test, "alwaysOnTop"))
            {
                eval_broam(&msg_test, M_BOL, &my.alwaysOnTop);
                break;
            }

            if (scan_broam(&msg_test, "drawBorder"))
            {
                eval_broam(&msg_test, M_BOL, &my.drawBorder);
                break;
            }

            if (scan_broam(&msg_test, "snapWindow"))
            {
                eval_broam(&msg_test, M_BOL, &my.snapWindow);
                break;
            }

            if (scan_broam(&msg_test, "pluginToggle"))
            {
                eval_broam(&msg_test, M_BOL, &my.pluginToggle);
                break;
            }

            if (scan_broam(&msg_test, "alphaEnabled"))
            {
                eval_broam(&msg_test, M_BOL, &my.alphaEnabled);
                break;
            }

            if (scan_broam(&msg_test, "alphaValue"))
            {
                eval_broam(&msg_test, M_INT, &my.alphaValue);
                break;
            }

            if (scan_broam(&msg_test, "windowText"))
            {
                eval_broam(&msg_test, M_STR, &my.windowText);
                break;
            }

            if (scan_broam(&msg_test, "editRC"))
            {
                edit_rc(rcpath);
                break;
            }

            if (scan_broam(&msg_test, "About"))
            {
                about_box();
                break;
            }

            break;
        }

        /* ---------------------------------------------------------- */
        /* prevent the user from closing the plugin with alt-F4 */

        case WM_CLOSE:
            break;

        /* ---------------------------------------------------------- */
        /* let windows handle any other message */
        default:
            return DefWindowProc(hwnd,message,wParam,lParam);
    }
    return 0;
}
Ejemplo n.º 6
0
//===========================================================================
LRESULT CALLBACK Toolbar_WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static UINT msgs[] =
	{
		BB_RECONFIGURE,
		BB_TASKSUPDATE,
		BB_SETTOOLBARLABEL,
		BB_BROADCAST,
		BB_DESKTOPINFO,
		BB_REDRAWGUI,
		0
		};

	switch (message)
	{
		//====================
	case WM_CREATE:
		DisableInputMethod(hwnd);
		TBInfo.hwnd = Toolbar_hwnd = hwnd;
		MessageManager_AddMessages (hwnd, msgs);
		MakeSticky(hwnd);
		Toolbar_UpdatePosition();
		break;

		//====================
	case WM_DESTROY:
		RemoveSticky(hwnd);
		MessageManager_RemoveMessages (hwnd, msgs);
		SetDesktopMargin(Toolbar_hwnd, 0, 0);
		if (Toolbar_hFont) DeleteObject(Toolbar_hFont), Toolbar_hFont = NULL;
		TBInfo.hwnd = Toolbar_hwnd = NULL;
		break;

		//====================
	case BB_RECONFIGURE:
	tbreconfig:
		Toolbar_UpdatePosition();
		Toolbar_ShowMenu(false);
		InvalidateRect(hwnd, NULL, FALSE);
		break;

		//====================
	case BB_REDRAWGUI:
		if (wParam & BBRG_TOOLBAR)
		{
			Toolbar_force_button_pressed = 0 != (wParam & BBRG_PRESSED);
			Toolbar_UpdatePosition();
			InvalidateRect(hwnd, NULL, FALSE);
		}
		break;

		//====================
	case BB_TASKSUPDATE:
	showlabel:
		Toolbar_setlabel();
		InvalidateRect(hwnd, NULL, FALSE);
		break;

	case BB_DESKTOPINFO:
		Toolbar_setlabel();
		InvalidateRect(hwnd, NULL, FALSE);
		break;

		//====================
	case WM_ACTIVATEAPP:
		if (wParam) SetOnTop(hwnd);
		break;

		//====================

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc = BeginPaint(hwnd, &ps);
			PaintToolbar(hdc, &ps.rcPaint);
			EndPaint(hwnd, &ps);
			break;
		}

		//====================

	case BB_SETTOOLBARLABEL:
		SetTimer(hwnd, TOOLBAR_SETLABEL_TIMER, 2000, (TIMERPROC)NULL);
		Toolbar_ShowingExternalLabel = true;
		strcpy_max(Toolbar_CurrentWindow, (LPCTSTR)lParam, sizeof(Toolbar_CurrentWindow)/sizeof(TCHAR));
		InvalidateRect(hwnd, NULL, FALSE);
		break;

		//====================

	case WM_TIMER:
		if (wParam == TOOLBAR_AUTOHIDE_TIMER)
		{
			if (TBInfo.autoHide)
			{
				if (check_mouse(hwnd) || (TBInfo.bbsb_hwnd && check_mouse(TBInfo.bbsb_hwnd)))
					break;

				Toolbar_AutoHide(true);
			}
			KillTimer(hwnd, wParam);
			break;
		}

		if (wParam == TOOLBAR_UPDATE_TIMER)
		{
			Toolbar_setclock();
			InvalidateRect(hwnd, NULL, FALSE);
			break;
		}

		KillTimer(hwnd, wParam);

		if (wParam == TOOLBAR_SETLABEL_TIMER)
		{
			Toolbar_ShowingExternalLabel = false;
			goto showlabel;
		}

		break;

		//====================
		/*
        case WM_DROPFILES:
            drop_style((HDROP)wParam);
            break;
		 */
		//====================

	case WM_LBUTTONDOWN:
		if (wParam & MK_CONTROL)
		{
			// Allow window to move if control key is being held down,
			UpdateWindow(hwnd);
			SendMessage(hwnd, WM_SYSCOMMAND, 0xf012, 0);
			break;
		}
		goto left_mouse;

	case WM_LBUTTONDBLCLK:
		if (wParam & MK_CONTROL)
		{
			// double click moves the window back to the default position
			Toolbar_set_pos();
			break;
		}
		goto left_mouse;

	case WM_MOUSEMOVE:
		if (TBInfo.autohidden)
		{
			// bring back from autohide
			SetTimer(hwnd, TOOLBAR_AUTOHIDE_TIMER, 250, NULL);
			Toolbar_AutoHide(false);
			break;
		}
		goto left_mouse;

	case WM_LBUTTONUP:
	left_mouse:
		{
			POINT MouseEventPoint;
			MouseEventPoint.x = (short)LOWORD(lParam);
			MouseEventPoint.y = (short)HIWORD(lParam);
			if (HandleCapture(hwnd, message, MouseEventPoint))
				break;

			for (int i=0; i<5; i++)
				if (CheckButton(
					hwnd,
					message,
					MouseEventPoint,
					&Toolbar_Button[i].r,
					&Toolbar_Button[i].pressed,
					Toolbar_button_event,
					i
					)) goto _break;

			if (message == WM_LBUTTONDOWN)
				SetActiveWindow(hwnd);
		}
	_break:
		break;

		//====================
		// show menus

	case WM_RBUTTONUP:
		{
			int x = (short)LOWORD(lParam);
			if (x < tbClockW)
				PostMessage(BBhwnd, BB_MENU, BB_MENU_TASKS, 0);
			else
				if (x >= TBInfo.width - tbClockW)
					PostMessage(BBhwnd, BB_MENU, BB_MENU_ROOT, 0);
				else
					Toolbar_ShowMenu(true);
			break;
		}

		//====================

	case WM_MBUTTONUP:
		// Is shift key held down?
		if (wParam & MK_SHIFT)
			PostMessage(BBhwnd, BB_TOGGLEPLUGINS, 0, 0);
		else
			PostMessage(BBhwnd, BB_TOGGLETRAY, 0, 0);
		break;

		//====================
		// If moved, snap window to screen edges...

	case WM_WINDOWPOSCHANGING:
		if (Toolbar_moving)
			SnapWindowToEdge((WINDOWPOS*)lParam, 0, SNAP_FULLSCREEN);
		break;

	case WM_ENTERSIZEMOVE:
		Toolbar_moving = true;
		break;

	case WM_EXITSIZEMOVE:
		Toolbar_moving = false;
		break;

		//====================

	case BB_BROADCAST:
		if (0 == _tmemcmp((LPTSTR)lParam, _T("@Toolbar"), 8))
		{
			const TCHAR *argument = (LPTSTR)lParam;
			const struct cfgmenu *p_menu, *p_item;
			const void *v = exec_internal_broam(argument, tb_main, &p_menu, &p_item);
			if (v) goto tbreconfig;
			break;
		}
		if (!_tcsicmp((LPCTSTR)lParam, _T("@BBShowPlugins")))
		{
			Toolbar_hidden = false;
			Toolbar_UpdatePosition();
			break;
		}
		if (!_tcsicmp((LPCTSTR)lParam, _T("@BBHidePlugins")))
		{
			if (Settings_toolbarPluginToggle)
			{
				Toolbar_hidden = true;
				Toolbar_UpdatePosition();
			}
			break;
		}
		break;

	case WM_CLOSE:
		break;

	default:
		return DefWindowProc(hwnd,message,wParam,lParam);

		//====================
	}
	return 0;
}
Ejemplo n.º 7
0
ST LRESULT CALLBACK Desk_WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    static const UINT msgs [] = { BB_DRAGTODESKTOP, BB_REDRAWGUI, 0 };
    static bool button_down, dblclk;
    int n;

    switch (uMsg)
    {
        //====================
        case WM_CREATE:
            hDesktopWnd = hwnd;
            MakeSticky(hwnd);
            MessageManager_Register(hwnd, msgs, true);
            init_DeskDropTarget(hwnd);
            Desk_SetPosition();
            break;

        //====================
        case WM_DESTROY:
            exit_DeskDropTarget(hwnd);
            MessageManager_Register(hwnd, msgs, false);
            RemoveSticky(hwnd);
            break;

        case WM_NCPAINT:
            // dbg_printf("ncpaint: %x %x %x %x", hwnd, uMsg, wParam, lParam);
            // keep the window on bottom
            Desk_SetPosition();
            break;

        case WM_SETTINGCHANGE:
			if (SPI_SETDESKWALLPAPER == wParam)
			{
				CHAR oldWallPaper[(MAX_PATH + 1)];
				if (TRUE == SystemParametersInfo(SPI_GETDESKWALLPAPER, sizeof(oldWallPaper), &oldWallPaper, 0))
					Desk_read_background(oldWallPaper);
					//Desk_new_background(oldWallPaper);
					//Desk_read_background(oldWallPaper);
				Desk_SetPosition();

				//InvalidateRect(hwnd, NULL, FALSE);
			}
            break;


        //====================
        case WM_CLOSE:
            break;

        //====================
        case WM_MOUSEACTIVATE:
            return MA_NOACTIVATE;
        
        case WM_LBUTTONDOWN:
        case WM_RBUTTONDOWN:
        case WM_MBUTTONDOWN:
        case WM_XBUTTONDOWN:
            dblclk = false;
            button_down = true;
            if (uMsg == WM_LBUTTONDOWN) {
                n = 0;
                goto post_click_2;
            }
            break;

        case WM_MOUSEMOVE:
            break;

        case WM_LBUTTONDBLCLK:
        case WM_RBUTTONDBLCLK:
        case WM_MBUTTONDBLCLK:
            dblclk = true;
            button_down = true;
            break;

        case WM_LBUTTONUP: n = dblclk ? 7 : 1; goto post_click;
        case WM_RBUTTONUP: n = 2; goto post_click;
        case WM_MBUTTONUP: n = 3; goto post_click;
        case WM_XBUTTONUP:
            switch (HIWORD(wParam)) {
            case XBUTTON1: n = 4; goto post_click;
            case XBUTTON2: n = 5; goto post_click;
            case XBUTTON3: n = 6; goto post_click;
            } break;

        post_click:
            if (false == button_down)
                break;
            button_down = dblclk = false;

        post_click_2:
            wParam &= (MK_CONTROL|MK_SHIFT);
            if (0x8000 & GetAsyncKeyState(VK_MENU))
                wParam |= MK_ALT;

            PostMessage(BBhwnd, BB_DESKCLICK, wParam, n);
            break;

        //====================

        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc_scrn;
            HDC hdc_bmp;
            HGDIOBJ other;

            hdc_scrn = BeginPaint(hwnd, &ps);
            if (Root.bmp) {
                hdc_bmp = CreateCompatibleDC(hdc_scrn);
                other = SelectObject(hdc_bmp, Root.bmp);
                BitBltRect(hdc_scrn, hdc_bmp, &ps.rcPaint);
                SelectObject(hdc_bmp, other);
                DeleteDC(hdc_bmp);
            } else {
                PaintDesktop(hdc_scrn);
            }
            EndPaint(hwnd, &ps);
            break;
        }

        //====================
        case WM_ERASEBKGND:
            return TRUE;

        //====================
        case BB_DRAGTODESKTOP:
            return get_drop_command((const char *)lParam, wParam);

        case BB_REDRAWGUI:
            if (wParam & BBRG_DESK)
                Desk_new_background("style");
            break;

        //====================
        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    return 0;
}