HWND XAP_Win32DialogBase::createModeless(XAP_Frame* pFrame, LPCWSTR dlgTemplate)
{
	UT_ASSERT(m_tag == magic_tag);
   	UT_return_val_if_fail(pFrame, NULL);

	XAP_App* pApp = XAP_App::getApp();
	UT_return_val_if_fail(pApp, NULL);

	XAP_Win32App* pWin32App = static_cast<XAP_Win32App*>(pApp);

	XAP_FrameImpl* pFrameImpl = pFrame->getFrameImpl();

	XAP_Win32FrameImpl* pWin32FrameImpl = static_cast<XAP_Win32FrameImpl*>(pFrameImpl);

	HWND hFrameWnd = pWin32FrameImpl->getTopLevelWindow();

	HWND hWnd = CreateDialogParamW(pWin32App->getInstance(),
							dlgTemplate,
							hFrameWnd,
							(DLGPROC)&XAP_Win32DialogBase::s_dlgProc,
							(LPARAM)this);
	UT_return_val_if_fail(hWnd, NULL);

    m_hDlg = hWnd;
	showWindow(SW_SHOW);
	bringWindowToTop();

	return hWnd;
}
Beispiel #2
0
void copyModuleMenuItem(char* module, MCONTACT hContact)
{
	ModuleAndContact *mac = (ModuleAndContact *)mir_calloc(sizeof(ModuleAndContact));
	mac->hContact = hContact;
	strncpy(mac->module, module, 255);

	CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_COPY_MOD), 0, copyModDlgProc, (LPARAM)mac);
}
Beispiel #3
0
HWND WINAPI __CreateDialogParamW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) {
	DLGPROC proc = lpDialogFunc;
	if (g_bOutput && (lpTemplateName == MAKEINTRESOURCEW(IDD_SERVER))) {
		__Frameserver_StatusDlgProcOrig = lpDialogFunc;
		proc = __Frameserver_StatusDlgProc;
	}
	return CreateDialogParamW(hInstance, lpTemplateName, hWndParent, proc, dwInitParam);
}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CFaceBasics::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
	wc.lpszMenuName =  MAKEINTRESOURCE(IDR_MENU1);
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"Face-And-HDFace-Basics-D2DAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

	//hMenu = LoadMenuW(hInstance, MAKEINTRESOURCE(IDR_MENU1));
	
    // Create main application window
    HWND hWndApp = CreateDialogParamW(        NULL,         MAKEINTRESOURCE(IDD_APP),         NULL,        (DLGPROC)CFaceBasics::MessageRouter,         reinterpret_cast<LPARAM>(this));

	//HWND hWndApp = CreateDialogParamW(        NULL,         MAKEINTRESOURCE(IDD_APP),         NULL,        (DLGPROC)CFaceBasics::MessageRouter,  WS_CAPTION);


    // Show window
    ShowWindow(hWndApp, nCmdShow);
	//ShowWindow(hWndApp, 3);

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        Update();

        while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if (hWndApp && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
Beispiel #5
0
void InitializeDisplayAdapters(PDXDIAG_CONTEXT pContext)
{
    DISPLAY_DEVICEW DispDevice;
    HWND * hDlgs;
    HWND hwndDlg;
    WCHAR szDisplay[20];
    WCHAR szText[30];
    DWORD dwOffset = 0;

    while(TRUE)
    {
        ZeroMemory(&DispDevice, sizeof(DISPLAY_DEVICEW));
        DispDevice.cb = sizeof(DISPLAY_DEVICEW);
        if (!EnumDisplayDevicesW(NULL, pContext->NumDisplayAdapter + dwOffset, &DispDevice, 0))
            return;

        /* skip devices not attached to the desktop and mirror drivers */
        if (!(DispDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) || (DispDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
        {
            dwOffset++;
            continue;
        }
        if (pContext->NumDisplayAdapter)
            hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hDisplayWnd, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));
        else
            hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumDisplayAdapter + 1) * sizeof(HWND));

        if (!hDlgs)
            break;

        pContext->hDisplayWnd = hDlgs;
        hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_DISPLAY_DIALOG), pContext->hMainDialog, DisplayPageWndProc, (LPARAM)pContext);
        if (!hwndDlg)
           break;

        /* initialize the dialog */
        InitializeDialog(hwndDlg, &DispDevice);

        szDisplay[0] = L'\0';
        LoadStringW(hInst, IDS_DISPLAY_DIALOG, szDisplay, sizeof(szDisplay)/sizeof(WCHAR));
        szDisplay[(sizeof(szDisplay)/sizeof(WCHAR))-1] = L'\0';

        wsprintfW (szText, L"%s %u", szDisplay, pContext->NumDisplayAdapter + 1);
        InsertTabCtrlItem(GetDlgItem(pContext->hMainDialog, IDC_TAB_CONTROL), pContext->NumDisplayAdapter + 1, szText);

        hDlgs[pContext->NumDisplayAdapter] = hwndDlg;
        pContext->NumDisplayAdapter++;
    }


}
Beispiel #6
0
VOID
InitializeTabCtrl(HWND hwndDlg, PDXDIAG_CONTEXT pContext)
{
    /* get tabctrl */
    hTabCtrlWnd = GetDlgItem(hwndDlg, IDC_TAB_CONTROL);
    pContext->hTabCtrl = hTabCtrlWnd;

    /* create the dialogs */
    pContext->hDialogs[0] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_SYSTEM_DIALOG), pContext->hMainDialog, SystemPageWndProc, (LPARAM)pContext);
    pContext->hDialogs[1] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_MUSIC_DIALOG), pContext->hMainDialog, MusicPageWndProc, (LPARAM)pContext);
    pContext->hDialogs[2] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_INPUT_DIALOG), pContext->hMainDialog, InputPageWndProc, (LPARAM)pContext);
    pContext->hDialogs[3] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_NETWORK_DIALOG), pContext->hMainDialog, NetworkPageWndProc, (LPARAM)pContext);
    pContext->hDialogs[4] = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_HELP_DIALOG), pContext->hMainDialog, HelpPageWndProc, (LPARAM)pContext);

    /* insert tab ctrl items */
    InsertTabCtrlItem(hTabCtrlWnd, 0, MAKEINTRESOURCEW(IDS_SYSTEM_DIALOG));
    InitializeDisplayAdapters(pContext);
    InitializeDirectSoundPage(pContext);
    InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, MAKEINTRESOURCEW(IDS_MUSIC_DIALOG));
    InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 2, MAKEINTRESOURCEW(IDS_INPUT_DIALOG));
    InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 3, MAKEINTRESOURCEW(IDS_NETWORK_DIALOG));
    InsertTabCtrlItem(hTabCtrlWnd, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 4, MAKEINTRESOURCEW(IDS_HELP_DIALOG));
    TabCtrl_OnSelChange(pContext);
}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CKinectFusionExplorer::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc  = {0};

    // Dialog custom window class
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursorW(nullptr, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"KinectFusionExplorerAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        nullptr,
        (DLGPROC)CKinectFusionExplorer::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        if (GetMessage(&msg, nullptr, 0, 0))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != nullptr) && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
