void NzWindowImpl::WindowThread(HWND* handle, DWORD styleEx, const wchar_t* title, DWORD style, unsigned int x, unsigned int y, unsigned int width, unsigned int height, NzWindowImpl* window, NzMutex* mutex, NzConditionVariable* condition)
{
	HWND& winHandle = *handle;
	winHandle = CreateWindowExW(styleEx, className, title, style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), window);

	mutex->Lock();
	condition->Signal();
	mutex->Unlock(); // mutex et condition sont considérés invalides à partir d'ici

	if (!winHandle)
		return;

	while (window->m_threadActive)
		window->ProcessEvents(true);

	DestroyWindow(winHandle);
}
Exemple #2
0
/******************************************************************************
 * create_listbox
 */
void CAutoComplete::CreateListbox()
{
    HWND hwndParent = GetParent(hwndEdit);

    /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
    hwndListBox = CreateWindowExW(0, WC_LISTBOXW, NULL,
                                  WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
                                  CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                                  hwndParent, NULL,
                                  (HINSTANCE)GetWindowLongPtrW(hwndParent, GWLP_HINSTANCE), NULL);

    if (hwndListBox)
    {
        wpOrigLBoxProc = (WNDPROC)SetWindowLongPtrW(hwndListBox, GWLP_WNDPROC, (LONG_PTR)ACLBoxSubclassProc);
        SetWindowLongPtrW(hwndListBox, GWLP_USERDATA, (LONG_PTR)this);
    }
}
Exemple #3
0
static void create_listbox(IAutoCompleteImpl *This)
{
    HWND hwndParent;

    hwndParent = GetParent(This->hwndEdit);

    /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
    This->hwndListBox = CreateWindowExW(0, WC_LISTBOXW, NULL,
                                    WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
                                    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                                    hwndParent, NULL, shell32_hInstance, NULL );

    if (This->hwndListBox) {
        This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc);
        SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This);
    }
}
Exemple #4
0
static BOOL AddContentTab(HHInfo *info)
{
    if(info->tabs[TAB_CONTENTS].id == -1)
        return TRUE; /* No "Contents" tab */
    info->tabs[TAB_CONTENTS].hwnd = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW,
           szEmpty, WS_CHILD | WS_BORDER | 0x25, 50, 50, 100, 100,
           info->WinType.hwndNavigation, NULL, hhctrl_hinstance, NULL);
    if(!info->tabs[TAB_CONTENTS].hwnd) {
        ERR("Could not create treeview control\n");
        return FALSE;
    }

    ResizeTabChild(info, TAB_CONTENTS);
    ShowWindow(info->tabs[TAB_CONTENTS].hwnd, SW_SHOW);

    return TRUE;
}
Exemple #5
0
HWND WindowImpl::createWindow(Point pos, WDims dims, wchar_t const windowname[], wchar_t const classname[], DWORD style)
{
	HWND hWnd = CreateWindowExW(
		WS_EX_APPWINDOW,
		classname, windowname,
//		WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW | style,
		WS_OVERLAPPEDWINDOW | style,
		pos.x, pos.y,
		dims.width, dims.height,
		NULL, NULL,
		GetModuleHandle(NULL), NULL
	);
	if( hWnd == NULL ) {
		throw std::runtime_error(log::nativeErrorString());
	}
    return hWnd;
}
int main(int argc, char *argv[])
{
	D2D1_FACTORY_OPTIONS opts;
	WNDCLASSW wc;
	HWND mainwin;
	MSG msg;
	HRESULT hr;

	CoInitialize(NULL);
	ZeroMemory(&opts, sizeof (D2D1_FACTORY_OPTIONS));
	opts.debugLevel = D2D1_DEBUG_LEVEL_NONE;
	hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED,
		IID_ID2D1Factory,
		&opts,
		(void **) (&d2dfactory));
	if (hr != S_OK) {
		loghr("D2D1CreateFactory()", hr);
		return 1;
	}

	ZeroMemory(&wc, sizeof (WNDCLASSW));
	wc.lpszClassName = L"mainwin";
	wc.lpfnWndProc = wndproc;
	wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
	RegisterClassW(&wc);

	mainwin = CreateWindowExW(0,
		L"mainwin", L"mainwin",
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, CW_USEDEFAULT,
		640, 480,
		NULL, NULL, NULL, NULL);

	ShowWindow(mainwin, SW_SHOWDEFAULT);
	UpdateWindow(mainwin);

	while (GetMessageW(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessageW(&msg);
	}

	d2dfactory->Release();
	CoUninitialize();
	return msg.wParam;
}
// Function to create Combo Box as child of Custom Combo Box
wyBool
CCustomComboBox::CreateCtrls(HWND hwnd, LPARAM lParam)
{
    CREATESTRUCT    *ctst = (CREATESTRUCT *)lParam;
    wyInt32         ret = 0;
    DWORD           style = CBS_DROPDOWN | CBS_SORT | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP | WS_CHILD | WS_CLIPCHILDREN;
    HFONT           hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
    m_id            = (wyInt32)ctst->hMenu;
    m_hwndParent    = ctst->hwndParent;
    m_hwnd          = hwnd;

    if((ctst->style &  CBS_OWNERDRAWFIXED))
        style |=  CBS_OWNERDRAWFIXED;
    m_hwndCombo     = CreateWindowExW(NULL, WC_COMBOBOX, NULL, 
                                style, 
                                0, 0, ctst->cx,ctst->cy, 
                                hwnd, (HMENU)IDC_COMBOCUSTOM, GetModuleHandle(NULL), 0);
    
    if(m_hwndCombo == NULL)
        return wyFalse;

    SendMessage(m_hwndCombo, WM_SETFONT, (WPARAM)hfont, (LPARAM)TRUE);
    
    ShowWindow(m_hwndCombo, SW_SHOW);

    ret = GetComboBoxInfo(m_hwndCombo, &m_cbif);

    m_editRect.bottom   = m_cbif.rcItem.bottom;
    m_editRect.right    = m_cbif.rcItem.right;
    m_editRect.left     = m_cbif.rcItem.left;
    m_editRect.top      = m_cbif.rcItem.top;
    
    if(ctst->style & WS_DISABLED)
    {
        SendMessage(hwnd, WM_ENABLE, FALSE, NULL);
    }

    SetWindowLongPtr(m_hwndCombo, GWLP_USERDATA, (LONG_PTR) this);
    m_origComboCtrlProc = (WNDPROC)SetWindowLongPtr(m_hwndCombo, GWLP_WNDPROC, (LONG_PTR) CCustomComboBox::ComboCtrlProc);
    
    SetWindowLongPtr(m_cbif.hwndItem, GWLP_USERDATA, (LONG_PTR)this);
    m_origEditCtrlProc = (WNDPROC)SetWindowLongPtr(m_cbif.hwndItem, GWLP_WNDPROC, (LONG_PTR) CCustomComboBox::EditCtrlProc);

    return wyTrue;
}
Exemple #8
0
static ATOM RegisterShieldClass()
{
    static ATOM atom = 0;

    if (!atom)
    {
        const WNDCLASSEX classex = {
            .cbSize        = sizeof(WNDCLASSEX),
            .style         = CS_NOCLOSE,
            .lpfnWndProc   = ShieldWndProc,
            .hInstance     = HINST_THISCOMPONENT,
            .hbrBackground = GetStockObject(WHITE_BRUSH),
            .lpszClassName = L"ClearshotShield",
        };

        atom = RegisterClassExW(&classex);
    }

    return atom;
}

