コード例 #1
0
ファイル: window.cpp プロジェクト: emuikernel/BaijieCppUILib
 static LRESULT CALLBACK wnd_proc_primordial( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   if(msg == WM_NCCREATE)
   {
     CREATESTRUCT* lpcs = (CREATESTRUCT*)lParam;
     window* pw = (window*)lpcs->lpCreateParams;
     pw->hwnd = hwnd;
     SetWindowLongPtr(hwnd, GWLP_USERDATA, LONG_PTR(pw));
     SetWindowLongPtr(hwnd, GWLP_WNDPROC,  LONG_PTR(&wnd_proc));
   }
   return DefWindowProc(hwnd, msg, wParam, lParam);
 }
コード例 #2
0
ファイル: BalloonMsg.cpp プロジェクト: mikekov/ExifPro
void BalloonMsg::Unsubclass()
{
	if (g_sentry)
	{
		if (g_pfnOldWindowProc)
			::SetWindowLongPtr(g_sentry, GWLP_WNDPROC, LONG_PTR(g_pfnOldWindowProc));
		if (g_pfnOldWindowProc2)
			::SetWindowLongPtr(g_parent, GWLP_WNDPROC, LONG_PTR(g_pfnOldWindowProc2));

		g_pfnOldWindowProc = 0;
		g_sentry = 0;
		g_pfnOldWindowProc2 = 0;
		g_parent = 0;
		g_balloon = 0;
	}
}
コード例 #3
0
ファイル: AsyncSocketEx.cpp プロジェクト: swax/GnucDNA
	CAsyncSocketExHelperWindow()
	{
		//Initialize data
		m_pAsyncSocketExWindowData=new t_AsyncSocketExWindowData[512]; //Reserve space for 512 active sockets
		memset(m_pAsyncSocketExWindowData, 0, 512*sizeof(t_AsyncSocketExWindowData));
		m_nWindowDataSize=512;
		m_nSocketCount=0;
		m_nWindowDataPos=0;

		//Create window
		WNDCLASSEX wndclass;
		wndclass.cbSize=sizeof wndclass;
		wndclass.style=0;
		wndclass.lpfnWndProc=WindowProc;
		wndclass.cbClsExtra=0;
		wndclass.cbWndExtra=0;
		wndclass.hInstance=GetModuleHandle(0);
		wndclass.hIcon=0;
		wndclass.hCursor=0;
		wndclass.hbrBackground=0;
		wndclass.lpszMenuName=0;
		wndclass.lpszClassName=_T("GnucDNA CAsyncSocketEx Helper Window");
		wndclass.hIconSm=0;

		RegisterClassEx(&wndclass);

		m_hWnd=CreateWindow(_T("GnucDNA CAsyncSocketEx Helper Window"), _T("GnucDNA CAsyncSocketEx Helper Window"), 0, 0, 0, 0, 0, 0, 0, 0, GetModuleHandle(0));
		ASSERT(m_hWnd);
		SetWindowLong(m_hWnd, GWL_USERDATA, LONG_PTR(this));
	};