Beispiel #8
0
static HWND show_wait_window(void)
{
    const char *config_dir = wine_get_config_dir();
    WCHAR *name;
    HWND hwnd;
    DWORD len;

    len = MultiByteToWideChar( CP_UNIXCP, 0, config_dir, -1, NULL, 0 );
    name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
    MultiByteToWideChar( CP_UNIXCP, 0, config_dir, -1, name, len );
    hwnd = CreateDialogParamW( GetModuleHandleW(0), MAKEINTRESOURCEW(IDD_WAITDLG), 0,
                               wait_dlgproc, (LPARAM)name );
    ShowWindow( hwnd, SW_SHOWNORMAL );
    HeapFree( GetProcessHeap(), 0, name );
    return hwnd;
}
Beispiel #9
0
static void hugsprim_CreateDialogParamW_6(HugsStackPtr hugs_root)
{
    HsPtr arg1;
    HsPtr arg2;
    HsPtr arg3;
    HsFunPtr arg4;
    HsInt32 arg5;
    HsPtr res1;
    arg1 = hugs->getPtr();
    arg2 = hugs->getPtr();
    arg3 = hugs->getPtr();
    arg4 = hugs->getFunPtr();
    arg5 = hugs->getInt32();
    res1 = CreateDialogParamW(arg1, arg2, arg3, arg4, arg5);
    hugs->putPtr(res1);
    hugs->returnIO(hugs_root,1);
}
void editSetting(MCONTACT hContact, char* module, char* setting)
{
	DBVARIANT dbv = { 0 }; // freed in the dialog
	if (!GetSetting(hContact, module, setting, &dbv))
	{
		struct DBsetting *dbsetting = (struct DBsetting *)mir_alloc(sizeof(struct DBsetting)); // gets free()ed in the window proc

		dbsetting->dbv = dbv; // freed in the dialog
		dbsetting->hContact = hContact;
		dbsetting->module = mir_tstrdup(module);
		dbsetting->setting = mir_tstrdup(setting);

		if (dbv.type == DBVT_UTF8)
			CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
		else
			CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT_SETTING), hwnd2mainWindow, EditSettingDlgProc, (LPARAM)dbsetting);
	}
}
Beispiel #11
0
/// <summary>
/// Create window of viewer
/// </sumarry>
/// <returns>Indicates success or failure</returns>
bool NuiViewer::CreateView()
{
    if (!m_hWnd)
    {
        HWND hWndParent = nullptr;
        if (m_pParent)
        {
            hWndParent = m_pParent->GetWindow();
        }

        m_hWnd = CreateDialogParamW(nullptr,
                                    MAKEINTRESOURCE(GetDlgId()),
                                    hWndParent,
                                    (DLGPROC)MessageRouter,
                                    reinterpret_cast<LPARAM>(this));
    }

    return (nullptr != m_hWnd);
}
Beispiel #12
0
bool CModelessDialog::Create(LPCWSTR templateName, HWND parentWindow)
{
  HWND aHWND;
  if (g_IsNT)
    aHWND = CreateDialogParamW(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this);
  else
  {
    AString name;
    LPCSTR templateNameA;
    if (IS_INTRESOURCE(templateName))
      templateNameA = (LPCSTR)templateName;
    else
    {
      name = GetSystemString(templateName);
      templateNameA = name;
    }
    aHWND = CreateDialogParamA(g_hInstance, templateNameA, parentWindow, DialogProcedure, (LPARAM)this);
  }
  if (aHWND == 0)
    return false;
  Attach(aHWND);
  return true;
}
Beispiel #13
0
static BOOL
OnMainCreate(HWND hwnd,
             PRDPSETTINGS pRdpSettings)
{
    PINFO pInfo;
    TCITEMW item;
    BOOL bRet = FALSE;

    pInfo = HeapAlloc(GetProcessHeap(),
                      HEAP_ZERO_MEMORY,
                      sizeof(INFO));
    if (pInfo)
    {
        SetWindowLongPtrW(hwnd,
                          GWLP_USERDATA,
                          (LONG_PTR)pInfo);

        pInfo->hSelf = hwnd;

        /* add main settings pointer */
        pInfo->pRdpSettings = pRdpSettings;

        /* set the dialog icons */
        pInfo->hMstscSm = LoadImageW(hInst,
                                   MAKEINTRESOURCEW(IDI_MSTSC),
                                   IMAGE_ICON,
                                   16,
                                   16,
                                   LR_DEFAULTCOLOR);
        if (pInfo->hMstscSm)
        {
            SendMessageW(hwnd,
                         WM_SETICON,
                         ICON_SMALL,
                        (WPARAM)pInfo->hMstscSm);
        }
        pInfo->hMstscLg = LoadImageW(hInst,
                                   MAKEINTRESOURCEW(IDI_MSTSC),
                                   IMAGE_ICON,
                                   32,
                                   32,
                                   LR_DEFAULTCOLOR);
        if (pInfo->hMstscLg)
        {
            SendMessageW(hwnd,
                         WM_SETICON,
                         ICON_BIG,
                        (WPARAM)pInfo->hMstscLg);
        }

        pInfo->hHeader = (HBITMAP)LoadImageW(hInst,
                                             MAKEINTRESOURCEW(IDB_HEADER),
                                             IMAGE_BITMAP,
                                             0,
                                             0,
                                             LR_DEFAULTCOLOR);
        if (pInfo->hHeader)
        {
            GetObjectW(pInfo->hHeader,
                       sizeof(BITMAP),
                       &pInfo->headerbitmap);
        }

        /* setup the tabs */
        pInfo->hTab = GetDlgItem(hwnd, IDC_TAB);
        if (pInfo->hTab)
        {
            if (CreateDialogParamW(hInst,
                                   MAKEINTRESOURCEW(IDD_GENERAL),
                                   pInfo->hTab,
                                   GeneralDlgProc,
                                   (LPARAM)pInfo))
            {
                WCHAR str[256];
                ZeroMemory(&item, sizeof(TCITEM));
                item.mask = TCIF_TEXT;
                if (LoadStringW(hInst, IDS_TAB_GENERAL, str, 256))
                    item.pszText = str;
                item.cchTextMax = 256;
                (void)TabCtrl_InsertItem(pInfo->hTab, 0, &item);
            }

            if (CreateDialogParamW(hInst,
                                   MAKEINTRESOURCEW(IDD_DISPLAY),
                                   pInfo->hTab,
                                   DisplayDlgProc,
                                   (LPARAM)pInfo))
            {
                WCHAR str[256];
                ZeroMemory(&item, sizeof(TCITEM));
                item.mask = TCIF_TEXT;
                if (LoadStringW(hInst, IDS_TAB_DISPLAY, str, 256))
                    item.pszText = str;
                item.cchTextMax = 256;
                (void)TabCtrl_InsertItem(pInfo->hTab, 1, &item);
            }

            OnTabWndSelChange(pInfo);
        }
    }

    return bRet;
}
Beispiel #14
0
/* Sends a message to a set of windows, displaying a dialog if the window
 * doesn't respond to the message within a set amount of time.
 * If the process has already been terminated, the function returns -1.
 * If the user or application cancels the process, the function returns 0.
 * Otherwise the function returns 0. */
