Exemplo n.º 1
2
static void test_customdraw(void) {
    static struct {
        LRESULT FirstReturnValue;
        int ExpectedCalls;
    } expectedResults[] = {
        /* Valid notification responses */
        {CDRF_DODEFAULT, TEST_CDDS_PREPAINT},
        {CDRF_SKIPDEFAULT, TEST_CDDS_PREPAINT},
        {CDRF_NOTIFYPOSTPAINT, TEST_CDDS_PREPAINT | TEST_CDDS_POSTPAINT},

        /* Invalid notification responses */
        {CDRF_NOTIFYITEMDRAW, TEST_CDDS_PREPAINT},
        {CDRF_NOTIFYPOSTERASE, TEST_CDDS_PREPAINT},
        {CDRF_NEWFONT, TEST_CDDS_PREPAINT}
    };

   DWORD       iterationNumber;
   WNDCLASSA wc;
   LRESULT   lResult;

   /* Create a class to use the custom draw wndproc */
   wc.style = CS_HREDRAW | CS_VREDRAW;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = GetModuleHandleA(NULL);
   wc.hIcon = NULL;
   wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
   wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
   wc.lpszMenuName = NULL;
   wc.lpszClassName = "CustomDrawClass";
   wc.lpfnWndProc = CustomDrawWndProc;
   RegisterClass(&wc);

   for (iterationNumber = 0;
        iterationNumber < sizeof(expectedResults)/sizeof(expectedResults[0]);
        iterationNumber++) {

       HWND parent, hwndTip;
       RECT rect;
       TOOLINFO toolInfo = { 0 };

       /* Create a main window */
       parent = CreateWindowEx(0, "CustomDrawClass", NULL,
                               WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
                               WS_MAXIMIZEBOX | WS_VISIBLE,
                               50, 50,
                               300, 300,
                               NULL, NULL, NULL, 0);
       ok(parent != NULL, "Creation of main window failed\n");

       /* Make it show */
       ShowWindow(parent, SW_SHOWNORMAL);
       flush_events(100);

       /* Create Tooltip */
       hwndTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS,
                                NULL, TTS_NOPREFIX | TTS_ALWAYSTIP,
                                CW_USEDEFAULT, CW_USEDEFAULT,
                                CW_USEDEFAULT, CW_USEDEFAULT,
                                parent, NULL, GetModuleHandleA(NULL), 0);
       ok(hwndTip != NULL, "Creation of tooltip window failed\n");

       /* Set up parms for the wndproc to handle */
       CD_Stages = 0;
       CD_Result = expectedResults[iterationNumber].FirstReturnValue;
       g_hwnd    = hwndTip;

       /* Make it topmost, as per the MSDN */
       SetWindowPos(hwndTip, HWND_TOPMOST, 0, 0, 0, 0,
             SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

       /* Create a tool */
       toolInfo.cbSize = TTTOOLINFO_V1_SIZE;
       toolInfo.hwnd = parent;
       toolInfo.hinst = GetModuleHandleA(NULL);
       toolInfo.uFlags = TTF_SUBCLASS;
       toolInfo.uId = 0x1234ABCD;
       toolInfo.lpszText = (LPSTR)"This is a test tooltip";
       toolInfo.lParam = 0xdeadbeef;
       GetClientRect (parent, &toolInfo.rect);
       lResult = SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
       ok(lResult, "Adding the tool to the tooltip failed\n");

       /* Make tooltip appear quickly */
       SendMessage(hwndTip, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELPARAM(1,0));

       /* Put cursor inside window, tooltip will appear immediately */
       GetWindowRect( parent, &rect );
       SetCursorPos( (rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2 );
       flush_events(200);

       if (CD_Stages)
       {
           /* Check CustomDraw results */
           ok(CD_Stages == expectedResults[iterationNumber].ExpectedCalls ||
              broken(CD_Stages == (expectedResults[iterationNumber].ExpectedCalls & ~TEST_CDDS_POSTPAINT)), /* nt4 */
              "CustomDraw run %d stages %x, expected %x\n", iterationNumber, CD_Stages,
              expectedResults[iterationNumber].ExpectedCalls);
       }

       /* Clean up */
       DestroyWindow(hwndTip);
       DestroyWindow(parent);
   }


}
Exemplo n.º 2
0
LRESULT CALLBACK notificationWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;
	HDC hdc;
	RECT rc = {0};
	UINT notify_duration = 0;
	static BOOL is_fading_out = FALSE;
	static HHOOK hook_mouse_over = NULL;
	static NotifyNotification notification_data_copy = {L"", L"", ICON_INFO};

	switch (message)
	{
	case WM_LIBNOTIFYSHOW:
		/* close if already running */
		if(IsWindowVisible(hWnd))
		{
			SendMessage(hWnd, WM_LIBNOTIFYCLOSE, 0, 0);
		}
		/* guarded by CS to make sure notification_data doesn't get corrupted
		   when this code and notify_notification_update is running in parallel */
		{
			EnterCriticalSection(&thread_guard);
			NotifyNotification *notification_data = (NotifyNotification*) lParam;
			if(notification_data &&
			   notification_data->body &&
			   notification_data->summary)
			{
				notification_data_copy = *notification_data;
			}
			else
			{
				LeaveCriticalSection(&thread_guard);
				break;
			}
			LeaveCriticalSection(&thread_guard);
		}

		/* deduce the allowed text width from the max width; see geometry for rationale */
		rc.right = notification_window_width_max - (icon_size + (icon_padding * 3));

		hdc = GetDC(hWnd);
		if(hdc)
		{
			HRGN hRgn = NULL;
			HGDIOBJ hOldFont = SelectObject(hdc, (HGDIOBJ) font_body);
			if(hOldFont)
			{
				DrawText(hdc,
						 notification_data_copy.body,
						 -1,
						 &rc,
						 DT_CALCRECT | DT_WORDBREAK |
						 DT_EDITCONTROL | DT_NOCLIP |
						 DT_NOPREFIX | DT_EXTERNALLEADING);

				SelectObject(hdc, hOldFont);
			}

			ReleaseDC(hWnd, hdc);
			if(!hOldFont) return 0;	/* exit if font selection failed */

			/* calculate the actual bounding rectangle from the DrawText output */
			notify_wnd.notification_window_height = notify_wnd.summary_body_divider +
													rc.bottom +
													(icon_padding * 3);
			notify_wnd.notification_window_width = rc.right + icon_size + (icon_padding * 3);

			/* word count * milliseconds per word */
			notify_duration = word_count(notification_data_copy.body) * milliseconds_per_word;

			/* in case the calculation renders too low a value, replace it with a de facto minimum */
			notify_duration = MAX(notify_duration, min_notification_timeout);

			/* get the screen area uncluttered by the taskbar */
			if(SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
			{
				LONG window_x = 0, window_y = 0;

				/* system tray @ right bottom */
				if((rc.bottom != GetSystemMetrics(SM_CYSCREEN)) ||
					(rc.right != GetSystemMetrics(SM_CXSCREEN)))
				{
					window_x = rc.right -
							   (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor) -
							   notify_wnd.notification_window_width;
					window_y = rc.bottom -
							   (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor) -
							   notify_wnd.notification_window_height;
				}
				else if(rc.left != 0)	/* left bottom */
				{
					window_x = rc.left +
							   (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor);
					window_y = rc.bottom -
							   (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor) -
							   notify_wnd.notification_window_height;
				}
				else					/* right top */
				{
					window_x = rc.right -
							   (GetSystemMetrics(SM_CXSCREEN) / window_offset_factor) -
							   notify_wnd.notification_window_width;
					window_y = rc.top +
							   (GetSystemMetrics(SM_CYSCREEN) / window_offset_factor);
				}

				/* resize and reposition the window */
				MoveWindow(hWnd,
						   window_x,
						   window_y,
						   notify_wnd.notification_window_width,
						   notify_wnd.notification_window_height,
						   TRUE);

				/* set the new positions to be used by the mouse over hook */
				notify_wnd.notification_window_rect.left = window_x;
				notify_wnd.notification_window_rect.top = window_y;
				notify_wnd.notification_window_rect.right = window_x + notify_wnd.notification_window_width;
				notify_wnd.notification_window_rect.bottom = window_y + notify_wnd.notification_window_height;

				/* make it as a rounded rect. */
				hRgn = CreateRoundRectRgn(0,
										  0,
										  notify_wnd.notification_window_width,
										  notify_wnd.notification_window_height,
										  rounded_rect_edge,
										  rounded_rect_edge);
				SetWindowRgn(hWnd, hRgn, TRUE);

				/* since bRedraw is set to TRUE in SetWindowRgn invalidation isn't required */
				/*InvalidateRect(hWnd, NULL, TRUE);*/

				/* show the window and set the timers for animation and overall visibility */
				ShowWindow(hWnd, SW_SHOWNOACTIVATE);

				SetTimer(hWnd, TIMER_ANIMATION, fade_duration, NULL);
				SetTimer(hWnd, TIMER_NOTIFICATION, notify_duration, NULL);
			}
		}
		break;
	case WM_LIBNOTIFYCLOSE:
		/* clean up and reset flags */
		{
			if(hook_mouse_over)
			{
				UnhookWindowsHookEx(hook_mouse_over);
				hook_mouse_over = NULL;
			}

			KillTimer(hWnd, TIMER_ANIMATION);
			KillTimer(hWnd, TIMER_NOTIFICATION);
			is_fading_out = FALSE;

			ShowWindow(hWnd, SW_HIDE);
		}
		break;
	case WM_PAINT:
		if((L'\0' != notification_data_copy.body[0]) &&
		   (L'\0' != notification_data_copy.summary[0]))
		{
			hdc = BeginPaint(hWnd, &ps);

			SetTextColor(hdc, RGB(255, 255, 255));
			SetBkMode(hdc, TRANSPARENT);

			HGDIOBJ hOldFont = SelectObject(hdc, (HGDIOBJ) font_summary);

			if(hOldFont)
			{
				/* set the padding as left offset and center the icon horizontally */
				DrawIcon(hdc,
						 icon_padding,
						 (notify_wnd.notification_window_height / 2) - (icon_size / 2),
						 notification_icons[notification_data_copy.icon_req]);

				/* calculate and DrawText for both summary and body
				   based on the geometry given above */
				rc.left = icon_size + (icon_padding * 2);
				rc.right = notify_wnd.notification_window_width - icon_padding;
				rc.top = icon_padding;
				rc.bottom = notify_wnd.summary_body_divider + (icon_padding * 2);

				DrawText(hdc,
						 notification_data_copy.summary,
						 -1,
						 &rc,
						 DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX);

				if(SelectObject(hdc, (HGDIOBJ) font_body))
				{
					rc.top = rc.bottom;
					rc.bottom = notify_wnd.notification_window_height - icon_padding;

					DrawText(hdc,
							 notification_data_copy.body,
							 -1,
							 &rc,
							 DT_WORDBREAK | DT_EDITCONTROL |
							 DT_NOCLIP | DT_NOPREFIX |
							 DT_EXTERNALLEADING);
				}

				SelectObject(hdc, hOldFont);
			}

			EndPaint(hWnd, &ps);
		}
		break;
	case WM_LIBNOTIFYEXIT:
		if(hook_mouse_over)
		{
			UnhookWindowsHookEx(hook_mouse_over);
			hook_mouse_over = NULL;
		}

		KillTimer(notify_wnd.notification_window, TIMER_ANIMATION);
		KillTimer(notify_wnd.notification_window, TIMER_NOTIFICATION);
		PostQuitMessage(0);
		break;
	case WM_TIMER:
		if(IsWindowVisible(hWnd))
		{
			if(wParam == TIMER_ANIMATION)	/* notification animation timer */
			{
				if(is_fading_out)
				{
					if(notify_wnd.notification_window_alpha > 5)
					{
						notify_wnd.notification_window_alpha -= 25;
					}
					else
					{
						/* once fully faded out, self destroy and reset the flags */
						KillTimer(hWnd, TIMER_ANIMATION);
						is_fading_out = FALSE;
						notify_wnd.notification_window_alpha = 0;
						SendMessage(hWnd, WM_LIBNOTIFYCLOSE, 0, 0);
					}
				}
				else
				{
					if(notify_wnd.notification_window_alpha < 250)
					{
						notify_wnd.notification_window_alpha += 25;
					}
					else
					{
						/* self destory as alpha reaches the maximum */
						KillTimer(hWnd, TIMER_ANIMATION);
						notify_wnd.notification_window_alpha = 255;

						/* set the mouse over hook once the window is fully visible */
						hook_mouse_over = SetWindowsHookEx(WH_MOUSE_LL,
														   mouse_over_hook_proc,
														   (HINSTANCE) GetModuleHandle(NULL),
														   0);
					}
				}
				/* for all the above cases set the newly calculated alpha */
				SetLayeredWindowAttributes(notify_wnd.notification_window,
										   0,
										   notify_wnd.notification_window_alpha,
										   LWA_ALPHA);
			}
			else	/* notification duration timer */
			{
				/* self destruct once timed out */
				KillTimer(hWnd, TIMER_NOTIFICATION);

				/* kill the hook set by animation timer */
				if(hook_mouse_over)
				{
					UnhookWindowsHookEx(hook_mouse_over);
					hook_mouse_over = NULL;
				}

				/* start fading out sequence */
				is_fading_out = TRUE;
				SetTimer(hWnd, TIMER_ANIMATION, fade_duration, NULL);
			}
		}
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}

	return 0;
}
Exemplo n.º 3
0
/*
 * handleKey - handle a key press
 */
static bool handleKey( HWND hwnd, vi_key key, bool process )
{
    char    tmp[MAX_INPUT_LINE];

    switch( key ) {
    case VI_KEY( ALT_O ):
    case VI_KEY( CTRL_O ):
        if( process ) {
            GetWindowText( hwnd, tmp, sizeof( tmp ) );
            InsertTextForSpecialKey( key, tmp );
        }
        break;
    case VI_KEY( CTRL_R ):
        if( !SelRgn.selected ||
            (SelRgn.lines && (SelRgn.start.line != SelRgn.end.line)) ) {
            return( FALSE );
        }
    case VI_KEY( CTRL_W ):
    case VI_KEY( CTRL_E ):
    case VI_KEY( ALT_L ):
    case VI_KEY( CTRL_L ):
        if( process ) {
            if( GetTextForSpecialKey( sizeof( tmp ), key, tmp ) ) {
                insertEditText( hwnd, tmp );
            }
        }
        break;
    case VI_KEY( CTRL_INS ):
        if( process ) {
            SendMessage( hwnd, EM_UNDO, 0, 0L );
        }
        break;
    case VI_KEY( UP ):
        if( process ) {
            currHist--;
            if( currHist < 0 || currHist < (hData->curr - hData->max) ) {
                currHist = hData->curr - 1;
            }
            setEditText( hwnd, hData->data[currHist % hData->max] );
        }
        break;
    case VI_KEY( DOWN ):
        if( process ) {
            currHist++;
            if( currHist >= hData->curr ) {
                currHist = hData->curr - hData->max;
                if( currHist < 0 ) {
                    currHist = 0;
                }
            }
            setEditText( hwnd, hData->data[currHist % hData->max] );
        }
        break;
    case VI_KEY( CTRL_F ):
    case VI_KEY( CTRL_B ):
        if( process ) {
        }
        break;
    default:
        return( FALSE );
    }
    return( TRUE );

} /* handleKey */
Exemplo n.º 4
0
static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    HWND btn, label, eq0, eq1, eq2, eq3;

    switch (iMsg)
    {
        case WM_CREATE:
        {
            btn = CreateWindow("button", "Reset",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               157, 143, 80, 25, hwnd,
                               (HMENU) ID_DEFAULTS,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            btn = CreateWindow("button", "Close",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               243, 143, 80, 25, hwnd,
                               (HMENU) ID_CLOSE,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            label = CreateWindow("static", "Brightness",
                                 WS_CHILD | WS_VISIBLE,
                                 12, 122, 70, 15, hwnd,
                                 NULL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance,
                                 NULL);
            SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            label = CreateWindow("static", "Contrast",
                                 WS_CHILD | WS_VISIBLE,
                                 99, 122, 70, 15, hwnd,
                                 NULL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance,
                                 NULL);
            SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            label = CreateWindow("static", "Hue",
                                 WS_CHILD | WS_VISIBLE,
                                 191, 122, 70, 15, hwnd,
                                 NULL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
            SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            label = CreateWindow("static", "Saturation",
                                 WS_CHILD | WS_VISIBLE,
                                 260, 122, 70, 15, hwnd,
                                 NULL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance,
                                 NULL);
            SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            eq0 = CreateWindow(TRACKBAR_CLASS, "brightness",
                               WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
                               TBS_VERT | TBS_NOTICKS,
                               30, 0, 20, 120, hwnd,
                               (HMENU) ID_EQ0,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200));

            eq1 = CreateWindow(TRACKBAR_CLASS, "contrast",
                               WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
                               TBS_VERT | TBS_NOTICKS,
                               112, 0, 20, 120, hwnd,
                               (HMENU) ID_EQ1,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200));

            eq2 = CreateWindow(TRACKBAR_CLASS, "hue",
                               WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
                               TBS_VERT | TBS_NOTICKS,
                               194, 0, 20, 120, hwnd,
                               (HMENU) ID_EQ2,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200));

            eq3 = CreateWindow(TRACKBAR_CLASS, "saturation",
                               WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
                               TBS_VERT | TBS_NOTICKS,
                               276, 0, 20, 120, hwnd,
                               (HMENU) ID_EQ3,
                               ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
            SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200));

            if(guiInfo.sh_video && guiInfo.Playing)
            {
                EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1);
                get_video_colors(guiInfo.sh_video, "brightness", &vo_gamma_brightness);
                get_video_colors(guiInfo.sh_video, "contrast", &vo_gamma_contrast);
                get_video_colors(guiInfo.sh_video, "hue", &vo_gamma_hue);
                get_video_colors(guiInfo.sh_video, "saturation", &vo_gamma_saturation);
            }
            SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness);
            SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast);
            SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue);
            SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation);
            break;
        }
        case WM_VSCROLL:
        {
            switch (LOWORD(wParam))
            {
                case TB_THUMBTRACK:
                    if(guiInfo.sh_video && guiInfo.Playing)
                    {
                        vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0);
                        set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness);

                        vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0);
                        set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast);

                        vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0);
                        set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue);

                        vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0);
                        set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation);
                    }
                    else
                    {
                        EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0);
                        EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0);
                        EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0);
                        EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0);
                    }
                    break;
            }
        }
        case WM_CTLCOLORDLG:
        case WM_CTLCOLORSTATIC:
        {
            HDC hdc = (HDC)wParam;
            SetBkMode(hdc, TRANSPARENT);
            return (INT_PTR)SOLID_GREY2;
        }
        break;
        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case ID_CLOSE:
                    DestroyWindow(hwnd);
                    return 0;
                case ID_DEFAULTS:
                    if(guiInfo.sh_video && guiInfo.Playing)
                    {
                        vo_gamma_brightness=0;
                        SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100);
                        set_video_colors(guiInfo.sh_video, "brightness", vo_gamma_brightness);

                        vo_gamma_contrast=0;
                        SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100);
                        set_video_colors(guiInfo.sh_video, "contrast", vo_gamma_contrast);

                        vo_gamma_hue=0;
                        SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100);
                        set_video_colors(guiInfo.sh_video, "hue", vo_gamma_hue);

                        vo_gamma_saturation=0;
                        SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100);
                        set_video_colors(guiInfo.sh_video, "saturation", vo_gamma_saturation);
                    }
                    break;
            }
        }
        return 0;
    }
    return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Exemplo n.º 5