コード例 #4
0
void OverrideWndProc(WNDPROC pWndProc, WNDPROC WindowProc, HWND hWnd) {
	if (!IsWindow(hWnd)) return;
	if (!(pWndProc = (WNDPROC)GetWindowLongPtr(hWnd, GWLP_WNDPROC)))
		OutputDebugStringEx(L"pOldWndProc: %s", GetLastErrorEx().c_str());
	if (!SetWindowLongPtr(hWnd, GWLP_WNDPROC, LONG_PTR(WindowProc)))
		OutputDebugStringEx(L"SetWindowLongPtr: %s", GetLastErrorEx().c_str());
}
コード例 #5
0
LRESULT CALLBACK Synchronizer::s_wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) // Win32-only
{
	Synchronizer * pThis;
	int swlresult;
	switch (msg)
	{
	
	case WM_NCCREATE:
		pThis = (Synchronizer *)((LPCREATESTRUCT(lParam))->lpCreateParams);
		UT_return_val_if_fail(pThis, 0);
		pThis->m_hWnd = hWnd;
		SetLastError(0);
		swlresult=SetWindowLongPtrW(hWnd,GWLP_USERDATA,LONG_PTR(pThis));
		if (swlresult==0)
		{
			// we might have an error
			int errorcode=GetLastError();
			if (errorcode)
			{
				UT_DEBUGMSG(("Error in setting the WindowLong GWLP_USERDATA: %d\n", errorcode));
			}
			
		}
		return 1;
		
	case WM_ABI_SYNCHRONIZER:
		UT_DEBUGMSG(("Received a message in Synchronizer message loop! 0x%x\n", msg));
		pThis = (Synchronizer *)GetWindowLongPtrW(hWnd,GWLP_USERDATA);
		UT_return_val_if_fail(pThis, 0);
		if (pThis->m_bIsProcessing)
		{
			pThis->m_iDeferredMessages++;
		}
		else
		{
			pThis->m_bIsProcessing = true;
			bool bIsDestroyed = false;
			pThis->m_bIsDestroyed = &bIsDestroyed;
			pThis->callMainloop();
			while (!bIsDestroyed && pThis->m_iDeferredMessages)
			{
				pThis->callMainloop();
				--pThis->m_iDeferredMessages;
			}
			if (!bIsDestroyed) 
			{
				pThis->m_bIsProcessing = false;
				pThis->m_bIsDestroyed = NULL;
			}
		}
		return true;

	default:
		UT_DEBUGMSG(("return DefWindowProc for message 0x%x\n", msg));
		// We do not want to handle this message so pass back to Windows
		// to handle it in a default way
		return 0;
	}
}
コード例 #6
0
ファイル: layered.cpp プロジェクト: Archs/sciter-sdk
bool window::init()
{
   SciterSetOption(_hwnd, SCITER_ALPHA_WINDOW, TRUE);
   SetWindowLongPtr(_hwnd, GWLP_USERDATA, LONG_PTR(this));
   setup_callback();
   load_file(L"res:default.htm");
   return true;
}
コード例 #7
0
ファイル: shortcut.cpp プロジェクト: quachdnguyen/locate-src
DWORD CSubAction::GetData(DWORD nAction,BYTE* pData_,BOOL bHeader) const
{
	BYTE* pData=pData_;
	
	if (bHeader)
	{
		*((WORD*)pData)=0xFFEA;
		pData+=sizeof(WORD);
	}

	*((DWORD*)pData)=m_nSubAction;
	*((DWORD*)(pData+sizeof(DWORD)))=(DWORD)min(LONG_PTR(m_pExtraInfo),MAXDWORD);
	pData+=2*sizeof(DWORD);
	

	switch (nAction)
	{
	case CAction::ResultListItems:
		if (m_nResultList==Execute && m_szVerb!=NULL)
		{
			DWORD dwUsed=DWORD(istrlenw(m_szVerb)+1);
			MemCopyW((LPWSTR)pData,m_szVerb,dwUsed);
			pData+=dwUsed*2;
		}
		else if (m_nResultList==ExecuteCommand && m_szCommand!=NULL)
		{
			DWORD dwUsed=DWORD(istrlenw(m_szCommand)+1);
			MemCopyW((LPWSTR)pData,m_szCommand,dwUsed);
			pData+=dwUsed*2;
		}
		break;
	case CAction::Misc:
		if ((m_nMisc==SendMessage || m_nMisc==PostMessage) && 			
			m_pSendMessage!=NULL)
		{
			DWORD dwUsed=m_pSendMessage->GetData(pData);
			pData+=dwUsed;
		}
		else if (m_nMisc==ExecuteCommandMisc && m_szCommand!=NULL)
		{
			DWORD dwUsed=DWORD(istrlenw(m_szCommand)+1);
			MemCopyW((LPWSTR)pData,m_szCommand,dwUsed);
			pData+=dwUsed*2;
		}
		break;
	case CAction::Presets:
	case CAction::ChangeValue:
		if (m_szPreset!=NULL)
		{
			DWORD dwUsed=DWORD(istrlenw(m_szPreset)+1);
			MemCopyW((LPWSTR)pData,m_szPreset,dwUsed);
			pData+=dwUsed*2;
		}
		break;
	}

	return DWORD(pData-pData_);
}
コード例 #8
0
ファイル: Twidget.cpp プロジェクト: JERUKA9/ffdshow-tryouts
Twidget::Twidget(HWND Ih):h(Ih),ownproc(false)
{
    if (h) {
        SetWindowLongPtr(h,GWLP_USERDATA,LONG_PTR(this));
        id=Twindow::getId(h);
    } else {
        id=0;
    }
}
コード例 #9
0
BOOL Tooltip::create(void)
{
	hwnd = CreateWindowEx( WS_EX_TOOLWINDOW, tooltipClass, NULL, WS_POPUP, 0, 0, 0, 0,
		HWND_DESKTOP, NULL, HINSTANCE(GetModuleHandle(NULL)), NULL);
	if( !hwnd )
		return FALSE;
	SetWindowLongPtr( hwnd, GWLP_USERDATA, LONG_PTR(this));
	return TRUE;
}
コード例 #10
0
ファイル: editwininfo.cpp プロジェクト: MASHinfo/mame
editwin_info::editwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) :
	debugwin_info(debugger, is_main_console, title, handler),
	m_editwnd(nullptr),
	m_edit_defstr(),
	m_original_editproc(nullptr),
	m_history(),
	m_last_history(0)
{
	if (window() == nullptr)
		return;

	// create an edit box and override its key handling
	m_editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), nullptr, EDIT_BOX_STYLE,
			0, 0, 100, 100, window(), nullptr, GetModuleHandleUni(), nullptr);
	m_original_editproc = WNDPROC(uintptr_t(GetWindowLongPtr(m_editwnd, GWLP_WNDPROC)));
	SetWindowLongPtr(m_editwnd, GWLP_USERDATA, LONG_PTR(this));
	SetWindowLongPtr(m_editwnd, GWLP_WNDPROC, LONG_PTR(&editwin_info::static_edit_proc));
	SendMessage(m_editwnd, WM_SETFONT, WPARAM(metrics().debug_font()), LPARAM(FALSE));
	SendMessage(m_editwnd, EM_LIMITTEXT, WPARAM(MAX_EDIT_STRING), LPARAM(0));
	set_editwnd_text("");
}
コード例 #11
0
ファイル: Subclass.cpp プロジェクト: ByteRisc/pwsafe
/////////////////
// Add hook to map; i.e., associate hook with window
//
void CSubclassWndMap::Add(HWND hwnd, CSubclassWnd* pSubclassWnd)
{
  ASSERT(hwnd && ::IsWindow(hwnd));

  // Add to front of list
  pSubclassWnd->m_pNext = Lookup(hwnd);
  SetAt(hwnd, pSubclassWnd);

  if (pSubclassWnd->m_pNext == NULL) {
    // If this is the first hook added, subclass the window
    pSubclassWnd->m_pOldWndProc =
      SetWindowLongPtr(hwnd, GWLP_WNDPROC, LONG_PTR(HookWndProc));
  } else {
    // just copy wndproc from next hook
    pSubclassWnd->m_pOldWndProc = pSubclassWnd->m_pNext->m_pOldWndProc;
  }
  ASSERT(pSubclassWnd->m_pOldWndProc);
}
コード例 #12
0
ファイル: Window2.cpp プロジェクト: Ando02/wubiuefi
static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message, 
    WPARAM wParam, LPARAM lParam)
{
  CWindow tempWindow(aHWND);
  if (message == WM_NCCREATE)
    tempWindow.SetUserDataLongPtr(
        LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams));
  CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr());
  if (window != NULL && message == WM_NCCREATE)
    window->Attach(aHWND);
  if (window == 0)
  {
    #ifndef _UNICODE
    if (g_IsNT)
      return DefWindowProcW(aHWND, message, wParam, lParam);
    else
    #endif
      return DefWindowProc(aHWND, message, wParam, lParam);
  }
  return window->OnMessage(message, wParam, lParam);
}
コード例 #13
0
ファイル: sciter.cpp プロジェクト: huxiyu/sciter-sdk
  bool frame::setup(const wchar_t* url, HWND parent)
  {
    _hwnd = CreateWindowEx(0,WINDOW_CLASS_NAME, L"sciter-frame", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, NULL, ghInstance, this);
    
    if (!_hwnd)
      return false;
     
    SetWindowLongPtr(_hwnd, GWLP_USERDATA, LONG_PTR(this));
    setup_callback(); // to receive SC_LOAD_DATA, SC_DATA_LOADED, etc. notification
    attach_dom_event_handler(_hwnd,this); // to receive DOM events

//#ifdef _DEBUG    
//    SciterSetMediaType(_hwnd,L"on-debug");
//#endif    


    init_window();

    load_file(url);

    dom::element root_el = root();

    //json::string s = root_el.combine_url(json::string());

    assert(root_el.is_valid());
    if(root_el)
    {
      init_instance(root_el);
      dom::element title_el = root_el.find_first(":root>head>title");
      set_title(title_el.text());
    }     
    
    ShowWindow(_hwnd, SW_SHOW);
    UpdateWindow(_hwnd);
    
    return true;
  }