static LRESULT send_messages_with_timeout_dialog(
    struct window_info *win, UINT count, HANDLE process_handle,
    UINT msg, WPARAM wparam, LPARAM lparam )
{
    unsigned int i;
    DWORD ret;
    DWORD start_time;
    struct callback_data *cb_data;
    HWND hwnd_endtask = NULL;
    struct endtask_dlg_data dlg_data;
    LRESULT result;

    cb_data = HeapAlloc( GetProcessHeap(), 0, sizeof(*cb_data) );
    if (!cb_data)
        return 1;

    cb_data->result = TRUE; /* we only care if a WM_QUERYENDSESSION response is FALSE */
    cb_data->timed_out = FALSE;
    cb_data->window_count = count;

    dlg_data.win = win;
    dlg_data.terminated = FALSE;
    dlg_data.cancelled = FALSE;

    for (i = 0; i < count; i++)
    {
        if (!SendMessageCallbackW( win[i].hwnd, msg, wparam, lparam,
                                   end_session_message_callback, (ULONG_PTR)cb_data ))
            cb_data->window_count --;
    }

    start_time = GetTickCount();
    while (TRUE)
    {
        DWORD current_time = GetTickCount();

        ret = MsgWaitForMultipleObjects( 1, &process_handle, FALSE,
                                         MESSAGE_TIMEOUT - (current_time - start_time),
                                         QS_ALLINPUT );
        if (ret == WAIT_OBJECT_0) /* process exited */
        {
            HeapFree( GetProcessHeap(), 0, cb_data );
            result = 1;
            goto cleanup;
        }
        else if (ret == WAIT_OBJECT_0 + 1) /* window message */
        {
            MSG msg;
            while(PeekMessageW( &msg, NULL, 0, 0, PM_REMOVE ))
            {
                if (!hwnd_endtask || !IsDialogMessageW( hwnd_endtask, &msg ))
                {
                    TranslateMessage( &msg );
                    DispatchMessageW( &msg );
                }
            }
            if (!cb_data->window_count)
            {
                result = dlg_data.terminated || cb_data->result;
                HeapFree( GetProcessHeap(), 0, cb_data );
                if (!result)
                    goto cleanup;
                break;
            }
            if (dlg_data.cancelled)
            {
                cb_data->timed_out = TRUE;
                result = 0;
                goto cleanup;
            }
        }
        else if ((ret == WAIT_TIMEOUT) && !hwnd_endtask)
        {
            hwnd_endtask = CreateDialogParamW( GetModuleHandleW(NULL),
                                               MAKEINTRESOURCEW(IDD_ENDTASK),
                                               NULL, endtask_dlg_proc,
                                               (LPARAM)&dlg_data );
        }
        else break;
    }

    result = 1;

cleanup:
    if (hwnd_endtask) DestroyWindow( hwnd_endtask );
    return result;
}
Beispiel #15
0
int WINAPI wWinMain(HINSTANCE hinstance, HINSTANCE /* hprevinstance */, PWSTR cmdline, int /* cmdshow */)
{
	//AllocConsole();
	//freopen("CONOUT$", "w", stdout);

	auto args = getArgs(cmdline);

	auto standby = args.size() > 2 && args[2] == "standby";

	const auto instanceString = L"XKXjdwnFYYL2eVdB";
	auto singleInstanceEvent = HandlePtr(OpenEventW(EVENT_ALL_ACCESS, false, instanceString));

	if (singleInstanceEvent != nullptr)
	{
		if (!standby)
		{
			auto decision = MessageBox(nullptr, L"There is already an instance "
				"of passchain running. Start anyway?", L"Warning", MB_OKCANCEL);

			if (decision != IDOK)
			{
				return 0;
			}
		}
	}
	else
	{
		singleInstanceEvent = HandlePtr(CreateEventW(nullptr, false, false, instanceString));
	}

	std::unique_ptr<LoginDatabase> database;
	std::string password;
	std::string filename = getFullyQualifiedPathName(args.size() > 1 ? args[1] : "passchain.dat");

	while (database == nullptr)
	{
		try
		{
			PasswordDialogCreateParams params;
			params.password = &password;
			params.filename = &filename;
			params.standby = standby;

			auto result = DialogBoxParamW(hinstance, MAKEINTRESOURCEW(DIALOG_PASSWORD), nullptr,
				dialogProcPassword, reinterpret_cast<LPARAM>(&params));

			if (result == 0)
			{ // Pressed cancel or close button
				return 0;
			}

			database = std::make_unique<LoginDatabase>(std::move(password));

			auto attributes = GetFileAttributesW(toWideString(filename).c_str());

			if (attributes != INVALID_FILE_ATTRIBUTES)
			{
				database->mergeFromEncryptedFile(filename);
			}
		}
		catch (std::exception& e)
		{
			database = nullptr;
			standby = false;
			showMessageBox("Error", e.what());
		}
	}

	bool timeoutQuit = false;

	MainDialogCreateParams mainParams;
	mainParams.database = database.get();
	mainParams.filename = &filename;
	mainParams.timeoutQuit = &timeoutQuit;

	CreateDialogParamW(hinstance, MAKEINTRESOURCE(DIALOG_MAIN), nullptr, 
		dialogProcMain, reinterpret_cast<LPARAM>(&mainParams));

	MSG message;

	while (GetMessageW(&message, nullptr, 0, 0) > 0)
	{
		database->reseedRng(&message, sizeof message);

		if (!IsDialogMessageW(GetParent(message.hwnd), &message))
		{
			TranslateMessage(&message);
			DispatchMessageW(&message);
		}
	}

	if (timeoutQuit)
	{
		auto callString = formatString("%s %s standby", args[0].c_str(), filename.c_str());

		STARTUPINFOA startupInfo = { sizeof startupInfo };
		PROCESS_INFORMATION processInformation;

		if (0 == CreateProcessA(nullptr, &callString[0], nullptr, nullptr,
			false, 0, nullptr, nullptr, &startupInfo, &processInformation))
		{
			showMessageBox("Warning", "Failed to create standby process.");
		}
	}

	return static_cast<int>(message.wParam);
}
Beispiel #16
0
BOOL CALLBACK DSEnumCallback(LPGUID lpGuid, LPCWSTR lpcstrDescription, LPCWSTR lpcstrModule, LPVOID lpContext)
{
    PDXDIAG_CONTEXT pContext = (PDXDIAG_CONTEXT)lpContext;
    HWND * hDlgs;
    HWND hwndDlg;
    WCHAR szSound[20];
    WCHAR szText[30];
    IDirectSound8 *pObj;
    HRESULT hResult;
    DWORD dwCertified;

    if (!lpGuid)
        return TRUE;

    if (pContext->NumSoundAdapter)
        hDlgs = HeapReAlloc(GetProcessHeap(), 0, pContext->hSoundWnd, (pContext->NumSoundAdapter + 1) * sizeof(HWND));
    else
        hDlgs = HeapAlloc(GetProcessHeap(), 0, (pContext->NumSoundAdapter + 1) * sizeof(HWND));

    if (!hDlgs)
        return FALSE;

    pContext->hSoundWnd = hDlgs;
    hwndDlg = CreateDialogParamW(hInst, MAKEINTRESOURCEW(IDD_SOUND_DIALOG), pContext->hMainDialog, SoundPageWndProc, (LPARAM)pContext);
    if (!hwndDlg)
        return FALSE;

    hResult = DirectSoundCreate8(lpGuid, (LPDIRECTSOUND8*)&pObj, NULL);
    if (hResult == DS_OK)
    {
        szText[0] = L'\0';
        if (IDirectSound8_VerifyCertification(pObj, &dwCertified) == DS_OK)
        {
            if (dwCertified == DS_CERTIFIED)
                LoadStringW(hInst, IDS_OPTION_YES, szText, sizeof(szText)/sizeof(WCHAR));
            else if (dwCertified == DS_UNCERTIFIED)
                LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
        }
        else
        {
            LoadStringW(hInst, IDS_OPTION_NO, szText, sizeof(szText)/sizeof(WCHAR));
        }
        szText[(sizeof(szText)/sizeof(WCHAR))-1] = L'\0';
        SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_LOGO, WM_SETTEXT, 0, (LPARAM)szText);
        IDirectSound8_Release(pObj);
    }

    /* set device name */
    SendDlgItemMessageW(hwndDlg, IDC_STATIC_DSOUND_NAME, WM_SETTEXT, 0, (LPARAM)lpcstrDescription);

    /* set range for slider */
    SendDlgItemMessageW(hwndDlg, IDC_SLIDER_DSOUND, TBM_SETRANGE, TRUE, MAKELONG(0, 3));

    /* FIXME set correct position */
    SendDlgItemMessageW(hwndDlg, IDC_SLIDER_DSOUND, TBM_SETSEL, FALSE, 0);

    /* set further device details */
    SetDeviceDetails(hwndDlg, &GUID_DEVCLASS_MEDIA, lpcstrDescription);



    /* load sound resource string */
    szSound[0] = L'\0';
    LoadStringW(hInst, IDS_SOUND_DIALOG, szSound, sizeof(szSound)/sizeof(WCHAR));
    szSound[(sizeof(szSound)/sizeof(WCHAR))-1] = L'\0';
    /* output the device id */
    wsprintfW (szText, L"%s %u", szSound, pContext->NumSoundAdapter + 1);
    /* insert it into general tab */
    InsertTabCtrlItem(pContext->hTabCtrl, pContext->NumDisplayAdapter + pContext->NumSoundAdapter + 1, szText);
    /* store dialog window */
    hDlgs[pContext->NumSoundAdapter] = hwndDlg;
    pContext->NumSoundAdapter++;
    return TRUE;
}
Beispiel #17
0
HRESULT
CLanStatus::InitializeNetTaskbarNotifications()
{
    NOTIFYICONDATAW nid;
    HWND hwndDlg;
    INetConnectionManager *pNetConMan;
    IEnumNetConnection *pEnumCon;
    INetConnection *pNetCon;
    NETCON_PROPERTIES* pProps;
    HRESULT hr;
    ULONG Count;
    ULONG Index;
    NOTIFICATION_ITEM * pItem, *pLast = NULL;
    LANSTATUSUI_CONTEXT * pContext;

    TRACE("InitializeNetTaskbarNotifications\n");

    if (m_pHead)
    {
       pItem = m_pHead;
       while (pItem)
       {
           hr = pItem->pNet->GetProperties(&pProps);
           if (SUCCEEDED(hr))
           {
                ZeroMemory(&nid, sizeof(nid));
                nid.cbSize = sizeof(nid);
                nid.uID = pItem->uID;
                nid.hWnd = pItem->hwndDlg;
                nid.uFlags = NIF_STATE;
                if (pProps->dwCharacter & NCCF_SHOW_ICON)
                    nid.dwState = 0;
                else
                    nid.dwState = NIS_HIDDEN;

                nid.dwStateMask = NIS_HIDDEN;
                Shell_NotifyIconW(NIM_MODIFY, &nid);
                NcFreeNetconProperties(pProps);
           }
           pItem = pItem->pNext;
       }
       return S_OK;
    }
    /* get an instance to of IConnectionManager */

    //hr = CoCreateInstance(&CLSID_ConnectionManager, NULL, CLSCTX_INPROC_SERVER, &IID_INetConnectionManager, (LPVOID*)&pNetConMan);

    hr = INetConnectionManager_Constructor(NULL, IID_INetConnectionManager, (LPVOID*)&pNetConMan);
    if (FAILED(hr))
    {
        ERR("INetConnectionManager_Constructor failed\n");
        return hr;
    }

    hr = pNetConMan->EnumConnections(NCME_DEFAULT, &pEnumCon);
    if (FAILED(hr))
    {
        ERR("EnumConnections failed\n");
        pNetConMan->Release();
        return hr;
    }

    Index = 1;
    do
    {
        hr = pEnumCon->Next(1, &pNetCon, &Count);
        if (hr == S_OK)
        {
            TRACE("new connection\n");
            pItem = static_cast<NOTIFICATION_ITEM*>(CoTaskMemAlloc(sizeof(NOTIFICATION_ITEM)));
            if (!pItem)
                break;

            pContext = static_cast<LANSTATUSUI_CONTEXT*>(CoTaskMemAlloc(sizeof(LANSTATUSUI_CONTEXT)));
            if (!pContext)
            {
                CoTaskMemFree(pItem);
                break;
            }

            ZeroMemory(pContext, sizeof(LANSTATUSUI_CONTEXT));
            pContext->uID = Index;
            pContext->pNet = pNetCon;
            pItem->uID = Index;
            pItem->pNext = NULL;
            pItem->pNet = pNetCon;
            hwndDlg = CreateDialogParamW(netshell_hInstance, MAKEINTRESOURCEW(IDD_STATUS), NULL, LANStatusDlg, (LPARAM)pContext);
            if (hwndDlg)
            {
                ZeroMemory(&nid, sizeof(nid));
                nid.cbSize = sizeof(nid);
                nid.uID = Index++;
                nid.uFlags = NIF_MESSAGE;
                nid.uVersion = 3;
                nid.uCallbackMessage = WM_SHOWSTATUSDLG;
                nid.hWnd = hwndDlg;

                hr = pNetCon->GetProperties(&pProps);
                if (SUCCEEDED(hr))
                {
                    CopyMemory(&pItem->guidItem, &pProps->guidId, sizeof(GUID));
                    if (!(pProps->dwCharacter & NCCF_SHOW_ICON))
                    {
                        nid.dwState = NIS_HIDDEN;
                        nid.dwStateMask = NIS_HIDDEN;
                        nid.uFlags |= NIF_STATE;
                    }
                    if (pProps->Status == NCS_MEDIA_DISCONNECTED || pProps->Status == NCS_DISCONNECTED || pProps->Status == NCS_HARDWARE_DISABLED)
                        nid.hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_OFF));
                    else if (pProps->Status == NCS_CONNECTED)
                        nid.hIcon = LoadIcon(netshell_hInstance, MAKEINTRESOURCE(IDI_NET_IDLE));

                    if (nid.hIcon)
                        nid.uFlags |= NIF_ICON;

                    wcscpy(nid.szTip, pProps->pszwName);
                    nid.uFlags |= NIF_TIP;
                }
                pContext->hwndStatusDlg = hwndDlg;
                pItem->hwndDlg = hwndDlg;

                if (Shell_NotifyIconW(NIM_ADD, &nid))
                {
                    if (pLast)
                        pLast->pNext = pItem;
                    else
                        m_pHead = pItem;

                    pLast = pItem;
                    Index++;
                }
                else
                {
                    ERR("Shell_NotifyIconW failed\n");
                    CoTaskMemFree(pItem);
                }

                if (nid.uFlags & NIF_ICON)
                    DestroyIcon(nid.hIcon);
            } else
                ERR("CreateDialogParamW failed\n");
        }
    } while (hr == S_OK);

    m_lpNetMan = pNetConMan;
    pEnumCon->Release();
    return S_OK;
}
Beispiel #18
0
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int Direct2DWindow::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"DepthBasicsAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)Direct2DWindow::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    const int eventCount = 2;
    HANDLE hEvents[eventCount];

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        hEvents[0] = m_cdmap->GetNextDepthFrameEvent();
        hEvents[1] = m_cdmap->GetNextColorFrameEvent();

        // Check to see if we have either a message (by passing in QS_ALLINPUT)
        // Or a Kinect event (hEvents)
        // Update() will check for Kinect events individually, in case more than one are signalled
        MsgWaitForMultipleObjects(eventCount, hEvents, FALSE, INFINITE, QS_ALLINPUT);

        // Explicitly check the Kinect frame event since MsgWaitForMultipleObjects
        // can return for other reasons even though it is signaled.
        Update();

        while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != NULL) && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