static void ShootArea(int left, int top, int width, int height, uint8_t* buffer)
{
    HWND window = CreateWindowExW(
                      WS_EX_NOACTIVATE,
                      (wchar_t*)(intptr_t)RegisterShieldClass(),
                      L"Clearshot",
                      WS_DISABLED | WS_POPUP,
                      left, top, width, height,
                      NULL, NULL, HINST_THISCOMPONENT, buffer);

    if (!window)
        Fatal(L"Couldn't create window.");

    /* Move the shield underneath all other windows */
    SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE);

    /* Start the modal message loop */
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
}
Exemple #9
0
int main(int argc, char *argv[])
{
	HWND mainwin;
	MSG msg;
	INITCOMMONCONTROLSEX icc;

	ZeroMemory(&icc, sizeof (INITCOMMONCONTROLSEX));
	icc.dwSize = sizeof (INITCOMMONCONTROLSEX);
	icc.dwICC = ICC_LISTVIEW_CLASSES;
	if (InitCommonControlsEx(&icc) == 0)
		panic("(test program) error initializing comctl32.dll");
	initTable(NULL);
	mainwin = CreateWindowExW(0,
		tableWindowClass, L"Main Window",
		WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
		CW_USEDEFAULT, CW_USEDEFAULT,
		400, 400,
		NULL, NULL, GetModuleHandle(NULL), NULL);
	if (mainwin == NULL)
		panic("(test program) error creating Table");
	SendMessageW(mainwin, tableAddColumn, tableColumnText, (LPARAM) L"Column");
	SendMessageW(mainwin, tableAddColumn, tableColumnImage, (LPARAM) L"Column 2");
	SendMessageW(mainwin, tableAddColumn, tableColumnCheckbox, (LPARAM) L"Column 3");
	if (argc > 1) {
		NONCLIENTMETRICSW ncm;
		HFONT font;

		ZeroMemory(&ncm, sizeof (NONCLIENTMETRICSW));
		ncm.cbSize = sizeof (NONCLIENTMETRICSW);
		if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof (NONCLIENTMETRICSW), &ncm, sizeof (NONCLIENTMETRICSW)) == 0)
			panic("(test program) error getting non-client metrics");
		font = CreateFontIndirectW(&ncm.lfMessageFont);
		if (font == NULL)
			panic("(test program) error creating lfMessageFont HFONT");
		SendMessageW(mainwin, WM_SETFONT, (WPARAM) font, TRUE);
	}
	ShowWindow(mainwin, SW_SHOWDEFAULT);
	if (UpdateWindow(mainwin) == 0)
		panic("(test program) error updating window");
	while (GetMessageW(&msg, NULL, 0, 0) > 0) {
		TranslateMessage(&msg);
		DispatchMessageW(&msg);
	}
	return 0;
}
Exemple #10
0
/*
 * Create a tooltip for the control passed as first parameter
 * duration sets the duration in ms. Use -1 for default
 * message is an UTF-8 string
 */