0
static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static HWND listbox;
    static char skinspath[MAX_PATH];
    gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    switch (iMsg)
    {
        case WM_CREATE:
        {
            HANDLE skinHandle = INVALID_HANDLE_VALUE;
            WIN32_FIND_DATA finddata;

            listbox = CreateWindow("listbox", NULL,
                                   WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT |
                                   LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP,
                                   4, 5, 166, 60, hwnd,
                                   (HMENU) ID_DIR,
                                   ((LPCREATESTRUCT) lParam) -> hInstance,
                                   NULL);
            SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            /* This opens the skins directory, lists the directory names, and adds them to the listbox */
            sprintf(skinspath, "%s/*.", get_path("skins"));

            skinHandle = FindFirstFile(skinspath, &finddata);
            if (skinHandle != INVALID_HANDLE_VALUE)
            {
                do
                {
                    if (finddata.cFileName[0] == '.') continue;
                    /* populate the listbox */
                    capitalize(finddata.cFileName);
                    SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName);
                } while (FindNextFile(skinHandle, &finddata));
                FindClose(skinHandle);
            }
            else
                mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins"));
            break;
        }
        case WM_COMMAND:
        {
            if ((HWND) lParam == listbox)
            {
                if(HIWORD(wParam) == LBN_DBLCLK)
                {
                    int index = SendMessage(listbox, LB_GETCURSEL, 0, 0);
                    int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0);
                    if (len)
                    {
                        if (guiInfo.Playing) gui(GUI_SET_STATE, (void *) GUI_STOP);
                        free(skinName);
                        skinName = malloc(len + 1);
                        SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName);
                        /* fill out the full pathname to the skin */
                        strcpy(skinspath, get_path("skins"));
                        strcat(skinspath, "\\");
                        strcat(skinspath, skinName);
                        ShowWindow(hwnd, SW_HIDE);
                        Shell_NotifyIcon(NIM_DELETE, &nid);
                        destroy_window(gui);
                        create_window(gui, skinspath);
                        create_subwindow(gui, skinspath);
                        SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */
                    }
                }
            }
        }
            return 0;
    }
    return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Exemplo n.º 6
0
static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static HWND url;
    HWND wdg;
    FILE *f;
    char *history = get_path("gui.url");
    gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    switch (iMsg)
    {
        case WM_CREATE:
            wdg = CreateWindow("button", "Ok",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               4, 43, 80, 25, hwnd,
                               (HMENU) ID_OK,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            wdg = CreateWindow("button", "Cancel",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               90, 43, 80, 25, hwnd,
                               (HMENU) ID_CANCEL,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,
                               "edit", NULL,
                               WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
                               4, 10, 300, 25, hwnd,
                               (HMENU) ID_URL,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
            SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);

            /*subclass the edit box to capture the VK_RETURN key*/
            OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);

            if((f = fopen(history, "r")))
            {
               char lasturl[MAX_PATH];
               fgets(lasturl, MAX_PATH, f);
               SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);
               SendMessage(url, EM_SETSEL, 0, -1);
               fclose(f);
            }
            break;
        case WM_KEYDOWN:
            switch (LOWORD(wParam))
            {
                case VK_RETURN:
                    SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);
                    break;
            }
        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case ID_CANCEL:
                    DestroyWindow(hwnd);
                    return 0;
                case ID_OK:
                {
                    char file[MAX_PATH];
                    SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);
                    uiSetFileName(NULL, file, STREAMTYPE_STREAM);
                    if((f = fopen(history, "wt+")))
                    {
                        fprintf(f, file);
                        fclose(f);
                    }
                    if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))
                        gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
                    if(!addurl)
                        gui->startplay(gui);
                    else update_playlistwindow();
                    DestroyWindow(hwnd);
                }
                break;
            }
        }
        return 0;
        case WM_DESTROY:
        {
            addurl = 0;
            return 0;
        }
    }
    return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Exemplo n.º 7