コード例 #14
0
//-------------------------------------------------------------------------
INT_PTR CALLBACK ResetPermissionDialog::s_MainDialogProc(
    HWND hWnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam)
{
    ResetPermissionDialog *Dlg;

    // Dialog initialized? Let's setup / remember the instance pointer
    if (message == WM_INITDIALOG)
    {
        // Get the passed instance
        Dlg = (ResetPermissionDialog *)lParam;

        // Associate the dialog instance with the window's user data
        SetWindowLongPtr(
            hWnd,
            GWLP_USERDATA,
            LONG_PTR(Dlg));
    }
    // Extract the dialog instance from the window's data
    else
    {
        Dlg = (ResetPermissionDialog *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
    }

    // Dispatch the message to this specific dialog instance
    INT_PTR Ret = Dlg == nullptr ? FALSE : Dlg->MainDialogProc(hWnd, message, wParam, lParam);

    if (message == WM_DESTROY)
    {
        // Delete the dialog instance
        delete Dlg;
    }

    return Ret;
}
コード例 #15
0
ファイル: Twinamp2.cpp プロジェクト: TheRyuu/ffdshow
unsigned int __stdcall Twinamp2dsp::threadProc(void *self0)
{
    Twinamp2dsp *self = (Twinamp2dsp*)self0;
    static const char_t *FFDSHOW_WINAMP_CLASS = _l("ffdshow_winamp_class");
    randomize();
    setThreadName(DWORD(-1), "winamp2");

    HINSTANCE hi = self->mod->hDllInstance;
    char_t windowName[80];
    tsnprintf_s(windowName, countof(windowName), _TRUNCATE, _l("%s_window%i"), FFDSHOW_WINAMP_CLASS, rand());
    HWND h = createInvisibleWindow(hi, FFDSHOW_WINAMP_CLASS, windowName, wndProc, self, NULL);
    self->mod->hwndParent = h;
    if (self->mod->Init(self->mod) == 0) {
        {
            boost::unique_lock<boost::mutex> lock(self->mut);
            self->h = h;
        }
        self->cond.notify_one();
        if (self->h) {
            SetWindowLongPtr(self->h, GWLP_USERDATA, LONG_PTR(self));
            MSG msg;
            while (GetMessage(&msg, NULL, 0, 0)) {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
    } else {
        self->h = (HWND) - 1;
        DestroyWindow(h);
    }
    if (self->mod->Quit) {
        self->mod->Quit(self->mod);
    }
    UnregisterClass(FFDSHOW_WINAMP_CLASS, hi);
    _endthreadex(0);
    return 0;
}
コード例 #16
0
ファイル: window.cpp プロジェクト: delfigamer/mist
	Window::Window( WindowCreationData const& wcd )
		: m_hwnd( 0 )
		, m_terminated( false )
		, m_renderermodule( 0 )
		, m_finishrequired( false )
		, m_finished( false )
	{
		memset( &m_pointstate, 0, sizeof( m_pointstate ) );
		m_silent = utils::MainConf->boolean( "silent", false );
		m_fpscounter = 0;
		m_fpstime = 0x7fffffff;
		if( !m_silent )
		{
			m_wndclass.style = CS_VREDRAW | CS_HREDRAW;
			m_wndclass.lpfnWndProc = &GlobalWindowProc;
			m_wndclass.cbClsExtra = 8;
			m_wndclass.cbWndExtra = 0;
			m_wndclass.hInstance = wcd.hInstance;
			m_wndclass.hIcon = LoadIcon( 0, IDI_APPLICATION );
			m_wndclass.hCursor = LoadCursor( 0, IDC_ARROW );
			m_wndclass.hbrBackground = 0;
			m_wndclass.lpszMenuName = 0;
			m_wndclass.lpszClassName = ClassName;
			if( !RegisterClassW( &m_wndclass ) )
			{
				CheckWinError();
			}
			HWND dummy = CreateWindowW(
				ClassName,
				L"dummy",
				WS_DISABLED,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				0,
				0,
				m_wndclass.hInstance,
				0 );
			if( !dummy )
			{
				CheckWinError();
			}
			if( !SetClassLongPtr( dummy, 0, LONG_PTR( this ) ) )
			{
				CheckWinError();
			}
			if( !DestroyWindow( dummy ) )
			{
				CheckWinError();
			}
			RECT WindowRect = {
				0,
				0,
				LONG( utils::MainConf->integer(
					"windowsize[1] or windowsize.x",
					640 ) ),
				LONG( utils::MainConf->integer(
					"windowsize[2] or windowsize.y",
					480 ) ) };
			if( !AdjustWindowRect(
				&WindowRect, WindowStyle, false ) )
			{
				CheckWinError();
			}
			m_hwnd = CreateWindowW(
				ClassName,
				WindowCaption,
				WindowStyle,
				20,
				20,
				WindowRect.right - WindowRect.left,
				WindowRect.bottom - WindowRect.top,
				0,
				0,
				m_wndclass.hInstance,
				0 );
			if( !m_hwnd )
			{
				CheckWinError();
			}
			ShowWindow( m_hwnd, SW_SHOW );
		}
		initialize();
		if( !m_silent )
		{
			UpdateWindow( m_hwnd );
		}
	}
コード例 #17
0
ファイル: BaseTrayIcon.cpp プロジェクト: lpl319/lavfilters
HRESULT CBaseTrayIcon::CreateMessageWindow()
{
  m_hWnd = CreateWindowEx(0, L"LAVTrayIconClass", L"LAV Tray Message Window", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL);
  SetWindowLongPtr(m_hWnd, GWLP_USERDATA, LONG_PTR(this));
  return m_hWnd == NULL ? E_FAIL : S_OK;
}
コード例 #18
0
ファイル: taskdialog.cpp プロジェクト: pilkch/library
  int cTaskDialog::Run(cWindow& parent, const cTaskDialogSettings& settings)
  {
    // Create our task dialog
    TASKDIALOGCONFIG tdc = { 0 };
    tdc.cbSize = sizeof(tdc);
    tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION;
    if (settings.bIsCheckBoxTickedInitially) tdc.dwFlags |= TDF_VERIFICATION_FLAG_CHECKED;
    tdc.dwCommonButtons = (settings.bCloseButtonText ? TDCBF_CLOSE_BUTTON : TDCBF_CANCEL_BUTTON);
    tdc.hwndParent = parent.GetWindowHandle();
    tdc.hInstance = GetHInstance();

    //tdc.hMainIcon = hIcon;

    switch (settings.type) {
      case cTaskDialogSettings::TYPE::INFORMATION: {
        tdc.pszMainIcon = TD_INFORMATION_ICON;
        break;
      }
      case cTaskDialogSettings::TYPE::WARNING: {
        tdc.pszMainIcon = TD_ERROR_ICON;
        break;
      }
      case cTaskDialogSettings::TYPE::ERROR: {
        tdc.pszMainIcon = TD_ERROR_ICON;
        break;
      }
    };

    tdc.pszWindowTitle = settings.sCaption.c_str();
    tdc.pszMainInstruction = settings.sInstructions.c_str();
    tdc.pszContent = settings.sContent.c_str();

    // Add our buttons
    TASKDIALOG_BUTTON* pButtons = nullptr;
    const size_t nButtons = settings.items.size();
    if (!settings.items.empty()) {
      tdc.dwFlags |= TDF_USE_COMMAND_LINKS;

      pButtons = new TASKDIALOG_BUTTON[nButtons];
      for (size_t i = 0; i < nButtons; i++) {
        pButtons[i].nButtonID = settings.items[i].iCommandID;
        string_t sText(settings.items[i].sText);
        if (!settings.items[i].sTextDescription.empty()) {
          sText += TEXT("\n");
          sText += settings.items[i].sTextDescription;
        }

        const size_t nSize = sText.length() + 1;
        pButtons[i].pszButtonText = new wchar_t[nSize];
        wcscpy_s((wchar_t*)(pButtons[i].pszButtonText), nSize, sText.c_str());
      }

      tdc.pButtons = pButtons;
      tdc.cButtons = UINT(nButtons);

      tdc.nDefaultButton = settings.iDefaultItemCommandID;
    }

    /*PCWSTR      pszExpandedInformation;
    PCWSTR      pszExpandedControlText;
    PCWSTR      pszCollapsedControlText;*/

    tdc.pfCallback = _TaskDialogCallbackProc;
    tdc.lpCallbackData = LONG_PTR(this);

    if (settings.bIsProgressBarVisible) {
      tdc.dwFlags |= TDF_CALLBACK_TIMER | TDF_SHOW_PROGRESS_BAR;
    }

    // Checkbox
    if (settings.bIsCheckBoxVisible) {
      tdc.dwFlags |= TDF_EXPAND_FOOTER_AREA;
      tdc.pszVerificationText = settings.sCheckBoxTitle.c_str();
    }

    // Run the task dialog
    int iButton = 0;
    //BOOL bResult = FALSE;
    const HRESULT rResult = TaskDialogIndirect(&tdc, &iButton, NULL, nullptr /*&bResult*/);
    assert(rResult == S_OK);

    // Clear our window handle
    hwndWindow = NULL;

    // Destroy our buttons
    if (pButtons != nullptr) {
      for (size_t i = 0; i < nButtons; i++) delete [] pButtons[i].pszButtonText;
      delete [] pButtons;
    }

    // If there was an error then pretend the user cancelled
    if (rResult != S_OK) iButton = IDCANCEL;
    
    // If no valid selection was made then pretend the user cancelled
    if (iButton < 0) iButton = IDCANCEL;

    // Return the button that was selected
    return iButton;
  }
コード例 #19
0
ファイル: view_sparrow.cpp プロジェクト: wangyongcong/pixpad
	bool CViewSparrow::initialize(int x, int y, unsigned w, unsigned h)
	{
		CWindowsApplication* app_inst = dynamic_cast<CWindowsApplication*>(CApplication::get_instance());
		if (!app_inst)
		{
			return false;
		}

		HINSTANCE os_instance = app_inst->os_instance();
		HWND main_wnd = app_inst->os_window();

		const wchar_t *className = L"D2DTargetWindow";
		WNDCLASSEX wndcls;
		if (!GetClassInfoEx(os_instance, className, &wndcls)) {
			wndcls.cbSize = sizeof(WNDCLASSEX);
			wndcls.style = CS_HREDRAW | CS_VREDRAW;
			wndcls.hInstance = os_instance;
			wndcls.lpfnWndProc = WNDPROC(&ViewSparrowProcess);
			wndcls.cbClsExtra = 0;
			wndcls.cbWndExtra = 0;
			wndcls.hCursor = LoadCursor(NULL, IDC_ARROW);
			wndcls.hIcon = NULL;
			wndcls.hIconSm = NULL;
			wndcls.hbrBackground = NULL;
			wndcls.lpszMenuName = NULL;
			wndcls.lpszClassName = className;
			if (!RegisterClassEx(&wndcls))
				return false;
		}

		HWND target_wnd = CreateWindowEx(0, className, NULL, WS_CHILDWINDOW,
			x, y, w, h, main_wnd, NULL, os_instance, NULL);
		if (!target_wnd)
		{
			return false;
		}

		ID2D1Factory *ptr_factory = nullptr;
		D2D1_FACTORY_OPTIONS options;
		options.debugLevel = D2D1_DEBUG_LEVEL_NONE;
		HRESULT result = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, options, &ptr_factory);
		if (result != S_OK)
		{
			error("Failed to initialize Direct2D factory.");
			return false;
		}

		m_hwnd = target_wnd;
		m_d2d_factory = ptr_factory;

		if (!rebuild_resource())
		{
			error("Failed to create graphic resource.");
			return false;
		}
		
		m_target = std::make_shared<CSpwRenderTarget>();
		if (!m_target->create(w, h, SPR_COLOR_B8G8R8A8 | SPR_DEPTH_16))
		{
			m_target = nullptr;
			error("Failed to create sparrow render target.");
			return false;
		}
		m_renderer = std::make_shared<CSpwRenderer>();
		m_renderer->set_render_target(m_target);

		m_view_pos.setValue(x, y);
		m_view_size.setValue(int(w), int(h));

		SetWindowLongPtr(m_hwnd, GWL_USERDATA, LONG_PTR(this));
		// do not response user input
		EnableWindow(target_wnd, FALSE);
		ShowWindow(target_wnd, SW_NORMAL);

		debug("Sparrow view at (%d, %d, %d, %d)", x, y, x + w, y + h);

		return true;
	}
コード例 #20
0
ファイル: BalloonMsg.cpp プロジェクト: mikekov/ExifPro
void BalloonMsg::SubclassWnd(HWND wnd)
{
	if (g_balloon)
		g_balloon->Close();

	Unsubclass();

	::GetWindowRect(wnd, &g_child_window_rect_rect);

	g_sentry = wnd;
	g_balloon = this;
	g_pfnOldWindowProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(wnd, GWLP_WNDPROC, LONG_PTR(SentryWindowProc)));
	g_parent = ::GetParent(wnd);
	if (g_parent)
		g_pfnOldWindowProc2 = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(g_parent, GWLP_WNDPROC, LONG_PTR(ParentWindowProc)));
}
コード例 #21
0
HRESULT CBaseTrayIcon::CreateMessageWindow()
{
  m_hWnd = CreateWindowEx(0, m_wszClassName, L"LAV Tray Message Window", 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr, nullptr, nullptr);
  SetWindowLongPtr(m_hWnd, GWLP_USERDATA, LONG_PTR(this));
  return m_hWnd == nullptr ? E_FAIL : S_OK;
}
コード例 #22
0
            static LRESULT CALLBACK on_win_event(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
            {
                LRESULT lRet = 1;

                switch (message)
                {
                case WM_CREATE:
                    SetWindowLongPtr(hWnd, GWLP_USERDATA, LONG_PTR(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams));
                    if (!DoRegisterDeviceInterfaceToHwnd(hWnd))
                case WM_QUIT:
                {
                    auto data = reinterpret_cast<extra_data*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
                    data->_stopped = true;
                    break;
                }
                case WM_DEVICECHANGE:
                {
                    //PDEV_BROADCAST_DEVICEINTERFACE b = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;
                    // Output some messages to the window.
                    switch (wParam)
                    {
                    case DBT_DEVICEARRIVAL:
                    {
                        auto data = reinterpret_cast<extra_data*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
                        backend_device_group next(data->_backend->query_uvc_devices(), data->_backend->query_usb_devices(), data->_backend->query_hid_devices());
                        /*if (data->_last != next)*/ data->_callback(data->_last, next);
                        data->_last = next;
                    }
                        break;

                    case DBT_DEVICEREMOVECOMPLETE:
                    {
                        auto data = reinterpret_cast<extra_data*>(GetWindowLongPtr(hWnd, GWLP_USERDATA));
                        auto next = data->_last;
                        std::wstring temp = reinterpret_cast<DEV_BROADCAST_DEVICEINTERFACE*>(lParam)->dbcc_name;
                        std::string path;
                        path.reserve(temp.length());
                        for (wchar_t ch : temp) {
                            if (ch != L'{') path.push_back(std::tolower(((char*)&ch)[0]));
                            else break;
                        }

                        next.uvc_devices.erase(std::remove_if(next.uvc_devices.begin(), next.uvc_devices.end(), [&path](const uvc_device_info& info)
                        { return info.device_path.substr(0, info.device_path.find_first_of("{")) == path; }), next.uvc_devices.end());
                        //                            next.usb_devices.erase(std::remove_if(next.usb_devices.begin(), next.usb_devices.end(), [&path](const usb_device_info& info)
                        //                            { return info.device_path.substr(0, info.device_path.find_first_of("{")) == path; }), next.usb_devices.end());
                        next.usb_devices = data->_backend->query_usb_devices();
                        next.hid_devices.erase(std::remove_if(next.hid_devices.begin(), next.hid_devices.end(), [&path](const hid_device_info& info)
                        { return info.device_path.substr(0, info.device_path.find_first_of("{")) == path; }), next.hid_devices.end());

                        /*if (data->_last != next)*/ data->_callback(data->_last, next);
                        data->_last = next;
                    }
                        break;
                    }
                    break;
                }

                default:
                    // Send all other messages on to the default windows handler.
                    lRet = DefWindowProc(hWnd, message, wParam, lParam);
                    break;
                }

                return lRet;
            }