Beispiel #19
0
BOOL CMainWindow::OnCreate(__in HINSTANCE hInstance)
{
	// window caption
	SetWindowTextW(m_hDialog, pStrings->Get(IDS_XPI).c_str());

	// XPIGUI
	m_pXPIGUI = new XPIGUI;

	ZeroMemory(m_pXPIGUI, sizeof(XPIGUI));

	// XPIGUI - instance
	m_pXPIGUI->hInstance = hInstance;

	// XPIGUI - application icon
	m_pXPIGUI->hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_XPI));
	if (m_pXPIGUI->hIcon != NULL)
		SendMessageW(m_hDialog, WM_SETICON, ICON_BIG, (LPARAM)m_pXPIGUI->hIcon);
#ifdef _DEBUG
	else
		pLog->Write(LOG_WF_ERROR | LOG_WF_ECHODEBUG, L"Couldn't load XPI icon, continuing anyway. [LE=0x%08X]", GetLastError());
#endif

	// XPIGUI - small application icon
	m_pXPIGUI->hIconSmall = LoadIconW(hInstance, MAKEINTRESOURCEW(IDI_XPI_SMALL));
	if (m_pXPIGUI->hIconSmall != NULL)
		SendMessageW(m_hDialog, WM_SETICON, ICON_SMALL, (LPARAM)m_pXPIGUI->hIconSmall);