HWND create_tooltip(HWND hControl, char* message, int duration)
{
	TOOLINFOW toolInfo = {0};
	int i;

	if ( (hControl == NULL) || (message == NULL) ) {
		return (HWND)NULL;
	}

	// Find an empty slot
	for (i=0; i<MAX_TOOLTIPS; i++) {
		if (ttlist[i].hTip == NULL) break;
	}
	if (i == MAX_TOOLTIPS) {
		return (HWND)NULL; // No more space
	}

	// Create the tooltip window
	ttlist[i].hTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hMainDialog, NULL,
		main_instance, NULL);

	if (ttlist[i].hTip == NULL) {
		return (HWND)NULL;
	}

	// Subclass the tooltip to handle multiline
	ttlist[i].original_proc = (WNDPROC)SetWindowLongPtr(ttlist[i].hTip, GWLP_WNDPROC, (LONG_PTR)tooltip_callback);

	// Set the string to display (can be multiline)
	ttlist[i].wstring = utf8_to_wchar(message);

	// Set tooltip duration (ms)
	PostMessage(ttlist[i].hTip, TTM_SETDELAYTIME, (WPARAM)TTDT_AUTOPOP, (LPARAM)duration);

	// Associate the tooltip to the control
	toolInfo.cbSize = sizeof(toolInfo);
	toolInfo.hwnd = ttlist[i].hTip;	// Set to the tooltip itself to ease up subclassing
	toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
	toolInfo.uId = (UINT_PTR)hControl;
	toolInfo.lpszText = LPSTR_TEXTCALLBACKW;
	SendMessageW(ttlist[i].hTip, TTM_ADDTOOLW, 0, (LPARAM)&toolInfo);

	return ttlist[i].hTip;
}
Exemple #11
0
bool CreateEditCtrl(EditCtrl *w) {
    // Note: has to remember this here because when I GetWindowStyle() later on,
    // WS_BORDER is not set, which is a mystery, because it is being drawn.
    // also, WS_BORDER seems to be painted in client areay
    w->hasBorder = bit::IsMaskSet<DWORD>(w->dwStyle, WS_BORDER);

    RECT rc = w->initialPos;
    w->hwnd = CreateWindowExW(w->dwExStyle, WC_EDIT, L"", w->dwStyle, rc.left, rc.top, RectDx(rc),
                              RectDy(rc), w->parent, nullptr, GetModuleHandleW(nullptr), nullptr);

    if (!w->hwnd) {
        return false;
    }
    SetFont(w, GetDefaultGuiFont());
    SetWindowSubclass(w->hwnd, EditProc, 0, (DWORD_PTR)w);
    SetWindowSubclass(GetParent(w->hwnd), EditParentProc, 0, (DWORD_PTR)w);
    return true;
}
Exemple #12
0
bool TreeCtrl::Create(const WCHAR* title) {
    if (!title) {
        title = L"";
    }

    RECT rc = this->initialPos;
    HMODULE hmod = GetModuleHandleW(nullptr);
    this->hwnd = CreateWindowExW(this->dwExStyle, WC_TREEVIEWW, title, this->dwStyle, rc.left, rc.top, RectDx(rc),
                                 RectDy(rc), this->parent, this->menu, hmod, nullptr);
    if (!this->hwnd) {
        return false;
    }
    TreeView_SetUnicodeFormat(this->hwnd, true);
    this->SetFont(GetDefaultGuiFont());
    Subclass(this);

    return true;
}
Exemple #13
0
static void create_tooltips_window(HTMLDocumentObj *This)
{
    tooltip_data *data = heap_alloc(sizeof(*data));

    This->tooltips_hwnd = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, TTS_NOPREFIX | WS_POPUP,
            CW_USEDEFAULT, CW_USEDEFAULT, 10, 10, This->hwnd, NULL, hInst, NULL);

    data->doc = This;
    data->proc = (WNDPROC)GetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC);

    SetPropW(This->tooltips_hwnd, wszTooltipData, data);

    SetWindowLongPtrW(This->tooltips_hwnd, GWLP_WNDPROC, (LONG_PTR)tooltips_proc);

    SetWindowPos(This->tooltips_hwnd, HWND_TOPMOST,0, 0, 0, 0,
                 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

}
	bool CWindowsApp::Init(wchar_t *windowName, int width, int height)
	{
		m_wndClassEx.cbSize = sizeof(WNDCLASSEX);
		m_wndClassEx.style = CS_CLASSDC;
		m_wndClassEx.lpfnWndProc = MsgProc;
		m_wndClassEx.cbClsExtra = 0L;
		m_wndClassEx.cbWndExtra = 0L;
		m_wndClassEx.hInstance = m_instanceHandle;
		m_wndClassEx.hIcon = nullptr;
		m_wndClassEx.hCursor = LoadCursor(nullptr, IDC_ARROW);
		m_wndClassEx.hbrBackground = nullptr;
		m_wndClassEx.lpszMenuName = nullptr;
		m_wndClassEx.lpszClassName = L"framework_9";
		m_wndClassEx.hIconSm = nullptr;
		//RegisterClassEx(&m_wndClassEx);
		RegisterClassExW(&m_wndClassEx);

		int screenX = GetSystemMetrics(SM_CXSCREEN);
		int screenY = GetSystemMetrics(SM_CYSCREEN);

		RECT windowRect;
		ZeroMemory(&windowRect, sizeof(windowRect));
		windowRect.left = (screenX - width) / 2;
		windowRect.top = (screenY - height) / 2;
		windowRect.right = windowRect.left + width;
		windowRect.bottom = windowRect.top + height;
		AdjustWindowRectEx(&windowRect, WindowStyle, 0, 0);

		//m_windowHandle = CreateWindowEx(
		m_windowHandle = CreateWindowExW(
			0L, m_wndClassEx.lpszClassName, windowName,
			WindowStyle,
			windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top,
			nullptr, nullptr, m_wndClassEx.hInstance, nullptr
			);

		m_width = width;
		m_height = height;

		if (!AllocDevice())
			return false;

		return true;
	}