0
static void test_ttm_gettoolinfo(void)
{
    TTTOOLINFOA ti;
    TTTOOLINFOW tiW;
    HWND hwnd;
    DWORD r;

    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0x1abe11ed;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessageA(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.lParam = 0xaaaaaaaa;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti);
    ok(r, "Getting tooltip info failed\n");
    ok(0x1abe11ed == ti.lParam ||
       broken(0x1abe11ed != ti.lParam), /* comctl32 < 5.81 */
       "Expected 0x1abe11ed, got %lx\n", ti.lParam);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    tiW.lParam = 0xaaaaaaaa;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOW, 0, (LPARAM)&tiW);
    ok(r, "Getting tooltip info failed\n");
    ok(0x1abe11ed == tiW.lParam ||
       broken(0x1abe11ed != tiW.lParam), /* comctl32 < 5.81 */
       "Expected 0x1abe11ed, got %lx\n", tiW.lParam);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.uId = 0x1234ABCD;
    ti.lParam = 0x55555555;
    SendMessageA(hwnd, TTM_SETTOOLINFOA, 0, (LPARAM)&ti);

    ti.cbSize = TTTOOLINFOA_V2_SIZE;
    ti.lParam = 0xdeadbeef;
    r = SendMessageA(hwnd, TTM_GETTOOLINFOA, 0, (LPARAM)&ti);
    ok(r, "Getting tooltip info failed\n");
    ok(0x55555555 == ti.lParam ||
       broken(0x55555555 != ti.lParam), /* comctl32 < 5.81 */
       "Expected 0x55555555, got %lx\n", ti.lParam);

    DestroyWindow(hwnd);

    /* 1. test size parameter validation rules (ansi messages) */
    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);

    ti.cbSize = TTTOOLINFOA_V1_SIZE - 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V1_SIZE - 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE - 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE - 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE + 1;
    ti.hwnd = NULL;
    ti.hinst = GetModuleHandleA(NULL);
    ti.uFlags = 0;
    ti.uId = 0x1234ABCD;
    ti.lpszText = NULL;
    ti.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &ti.rect);
    r = SendMessage(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&ti);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    ti.cbSize = TTTOOLINFOA_V2_SIZE + 1;
    ti.hwnd = NULL;
    ti.uId = 0x1234ABCD;
    SendMessage(hwnd, TTM_DELTOOLA, 0, (LPARAM)&ti);
    r = SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    DestroyWindow(hwnd);

    /* 2. test size parameter validation rules (w-messages) */
    hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);
    if(!hwnd)
    {
        win_skip("CreateWindowExW() not supported. Skipping.\n");
        return;
    }

    tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V1_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLW, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE - 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE + 1;
    tiW.hwnd = NULL;
    tiW.hinst = GetModuleHandleA(NULL);
    tiW.uFlags = 0;
    tiW.uId = 0x1234ABCD;
    tiW.lpszText = NULL;
    tiW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &tiW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOLA, 0, (LPARAM)&tiW);
    ok(r, "Adding the tool to the tooltip failed\n");
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);
    /* looks like TTM_DELTOOLW doesn't work with invalid size */
    tiW.cbSize = TTTOOLINFOW_V2_SIZE + 1;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(1, r);

    tiW.cbSize = TTTOOLINFOW_V2_SIZE;
    tiW.hwnd = NULL;
    tiW.uId = 0x1234ABCD;
    SendMessageW(hwnd, TTM_DELTOOLW, 0, (LPARAM)&tiW);
    r = SendMessageW(hwnd, TTM_GETTOOLCOUNT, 0, 0);
    expect(0, r);

    DestroyWindow(hwnd);
}
Exemplo n.º 8
0
//------------------------------------------------------------------------------
DWORD WINAPI UpdateRtCA_Thread(LPVOID lParam)
{
  update_thread_start = 1;

  //get current date
  time_t date;
  time(&date);
  struct tm *today = localtime(&date);

  //get date
  char date_today[DATE_SIZE_MAX]="";
  strftime(date_today, DATE_SIZE_MAX,"%Y/%m/%d %H:%M:%S",today);
//---------------------------
//update malware database
//http://www.selectrealsecurity.com/public-block-lists
  SendMessage(hstatus_bar,SB_SETTEXT,0, (LPARAM)cps[TXT_UPDATE_START].c);
  //init database ?
  //sqlite3_exec(db_scan,"DELETE from malware_dns_list;", NULL, NULL, NULL);

  //ddl malware file https://easylist-downloads.adblockplus.org/malwaredomains_full.txt
  //init SSL connexion
  HINTERNET M_connexion = 0;
  if (!use_other_proxy)M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
  else M_connexion = InternetOpen("",/*INTERNET_OPEN_TYPE_DIRECT*/INTERNET_OPEN_TYPE_PROXY, proxy_ch_auth, NULL, 0);

  if (M_connexion==NULL)M_connexion = InternetOpen("",INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE);
  if (M_connexion==NULL)return 0;

  if(!SQLITE_FULL_SPEED)sqlite3_exec(db_scan,"BEGIN TRANSACTION;", NULL, NULL, NULL);
  //---------------------------
  HINTERNET M_session = InternetConnect(M_connexion, "easylist-downloads.adblockplus.org",443,"","",INTERNET_SERVICE_HTTP,0,0);
  if (M_session!=NULL)
  {
    //connexion
    HINTERNET M_requete = HttpOpenRequest(M_session,"GET","/malwaredomains_full.txt",NULL,"https://easylist-downloads.adblockplus.org",NULL,
                                          INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_SECURE
                                          |INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID,0);
    if (use_proxy_advanced_settings)
    {
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_USERNAME,proxy_ch_user,sizeof(proxy_ch_user));
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_PASSWORD,proxy_ch_password,sizeof(proxy_ch_password));
    }

    if (HttpSendRequest(M_requete, NULL, 0, NULL, 0))
    {
      char *res = malloc(DIXM); //10MO
      memset(res,0,DIXM);
      if (res != NULL)
      {
        INTERNET_BUFFERS ib;
        ib.dwStructSize       = sizeof(INTERNET_BUFFERS);
        ib.lpcszHeader        = NULL;
        ib.dwHeadersLength    = 0;
        ib.dwHeadersTotal     = 0;
        ib.dwOffsetLow        = 0;
        ib.dwOffsetHigh       = 0;
        ib.lpvBuffer          = res;
        ib.dwBufferLength     = DIXM-1;
        ib.dwBufferTotal      = DIXM-1;

        if(InternetReadFileEx(M_requete,&ib,IRF_NO_WAIT,0))
        {
          if (strlen(res)>0)
          {
            //working with file and update
            char request[MAX_LINE_SIZE], domain[MAX_PATH], *c = res, *d;
            do
            {
              //get data by line
              if (*c++ == '|')
              {
                if (*c++ == '|')
                {
                  d = domain;
                  while (*c && *c!='^' && (d-domain < MAX_PATH)) *d++ = *c++;
                  *d = 0;

                  if (strlen(domain)>=DNS_MALWARE_MIN_SIZE)
                  {
                    snprintf(request,MAX_LINE_SIZE,"INSERT INTO malware_dns_list (domain,description,update_time) "
                                                   "VALUES(\"%s\",\"https://easylist-downloads.adblockplus.org/malwaredomains_full.txt\",\"%s\");",domain,date_today);
                    //MessageBox(NULL,"OK",request,MB_OK|MB_TOPMOST);
                    sqlite3_exec(db_scan,request, NULL, NULL, NULL);
                    SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)domain);
                  }

           //next
                  while (*c && *c != '\n')c++;
                }else while (*c && *c != '\n')c++;
              }else while (*c && *c != '\n')c++;
              if (*c == '\n')c++;
            }while (*c);
          }
        }
        free(res);
      }
    }
    SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)"OK : https://easylist-downloads.adblockplus.org/malwaredomains_full.txt");
  }
  //---------------------------
  //http://malc0de.com/bl/BOOT
  M_session = InternetConnect(M_connexion, "malc0de.com",80,"","",INTERNET_SERVICE_HTTP,0,0);
  if (M_session!=NULL)
  {
    //connexion
    HINTERNET M_requete = HttpOpenRequest(M_session,"GET","/bl/BOOT",NULL,"http://malc0de.com",NULL,
                                          INTERNET_FLAG_NO_CACHE_WRITE,0);

    if (use_proxy_advanced_settings)
    {
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_USERNAME,proxy_ch_user,sizeof(proxy_ch_user));
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_PASSWORD,proxy_ch_password,sizeof(proxy_ch_password));
    }

    if (HttpSendRequest(M_requete, NULL, 0, NULL, 0))
    {
      char *res = malloc(DIXM); //10MO
      memset(res,0,DIXM);
      if (res != NULL)
      {
        INTERNET_BUFFERS ib;
        ib.dwStructSize       = sizeof(INTERNET_BUFFERS);
        ib.lpcszHeader        = NULL;
        ib.dwHeadersLength    = 0;
        ib.dwHeadersTotal     = 0;
        ib.dwOffsetLow        = 0;
        ib.dwOffsetHigh       = 0;
        ib.lpvBuffer          = res;
        ib.dwBufferLength     = DIXM-1;
        ib.dwBufferTotal      = DIXM-1;

        if(InternetReadFileEx(M_requete,&ib,IRF_NO_WAIT,0))
        {
          if (strlen(res)>323)//bypass 323 first caracts
          {
            //working with file and update
            char request[MAX_LINE_SIZE], domain[MAX_PATH], *c = res+323, *d;
            do
            {
              //get data by line
              //PRIMARY duote.com.cn blockeddomain.hosts

              while(*c && *c!=' ')c++;
              if (*c==' ')
              {
                c++;
                d = domain;
                while ((d-domain < MAX_PATH) && *c && *c!=' ') *d++ = *c++;
                *d = 0;

                if (strlen(domain)>=DNS_MALWARE_MIN_SIZE)
                {
                  snprintf(request,MAX_LINE_SIZE,"INSERT INTO malware_dns_list (domain,description,update_time) "
                                                 "VALUES(\"%s\",\"http://malc0de.com/bl/BOOT\",\"%s\");",domain,date_today);
                  sqlite3_exec(db_scan,request, NULL, NULL, NULL);
                  SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)domain);
                }

                //next line
                while (*c && *c != '\n')c++;
                if (*c == '\n')c++;
              }else break;
            }while (*c);
          }
        }
        free(res);
      }
    }
    SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)"OK : http://malc0de.com/bl/BOOT");
  }
  //---------------------------
  //http://www.malwaredomainlist.com/hostslist/hosts.txt
  M_session = InternetConnect(M_connexion, "www.malwaredomainlist.com",80,"","",INTERNET_SERVICE_HTTP,0,0);
  if (M_session!=NULL)
  {
    //connexion
    HINTERNET M_requete = HttpOpenRequest(M_session,"GET","/hostslist/hosts.txt",NULL,"http://www.malwaredomainlist.com",NULL,
                                          INTERNET_FLAG_NO_CACHE_WRITE,0);
    if (use_proxy_advanced_settings)
    {
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_USERNAME,proxy_ch_user,sizeof(proxy_ch_user));
      InternetSetOption(M_requete,INTERNET_OPTION_PROXY_PASSWORD,proxy_ch_password,sizeof(proxy_ch_password));
    }

    if (HttpSendRequest(M_requete, NULL, 0, NULL, 0))
    {
      char *res = malloc(DIXM); //10MO
      memset(res,0,DIXM);
      if (res != NULL)
      {
        INTERNET_BUFFERS ib;
        ib.dwStructSize       = sizeof(INTERNET_BUFFERS);
        ib.lpcszHeader        = NULL;
        ib.dwHeadersLength    = 0;
        ib.dwHeadersTotal     = 0;
        ib.dwOffsetLow        = 0;
        ib.dwOffsetHigh       = 0;
        ib.lpvBuffer          = res;
        ib.dwBufferLength     = DIXM-1;
        ib.dwBufferTotal      = DIXM-1;

        if(InternetReadFileEx(M_requete,&ib,IRF_NO_WAIT,0))
        {
          DWORD sz = strlen(res);
          if (sz>207) //bypass 206 first caracts
          {
            //working with file and update
            char request[MAX_LINE_SIZE], domain[MAX_PATH], *c = res+206, *d;
            do
            {
              //get data by line
              //127.0.0.1  0koryu0.easter.ne.jp
              d = domain;
              while ((d-domain < MAX_PATH) && *c && *c!='\r' && *c!='\n') *d++ = *c++;
              *d = 0;

              if (strlen(domain)>=DNS_MALWARE_MIN_SIZE)
              {
                snprintf(request,MAX_LINE_SIZE,"INSERT INTO malware_dns_list (domain,description,update_time) "
                                               "VALUES(\"%s\",\"http://www.malwaredomainlist.com/hostslist/hosts.txt\",\"%s\");",domain,date_today);
                sqlite3_exec(db_scan,request, NULL, NULL, NULL);
                SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)domain);
              }

              //next datas
              while (*c && *c != ' ')c++;
              if (*c == ' ')c++;
              if (*c == ' ')c++;
            }while (*c);
          }
        }
        free(res);
      }
    }
    SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)"OK : http://www.malwaredomainlist.com/hostslist/hosts.txt");
  }
  //---------------------------
  InternetCloseHandle(M_connexion);
  SendMessage(hstatus_bar,SB_SETTEXT,0, (LPARAM)cps[TXT_UPDATE_END].c);
  SendMessage(hstatus_bar,SB_SETTEXT,1, (LPARAM)"");
  if(!SQLITE_FULL_SPEED)sqlite3_exec(db_scan,"END TRANSACTION;", NULL, NULL, NULL);
  update_thread_start = 0;
  return 0;
}
Exemplo n.º 9
0
/* No need for locking, since this is a request rather than a message
   that needs to indicate what has already happened. */