#ifdef _DEBUG
	else
		pLog->Write(LOG_WF_ERROR | LOG_WF_ECHODEBUG, L"Couldn't load small XPI icon, continuing anyway. [LE=0x%08X]", GetLastError());
#endif

	// XPIGUI - load Consolas from resource
	m_pXPIGUI->hMemFont = AddFontFromResource(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDR_CONSOLAS));
	if (m_pXPIGUI->hMemFont == NULL)
	{
	}

	// XPIGUI - Consolas font handle
	m_pXPIGUI->hFont = CreateFontW(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_CHARACTER_PRECIS, CLEARTYPE_QUALITY, FF_DONTCARE, L"Consolas");
	if (m_pXPIGUI->hFont == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't create log font, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}

	// XPIGUI - direction image list
	do
	{
		m_pXPIGUI->hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 4, 0);
		ImageList_SetBkColor(m_pXPIGUI->hImageList, CLR_NONE);
		if (m_pXPIGUI->hImageList != NULL)
		{
			HBITMAP hBitmap = LoadBitmapW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDB_DIRECTIONS));
			if (hBitmap != NULL)
			{
				if (ImageList_AddMasked(m_pXPIGUI->hImageList, hBitmap, RGB(255, 0, 255)) != -1)
					break;
				DeleteObject((HGDIOBJ)hBitmap);
			}
		}