Exemple #15
0
		DummyWindow::DummyWindow(HINSTANCE hinstance)
		{
			this->hinstance = hinstance;

			WCHAR classname[sizeof(DummyWindow*) * 2 + 1];
			win32::genClassNameStr(this, classname);

			WNDCLASSEXW klass;
			klass.cbSize = sizeof(WNDCLASSEXW);
			klass.style = CS_OWNDC;
			klass.lpfnWndProc = &wndproc;
			klass.cbClsExtra = 0;
			klass.cbWndExtra = 0;
			klass.hInstance = hinstance;
			klass.hIcon = 0;
			klass.hCursor = 0;
			klass.hbrBackground = 0;
			klass.lpszMenuName = 0;
			klass.lpszClassName = &classname[0];
			klass.hIconSm = 0;

			classatom = RegisterClassExW(&klass);
			if(!classatom)
				throw Exception("Can't register win32 window class: " + win32::getErrorMsg());

			hwnd = CreateWindowExW(
				0,
				&classname[0],
				L"",	// window title
				WS_POPUP | WS_DISABLED,
				CW_USEDEFAULT, CW_USEDEFAULT,
				100, 100, // width, height
				0,
				0,
				hinstance,
				0);

			if(!hwnd)
			{
				DWORD err = GetLastError();
				UnregisterClassW(&classname[0], hinstance);
				throw wm::Exception("Can't create Window: " + wm::win32::getErrorMsg(err));
			}
		}