static void
do_destroy(HWND hwnd)
{
	SendMessage(hwnd, WM_CLOSE, 0, 0);
}
Exemplo n.º 10
0
INT_PTR CALLBACK
ProxySettingsDialogFunc(HWND hwndDlg, UINT msg, WPARAM wParam, UNUSED LPARAM lParam)
{
    HICON hIcon;
    LPPSHNOTIFY psn;

    switch (msg)
    {
    case WM_INITDIALOG:
        hIcon = LoadLocalizedIcon(ID_ICO_APP);
        if (hIcon)
        {
            SendMessage(hwndDlg, WM_SETICON, (WPARAM) (ICON_SMALL), (LPARAM) (hIcon));
            SendMessage(hwndDlg, WM_SETICON, (WPARAM) (ICON_BIG), (LPARAM) (hIcon));
        }

        /* Limit Port editbox to 5 chars. */
        SendMessage(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), EM_SETLIMITTEXT, 5, 0);

        LoadProxySettings(hwndDlg);
        break;

    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case ID_RB_PROXY_OPENVPN:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), FALSE);
            }
            break;

        case ID_RB_PROXY_MSIE:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), FALSE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), FALSE);
            }
            break;

        case ID_RB_PROXY_MANUAL:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_HTTP), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_RB_PROXY_SOCKS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_ADDRESS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_EDT_PROXY_PORT), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_ADDRESS), TRUE);
                EnableWindow(GetDlgItem(hwndDlg, ID_TXT_PROXY_PORT), TRUE);
            }
            break;

        case ID_RB_PROXY_HTTP:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_ADDRESS, o.proxy_http_address);
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_PORT, o.proxy_http_port);
            }
            break;

        case ID_RB_PROXY_SOCKS:
            if (HIWORD(wParam) == BN_CLICKED)
            {
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_ADDRESS, o.proxy_socks_address);
                SetDlgItemText(hwndDlg, ID_EDT_PROXY_PORT, o.proxy_socks_port);
            }
            break;
        }
        break;

    case WM_NOTIFY:
        psn = (LPPSHNOTIFY) lParam;
        if (psn->hdr.code == (UINT) PSN_KILLACTIVE)
        {
            SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (CheckProxySettings(hwndDlg) ? FALSE : TRUE));
            return TRUE;
        }
        else if (psn->hdr.code == (UINT) PSN_APPLY)
        {
            SaveProxySettings(hwndDlg);
            SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
            return TRUE;
        }
        break;

    case WM_CLOSE:
        EndDialog(hwndDlg, LOWORD(wParam));
        return TRUE;
    }
    return FALSE;
}
Exemplo n.º 11
0
BOOL
DlgKernelDbg(
    HWND    hDlg,
    UINT    message,
    WPARAM  wParam,
    LONG    lParam
    )
{
    char        rgch[256];
    BOOL        b;
    BOOL        fChange = FALSE;
    int         i;
    HWND        hCtl;
    DWORD       tmp;

    switch (message) {
        case WM_INITDIALOG:
            KdParams = (LPKDPARAMS) lParam;

            if (KdParams->fEnable) {
                CheckDlgButton( hDlg, ID_KD_ENABLE, 1);
            }

            if (KdParams->fGoExit) {
                CheckDlgButton( hDlg, ID_KD_GOEXIT, 1);
            }

            if (KdParams->fVerbose) {
                CheckDlgButton( hDlg, ID_KD_VERBOSE, 1);
            }

            if (KdParams->fInitialBp) {
                CheckDlgButton( hDlg, ID_KD_INITIALBP, 1);
            }

            if (KdParams->fDefer) {
                CheckDlgButton( hDlg, ID_KD_DEFER, 1);
            }

            if (KdParams->fUseModem) {
                CheckDlgButton( hDlg, ID_KD_MODEM, 1);
            }

            hCtl = GetDlgItem(hDlg,ID_KD_PORT);
            sprintf( rgch, "COM%d", KdParams->dwPort );
            for (i=0; i<KdMaxComPorts; i++) {
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)KdComPorts[i]);
                if (strcmp( rgch, KdComPorts[i] ) == 0) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_BAUDRATE);
            for (i=0; i<KdMaxBaudRates; i++) {
                sprintf( rgch, "%d", KdBaudRates[i] );
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)rgch);
                if (KdParams->dwBaudRate ==  KdBaudRates[i] ) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_CACHE);
            for (i=0; i<KdMaxCacheSizes; i++) {
                sprintf( rgch, "%d", KdCacheSizes[i] );
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)rgch);
                if (KdParams->dwCache ==  KdCacheSizes[i] ) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            hCtl = GetDlgItem(hDlg,ID_KD_PLATFORM);
            for (i=0; i<KdMaxPlatforms; i++) {
                SendMessage(hCtl, CB_ADDSTRING, 0, (LPARAM)KdPlatforms[i]);
                if (KdParams->dwPlatform == (DWORD)i) {
                    SendMessage(hCtl, CB_SETCURSEL, i, 0);
                }
            }

            return TRUE;

        case WM_COMMAND:
            switch (wParam) {
                case IDOK :

                    /*
                     * Transfer the options to global
                     *
                     * Now start looking at the rest and determine what needs to
                     * be updated
                     */

                    b = (IsDlgButtonChecked(hDlg,ID_KD_ENABLE) != 0);
                    if (b != KdParams->fEnable) {
                        KdParams->fEnable = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_GOEXIT) != 0);
                    if (b != KdParams->fGoExit) {
                        KdParams->fGoExit = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_VERBOSE) != 0);
                    if (b != KdParams->fVerbose) {
                        KdParams->fVerbose = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_INITIALBP) != 0);
                    if (b != KdParams->fInitialBp) {
                        KdParams->fInitialBp = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_DEFER) != 0);
                    if (b != KdParams->fDefer) {
                        KdParams->fDefer = b;
                        fChange = TRUE;
                    }

                    b = (IsDlgButtonChecked(hDlg,ID_KD_MODEM) != 0);
                    if (b != KdParams->fUseModem) {
                        KdParams->fUseModem = b;
                        fChange = TRUE;
                    }

                    if (GetDlgItemText( hDlg, ID_KD_PORT, rgch, sizeof(rgch) )) {
                        for (i=0; i<KdMaxComPorts; i++) {
                            if (strcmp(KdComPorts[i],rgch)==0) {
                                KdParams->dwPort = i+1;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_BAUDRATE, rgch, sizeof(rgch) )) {
                        tmp = atol( rgch );
                        for (i=0; i<KdMaxBaudRates; i++) {
                            if (KdBaudRates[i] == tmp) {
                                KdParams->dwBaudRate = tmp;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_CACHE, rgch, sizeof(rgch) )) {
                        tmp = atol( rgch );
                        for (i=0; i<KdMaxCacheSizes; i++) {
                            if (KdCacheSizes[i] == tmp) {
                                KdParams->dwCache = tmp;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    if (GetDlgItemText( hDlg, ID_KD_PLATFORM, rgch, sizeof(rgch) )) {
                        for (i=0; i<KdMaxPlatforms; i++) {
                            if (strcmp(KdPlatforms[i],rgch)==0) {
                                KdParams->dwPlatform = i;
                                fChange = TRUE;
                                break;
                            }
                        }
                    }

                    EndDialog(hDlg, TRUE);
                    return (TRUE);

                case IDCANCEL:
                    EndDialog(hDlg, TRUE);
                    return (TRUE);

#if 0
                case IDHELP:                /* User Help */
                    Dbg(WinHelp(hDlg, szHelpFileName, (DWORD) HELP_CONTEXT,(DWORD)ID_DBUGOPT_HELP));
                    return (TRUE);
#endif

                default:
                    break;
            }
            break;
    }
    return FALSE;
}
Exemplo n.º 12
0
//創建CAPS和SHIFT鍵都未觸發的鍵盤
static void CreateKbd (HWND hWnd)
{
	HWND            cb1, cb2, cb3, cb4, cb5;
	COOLBARITEMINFO item;
	int             i;

	cb1 = CreateWindow(CTRL_COOLBAR,
			   "",
			   WS_CHILD | WS_VISIBLE | CBS_BMP_16X16,
			   IDC_KB,
			   0, 0, 230, 16,
			   hWnd,
			   0);

	cb2 = CreateWindow(CTRL_COOLBAR,
			   "",
			   WS_CHILD | WS_VISIBLE,
			   IDC_KB,
			   0, 22, 230, 16,
			   hWnd,
			   0);

	cb3 = CreateWindow(CTRL_COOLBAR,
			   "",
			   WS_CHILD | WS_VISIBLE,
			   IDC_KB,
			   0, 44, 230, 16,
			   hWnd,
			   0);

	cb4 = CreateWindow(CTRL_COOLBAR,
			   "",
			   WS_CHILD | WS_VISIBLE,
			   IDC_KB,
			   0, 66, 230, 16,
			   hWnd,
			   0);

	item.ItemType  = TYPE_TEXTITEM;
	item.Bmp       = NULL;
	item.dwAddData = 0;
	item.ItemHint  = NULL;
	for (i = 0; i < KBL1; i++) {
		item.insPos  = i;
		item.id      = i;
		item.Caption = caption[i];
		SendMessage(cb1, CBM_ADDITEM, 0, (LPARAM)&item);
	}

	for (i = KBL1; i < KBL1 + KBL2; i++) {
		item.insPos  = i;
		item.id      = i;
		item.Caption = caption[i];
		SendMessage(cb2, CBM_ADDITEM, 0, (LPARAM)&item);
	}

	for (i = KBL1 + KBL2; i < KBL1 + KBL2 + KBL3; i++) {
		item.insPos  = i;
		item.id      = i;
		item.Caption = caption[i];
		SendMessage(cb3, CBM_ADDITEM, 0, (LPARAM)&item);
	}

	for (i = KBL1 + KBL2 + KBL3; i < KBL1 + KBL2 + KBL3 + KBL4; i++) {
		item.insPos  = i;
		item.id      = i;
		item.Caption = caption[i];
		SendMessage(cb4, CBM_ADDITEM, 0, (LPARAM)&item);
	}
}
Exemplo n.º 13
0
static LRESULT CALLBACK ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	const char *cmdString;
	static qboolean s_timePolarity;

	switch (uMsg)
	{
	case WM_ACTIVATE:
		if ( LOWORD( wParam ) != WA_INACTIVE )
		{
			SetFocus( s_wcd.hwndInputLine );
		}

		if ( com_viewlog && ( com_dedicated && !com_dedicated->integer ) )
		{
			// if the viewlog is open, check to see if it's being minimized
			if ( com_viewlog->integer == 1 )
			{
				if ( HIWORD( wParam ) )		// minimized flag
				{
					Cvar_Set( "viewlog", "2" );
				}
			}
			else if ( com_viewlog->integer == 2 )
			{
				if ( !HIWORD( wParam ) )		// minimized flag
				{
					Cvar_Set( "viewlog", "1" );
				}
			}
		}
		break;

	case WM_CLOSE:
		if ( ( com_dedicated && com_dedicated->integer ) )
		{
			cmdString = CopyString( "quit" );
			Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, (void *)cmdString );
		}
		else if ( s_wcd.quitOnClose )
		{
			PostQuitMessage( 0 );
		}
		else
		{
			Sys_ShowConsole( 0, qfalse );
			Cvar_Set( "viewlog", "0" );
		}
		return 0;
	case WM_CTLCOLORSTATIC:
		if ( ( HWND ) lParam == s_wcd.hwndBuffer )
		{
			SetBkColor( ( HDC ) wParam, RGB( 0, 0, 0 ) );
			SetTextColor( ( HDC ) wParam, RGB( 249, 249, 000 ) );
			return ( long ) s_wcd.hbrEditBackground;
		}
		else if ( ( HWND ) lParam == s_wcd.hwndErrorBox )
		{
			if ( s_timePolarity & 1 )
			{
				SetBkColor(   ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
				SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x00, 0x00 ) );
			}
			else
			{
				SetBkColor(   ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
				SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x00, 0x00 ) );
			}
			return ( long ) s_wcd.hbrErrorBackground;
		}
		return FALSE;
		break;

	case WM_COMMAND:
		if ( wParam == COPY_ID )
		{
			SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
			SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
		}
		else if ( wParam == QUIT_ID )
		{
			if ( s_wcd.quitOnClose )
			{
				PostQuitMessage( 0 );
			}
			else
			{
				cmdString = CopyString( "quit" );
				Sys_QueEvent( 0, SE_CONSOLE, 0, 0, strlen( cmdString ) + 1, (void *)cmdString );
			}
		}
		else if ( wParam == CLEAR_ID )
		{
			SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
			SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" );
			UpdateWindow( s_wcd.hwndBuffer );
		}
		break;
	case WM_CREATE:
		s_wcd.hbrEditBackground =  CreateSolidBrush( RGB( 0x00, 0x00, 0x00 ) );
		s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );
		SetTimer( hWnd, 1, 1000, NULL );
		break;
	case WM_ERASEBKGND:
	    return DefWindowProc( hWnd, uMsg, wParam, lParam );
	case WM_TIMER:
		if ( wParam == 1 )
		{
			s_timePolarity = (qboolean)!s_timePolarity;
			if ( s_wcd.hwndErrorBox )
			{
				InvalidateRect( s_wcd.hwndErrorBox, NULL, FALSE );
			}
		}
		break;
    }

    return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
Exemplo n.º 14
0
/*
** Sys_CreateConsole
*/
void Sys_CreateConsole( void )
{
	HDC hDC;
	WNDCLASS wc;
	RECT rect;
	const char *DEDCLASS = "JAMP WinConsole";
	int nHeight;
	int swidth, sheight;
	int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;

	memset( &wc, 0, sizeof( wc ) );

	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC) ConWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = g_wv.hInstance;
	wc.hIcon         = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (HBRUSH__ *)COLOR_INACTIVEBORDER;
	wc.lpszMenuName  = 0;
	wc.lpszClassName = DEDCLASS;

	if ( !RegisterClass (&wc) )	{
		return;
	}

	rect.left = 0;
	rect.right = 600;
	rect.top = 0;
	rect.bottom = 450;
	AdjustWindowRect( &rect, DEDSTYLE, FALSE );

	hDC = GetDC( GetDesktopWindow() );
	swidth = GetDeviceCaps( hDC, HORZRES );
	sheight = GetDeviceCaps( hDC, VERTRES );
	ReleaseDC( GetDesktopWindow(), hDC );

	s_wcd.windowWidth = rect.right - rect.left + 1;
	s_wcd.windowHeight = rect.bottom - rect.top + 1;

	s_wcd.hWnd = CreateWindowEx( 0,
							   DEDCLASS,
							   CLIENT_CONSOLE_TITLE,
							   DEDSTYLE,
							   ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
							   NULL,
							   NULL,
							   g_wv.hInstance,
							   NULL );

	if ( s_wcd.hWnd == NULL )
	{
		return;
	}

	//
	// create fonts
	//
	hDC = GetDC( s_wcd.hWnd );
	nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);

	s_wcd.hfBufferFont = CreateFont( nHeight,
									  0,
									  0,
									  0,
									  FW_LIGHT,
									  0,
									  0,
									  0,
									  DEFAULT_CHARSET,
									  OUT_DEFAULT_PRECIS,
									  CLIP_DEFAULT_PRECIS,
									  DEFAULT_QUALITY,
									  FF_MODERN | FIXED_PITCH,
									  "Courier New" );

	ReleaseDC( s_wcd.hWnd, hDC );

	//
	// create the input line
	//
	s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | 
												ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP,
												6, 400, s_wcd.windowWidth-20, 20,
												s_wcd.hWnd, 
												( HMENU ) INPUT_ID,	// child window ID
												g_wv.hInstance, NULL );

	//
	// create the buttons
	//
	s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP,
												5, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) COPY_ID,	// child window ID
												g_wv.hInstance, NULL );
	SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "Copy" );

	s_wcd.hwndButtonClear = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP,
												82, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) CLEAR_ID,	// child window ID
												g_wv.hInstance, NULL );
	SendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) "Clear" );

	s_wcd.hwndButtonQuit = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | WS_TABSTOP,
												s_wcd.windowWidth-92, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) QUIT_ID,	// child window ID
												g_wv.hInstance, NULL );
	SendMessage( s_wcd.hwndButtonQuit, WM_SETTEXT, 0, ( LPARAM ) "Quit" );


	//
	// create the scrollbuffer
	//
	s_wcd.hwndBuffer = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | 
												ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_TABSTOP,
												6, 40, s_wcd.windowWidth-20, 354,
												s_wcd.hWnd, 
												( HMENU ) EDIT_ID,	// child window ID
												g_wv.hInstance, NULL );
	SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );

	s_wcd.SysInputLineWndProc = ( WNDPROC ) SetWindowLongPtr( s_wcd.hwndInputLine, GWLP_WNDPROC, ( long ) InputLineWndProc );
	SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
	SendMessage( s_wcd.hwndBuffer, EM_LIMITTEXT, ( WPARAM ) 0x7fff, 0 );

	ShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT);
	UpdateWindow( s_wcd.hWnd );
	SetForegroundWindow( s_wcd.hWnd );
	SetFocus( s_wcd.hwndInputLine );

	Field_Clear( &s_wcd.g_consoleField );
	s_wcd.g_consoleField.widthInChars = g_console_field_width;
	for ( int i = 0 ; i < COMMAND_HISTORY ; i++ ) {
		Field_Clear( &s_wcd.historyEditLines[i] );
		s_wcd.historyEditLines[i].widthInChars = g_console_field_width;
	}

	s_wcd.visLevel = 1;
}
Exemplo n.º 15
0
bool Syscon_Init() {
	HDC hDC;
	WNDCLASS wc;
	RECT rect;
	const char *DEDCLASS = "Q3 WinConsole";
	int nHeight;
	int swidth, sheight;
	int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;

	memset( &wc, 0, sizeof( wc ) );

	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC) ConWndProc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = GetModuleHandle(0);