#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't create packet direction icons image-list, aborting.");
#endif
		NotifyErrorUI();
		return FALSE;
	} while (0);

	// XPIGUI - injection icons
	m_pXPIGUI->hInjectOut = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_INJECT_OUT), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hInjectOut == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load inject OUT icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}
	m_pXPIGUI->hInjectIn = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_INJECT_IN), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hInjectIn == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load inject IN icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}

	// XPIGUI - pause/resume icons
	m_pXPIGUI->hPauseIcon = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_PAUSE), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hPauseIcon == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load pause icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}
	Static_SetIcon(GetDlgItem(m_hDialog, IDC_PAUSELOGGING), m_pXPIGUI->hPauseIcon);
	m_pXPIGUI->hResumeIcon = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_RESUME), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hResumeIcon == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load resume icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}

	RECT rcClient;
	GetClientRect(m_hDialog, &rcClient);
	SetWindowPos(GetDlgItem(m_hDialog, IDC_PAUSELOGGING), NULL, rcClient.right - rcClient.left - UI_PAUSE_WIDTH - UI_PAUSE_PADDING, UI_PAUSE_PADDING, UI_PAUSE_WIDTH, UI_PAUSE_HEIGHT, 0);

	// XPIGUI - clear packets icon
	m_pXPIGUI->hClearIcon = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_CLEAR), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hClearIcon == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load clear icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}
	Static_SetIcon(GetDlgItem(m_hDialog, IDC_CLEAR), m_pXPIGUI->hClearIcon);
	SetWindowPos(GetDlgItem(m_hDialog, IDC_CLEAR), NULL, rcClient.right - rcClient.left - UI_CLEAR_WIDTH - (UI_CLEAR_PADDING * 2) - UI_PAUSE_WIDTH, UI_CLEAR_PADDING, UI_CLEAR_WIDTH, UI_CLEAR_HEIGHT, 0);

	// XPIGUI - settings image list
	do
	{
		m_pXPIGUI->hSettingsImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 4, 0);
		ImageList_SetBkColor(m_pXPIGUI->hSettingsImageList, CLR_NONE);
		if (m_pXPIGUI->hSettingsImageList != NULL)
		{
			HBITMAP hBitmap = LoadBitmapW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDB_PACKET_STATES));
			if (hBitmap != NULL)
			{
				if (ImageList_AddMasked(m_pXPIGUI->hSettingsImageList, hBitmap, RGB(255, 0, 255)) != -1)
					break;
				DeleteObject((HGDIOBJ)hBitmap);
			}
		}