Exemple #16
0
// Creates a dummy window for behind-the-scenes work
//
static HWND createHelperWindow(void)
{
    MSG msg;
    HWND window = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
                                  _GLFW_WNDCLASSNAME,
                                  L"GLFW message window",
                                  WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
                                  0, 0, 1, 1,
                                  NULL, NULL,
                                  GetModuleHandleW(NULL),
                                  NULL);
    if (!window)
    {
        _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
                             "Win32: Failed to create helper window");
        return NULL;
    }

    // HACK: The command to the first ShowWindow call is ignored if the parent
    //       process passed along a STARTUPINFO, so clear that with a no-op call
    ShowWindow(window, SW_HIDE);

    // Register for HID device notifications
    {
        DEV_BROADCAST_DEVICEINTERFACE_W dbi;
        ZeroMemory(&dbi, sizeof(dbi));
        dbi.dbcc_size = sizeof(dbi);
        dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
        dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;

        _glfw.win32.deviceNotificationHandle =
            RegisterDeviceNotificationW(window,
                                        (DEV_BROADCAST_HDR*) &dbi,
                                        DEVICE_NOTIFY_WINDOW_HANDLE);
    }

    while (PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessageW(&msg);
    }

   return window;
}
Exemple #17
0
HWND get_notif_hwnd(void)
{
    static ATOM wnd_class = 0;
    tls_data_t *tls_data;

    static const WCHAR wszURLMonikerNotificationWindow[] =
        {'U','R','L',' ','M','o','n','i','k','e','r',' ',
         'N','o','t','i','f','i','c','a','t','i','o','n',' ','W','i','n','d','o','w',0};

    tls_data = get_tls_data();
    if(!tls_data)
        return NULL;

    if(tls_data->notif_hwnd_cnt) {
        tls_data->notif_hwnd_cnt++;
        return tls_data->notif_hwnd;
    }

    if(!wnd_class) {
        static WNDCLASSEXW wndclass = {
            sizeof(wndclass), 0,
            notif_wnd_proc, 0, 0,
            NULL, NULL, NULL, NULL, NULL,
            wszURLMonikerNotificationWindow,
            NULL
        };

        wndclass.hInstance = hProxyDll;

        wnd_class = RegisterClassExW(&wndclass);
        if (!wnd_class && GetLastError() == ERROR_CLASS_ALREADY_EXISTS)
            wnd_class = 1;
    }

    tls_data->notif_hwnd = CreateWindowExW(0, wszURLMonikerNotificationWindow,
            wszURLMonikerNotificationWindow, 0, 0, 0, 0, 0, HWND_MESSAGE,
            NULL, hProxyDll, NULL);
    if(tls_data->notif_hwnd)
        tls_data->notif_hwnd_cnt++;

    TRACE("hwnd = %p\n", tls_data->notif_hwnd);

    return tls_data->notif_hwnd;
}
Exemple #18
0
int CIntfEnum::CreateEnumNotifWnd(HINSTANCE hInstance)
{
	if(hInstance)
	{
		WNDCLASSW WndClass;
		WndClass.style = 0;
		WndClass.cbClsExtra = 0;
		WndClass.cbWndExtra = 0;
		WndClass.hIcon = 0;
		WndClass.hCursor = 0;
		WndClass.hbrBackground = 0;
		WndClass.lpszMenuName = 0;
		WndClass.lpfnWndProc = CIntfEnum::EnumNotifWndProcStatic;
		WndClass.hInstance = hInstance;
		WndClass.lpszClassName = L"CIntfEnumNotifWnd";
		g_pEnumerator = this;
		RegisterClassW(&WndClass);
		m_hEnumNotifWnd = CreateWindowExW(0x80, L"CIntfEnumNotifWnd", L"CIntfEnumNotifWnd", 0x80000000u, 0, 0, 0, 0, 0, 0, hInstance, (LPVOID)this);
		if(m_hEnumNotifWnd)
		{
			ShowWindow(m_hEnumNotifWnd, 0);
		}
	}
	m_hSetupApiLibrary = LoadLibraryW(L"SetupApi.dll");
	if(m_hSetupApiLibrary)
	{
#define RESOLVE_SETUPAPI_FUNC(def) do{if(!(m_pfn##def = (Def_##def*)GetProcAddress(m_hSetupApiLibrary, #def)))return 0;}while(0)
		RESOLVE_SETUPAPI_FUNC(CM_Get_Parent);
		RESOLVE_SETUPAPI_FUNC(CM_Get_Depth);
		RESOLVE_SETUPAPI_FUNC(CM_Get_Device_IDA);
		RESOLVE_SETUPAPI_FUNC(CM_Locate_DevNodeA);
		RESOLVE_SETUPAPI_FUNC(CMP_WaitNoPendingInstallEvents);
		RESOLVE_SETUPAPI_FUNC(SetupDiGetClassDevsW);
		RESOLVE_SETUPAPI_FUNC(SetupDiGetDeviceInterfaceDetailW);
		RESOLVE_SETUPAPI_FUNC(SetupDiGetDeviceRegistryPropertyW);
		RESOLVE_SETUPAPI_FUNC(SetupDiEnumDeviceInterfaces);
		RESOLVE_SETUPAPI_FUNC(SetupDiDestroyDeviceInfoList);
		RESOLVE_SETUPAPI_FUNC(SetupDiEnumDeviceInfo);
		RESOLVE_SETUPAPI_FUNC(SetupDiOpenDeviceInterfaceRegKey);
		return 1;
	#undef RESOLVE_SETUPAPI_FUNC
	}
	return 0;
}
Exemple #19
0
uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar)
{
	uiWindow *w;
	WCHAR *wtitle;
	BOOL hasMenubarBOOL;

	uiWindowsNewControl(uiWindow, w);

	hasMenubarBOOL = FALSE;
	if (hasMenubar)
		hasMenubarBOOL = TRUE;
	w->hasMenubar = hasMenubarBOOL;

#define style WS_OVERLAPPEDWINDOW
#define exstyle 0

	wtitle = toUTF16(title);
	w->hwnd = CreateWindowExW(exstyle,
		windowClass, wtitle,
		style,
		CW_USEDEFAULT, CW_USEDEFAULT,
		// use the raw width and height for now
		// this will get CW_USEDEFAULT (hopefully) predicting well
		// even if it doesn't, we're adjusting it later
		width, height,
		NULL, NULL, hInstance, w);
	if (w->hwnd == NULL)
		logLastError(L"error creating window");
	uiFree(wtitle);

	if (hasMenubar) {
		w->menubar = makeMenubar();
		if (SetMenu(w->hwnd, w->menubar) == 0)
			logLastError(L"error giving menu to window");
	}

	// and use the proper size
	setClientSize(w, width, height, hasMenubarBOOL, style, exstyle);

	uiWindowOnClosing(w, defaultOnClosing, NULL);

	windows[w] = true;
	return w;
}
static HWND CreateWND(HINSTANCE const hInstance,
                      std::string const &window_name)
{
    std::wstring const window_wname(window_name.begin(), window_name.end());

    HWND const wnd = CreateWindowExW(0,                      // dwExStyle
                                     GetWNDCLASS(hInstance), // lpClassName
                                     window_wname.c_str(),   // lpWindowName
                                     WS_OVERLAPPEDWINDOW,    // dwStyle
                                     CW_USEDEFAULT,          // X
                                     CW_USEDEFAULT,          // Y
                                     CW_USEDEFAULT,          // nWidth
                                     CW_USEDEFAULT,          // nHeight
                                     HWND_DESKTOP,           // hWndParent
                                     nullptr,                // hMenu
                                     hInstance,              // hInstance
                                     nullptr);               // lpParam
    return wnd;
}
Exemple #21
0
//Registers, creates, and shows the Window!!
bool WinCreate()
{
    WindowINST = GetModuleHandle(0); // Get current process handle
    const WCHAR *szTitle=  (L"Cataclysm: Dark Days Ahead - 0.6git");

    // Register window class
    WNDCLASSEXW WindowClassType = {0};
    WindowClassType.cbSize        = sizeof(WNDCLASSEXW);
    WindowClassType.lpfnWndProc   = ProcessMessages;//the procedure that gets msgs
    WindowClassType.hInstance     = WindowINST;// hInstance
    WindowClassType.hIcon         = LoadIcon(WindowINST, MAKEINTRESOURCE(0)); // Get first resource
    WindowClassType.hIconSm       = LoadIcon(WindowINST, MAKEINTRESOURCE(0));
    WindowClassType.hCursor       = LoadCursor(NULL, IDC_ARROW);
    WindowClassType.lpszMenuName  = NULL;
    WindowClassType.lpszClassName = szWindowClass;
    if (!RegisterClassExW(&WindowClassType))
        return false;

    // Adjust window size
    uint32_t WndStyle = WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_VISIBLE; // Basic window, show on creation
    RECT WndRect;
    WndRect.left   = WndRect.top = 0;
    WndRect.right  = WindowWidth;
    WndRect.bottom = WindowHeight;
    AdjustWindowRect(&WndRect, WndStyle, false);

    // Center window
    RECT WorkArea;
    SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkArea, 0);
    int WindowX = WorkArea.right/2 - (WndRect.right - WndRect.left)/2;
    int WindowY = WorkArea.bottom/2 - (WndRect.bottom - WndRect.top)/2;

    // Magic
    WindowHandle = CreateWindowExW(0, szWindowClass , szTitle, WndStyle,
                                   WindowX, WindowY,
                                   WndRect.right - WndRect.left,
                                   WndRect.bottom - WndRect.top,
                                   0, 0, WindowINST, NULL);
    if (WindowHandle == 0)
        return false;

    return true;
};
// Creates a dummy window for behind-the-scenes work
//
static HWND createHelperWindow(void)
{
    HWND window = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
                                  _GLFW_WNDCLASSNAME,
                                  L"GLFW helper window",
                                  WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
                                  0, 0, 1, 1,
                                  NULL, NULL,
                                  GetModuleHandleW(NULL),
                                  NULL);
    if (!window)
    {
        _glfwInputError(GLFW_PLATFORM_ERROR,
                        "Win32: Failed to create helper window");
        return NULL;
    }

    return window;
}
Exemple #23
0
Window::Window()
    : closed(false)
{
    hinst = (HINSTANCE)GetModuleHandleW(nullptr);

    WNDCLASSEXW wndc = { sizeof(wndc) };
    wndc.lpszClassName = WINDOW_CLASS;
    wndc.cbWndExtra = sizeof(Window *);
    wndc.lpfnWndProc = WinProc;
    RegisterClassExW(&wndc);

    hwnd = CreateWindowExW(
        0U, WINDOW_CLASS, L"Cnnr's Vulkan Renderer", WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
        nullptr, nullptr, hinst, this
    );

    ShowWindow(hwnd, SW_SHOW);
}
Exemple #24
0
static HWND create_syslink(DWORD style, HWND parent)
{
    HWND hWndSysLink;
    static const WCHAR linkW[] = {'H','e','a','d',' ','<','a',' ','h','r','e','f','=','"','l','i','n','k','1','"','>','N','a','m','e','1','<','/','a','>',' ','M','i','d','d','l','e',' ','<','a',' ','h','r','e','f','=','"','l','i','n','k','2','"','>','N','a','m','e','2','<','/','a','>',' ','T','a','i','l',0};

    /* Only Unicode will do here */
    hWndSysLink = CreateWindowExW(0, WC_LINK, linkW,
                                style, 0, 0, 150, 50,
                                parent, NULL, GetModuleHandleW(NULL), NULL);
    if (!hWndSysLink) return NULL;

    if (GetWindowLongPtrW(hWndSysLink, GWLP_USERDATA))
        /* On Windows XP SysLink takes GWLP_USERDATA for itself! */
        trace("SysLink makes use of GWLP_USERDATA\n");

    syslink_oldproc = (WNDPROC)SetWindowLongPtrW(hWndSysLink, GWLP_WNDPROC, (LONG_PTR)syslink_subclass_proc);

    return hWndSysLink;
}
void little::initWindow()
{
    RECT& rc = m_rcDesktop;
    GetWindowRect(GetDesktopWindow(), &m_rcDesktop);
    m_rect.x       = rc.left;
    m_rect.y       = rc.top;
    m_rect.width   = rc.right - rc.left;
    m_rect.height  = rc.bottom - rc.top;
    m_cyFullScreen = GetSystemMetrics(SM_CYFULLSCREEN);
    
    WNDCLASSEXW wndCls;
    wndCls.cbSize        = sizeof(wndCls);
    wndCls.hInstance     = m_hInst;
    wndCls.lpszClassName = WNDCLASSNAME;
    wndCls.style         = CS_HREDRAW | CS_VREDRAW;
    wndCls.lpfnWndProc   = WndProc;
    wndCls.hIcon         = NULL; // todo
    wndCls.hIconSm       = NULL; // todo
    wndCls.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wndCls.cbClsExtra    = 0;
    wndCls.cbWndExtra    = 0;
    wndCls.hbrBackground = NULL;
    wndCls.lpszMenuName  = NULL;

    RegisterClassExW(&wndCls);

    m_hWnd = CreateWindowExW(WS_EX_LAYERED |
                             WS_EX_TOPMOST |
                             WS_EX_TOOLWINDOW|  // Òþ²ØÈÎÎñÀ¸Í¼±ê
                             WS_EX_TRANSPARENT, // Êó±ê´©Í¸
                                WNDCLASSNAME,
                                NULL,
                                WS_OVERLAPPEDWINDOW,
                                m_rect.x,
                                m_rect.y,
                                m_rect.width,
                                m_rect.height,
                                NULL,
                                NULL,
                                m_hInst,
                                NULL);
}
Exemple #26
0
void bbGLGraphicsShareContexts(){
	BBGLContext *context;
	HDC hdc;
	HWND hwnd;
	HGLRC hglrc;
	long pf;
	PIXELFORMATDESCRIPTOR pfd;
	
	if( _sharedContext ) return;
	
	_initWndClass();
	
	if( _bbusew ){
		hwnd=CreateWindowExW( 0,CLASS_NAMEW,0,WS_POPUP,0,0,1,1,0,0,GetModuleHandle(0),0 );
	}else{
		hwnd=CreateWindowEx( 0,CLASS_NAME,0,WS_POPUP,0,0,1,1,0,0,GetModuleHandle(0),0 );
	}
		
	_initPfd( &pfd,0 );
	
	hdc=GetDC( hwnd );
	pf=ChoosePixelFormat( hdc,&pfd );
	if( !pf ){
		exit(0);
		DestroyWindow( hwnd );
		return;
	}
	SetPixelFormat( hdc,pf,&pfd );
	hglrc=wglCreateContext( hdc );
	if( !hglrc ) exit(0);
	
	_sharedContext=(BBGLContext*)malloc( sizeof(BBGLContext) );
	memset( _sharedContext,0,sizeof(BBGLContext) );

	_sharedContext->mode=MODE_SHARED;	
	_sharedContext->width=1;
	_sharedContext->height=1;
	
	_sharedContext->hdc=hdc;
	_sharedContext->hwnd=hwnd;
	_sharedContext->hglrc=hglrc;
}
Exemple #27
0
/* Create vertical splitter bar */
BOOL
CreateVSplitBar(HWND hwnd)
{
    WCHAR szWindowClass[] = L"VSplitterWindowClass";
    WNDCLASSEXW WndClass = {0};

    WndClass.cbSize        = sizeof(WNDCLASSEXW);
    WndClass.lpszClassName = szWindowClass;
    WndClass.lpfnWndProc   = VSplitterWindowProc;
    WndClass.hInstance     = hInst;
    WndClass.style         = CS_HREDRAW | CS_VREDRAW;
    WndClass.hCursor       = LoadCursor(0, IDC_SIZEWE);
    WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);

    if (RegisterClassExW(&WndClass) == (ATOM) 0)
    {
        /* TODO: Show error message */
        return FALSE;
    }

    hVSplitter = CreateWindowExW(WS_EX_TRANSPARENT,
                                 szWindowClass,
                                 NULL,
                                 WS_CHILD | WS_VISIBLE,
                                 201, 28, SPLIT_WIDTH, 350,
                                 hwnd,
                                 NULL,
                                 hInst,
                                 NULL);


    if (!hVSplitter)
    {
        /* TODO: Show error message */
        return FALSE;
    }

    ShowWindow(hVSplitter, SW_SHOW);
    UpdateWindow(hVSplitter);

    return TRUE;
}
Exemple #28
0
DcxEdit::DcxEdit(const UINT ID, DcxDialog *p_Dialog, const HWND mParentHwnd, const RECT *rc, TString &styles)
: DcxControl(ID, p_Dialog)
{
	LONG Styles = 0, ExStyles = 0;
	BOOL bNoTheme = FALSE;
	this->parseControlStyles(styles, &Styles, &ExStyles, &bNoTheme);

	this->m_Hwnd = CreateWindowExW(
		ExStyles | WS_EX_CLIENTEDGE, 
		L"EDIT",
		NULL,
		WS_CHILD | Styles,
		rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top,
		mParentHwnd,
		(HMENU) ID,
		GetModuleHandle(NULL), 
		NULL);

	if (!IsWindow(this->m_Hwnd))
		throw "Unable To Create Window";

	if (bNoTheme)
		Dcx::UXModule.dcxSetWindowTheme(this->m_Hwnd , L" ", L" ");

	Edit_LimitText(this->m_Hwnd, 0);
	//this->m_tsText = "";

	//SendMessage(this->m_Hwnd, CCM_SETUNICODEFORMAT, TRUE, NULL);

	if (p_Dialog->getToolTip() != NULL) {
		if (styles.istok("tooltips")) {
			this->m_ToolTipHWND = p_Dialog->getToolTip();
			AddToolTipToolInfo(this->m_ToolTipHWND, this->m_Hwnd);
		}
	}

	this->m_bIgnoreRepeat = TRUE;
	this->setControlFont((HFONT) GetStockObject(DEFAULT_GUI_FONT), FALSE);
	this->registreDefaultWindowProc();
	SetProp(this->m_Hwnd, "dcx_cthis", (HANDLE) this);
	DragAcceptFiles(this->m_Hwnd, TRUE);
}
Exemple #29
0
DWORD CreateSwitcherWindow(HINSTANCE hInstance)
{
    switchdialog = CreateWindowExW( WS_EX_TOPMOST|WS_EX_DLGMODALFRAME|WS_EX_TOOLWINDOW,
                                    WC_SWITCH,
                                    L"",
                                    WS_POPUP|WS_BORDER|WS_DISABLED,
                                    CW_USEDEFAULT,
                                    CW_USEDEFAULT,
                                    400, 150,
                                    NULL, NULL,
                                    hInstance, NULL);
    if (!switchdialog)
    {
       TRACE("[ATbot] Task Switcher Window failed to create.\n");
       return 0;
    }
                                
    isOpen = FALSE;
    return 1;
}
Exemple #30
0
/*
 * CreateTreeView - creates a tree view control.
 * Returns the handle to the new control if successful, or NULL otherwise.
 * hwndParent - handle to the control's parent window.
 */
HWND CreateTreeView(HWND hwndParent, LPWSTR pHostName, UINT id)
{
    RECT rcClient;
    HWND hwndTV;
    WCHAR TreeView[] = {'T','r','e','e',' ','V','i','e','w',0};

    /* Get the dimensions of the parent window's client area, and create the tree view control.  */
    GetClientRect(hwndParent, &rcClient);
    hwndTV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_TREEVIEWW, TreeView,
                            WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS,
                            0, 0, rcClient.right, rcClient.bottom,
                            hwndParent, ULongToHandle(id), hInst, NULL);
    SendMessageW(hwndTV, TVM_SETUNICODEFORMAT, TRUE, 0);
    /* Initialize the image list, and add items to the control.  */
    if (!InitTreeViewImageLists(hwndTV) || !InitTreeViewItems(hwndTV, pHostName)) {
        DestroyWindow(hwndTV);
        return NULL;
    }
    return hwndTV;
}