//	wc.hIcon         = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));
	wc.hCursor       = LoadCursor (NULL,IDC_ARROW);
	wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
	wc.lpszMenuName  = 0;
	wc.lpszClassName = DEDCLASS;

	if ( !RegisterClass (&wc) )
		return false;

	rect.left = 0;
	rect.right = 540;
	rect.top = 0;
	rect.bottom = 450;
	AdjustWindowRect( &rect, DEDSTYLE, FALSE );

	hDC = GetDC( GetDesktopWindow() );
	swidth = GetDeviceCaps( hDC, HORZRES );
	sheight = GetDeviceCaps( hDC, VERTRES );
	ReleaseDC( GetDesktopWindow(), hDC );

	s_wcd.windowWidth = rect.right - rect.left + 1;
	s_wcd.windowHeight = rect.bottom - rect.top + 1;

	s_wcd.hWnd = CreateWindowEx( 0,
							   DEDCLASS,
							   "Game",
							   DEDSTYLE,
							   ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
							   NULL,
							   NULL,
							   GetModuleHandle(0),
							   NULL );

	if ( s_wcd.hWnd == NULL )
	{
		return false;
	}

	//
	// create fonts
	//
	hDC = GetDC( s_wcd.hWnd );
	nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);

	s_wcd.hfBufferFont = CreateFont( nHeight,
									  0,
									  0,
									  0,
									  FW_LIGHT,
									  0,
									  0,
									  0,
									  DEFAULT_CHARSET,
									  OUT_DEFAULT_PRECIS,
									  CLIP_DEFAULT_PRECIS,
									  DEFAULT_QUALITY,
									  FF_MODERN | FIXED_PITCH,
									  "Courier New" );

	ReleaseDC( s_wcd.hWnd, hDC );

	//
	// create the input line
	//
	s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | 
												ES_LEFT | ES_AUTOHSCROLL,
												6, 400, 528, 20,
												s_wcd.hWnd, 
												( HMENU ) INPUT_ID,	// child window ID
												GetModuleHandle(0), NULL );

	//
	// create the buttons
	//
	s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												5, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) COPY_ID,	// child window ID
												GetModuleHandle(0), NULL );
	SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "copy" );

	s_wcd.hwndButtonClear = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												82, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) CLEAR_ID,	// child window ID
												GetModuleHandle(0), NULL );
	SendMessage( s_wcd.hwndButtonClear, WM_SETTEXT, 0, ( LPARAM ) "clear" );

	s_wcd.hwndButtonQuit = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
												462, 425, 72, 24,
												s_wcd.hWnd, 
												( HMENU ) QUIT_ID,	// child window ID
												GetModuleHandle(0), NULL );
	SendMessage( s_wcd.hwndButtonQuit, WM_SETTEXT, 0, ( LPARAM ) "quit" );


	//
	// create the scrollbuffer
	//
	s_wcd.hwndBuffer = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | 
												ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY,
												6, 40, 526, 354,
												s_wcd.hWnd, 
												( HMENU ) EDIT_ID,	// child window ID
												GetModuleHandle(0), NULL );
	SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );

	s_wcd.SysInputLineWndProc = ( WNDPROC ) SetWindowLongPtr( s_wcd.hwndInputLine, GWLP_WNDPROC, (LONG_PTR) InputLineWndProc );
	SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );

	ShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT);
	UpdateWindow( s_wcd.hWnd );
	SetForegroundWindow( s_wcd.hWnd );
	SetFocus( s_wcd.hwndInputLine );

	s_wcd.visLevel = 1;

	con_redirectOutput(Syscon_Print);

	return true;
}
Exemplo n.º 16
0
//options page on miranda called
INT_PTR CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList;
	switch (msg) {
	case WM_INITDIALOG://initialize dialog, so set properties from db.
	{
		LVCOLUMN lvc = { 0 };
		LVITEM lvI = { 0 };
		TCHAR buff[256];
		bOptionsOpen = TRUE;
		TranslateDialogDefault(hwndDlg);//translate miranda function
#ifdef _WIN64
		mir_sntprintf(buff,_countof(buff),_T("%d.%d.%d.%d/64"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#else
		mir_sntprintf(buff, _T("%d.%d.%d.%d/32"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#endif
		SetDlgItemText(hwndDlg, IDC_VERSION, buff);
		LoadSettings();
		//connExceptionsTmp=LoadSettingsConnections();
		SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE);
		SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE);
		CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? BST_CHECKED : BST_UNCHECKED);

		SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor);
		SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor);
		if (!settingSetColours) {
			HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
			CheckDlgButton(hwndDlg, IDC_SETCOLOURS, BST_UNCHECKED);
			EnableWindow(hwnd, FALSE);
			hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
			EnableWindow(hwnd, FALSE);
		}
		SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON6), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON4), IMAGE_ICON, 16, 16, 0));
		SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON5), IMAGE_ICON, 16, 16, 0));
		// initialise and fill listbox
		hwndList = GetDlgItem(hwndDlg, IDC_STATUS);
		ListView_DeleteAllItems(hwndList);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
		// Initialize the LVCOLUMN structure.
		// The mask specifies that the format, width, text, and
		// subitem members of the structure are valid. 
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lvc.fmt = LVCFMT_LEFT;
		lvc.iSubItem = 0;
		lvc.pszText = TranslateT("Status");
		lvc.cx = 120;     // width of column in pixels
		ListView_InsertColumn(hwndList, 0, &lvc);
		// Some code to create the list-view control.
		// Initialize LVITEM members that are common to all
		// items. 
		lvI.mask = LVIF_TEXT;
		for (int i = 0; i < STATUS_COUNT; i++) {
			lvI.pszText = pcli->pfnGetStatusModeDescription(ID_STATUS_ONLINE + i, 0);
			lvI.iItem = i;
			ListView_InsertItem(hwndList, &lvI);
			ListView_SetCheckState(hwndList, i, settingStatus[i]);
		}

		connExceptionsTmp = LoadSettingsConnections();
		hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
		SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);

		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
		lvc.fmt = LVCFMT_LEFT;
		lvc.iSubItem = 0;
		lvc.cx = 120;     // width of column in pixels
		lvc.pszText = TranslateT("Application");
		ListView_InsertColumn(hwndList, 1, &lvc);
		lvc.pszText = TranslateT("Internal socket");
		ListView_InsertColumn(hwndList, 2, &lvc);
		lvc.pszText = TranslateT("External socket");
		ListView_InsertColumn(hwndList, 3, &lvc);
		lvc.pszText = TranslateT("Action");
		lvc.cx = 50;
		ListView_InsertColumn(hwndList, 4, &lvc);

		//fill exceptions list
		fillExceptionsListView(hwndDlg);
	}
	break;

	case WM_COMMAND://user changed something, so get changes to variables
		PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
		switch (LOWORD(wParam)) {
		case IDC_INTERVAL: settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break;
		case IDC_INTERVAL1: settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break;
		case IDC_RESOLVEIP: settingResolveIp = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break;
		case ID_CHK_DEFAULTACTION: settingDefaultAction = (BYTE)IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break;
		case ID_ADD:
		{
			struct CONNECTION *cur = (struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION));
			memset(cur, 0, sizeof(struct CONNECTION));
			cur->intExtPort = -1;
			cur->intIntPort = -1;
			cur->Pid = 0;
			cur->PName[0] = '*';
			cur->strExtIp[0] = '*';
			cur->strIntIp[0] = '*';

			if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur) == IDCANCEL) {
				mir_free(cur);
				cur = NULL;
			}
			else {
				cur->next = connExceptionsTmp;
				connExceptionsTmp = cur;
			}

			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), 0, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
		}
		break;

		case ID_DELETE:
		{
			int pos, pos1;
			struct CONNECTION *cur = connExceptionsTmp, *pre = NULL;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				pre = cur;
				cur = cur->next;
			}
			if (pre == NULL)
				connExceptionsTmp = connExceptionsTmp->next;
			else
				(pre)->next = cur->next;
			mir_free(cur);
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case ID_UP:
		{
			int pos, pos1;
			struct CONNECTION *cur = NULL, *pre = NULL, *prepre = NULL;

			cur = connExceptionsTmp;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				prepre = pre;
				pre = cur;
				cur = cur->next;
			}
			if (prepre != NULL)
			{
				pre->next = cur->next;
				cur->next = pre;
				prepre->next = cur;
			}
			else if (pre != NULL)
			{
				pre->next = cur->next;
				cur->next = pre;
				connExceptionsTmp = cur;
			}
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 - 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case ID_DOWN:
		{
			int pos, pos1;
			struct CONNECTION *cur = NULL, *pre = NULL;

			cur = connExceptionsTmp;

			pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
			if (pos == -1)break;
			pos1 = pos;
			while (pos--)
			{
				pre = cur;
				cur = cur->next;
			}
			if (cur == connExceptionsTmp&&cur->next != NULL)
			{
				connExceptionsTmp = cur->next;
				cur->next = cur->next->next;
				connExceptionsTmp->next = cur;
			}
			else if (cur->next != NULL)
			{
				struct CONNECTION *tmp = cur->next->next;
				pre->next = cur->next;
				cur->next->next = cur;
				cur->next = tmp;
			}
			fillExceptionsListView(hwndDlg);
			ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 + 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
			SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
			break;
		}
		case IDC_SETCOLOURS:
		{
			HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
			settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS);
			EnableWindow(hwnd, settingSetColours);
			hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
			EnableWindow(hwnd, settingSetColours);
			break;
		}
		case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); break;
		case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); break;

		}
		break;

	case WM_NOTIFY://apply changes so write it to db
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			switch (((LPNMHDR)lParam)->code) {
			case PSN_RESET:
				LoadSettings();
				deleteConnectionsTable(connExceptionsTmp);
				connExceptionsTmp = LoadSettingsConnections();
				return TRUE;

			case PSN_APPLY:
				db_set_dw(NULL, PLUGINNAME, "Interval", settingInterval);
				db_set_dw(NULL, PLUGINNAME, "PopupInterval", settingInterval1);
				db_set_b(NULL, PLUGINNAME, "PopupSetColours", settingSetColours);
				db_set_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)settingBgColor);
				db_set_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)settingFgColor);
				db_set_b(NULL, PLUGINNAME, "ResolveIp", settingResolveIp);
				db_set_b(NULL, PLUGINNAME, "FilterDefaultAction", settingDefaultAction);

				for (int i = 0; i < STATUS_COUNT; i++) {
					char buff[128];
					mir_snprintf(buff, "Status%d", i);
					settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE);
					db_set_b(0, PLUGINNAME, buff, settingStatus[i] ? 1 : 0);
				}
				if (WAIT_OBJECT_0 == WaitForSingleObject(hExceptionsMutex, 100)) {
					deleteConnectionsTable(connExceptions);
					saveSettingsConnections(connExceptionsTmp);
					connExceptions = connExceptionsTmp;
					connExceptionsTmp = LoadSettingsConnections();
					ReleaseMutex(hExceptionsMutex);
				}
				return TRUE;
			}
			break;
		}

		if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS) == ((LPNMHDR)lParam)->hwndFrom) {
			switch (((LPNMHDR)lParam)->code) {
			case NM_DBLCLK:
			{
				int pos, pos1;
				struct CONNECTION *cur = NULL;

				cur = connExceptionsTmp;

				pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
				if (pos == -1)break;
				pos1 = pos;
				while (pos--)
				{
					cur = cur->next;
				}
				DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur);
				fillExceptionsListView(hwndDlg);
				ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
				SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
				break;
			}
			}
		}

		if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) {
			switch (((LPNMHDR)lParam)->code) {
			case LVN_ITEMCHANGED:
				NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
				if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
		}
		break;

	case WM_DESTROY:
		bOptionsOpen = FALSE;
		deleteConnectionsTable(connExceptionsTmp);
		connExceptionsTmp = NULL;
		return TRUE;
	}
	return 0;
}
Exemplo n.º 17
0
/*
** Conbuf_AppendText
*/
void Syscon_Print(const char *pMsg) {
#define CONSOLE_BUFFER_SIZE		16384

	char buffer[CONSOLE_BUFFER_SIZE*2];
	char *b = buffer;
	const char *msg;
	int bufLen;
	int i = 0;
	static unsigned long s_totalChars;

	//
	// if the message is REALLY long, use just the last portion of it
	//
	if ( strlen( pMsg ) > CONSOLE_BUFFER_SIZE - 1 )
	{
		msg = pMsg + strlen( pMsg ) - CONSOLE_BUFFER_SIZE + 1;
	}
	else
	{
		msg = pMsg;
	}

	//
	// copy into an intermediate buffer
	//
	while ( msg[i] && ( ( b - buffer ) < sizeof( buffer ) - 1 ) )
	{
		if ( msg[i] == '\n' && msg[i+1] == '\r' )
		{
			b[0] = '\r';
			b[1] = '\n';
			b += 2;
			i++;
		}
		else if ( msg[i] == '\r' )
		{
			b[0] = '\r';
			b[1] = '\n';
			b += 2;
		}
		else if ( msg[i] == '\n' )
		{
			b[0] = '\r';
			b[1] = '\n';
			b += 2;
		}
		//else if ( Q_IsColorString( &msg[i] ) )
		//{
		//	i++;
		//}
		else
		{
			*b= msg[i];
			b++;
		}
		i++;
	}
	*b = 0;
	bufLen = int(b - buffer);

	s_totalChars += bufLen;

	//
	// replace selection instead of appending if we're overflowing
	//
	if ( s_totalChars > 0x7fff )
	{
		SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
		s_totalChars = bufLen;
	}

	//
	// put this text into the windows console
	//
	SendMessage( s_wcd.hwndBuffer, EM_LINESCROLL, 0, 0xffff );
	SendMessage( s_wcd.hwndBuffer, EM_SCROLLCARET, 0, 0 );
	SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, 0, (LPARAM) buffer );
}
Exemplo n.º 18
0
static void test_gettext(void)
{
    HWND hwnd, notify;
    TTTOOLINFOA toolinfoA;
    TTTOOLINFOW toolinfoW;
    LRESULT r;
    CHAR bufA[10] = "";
    WCHAR bufW[10] = { 0 };
    static const CHAR testtipA[] = "testtip";

    notify = create_parent_window();
    ok(notify != NULL, "Expected notification window to be created\n");

    /* For bug 14790 - lpszText is NULL */
    hwnd = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);
    assert(hwnd);

    /* use sizeof(TTTOOLINFOA) instead of TTTOOLINFOA_V1_SIZE so that adding it fails on Win9x */
    /* otherwise it crashes on the NULL lpszText */
    toolinfoA.cbSize = sizeof(TTTOOLINFOA);
    toolinfoA.hwnd = NULL;
    toolinfoA.hinst = GetModuleHandleA(NULL);
    toolinfoA.uFlags = 0;
    toolinfoA.uId = 0x1234ABCD;
    toolinfoA.lpszText = NULL;
    toolinfoA.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &toolinfoA.rect);
    r = SendMessageA(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoA);
    if (r)
    {
        toolinfoA.hwnd = NULL;
        toolinfoA.uId = 0x1234ABCD;
        toolinfoA.lpszText = bufA;
        SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
        ok(strcmp(toolinfoA.lpszText, "") == 0, "lpszText should be an empty string\n");
    }
    else
    {
        win_skip( "Old comctl32, not testing NULL text\n" );
        DestroyWindow( hwnd );
        return;
    }

    /* add another tool with text */
    toolinfoA.cbSize = sizeof(TTTOOLINFOA);
    toolinfoA.hwnd = NULL;
    toolinfoA.hinst = GetModuleHandleA(NULL);
    toolinfoA.uFlags = 0;
    toolinfoA.uId = 0x1235ABCD;
    strcpy(bufA, testtipA);
    toolinfoA.lpszText = bufA;
    toolinfoA.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &toolinfoA.rect);
    r = SendMessageA(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoA);
    ok(r, "Adding the tool to the tooltip failed\n");
    if (r)
    {
        DWORD length;

        length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
        ok(length == 0, "Expected 0, got %d\n", length);

        toolinfoA.hwnd = NULL;
        toolinfoA.uId = 0x1235ABCD;
        toolinfoA.lpszText = bufA;
        SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
        ok(strcmp(toolinfoA.lpszText, testtipA) == 0, "lpszText should be an empty string\n");

        length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0);
        ok(length == 0, "Expected 0, got %d\n", length);
    }

    /* add another with callback text */
    toolinfoA.cbSize = sizeof(TTTOOLINFOA);
    toolinfoA.hwnd = notify;
    toolinfoA.hinst = GetModuleHandleA(NULL);
    toolinfoA.uFlags = 0;
    toolinfoA.uId = 0x1236ABCD;
    toolinfoA.lpszText = LPSTR_TEXTCALLBACKA;
    toolinfoA.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &toolinfoA.rect);
    r = SendMessageA(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoA);
    ok(r, "Adding the tool to the tooltip failed\n");
    if (r)
    {
        toolinfoA.hwnd = notify;
        toolinfoA.uId = 0x1236ABCD;
        toolinfoA.lpszText = bufA;
        SendMessageA(hwnd, TTM_GETTEXTA, 0, (LPARAM)&toolinfoA);
        ok(strcmp(toolinfoA.lpszText, testcallbackA) == 0,
           "lpszText should be an (%s) string\n", testcallbackA);
    }

    DestroyWindow(hwnd);
    DestroyWindow(notify);

    SetLastError(0xdeadbeef);
    hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0,
                           10, 10, 300, 100,
                           NULL, NULL, NULL, 0);

    if (!hwnd && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
        win_skip("CreateWindowExW is not implemented\n");
        return;
    }

    assert(hwnd);

    toolinfoW.cbSize = sizeof(TTTOOLINFOW);
    toolinfoW.hwnd = NULL;
    toolinfoW.hinst = GetModuleHandleA(NULL);
    toolinfoW.uFlags = 0;
    toolinfoW.uId = 0x1234ABCD;
    toolinfoW.lpszText = NULL;
    toolinfoW.lParam = 0xdeadbeef;
    GetClientRect(hwnd, &toolinfoW.rect);
    r = SendMessageW(hwnd, TTM_ADDTOOL, 0, (LPARAM)&toolinfoW);
    ok(r, "Adding the tool to the tooltip failed\n");

    if (0)  /* crashes on NT4 */
    {
        toolinfoW.hwnd = NULL;
        toolinfoW.uId = 0x1234ABCD;
        toolinfoW.lpszText = bufW;
        SendMessageW(hwnd, TTM_GETTEXTW, 0, (LPARAM)&toolinfoW);
        ok(toolinfoW.lpszText[0] == 0, "lpszText should be an empty string\n");
    }

    DestroyWindow(hwnd);
}
Exemplo n.º 19
0
static LRESULT WINAPI ConWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	//char *cmdString;
	static bool s_timePolarity;

	switch (uMsg)
	{
	case WM_ACTIVATE:
		if ( LOWORD( wParam ) != WA_INACTIVE )
		{
			SetFocus( s_wcd.hwndInputLine );
		}

		break;
    case WM_CLOSE:
        DestroyWindow(hWnd);
    break;
    case WM_DESTROY:
        PostQuitMessage(0);
    break;

	//case WM_CLOSE:
	//	PostQuitMessage( 0 );
	//	return 0;
	case WM_CTLCOLORSTATIC:
		if ( ( HWND ) lParam == s_wcd.hwndBuffer )
		{
			SetBkColor( ( HDC ) wParam, RGB( 0x00, 0x00, 0xB0 ) );
			SetTextColor( ( HDC ) wParam, RGB( 0xff, 0xff, 0x00 ) );
			return ( long ) s_wcd.hbrEditBackground;
		}
		else if ( ( HWND ) lParam == s_wcd.hwndErrorBox )
		{
			if ( s_timePolarity & 1 )
			{
				SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
				SetTextColor( ( HDC ) wParam, RGB( 0xff, 0x0, 0x00 ) );
			}
			else
			{
				SetBkColor( ( HDC ) wParam, RGB( 0x80, 0x80, 0x80 ) );
				SetTextColor( ( HDC ) wParam, RGB( 0x00, 0x0, 0x00 ) );
			}
			return ( long ) s_wcd.hbrErrorBackground;
		}
		break;

	case WM_COMMAND:
		if ( wParam == COPY_ID )
		{
			SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
			SendMessage( s_wcd.hwndBuffer, WM_COPY, 0, 0 );
		}
		else if ( wParam == QUIT_ID )
		{
			//PostQuitMessage( 0 );
	        DestroyWindow(hWnd);
		}
		else if ( wParam == CLEAR_ID )
		{
			SendMessage( s_wcd.hwndBuffer, EM_SETSEL, 0, -1 );
			SendMessage( s_wcd.hwndBuffer, EM_REPLACESEL, FALSE, ( LPARAM ) "" );
			UpdateWindow( s_wcd.hwndBuffer );
		}
		break;
	case WM_CREATE:
//		s_wcd.hbmLogo = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP1 ) );
//		s_wcd.hbmClearBitmap = LoadBitmap( g_wv.hInstance, MAKEINTRESOURCE( IDB_BITMAP2 ) );
		s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x00, 0x00, 0xB0 ) );
		s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );
		SetTimer( hWnd, 1, 1000, NULL );
		break;