#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't create settings image-list, aborting.");
#endif
		NotifyErrorUI();
		return FALSE;
	} while (0);

	// XPIGUI - color icons
	for (INT i = 0; i < _countof(m_pXPIGUI->hColorIcon); i++)
	{
		HICON hTempIcon = LoadIcon(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(g_XPIColors[i].wIcon));
		m_pXPIGUI->hColorIcon[i] = MenuBitmapFromIcon(m_hDialog, hTempIcon, 16, 16);
		if (m_pXPIGUI->hColorIcon[i] == NULL)
		{
#ifdef _DEBUG
			pLog->Write(LOG_WF_ERROR, L"Couldn't load color icon #%d, aborting. [LE=0x%08X]", i, GetLastError());
#endif
			NotifyErrorUI();
			return FALSE;
		}
		DestroyIcon(hTempIcon);
	}

	// XPIGUI - formatted image list
	do
	{
		m_pXPIGUI->hFormattedImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 4, 0);
		if (m_pXPIGUI->hFormattedImageList != NULL)
		{
			ImageList_SetBkColor(m_pXPIGUI->hFormattedImageList, CLR_NONE);

			HBITMAP hBitmap = LoadBitmapW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDB_FORMATTED_LIST));
			if (hBitmap != NULL)
			{
				if (ImageList_AddMasked(m_pXPIGUI->hFormattedImageList, hBitmap, RGB(255, 0, 255)) != -1)
					break;
				DeleteObject((HGDIOBJ)hBitmap);
			}
		}