//	case WM_ERASEBKGND:
//	    return DefWindowProc( hWnd, uMsg, wParam, lParam );
	case WM_TIMER:
		if ( wParam == 1 )
		{
			s_timePolarity = !s_timePolarity;
			if ( s_wcd.hwndErrorBox )
			{
				InvalidateRect( s_wcd.hwndErrorBox, NULL, FALSE );
			}
		}
		break;
    }

    return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
Exemplo n.º 20
0
void DDEQuikServerWrap::switchDDEOff()
{
	
	SendMessage(hWnd_m, UWM_UNSUBSCRIBE_DDE, 0, (LPARAM)this);
}
Exemplo n.º 21
0
void RSpeechRecognition::CallbackRule()
{
	USES_CONVERSION;
	HRESULT hr;
	std::string dictationString;

	CSpEvent ruleEvent;
	hr = ruleEvent.GetFrom( this->RuleRecoCtxt );
	if ( FAILED(hr) )	return ;

	//認識した結果
	ISpRecoResult* result;
	result = ruleEvent.RecoResult();

	//認識した文字列の取得
	CSpDynamicString dstrText;
	hr = result->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &dstrText, NULL);
	if ( FAILED(hr) )	return ;
	this->ResultString = W2A(dstrText);

	//ルールベースで認識した結果の音声部分をもう一度 ディクテーションにかけます。
	//これで過剰なマッチを排除します。
	{
		CComPtr<ISpStreamFormat>	resultStream;
		hr = result->GetAudio( 0, 0, &resultStream );
		if ( FAILED(hr) )	return;

		//オーディオから読み込んでね
		hr = this->DictationEngine->SetInput( resultStream, TRUE);  
		if(FAILED(hr))	 return;

		hr = this->DictationGrammar->SetDictationState(SPRS_ACTIVE );
		if(FAILED(hr))	 return;

		hr = this->DictationRecoCtxt->WaitForNotifyEvent(10000); //10秒タイムアウト
		if ( FAILED(hr) )	return;

		hr = this->DictationGrammar->SetDictationState(SPRS_INACTIVE );
		if(FAILED(hr))	 return;

		CSpEvent tempevent;
		hr = tempevent.GetFrom( this->DictationRecoCtxt );
		if ( FAILED(hr) )	return ;

		//認識した結果
		ISpRecoResult* tempresult;
		tempresult = tempevent.RecoResult();

		//認識した文字列の取得
		CSpDynamicString tempdstrText;
		hr = tempresult->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &tempdstrText, NULL);
		if ( FAILED(hr) )	return ;
		std::string dictationString = W2A(tempdstrText);
		//ディクテーションフィルターで絞る
		if ( dictationString.find(this->DicticationFilterWord) == std::string::npos )
		{
			//フィルターにより拒否
			this->FlagCleanup();
			return ;
		}
	}


	//認識に XMLを使用した場合、代入された結果を得る.
	SPPHRASE *pPhrase;
	hr = result->GetPhrase(&pPhrase);
	if ( FAILED(hr) )	return ;

	this->ResultMap.clear();
	const SPPHRASEPROPERTY *pProp;
	for (pProp = pPhrase->pProperties; pProp; pProp = pProp->pNextSibling)
	{
		this->ResultMap[ W2A(pProp->pszName) ] = W2A(pProp->pszValue);
	}
	CoTaskMemFree(pPhrase);

	//コマンド認識
	SendMessage(this->CallbackWindowHandle , this->CallbackWindowMesage , 0 , 0);
	this->FlagCleanup();
}
Exemplo n.º 22
0
static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    HWND wdg;
    POINT cursor;
    gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    playlist_t *pl = gui ? gui->playlist : NULL;
    switch (iMsg)
    {
        case WM_CREATE:
        {
            wdg = CreateWindow("button", "Play",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               4, 10, 80, 25, hwnd,
                               (HMENU) ID_PLAY,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            wdg = CreateWindow ("button", "Up",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 37, 80, 25, hwnd,
                                (HMENU) ID_UP,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            wdg = CreateWindow ("button", "Down",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 64, 80, 25, hwnd,
                                (HMENU) ID_DOWN,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);

            wdg = CreateWindow ("button", "Remove",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 91, 80, 25, hwnd,
                                (HMENU) ID_REMOVE,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);

            wdg = CreateWindow ("button", "Load",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 118, 80, 25, hwnd,
                                (HMENU) ID_PLAYLISTLOAD,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);

            wdg = CreateWindow ("button", "Save",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 145, 80, 25, hwnd,
                                (HMENU) ID_PLAYLISTSAVE,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);

            wdg = CreateWindow ("button", "Close",
                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                                4, 193, 80, 25, hwnd,
                                (HMENU) ID_CLOSE,
                                ((LPCREATESTRUCT) lParam) -> hInstance,
                                NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);

            wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL |
                               WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST,
                               ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
            SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0);
            break;
        }
        case WM_CONTEXTMENU:
        {
            GetCursorPos(&cursor);
            SetForegroundWindow(hwnd);
            TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL);
            break;
        }
        case WM_COMMAND:
        {
            int selected = 0;
            int i;
            for (i=0; i<pl->trackcount; i++)
                if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1;
            switch (LOWORD(wParam))
            {
                case ID_CLOSE:
                    DestroyWindow(hwnd);
                    return 0;
                case ID_TRACKLIST:
                    if(HIWORD(wParam) == LBN_DBLCLK)
                    {
                case ID_PLAY:
                        if(selected) pl->current = selected - 1;
                        uiSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_STREAM);
                        gui->startplay(gui);
                    }
                    return 0;
                case ID_UP:
                {
                    if(selected) pl->moveup_track(pl, selected);
                    selected--;
                    break;
                }
                case ID_DOWN:
                {
                    if(selected) pl->movedown_track(pl, selected);
                    selected++;
                    break;
                }
                case ID_REMOVE:
                    if(selected) pl->remove_track(pl, selected);
                    break;
                case ID_ADDFILE:
                {
                    if(guiInfo.StreamType == STREAMTYPE_DVD ||
                       guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0;
                    display_openfilewindow(gui, 1);
                    break;
                }
                case ID_ADDURL:
                {
                    if(guiInfo.StreamType == STREAMTYPE_DVD ||
                       guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0;
                    display_openurlwindow(gui, 1);
                    break;
                }
                case ID_CLEAR:
                {
                    if(!gui->playlist->trackcount) return 0;
                    gui->playlist->clear_playlist(gui->playlist);
                    break;
                }
                case ID_PLAYLISTLOAD:
                {
                    if(guiInfo.StreamType == STREAMTYPE_DVD ||
                       guiInfo.StreamType == STREAMTYPE_DVDNAV) return 0;
                    display_loadplaylistwindow(gui);
                    break;
                }
                case ID_PLAYLISTSAVE:
                {
                    /* no point saving an empty playlist */
                    if(!gui->playlist->trackcount ||
                        guiInfo.StreamType == STREAMTYPE_DVD ||
                        guiInfo.StreamType == STREAMTYPE_DVDNAV)
                        return 0;
                    display_saveplaylistwindow(gui);
                    break;
                }
            }
            updatetracklist(hwnd);
            if(selected < 1) selected = 1;
            else if(selected>pl->trackcount) selected = pl->trackcount;
            SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_SETCURSEL, selected - 1, 0);
            return 0;
        }
        case WM_DROPFILES:
        {
            char file[MAX_PATH];
            int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH);
            int i;
            for (i=0; i<filecount; i++)
            {
                DragQueryFile((HDROP) wParam, i, file, MAX_PATH);
                if(!parse_filename(file, playtree, mconfig, 0))
                    pl->add_track(pl, file, NULL, NULL, 0);
            }
            DragFinish((HDROP) wParam);
            updatetracklist(hwnd);
        }
            break;
    }
    return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Exemplo n.º 23