#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't create formatted image-list, aborting.");
#endif
		NotifyErrorUI();
		return FALSE;
	} while (0);

	// XPIGUI - stop icon
	m_pXPIGUI->hStop = (HICON)LoadImageW(m_pXPIGUI->hInstance, MAKEINTRESOURCEW(IDI_STOP), IMAGE_ICON, 16, 16, 0);
	if (m_pXPIGUI->hStop == NULL)
	{
#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't load stop icon, aborting. [LE=0x%08X]", GetLastError());
#endif
		NotifyErrorUI();
		return FALSE;
	}

	// shell notify icon
	ZeroMemory(&m_NotifyIconData, sizeof(m_NotifyIconData));
	m_NotifyIconData.cbSize = sizeof(m_NotifyIconData);
	m_NotifyIconData.hWnd = m_hDialog;
	m_NotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
	m_NotifyIconData.hIcon = m_pXPIGUI->hIconSmall;
	m_NotifyIconData.uCallbackMessage = WM_SHELLNOTIFY;
	if (FAILED(StringCchCopyW(m_NotifyIconData.szTip, _countof(m_NotifyIconData.szTip), pStrings->Get(IDS_XPI).c_str())))
		m_NotifyIconData.uFlags &= ~NIF_TIP;
	Shell_NotifyIconW(NIM_ADD, &m_NotifyIconData);

	// tooltips window (for icons)
	m_hIconTips = CreateWindowEx(0, TOOLTIPS_CLASS, L"", TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, m_hDialog, 0, m_pXPIGUI->hInstance, NULL);
	SetWindowPos(m_hIconTips, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

	TOOLINFO ti;
	ti.cbSize = sizeof(ti);
	ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
	ti.hwnd = m_hDialog;

	std::wstring wstrTemp;

	wstrTemp = pStrings->Get(IDS_CLEAR_ALL_PACKETS);
	ti.uId = (UINT_PTR)GetDlgItem(m_hDialog, IDC_CLEAR);
	ti.lpszText = (LPWSTR)wstrTemp.c_str();
	SendMessage(m_hIconTips, TTM_ADDTOOL, 0, (LPARAM)&ti);

	wstrTemp = pStrings->Get(IDS_PAUSE_LOGGING);
	ti.uId = (UINT_PTR)GetDlgItem(m_hDialog, IDC_PAUSELOGGING);
	ti.lpszText = (LPWSTR)wstrTemp.c_str();
	SendMessage(m_hIconTips, TTM_ADDTOOL, 0, (LPARAM)&ti);

	// tabs creation
	TAB_INFO  Tabs[] =
	{
		{ pStrings->Get(IDS_TAB_PLAIN), MAKEINTRESOURCEW(IDD_PLAINVIEW), CPlainView::DialogProc },
		{ pStrings->Get(IDS_TAB_FORMATTED), MAKEINTRESOURCEW(IDD_FORMATTEDVIEW), CFormattedView::DialogProc },
		{ pStrings->Get(IDS_TAB_SETTINGS), MAKEINTRESOURCEW(IDD_SETTINGS), CMainSettings::DialogProc }
	};

	INT iCount = 0;

	foreach(const TAB_INFO& i, Tabs)
	{
		HWND hWnd = CreateDialogParamW(m_pXPIGUI->hInstance, i.lpwszTemplate, m_hDialog, i.DlgProc, (LPARAM)m_pXPIGUI);
		if (hWnd != NULL)
		{
			TCITEMW tci;
			tci.mask = TCIF_TEXT | TCIF_PARAM;
			tci.pszText = (LPWSTR)i.wstrCaption.c_str();
			tci.lParam = (LPARAM)m_pXPIGUI;

			if (TabCtrl_InsertItem(GetDlgItem(m_hDialog, IDC_TAB), iCount++, &tci) != -1)
			{
				ShowWindow(hWnd, m_vhTabs.empty() ? SW_SHOW : SW_HIDE);
				m_vhTabs.push_back(hWnd);
				continue;
			}
		}

#ifdef _DEBUG
		pLog->Write(LOG_WF_ERROR, L"Couldn't create tab ID %s, aborting.", i.wstrCaption);
#endif
		NotifyErrorUI();
		return FALSE;
	}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int KinectEasyGrabber::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"KinectEasyGrabberAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)KinectEasyGrabber::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    const int eventCount = 2;
    HANDLE hEvents[eventCount];

    LoadResourceImage(L"Background", L"Image", m_colorWidth*m_colorHeight*cBytesPerPixel, m_backgroundRGBX);

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        hEvents[0] = m_hNextDepthFrameEvent;
        hEvents[1] = m_hNextColorFrameEvent;

        // Check to see if we have either a message (by passing in QS_ALLINPUT)
        // Or a Kinect event (hEvents)
        // Update() will check for Kinect events individually, in case more than one are signalled
        DWORD dwEvent = MsgWaitForMultipleObjects(eventCount, hEvents, FALSE, INFINITE, QS_ALLINPUT);

        // Check if this is an event we're waiting on and not a timeout or message
        if (WAIT_OBJECT_0 == dwEvent || WAIT_OBJECT_0 + 1 == dwEvent)
        {
            //Update();
			//Record();
			RecordArray();
        }

        if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != NULL) && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CCoordinateMappingBasics::Run(HINSTANCE hInstance, int nCmdShow)
{
    if (m_pBackgroundRGBX)
    {
        //if (FAILED(LoadResourceImage(L"Background", L"Image", cDepthWidth, cDepthHeight, m_pBackgroundRGBX)))
		//if (FAILED(LoadResourceImage(MAKEINTRESOURCE(IDB_BITMAP1), RT_BITMAP, cDepthWidth, cDepthHeight, m_pBackgroundRGBX)))
		if (FAILED(LoadResourceImage(MAKEINTRESOURCE(IDB_PNG1), L"Png", cDepthWidth, cDepthHeight, m_pBackgroundRGBX)))
        {
            delete [] m_pBackgroundRGBX;
            m_pBackgroundRGBX = NULL;
        }
    }

    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"CoordinateMappingBasicsAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        NULL,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)CCoordinateMappingBasics::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        Update();

        while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if (hWndApp && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CSkeletonBasics::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc  = {0};

    // Dialog custom window class
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"SkeletonBasicsAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)CSkeletonBasics::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Show window
    ShowWindow(hWndApp, nCmdShow);

    const int eventCount = 1;
    HANDLE hEvents[eventCount];

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        hEvents[0] = m_hNextSkeletonEvent;

        // Check to see if we have either a message (by passing in QS_ALLEVENTS)
        // Or a Kinect event (hEvents)
        // Update() will check for Kinect events individually, in case more than one are signalled
        DWORD dwEvent = MsgWaitForMultipleObjects(eventCount, hEvents, FALSE, INFINITE, QS_ALLINPUT);

        // Check if this is an event we're waiting on and not a timeout or message
        if (WAIT_OBJECT_0 == dwEvent)
        {
            Update();
        }

        if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != NULL) && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
/// <summary>
/// Creates the main window and begins processing
/// </summary>
/// <param name="hInstance">handle to the application instance</param>
/// <param name="nCmdShow">whether to display minimized, maximized, or normally</param>
int CBackgroundRemovalBasics::Run(HINSTANCE hInstance, int nCmdShow)
{
    MSG       msg = {0};
    WNDCLASS  wc;

    // Dialog custom window class
    ZeroMemory(&wc, sizeof(wc));
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.cbWndExtra    = DLGWINDOWEXTRA;
    wc.hInstance     = hInstance;
    wc.hCursor       = LoadCursorW(NULL, IDC_ARROW);
    wc.hIcon         = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP));
    wc.lpfnWndProc   = DefDlgProcW;
    wc.lpszClassName = L"BackgroundRemovalBasicsAppDlgWndClass";

    if (!RegisterClassW(&wc))
    {
        return 0;
    }

	DWORD threadId; 
	HANDLE hThread = CreateThread(NULL, 0, NetworkManager::ThreadFunc, (LPVOID)nManager, CREATE_SUSPENDED, &threadId); 
	ResumeThread(hThread);

    // Create main application window
    HWND hWndApp = CreateDialogParamW(
        hInstance,
        MAKEINTRESOURCE(IDD_APP),
        NULL,
        (DLGPROC)CBackgroundRemovalBasics::MessageRouter, 
        reinterpret_cast<LPARAM>(this));

    // Set the init sensor status
    UpdateNscControlStatus();

    // Show window
    ShowWindow(hWndApp, nCmdShow);
    UpdateWindow(hWndApp);

    const HANDLE hEvents[] = {m_hNextDepthFrameEvent, m_hNextColorFrameEvent, m_hNextSkeletonFrameEvent, m_hNextBackgroundRemovedFrameEvent};
    LoadResourceImage(L"Background", L"Image", m_colorWidth * m_colorHeight * cBytesPerPixel, m_backgroundRGBX);

    // Main message loop
    while (WM_QUIT != msg.message)
    {
        // Check to see if we have either a message (by passing in QS_ALLINPUT)
        // Or a Kinect event (hEvents)
        // Update() will check for Kinect events individually, in case more than one are signaled
        MsgWaitForMultipleObjects(_countof(hEvents), hEvents, FALSE, INFINITE, QS_ALLINPUT);

        // Individually check the Kinect stream events since MsgWaitForMultipleObjects
        // can return for other reasons even though these are signaled.
        Update();
        
        while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // If a dialog message will be taken care of by the dialog proc
            if ((hWndApp != NULL) && IsDialogMessageW(hWndApp, &msg))
            {
                continue;
            }

            TranslateMessage(&msg);
            DispatchMessageW(&msg);
        }
    }

    return static_cast<int>(msg.wParam);
}
HWND VDXVideoFilterDialog::ShowModeless(HINSTANCE hInst, LPCWSTR templName, HWND parent) {
	if (!hInst)
		hInst = GetLocalHInstance();

	return CreateDialogParamW(hInst, templName, parent, StaticDlgProc, (LPARAM)this);
}