0
static INT_PTR CALLBACK AvatarDlgProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hwnd, IDC_AVATARLIST);

	switch(uMsg) {
	case WM_INITDIALOG:
		{
			AvatarDialogData *data = (struct AvatarDialogData*) lParam;
			SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)createDefaultOverlayedIcon(TRUE));
			SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)createDefaultOverlayedIcon(FALSE));
			if (db_get_b(NULL, MODULE_NAME, "LogToHistory", AVH_DEF_LOGTOHISTORY))
				FillAvatarListFromDB(hwndList, data->hContact);
			else if (opts.log_store_as_hash)
				FillAvatarListFromFolder(hwndList, data->hContact);
			else
				FillAvatarListFromFiles(hwndList, data->hContact);

			TCHAR *displayName = pcli->pfnGetContactDisplayName(data->hContact, 0);
			if (displayName) {
				TCHAR title[MAX_PATH];
				mir_sntprintf(title, _countof(title), TranslateT("Avatar History for %s"), displayName);
				SetWindowText(hwnd, title);
			}

			SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data->hContact);
			UpdateAvatarPic(hwnd);
			CheckDlgButton(hwnd, IDC_LOGUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToDisk", BST_INDETERMINATE));
			CheckDlgButton(hwnd, IDC_POPUPUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "AvatarPopups", BST_INDETERMINATE));
			CheckDlgButton(hwnd, IDC_HISTORYUSER, (UINT)db_get_b(data->hContact, MODULE_NAME, "LogToHistory", BST_INDETERMINATE));
			ShowWindow(GetDlgItem(hwnd, IDC_OPENFOLDER), opts.log_per_contact_folders ? SW_SHOW : SW_HIDE);
			Utils_RestoreWindowPositionNoSize(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog");
			WindowList_Add(hAvatarWindowsList,hwnd,data->hContact);
			TranslateDialogDefault(hwnd);
			EnableDisableControls(hwnd);
			free(data);
			data = NULL;
		}
		break;

	case WM_CLOSE:
		CleanupAvatarPic(hwnd);
		EndDialog(hwnd, 0);
		return TRUE;

	case WM_DESTROY:
		Utils_SaveWindowPosition(hwnd,NULL,MODULE_NAME,"AvatarHistoryDialog");
		WindowList_Remove(hAvatarWindowsList,hwnd);
		DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0));
		DestroyIcon((HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0));
		{
			int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0);
			for(int i = 0; i < count; i++)
				delete (ListEntry*)SendMessage(hwndList, LB_GETITEMDATA, i, 0);
		}
		break;

	case WM_CONTEXTMENU:
		{
			HWND pic = GetDlgItem(hwnd, IDC_AVATAR);
			int pos;

			if ((HANDLE)wParam == hwndList) {
				POINT p = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
				ScreenToClient(hwndList, &p);

				pos = SendMessage(hwndList, LB_ITEMFROMPOINT, 0, MAKELONG(p.x, p.y));
				if (HIWORD(pos))
					break;
				pos = LOWORD(pos);

				int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0);
				if (pos >= count)
					break;

				SendMessage(hwndList, LB_SETCURSEL, pos, 0);
				EnableDisableControls(hwnd);
			}
			else if ((HANDLE) wParam == pic) {
				pos = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
				if (pos == LB_ERR)
					break;
			}
			else break;

			HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1));
			HMENU submenu = GetSubMenu(menu, 0);
			TranslateMenu(submenu);

			if (!UpdateAvatarPic(hwnd)) {
				RemoveMenu(submenu, 2, MF_BYPOSITION);
				RemoveMenu(submenu, 0, MF_BYPOSITION);
			}

			POINT p;
			p.x = LOWORD(lParam); 
			p.y = HIWORD(lParam); 
			int ret = TrackPopupMenu(submenu, TPM_TOPALIGN|TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, p.x, p.y, 0, hwndList, NULL);
			DestroyMenu(menu);

			ListEntry *le = (ListEntry*) SendMessage(hwndList, LB_GETITEMDATA, pos, 0);
			MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA);
			switch(ret) {
			case ID_AVATARLISTPOPUP_SAVEAS:
				ShowSaveDialog(hwnd, le->filename, hContact);
				break;

			case ID_AVATARLISTPOPUP_DELETE:
				{
					BOOL blDelete;

					if (le->hDbEvent)
						blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this history entry?\nOnly the entry in history will be deleted, bitmap file will be kept!"), 
						TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES;
					else
						blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this avatar shortcut?\nOnly shortcut will be deleted, bitmap file will be kept!"), 
						TranslateT("Delete avatar log?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES;

					if (blDelete) {
						if (le->hDbEvent)
							db_event_delete(hContact, le->hDbEvent);
						else
							DeleteFile(le->filelink);

						delete le;

						SendMessage(hwndList, LB_DELETESTRING, pos, 0);

						int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0);
						if (count > 0) {
							if (pos >= count)
								pos = count -1;
							SendMessage(hwndList, LB_SETCURSEL, pos, 0);
						}

						UpdateAvatarPic(hwnd);
						EnableDisableControls(hwnd);
					}
				}
				break;

			case ID_AVATARLISTPOPUP_DELETE_BOTH:
				BOOL blDelete;

				if (le->hDbEvent)
					blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the history entry and the bitmap file.\nWARNING:This can affect more than one entry in history!"), 
					TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES;
				else
					blDelete = MessageBox(hwnd, TranslateT("Are you sure you wish to delete this archived avatar?\nThis will delete the shortcut and the bitmap file.\nWARNING:This can affect more than one shortcut!"), 
					TranslateT("Delete avatar?"), MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SETFOREGROUND|MB_TOPMOST) == IDYES;

				if (blDelete) {
					DeleteFile(le->filename);

					if (le->hDbEvent)
						db_event_delete(hContact, le->hDbEvent);
					else
						DeleteFile(le->filelink);

					delete le;

					SendMessage(hwndList, LB_DELETESTRING, pos, 0);

					int count = SendMessage(hwndList, LB_GETCOUNT, 0, 0);
					if (count > 0) {
						if (pos >= count)
							pos = count -1;
						SendMessage(hwndList, LB_SETCURSEL, pos, 0);
					}

					UpdateAvatarPic(hwnd);
					EnableDisableControls(hwnd);
				}
			}
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDOK:
			if (HIWORD(wParam) == BN_CLICKED) {
				MCONTACT hContact = (MCONTACT) GetWindowLongPtr(hwnd, GWLP_USERDATA);
				db_set_b(hContact, MODULE_NAME, "AvatarPopups", (BYTE) IsDlgButtonChecked(hwnd, IDC_POPUPUSER));
				db_set_b(hContact, MODULE_NAME, "LogToDisk", (BYTE) IsDlgButtonChecked(hwnd, IDC_LOGUSER));
				db_set_b(hContact, MODULE_NAME, "LogToHistory", (BYTE) IsDlgButtonChecked(hwnd, IDC_HISTORYUSER));

				CleanupAvatarPic(hwnd);
				EndDialog(hwnd, 0);
				return TRUE;
			}
			break;

		case IDC_AVATARLIST:
			if (HIWORD(wParam) == LBN_SELCHANGE) {
				UpdateAvatarPic(hwnd);
				EnableDisableControls(hwnd);
				return TRUE;
			}
			break;

		case IDC_OPENFOLDER:
			if (HIWORD(wParam) == BN_CLICKED && opts.log_per_contact_folders) {
				TCHAR avfolder[MAX_PATH];
				MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
				GetContactFolder(avfolder, hContact);
				ShellExecute(NULL, db_get_b(NULL, MODULE_NAME, "OpenFolderMethod", 0) ? _T("explore") : _T("open"), avfolder, NULL, NULL, SW_SHOWNORMAL);
				return TRUE;
			}
			break;

		case IDC_NEXT:
			if (HIWORD(wParam) == BN_CLICKED) {
				SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCURSEL, 0, 0) +1, 0);
				UpdateAvatarPic(hwnd);
				EnableDisableControls(hwnd);
				return TRUE;
			}
			break;

		case IDC_BACK:
			if (HIWORD(wParam) == BN_CLICKED) {
				int cursel = SendMessage(hwndList, LB_GETCURSEL, 0, 0);
				if (cursel == LB_ERR)
					SendMessage(hwndList, LB_SETCURSEL, SendMessage(hwndList, LB_GETCOUNT, 0, 0) -1, 0);
				else
					SendMessage(hwndList, LB_SETCURSEL, cursel -1, 0);
				UpdateAvatarPic(hwnd);
				EnableDisableControls(hwnd);
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}
Exemplo n.º 24
0
static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
    static HWND title;
    static HWND chapter;
    HWND wdg;
    int i=0, j=0;
    char titles[MAX_PATH] = "";
    char chapters[MAX_PATH] = "";
    gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
    switch (iMsg)
    {
        case WM_CREATE:
            wdg = CreateWindow("button", "Ok",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               4, 43, 80, 25, hwnd,
                               (HMENU) ID_OK,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
                              SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            wdg = CreateWindow("button", "Cancel",
                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
                               90, 43, 80, 25, hwnd,
                               (HMENU) ID_CANCEL,
                               ((LPCREATESTRUCT) lParam) -> hInstance,
                               NULL);
                              SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            title = CreateWindow("combobox", NULL,
                                 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
                                 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
                                 4, 10, 80, 160, hwnd,
                                 (HMENU) ID_TITLESEL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance,
                                 NULL);

            SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            chapter = CreateWindow("combobox", NULL,
                                 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
                                 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
                                 90, 10, 80, 160, hwnd,
                                 (HMENU) ID_CHAPTERSEL,
                                 ((LPCREATESTRUCT) lParam) -> hInstance,
                                 NULL);
            SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);

            for (i=0; i<guiInfo.DVD.titles; i++)
            {
                /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */
                sprintf(&titles[i], "%d", guiInfo.DVD.titles - i);
                SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]);
            }
            SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0);

            for (j=0; j<guiInfo.DVD.chapters; j++)
            {
                sprintf(&chapters[j], "%d", guiInfo.DVD.chapters - j);
                SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]);
            }
            SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0);

            break;
        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case ID_CANCEL:
                    DestroyWindow(hwnd);
                    return 0;
                case ID_OK:
                {
                    guiInfo.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1;
                    guiInfo.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1;

                    if((guiInfo.DVD.current_title != 0 || guiInfo.DVD.current_chapter != 0))
                    {
                        gui->startplay(gui);
                        DestroyWindow(hwnd);
                    }
                }
                break;
            }
        }
        return 0;
    }
    return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
Exemplo n.º 25
0
LRESULT CALLBACK MainWndMsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_POWERBROADCAST:
		{
			SYSTEMTIME st;
			GetSystemTime(&st);

			switch(wParam)
			{
			/* Power status has changed. */
			case PBT_APMPOWERSTATUSCHANGE:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMPOWERSTATUSCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("1"), MB_OK);

					break;
				}
			/* Operation is resuming automatically from a low-power state. */
			/* This message is sent every time the system resumes. */
			case PBT_APMRESUMEAUTOMATIC:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMEAUTOMATIC %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("2"), MB_OK);

					break;
				}
			/* Operation is resuming from a low-power state. */
			/* This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key. */
			case PBT_APMRESUMESUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMESUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("3"), MB_OK);

					break;
				}
			/* System is suspending operation. */
			case PBT_APMSUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("4"), MB_OK);

					break;
				}
			/* A power setting change event has been received. */
			case PBT_POWERSETTINGCHANGE:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_POWERSETTINGCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("5"), MB_OK);

					break;
				}
			/* Battery power is low. In Windows Server 2008 and Windows Vista, use PBT_APMPOWERSTATUSCHANGE instead. */
			case PBT_APMBATTERYLOW:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMBATTERYLOW %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("6"), MB_OK);

					break;
				}
			/* OEM-defined event occurred. 
			/* In Windows Server 2008 and Windows Vista, this event is not available because these operating systems support only ACPI; 
			/* APM BIOS events are not supported. */
			case PBT_APMOEMEVENT:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMOEMEVENT %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("7"), MB_OK);

					break;
				}
			/* Request for permission to suspend. In Windows Server 2008 and Windows Vista, use the SetThreadExecutionState function instead. */
			case PBT_APMQUERYSUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMQUERYSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("8"), MB_OK);

					break;
				}
			/* Suspension request denied. In Windows Server 2008 and Windows Vista, use SetThreadExecutionState instead. */
			case PBT_APMQUERYSUSPENDFAILED:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMQUERYSUSPENDFAILED %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("9"), MB_OK);

					break;
				}
			/* Operation resuming after critical suspension. In Windows Server 2008 and Windows Vista, use PBT_APMRESUMEAUTOMATIC instead. */
			case PBT_APMRESUMECRITICAL:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMECRITICAL %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("10"), MB_OK);

					break;
				}
			default:
				{
					break;
				}
			}
			return 0;
			break;
		}
	case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED) {
				//SendMessage(hWndSpeedMultipleComboBox, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0);
			}

			if ( HIWORD(wParam) == CBN_SELCHANGE) {               
				LRESULT  sel = SendMessage(hWndSpeedMultipleComboBox, CB_GETCURSEL, 0, 0);
				//SetWindowText(hwndStatic, items[sel]);
				//SetFocus(hwnd);
			}

			break;
		}
	case WM_CREATE:
		{
			/* 为窗口添加扩展风格 WS_EX_LAYERED,从而为实现窗口透明做准备 */
			LONG lExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
			lExStyle = lExStyle | WS_EX_LAYERED;
			SetWindowLong(hWnd, GWL_EXSTYLE, lExStyle);

			/* 实现窗口透明 - 设置窗口透明度为 220 */
			SetLayeredWindowAttributes(hWnd, 0, WND_TRANSPARENCY, LWA_ALPHA);


			InitSpeedMultipleComboBox(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化 Tracker Bar */
			InitSpeedMultipleTrackBar(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化按钮 */
			InitButton(((LPCREATESTRUCT)lParam)->hInstance, hWnd);


			/* 初始化速度未改变的进程列表框 */
			InitNotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化速度已改变的进程列表框 */
			InitHasSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 绑定数据到速度未改变的进程列表框 */
			BindData2NotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance);

			break;
		}
	case WM_CTLCOLORSTATIC:
		{
			/* 使得静态文本框使用透明背景色 */
			return (DWORD)GetStockObject(NULL_BRUSH);
		}
		/*case WM_COMMAND:
		{
		switch (wParam)
		{
		case ID_BUTTON_INSERT_PROCESS:
		{
		DestroyWindow(hWnd);

		break;
		}
		case ID_BUTTON_REMOVE_PROCESS:
		{
		break;
		}
		case ID_BUTTON_REFRESH_PROCESS:
		{
		break;
		}
		default:
		{
		break;
		}
		}
		break;
		}*/
	case WM_CLOSE:
		{
			DestroyWindow(hWnd);

			break;
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0);

			break;
		}
	default:
		{
			break;
		}
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Exemplo n.º 26
0
/*
 * insertEditText - insert some text into the current edit window
 */
static void insertEditText( HWND hwnd, char *tmp )
{
    SendMessage( hwnd, EM_REPLACESEL, 0, (LPARAM)tmp );

} /* insertEditText */
Exemplo n.º 27
0
void CSMPackageInstallDlg::OnOK()
{
    // TODO: Add extra validation here

    int ProgressInit = 0;

    m_comboDir.EnableWindow( FALSE );
    m_buttonEdit.EnableWindow( FALSE );

    RString sInstallDir;
    {
        CString s;
        m_comboDir.GetWindowText( s );
        sInstallDir = s;
    }

    // selected install dir becomes the new default
    int iSelectedInstallDirIndex = m_comboDir.GetCurSel();
    if( iSelectedInstallDirIndex == -1 )
    {
        Dialog::OK( NO_INSTALLATIONS.GetValue() );
        return;
    }

    SMPackageUtil::SetDefaultInstallDir( iSelectedInstallDirIndex );


    // mount the zip
    RageFileOsAbsolute file;
    if( !file.Open(m_sPackagePath) )
    {
        Dialog::OK( ssprintf(COULD_NOT_OPEN_FILE.GetValue(),m_sPackagePath.c_str()) );
        exit(1);	// better way to abort?
    }

    RageFileDriverZip zip;
    if( !zip.Load(&file) )
    {
        Dialog::OK( ssprintf(IS_NOT_A_VALID_ZIP.GetValue(),m_sPackagePath.c_str()) );
        exit(1);	// better way to abort?
    }

    RageFileDriverDirect dir( sInstallDir );
    // handle error?

    // Show comment (if any)
    {
        RString sComment = zip.GetGlobalComment();
        bool DontShowComment;
        if( sComment != "" && (!SMPackageUtil::GetPref("DontShowComment", DontShowComment) || !DontShowComment) )
        {
            ShowComment commentDlg;
            commentDlg.m_sComment = sComment;
            int nResponse = commentDlg.DoModal();
            if( nResponse != IDOK )
                return;	// cancelled
            if( commentDlg.m_bDontShow )
                SMPackageUtil::SetPref( "DontShowComment", true );
        }
    }

    /* Check for installed packages that should be deleted before installing. */
    if( !CheckPackages(zip) )
        return;	// cancelled


    // Unzip the SMzip package into the installation folder
    vector<RString> vs;
    GetSmzipFilesToExtract( zip, vs );
    for( unsigned i=0; i<vs.size(); i++ )
    {
        // Throw some text up so the user has something to look at during the long pause.
        CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_STATIC_MESSAGE1);
        pEdit1->SetWindowText( ssprintf(INSTALLING_PLEASE_WAIT.GetValue(), m_sPackagePath.c_str()) );
        CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2);
        pEdit2->SetWindowText( "" );
        GetDlgItem(IDC_STATIC_MESSAGE2)->ShowWindow( SW_HIDE );
        CProgressCtrl* pProgress1 = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS1);
        //Show the hided progress bar
        if(!pProgress1->IsWindowVisible())
        {
            pProgress1->ShowWindow(SW_SHOWNORMAL);
        }
        //Initialize the progress bar and update the window 1 time (it's enough)
        if(!ProgressInit)
        {
            pProgress1->SetRange( 0, (short)vs.size() );
            pProgress1->SetStep(1);
            pProgress1->SetPos(0);
            SendMessage( WM_PAINT );
            UpdateWindow();		// Force the silly thing to hadle WM_PAINT now!
            ProgressInit = 1;
        }

        Dialog::Result result;
        do
        {
            // Extract the files
            const RString sFile = vs[i];
            LOG->Trace( "Extracting: "+sFile );

            RString sError;
            {
                int iErr;
                RageFileBasic *pFileFrom = zip.Open( sFile, RageFile::READ, iErr );
                if( pFileFrom == NULL )
                {
                    sError = ssprintf( ERROR_OPENING_SOURCE_FILE.GetValue(), sFile.c_str(), ssprintf("%d",iErr).c_str() );
                    goto show_error;
                }

                int iError;
                RageFileBasic *pFileTo = dir.Open( sFile, RageFile::WRITE, iError );
                if( pFileTo == NULL )
                {
                    sError = ssprintf( ERROR_OPENING_DESTINATION_FILE.GetValue(), sFile.c_str(), pFileTo->GetError().c_str() );
                    goto show_error;
                }

                RString sErr;
                if( !FileCopy(*pFileFrom, *pFileTo, sErr) )
                {
                    sError = ssprintf( ERROR_COPYING_FILE.GetValue(), sFile.c_str(), sErr.c_str() );
                    goto show_error;
                }

                SAFE_DELETE( pFileFrom );
                SAFE_DELETE( pFileTo );
            }

            break;

show_error:
            Dialog::Result result = Dialog::AbortRetryIgnore(sError);
            switch( result )
            {
            case Dialog::abort:
                exit(1);	// better way to exit?
                break;
            case Dialog::retry:
                break;
            case Dialog::ignore:
                // do nothing
                break;
            }
        } while( result == Dialog::retry );

        pProgress1->StepIt(); //increase the progress bar of 1 step
    }

    Dialog::OK( PACKAGE_INSTALLED_SUCCESSFULLY.GetValue() );

    // close the dialog
    CDialog::OnOK();
}
Exemplo n.º 28
0
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    if (msg == WM_TRAY) {
        if (lParam == WM_LBUTTONDOWN || lParam == WM_LBUTTONDBLCLK) {
            ToggleState();
            if (lParam == WM_LBUTTONDBLCLK && !(GetAsyncKeyState(VK_SHIFT)&0x8000)) {
                SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
            }
        }
        else if (lParam == WM_MBUTTONDOWN) {
            ShellExecute(NULL, L"open", inipath, NULL, NULL, SW_SHOWNORMAL);
        }
        else if (lParam == WM_RBUTTONDOWN) {
            ShowContextMenu(hwnd);
        }
        else if (lParam == NIN_BALLOONUSERCLICK) {
            hide = 0;
            SendMessage(hwnd, WM_COMMAND, SWM_UPDATE, 0);
        }
        else if (lParam == NIN_BALLOONTIMEOUT) {
            if (hide) {
                RemoveTray();
            }
        }
    }
    else if (msg == WM_UPDATESETTINGS) {
        UpdateLanguage();
        // Reload hooks
        if (ENABLED()) {
            UnhookSystem();
            HookSystem();
        }
        // Reload config language
        if (!wParam && IsWindow(g_cfgwnd)) {
            SendMessage(g_cfgwnd, WM_UPDATESETTINGS, 0, 0);
        }
    }
    else if (msg == WM_ADDTRAY) {
        hide = 0;
        UpdateTray();
    }
    else if (msg == WM_HIDETRAY) {
        hide = 1;
        RemoveTray();
    }
    else if (msg == WM_OPENCONFIG && (lParam || !hide)) {
        OpenConfig(wParam);
    }
    else if (msg == WM_CLOSECONFIG) {
        CloseConfig();
    }
    else if (msg == WM_TASKBARCREATED) {
        tray_added = 0;
        UpdateTray();
    }
    else if (msg == WM_COMMAND) {
        int wmId=LOWORD(wParam), wmEvent=HIWORD(wParam);
        if (wmId == SWM_TOGGLE) {
            ToggleState();
        }
        else if (wmId == SWM_HIDE) {
            hide = 1;
            RemoveTray();
        }
        else if (wmId == SWM_UPDATE) {
            if (MessageBox(NULL,l10n->update_dialog,APP_NAME,MB_ICONINFORMATION|MB_YESNO|MB_TOPMOST|MB_SETFOREGROUND) == IDYES) {
                OpenUrl(APP_URL);
            }
        }
        else if (wmId == SWM_CONFIG) {
            SendMessage(hwnd, WM_OPENCONFIG, 0, 0);
        }
        else if (wmId == SWM_ABOUT) {
            SendMessage(hwnd, WM_OPENCONFIG, 4, 0);
        }
        else if (wmId == SWM_EXIT) {
            DestroyWindow(hwnd);
        }
    }
    else if (msg == WM_QUERYENDSESSION && msghook) {
        showerror = 0;
        UnhookSystem();
    }
    else if (msg == WM_DESTROY) {
        showerror = 0;
        UnhookSystem();
        RemoveTray();
        PostQuitMessage(0);
    }
    else if (msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
        // Hide cursorwnd if clicked on, this might happen if it wasn't hidden by hooks.c for some reason
        ShowWindow(hwnd, SW_HIDE);
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}
Exemplo n.º 29
0
static LRESULT CALLBACK InputLineWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch ( uMsg )
	{
		case WM_KILLFOCUS:
			if ( ( HWND ) wParam == s_wcd.hWnd ||
				 ( HWND ) wParam == s_wcd.hwndErrorBox )
			{
				SetFocus( hWnd );
				return 0;
			}
			break;

		case WM_CHAR:
			GetWindowText( s_wcd.hwndInputLine, s_wcd.g_consoleField.buffer, sizeof( s_wcd.g_consoleField.buffer ) );
			SendMessage( s_wcd.hwndInputLine, EM_GETSEL, (WPARAM) NULL, (LPARAM) &s_wcd.g_consoleField.cursor );

			if ( wParam == VK_RETURN )
			{
				strncat( s_wcd.consoleText, s_wcd.g_consoleField.buffer, sizeof( s_wcd.consoleText ) - strlen( s_wcd.consoleText ) - 5 );
				strcat( s_wcd.consoleText, "\n" );
				SetWindowText( s_wcd.hwndInputLine, "" );

				Sys_Print( va( "%c%s\n", CONSOLE_PROMPT_CHAR, s_wcd.g_consoleField.buffer ) );

				// empty lines just scroll the console without adding to history
				if ( !s_wcd.g_consoleField.buffer[0] )
					return 0;

				// copy line to history buffer
				s_wcd.historyEditLines[s_wcd.nextHistoryLine % COMMAND_HISTORY] = s_wcd.g_consoleField;
				s_wcd.nextHistoryLine++;
				s_wcd.historyLine = s_wcd.nextHistoryLine;
				Field_Clear( &s_wcd.g_consoleField );
				s_wcd.g_consoleField.widthInChars = g_console_field_width;

				return 0;
			}

			if ( wParam == VK_TAB )
			{
				Field_AutoComplete( &s_wcd.g_consoleField );
				SetWindowText( s_wcd.hwndInputLine, s_wcd.g_consoleField.buffer );
				SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.g_consoleField.cursor, s_wcd.g_consoleField.cursor );
				return 0;
			}
		break;
		case WM_KEYDOWN:
			// history scrolling
			if ( wParam == VK_UP )
			{// scroll up: arrow-up
				if ( s_wcd.nextHistoryLine - s_wcd.historyLine < COMMAND_HISTORY && s_wcd.historyLine > 0 ) 
					s_wcd.historyLine--;
				s_wcd.g_consoleField = s_wcd.historyEditLines[s_wcd.historyLine % COMMAND_HISTORY];
				SetWindowText( s_wcd.hwndInputLine, s_wcd.g_consoleField.buffer );
				SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.g_consoleField.cursor, s_wcd.g_consoleField.cursor );

				return 0;
			}

			if ( wParam == VK_DOWN )
			{// scroll down: arrow-down
				s_wcd.historyLine++;
				if (s_wcd.historyLine >= s_wcd.nextHistoryLine) {
					s_wcd.historyLine = s_wcd.nextHistoryLine;
					Field_Clear( &s_wcd.g_consoleField );
					s_wcd.g_consoleField.widthInChars = g_console_field_width;
					SetWindowText( s_wcd.hwndInputLine, s_wcd.g_consoleField.buffer );
					SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.g_consoleField.cursor, s_wcd.g_consoleField.cursor );
					return 0;
				}
				s_wcd.g_consoleField = s_wcd.historyEditLines[s_wcd.historyLine % COMMAND_HISTORY];
				SetWindowText( s_wcd.hwndInputLine, s_wcd.g_consoleField.buffer );
				SendMessage( s_wcd.hwndInputLine, EM_SETSEL, s_wcd.g_consoleField.cursor, s_wcd.g_consoleField.cursor );

				return 0;
			}
			break;
	}

	return CallWindowProc( s_wcd.SysInputLineWndProc, hWnd, uMsg, wParam, lParam );
}
Exemplo n.º 30
-1
    bool setFont(const char * pFontName = nullptr, int nSize = 0)
    {
        bool bRet = false;
        do 
        {
            std::string fontName = pFontName;
            std::string fontPath;
            HFONT       hDefFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
            LOGFONTA    tNewFont = {0};
            LOGFONTA    tOldFont = {0};
            GetObjectA(hDefFont, sizeof(tNewFont), &tNewFont);
            if (fontName.c_str())
            {    
                // create font from ttf file
                int nFindttf = fontName.find(".ttf");
                int nFindTTF = fontName.find(".TTF");
                if (nFindttf >= 0 || nFindTTF >= 0)
                {
                    fontPath = FileUtils::getInstance()->fullPathForFilename(fontName.c_str());
                    int nFindPos = fontName.rfind("/");
                    fontName = &fontName[nFindPos+1];
                    nFindPos = fontName.rfind(".");
                    fontName = fontName.substr(0,nFindPos);                
                }
                else
                {
                    auto nFindPos = fontName.rfind("/");
                    if (nFindPos != fontName.npos)
                    {
                        if (fontName.length() == nFindPos + 1)
                        {
                            fontName = "";
                        } 
                        else
                        {
                            fontName = &fontName[nFindPos+1];
                        }
                    }
                }
                tNewFont.lfCharSet = DEFAULT_CHARSET;
                strcpy_s(tNewFont.lfFaceName, LF_FACESIZE, fontName.c_str());
            }
            if (nSize)
            {
                tNewFont.lfHeight = -nSize;
            }
            GetObjectA(_font,  sizeof(tOldFont), &tOldFont);

            if (tOldFont.lfHeight == tNewFont.lfHeight
                && 0 == strcmp(tOldFont.lfFaceName, tNewFont.lfFaceName))
            {
                // already has the font 
                bRet = true;
                break;
            }

            // delete old font
            removeCustomFont();

            if (fontPath.size() > 0)
            {
                _curFontPath = fontPath;
                wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
                if (pwszBuffer)
                {
                    if(AddFontResource(pwszBuffer))
                    {
                        SendMessage( _wnd, WM_FONTCHANGE, 0, 0);
                    }						
                    delete [] pwszBuffer;
                    pwszBuffer = nullptr;
                }
            }

            _font = nullptr;

            // disable Cleartype
            tNewFont.lfQuality = ANTIALIASED_QUALITY;

            // create new font
            _font = CreateFontIndirectA(&tNewFont);
            if (! _font)
            {
                // create failed, use default font
                _font = hDefFont;
                break;
            }

            bRet = true;
        } while (0);
        return bRet;
    }