Example #1
0
void MakeIcon(HICON icon, char* path) {
  Gdiplus::Bitmap* bitmap = Gdiplus::Bitmap::FromFile(ToWChar(path));
  if (bitmap->GetWidth()) {
    bitmap->GetHICON(&icon);
    delete bitmap;
  }
}
Example #2
0
BOOL CVideoPane::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here

	// 获取参数
	CRect rect;
	GetClientRect(rect);
	CString strOcxPath = eLTE_Tool::GetOcxPath();

	// 设置图标
	Gdiplus::Bitmap* pBitmap = Gdiplus::Bitmap::FromFile(strOcxPath + _T("Skin\\Icon.ico"));
	if (NULL != pBitmap && Gdiplus::Ok == pBitmap->GetLastStatus())
	{
		HICON hIcon = NULL;
		pBitmap->GetHICON(&hIcon);
		if (NULL != hIcon)
		{
			SetIcon(hIcon, FALSE);		// Set small icon
			SetIcon(hIcon, TRUE);		// Set big icon
		}
	}

	// 显示边框
	ModifyStyle(0, WS_BORDER);
	SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_DRAWFRAME);

	// 创建标题栏
	CreateCaption(rect, strOcxPath);

	// 创建视频窗口
	CreateVideoStatic(rect, strOcxPath);

	// 创建工具栏
	CreateToolBar(rect, strOcxPath);

	// 禁用按钮
	EnableImageButton(FALSE);

	// 工具栏隐藏
	if (!m_bShowToolBar)
	{
		m_SnapshotBtn.ShowWindow(SW_HIDE);
		m_ReversePlayBtn.ShowWindow(SW_HIDE);
		m_FullScreenBtn.ShowWindow(SW_HIDE);
		m_AudioBtn.ShowWindow(SW_HIDE);
	}

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #3
0
HICON GetIcon(CefString url, CefString path){
	if (path.ToWString().find(L":") == -1){// 如果指定的路径是相对路径
		wstring _path;
		_path = url.ToWString();
		jw::replace_allW(_path, L"\\", L"/");
		_path = _path.substr(0, _path.find_last_of('/') + 1);
		path = _path.append(path);
	}
	Gdiplus::GdiplusStartupInput StartupInput;
	ULONG_PTR m_gdiplusToken;
	Gdiplus::Status sResult = Gdiplus::GdiplusStartup(&m_gdiplusToken, &StartupInput, NULL);
	if (sResult == Gdiplus::Ok){
		Gdiplus::Bitmap * bb = Gdiplus::Bitmap::FromFile(path.c_str(), false);
		HICON hIcon = NULL;
		bb->GetHICON(&hIcon);
		delete bb;
		Gdiplus::GdiplusShutdown(m_gdiplusToken);// 关闭gdi
		return hIcon;
	}
	return NULL;
}
Example #4
0
void NativeWindow::Init(char* url, Settings* settings) {
  url_ = url;

  HINSTANCE hInstance = GetModuleHandle(NULL);

  if (is_main_window_) {
    dwmapiDLL = LoadLibrary(TEXT("dwmapi.dll"));
    if (dwmapiDLL != NULL) {
      DwmExtendFrameIntoClientArea = (DWMEFICA)GetProcAddress(dwmapiDLL, "DwmExtendFrameIntoClientArea");
      DwmEnableBlurBehindWindow = (DWMEBBW)GetProcAddress(dwmapiDLL, "DwmEnableBlurBehindWindow");
      DwmDefWindowProc = (DWMWP)GetProcAddress(dwmapiDLL, "DwmDefWindowProc");
    }

    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    WCHAR* wSmallIconPath = icons->getString("small",L"");
    WCHAR* wBigIconPath = icons->getString("big",L"");

    Gdiplus::Bitmap* smallIconBitmap = Gdiplus::Bitmap::FromFile(wSmallIconPath);
    Gdiplus::Bitmap* bigIconBitmap = Gdiplus::Bitmap::FromFile(wBigIconPath);

    if (smallIconBitmap->GetWidth()) {
      smallIconBitmap->GetHICON(&smallIcon);
      delete[] wSmallIconPath;
      delete smallIconBitmap;
    }

    if (bigIconBitmap->GetWidth()) {
      bigIconBitmap->GetHICON(&bigIcon);
      delete[] wBigIconPath;
      delete bigIconBitmap;
    }

    strcpy(szWindowClass,"AppjsWindow");
    MyRegisterClass(hInstance);
  }

  browserSettings = settings;

  if (rect_.left < 0 || rect_.top < 0) {
    rect_.left = (GetSystemMetrics(SM_CXSCREEN) - rect_.width) / 2;
    rect_.top = (GetSystemMetrics(SM_CYSCREEN) - rect_.height) / 2;
  }
  browser_ = NULL;
  handle_ = CreateWindowEx(NULL, szWindowClass,"", WS_OVERLAPPEDWINDOW,
                           rect_.left, rect_.top, rect_.width, rect_.height,
                           NULL, NULL, hInstance, NULL);

  SetWindowLongPtr(handle_, GWLP_USERDATA, (LONG)this);

  if (alpha_) {
    SetAlpha(true);
  }

  SetResizable(resizable_);

  if (fullscreen_) {
    fullscreen_ = false;
    Fullscreen();
  } else if (!show_chrome_) {
    SetShowChrome(false);
  }

  UpdateWindow(handle_);

  Cef::Run();
};
Example #5
0
void SetUUIDOverlayIcon( HWND hWnd )
{
    if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepo"), 3))
        return;

    if (!CRegStdDWORD(_T("Software\\TortoiseGit\\GroupTaskbarIconsPerRepoOverlay"), TRUE))
        return;

    std::wstring uuid;
    std::wstring sicon;
    bool bRemoveicon = false;
#ifdef __AFXWIN_H__
    uuid = g_sGroupingUUID;
    sicon = g_sGroupingIcon;
    bRemoveicon = g_bGroupingRemoveIcon;
#else
    CCmdLineParser parser(GetCommandLine());
    if (parser.HasVal(L"groupuuid"))
        uuid = parser.GetVal(L"groupuuid");
#endif
    if (uuid.empty())
        return;

    CComPtr<ITaskbarList3> pTaskbarInterface;
    if (FAILED(pTaskbarInterface.CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER)))
        return;

    int foundUUIDIndex = 0;
    do
    {
        wchar_t buf[MAX_PATH] = { 0 };
        swprintf_s(buf, _countof(buf), L"%s%d", L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\", foundUUIDIndex);
        CRegStdString r = CRegStdString(buf);
        std::wstring sr = r;
        if (sr.empty())
        {
            r = uuid + (sicon.empty() ? L"" : (L";" + sicon));
            break;
        }
        size_t sep = sr.find(L';');
        std::wstring olduuid = sep != std::wstring::npos ? sr.substr(0, sep) : sr;
        if (olduuid.compare(uuid) == 0)
        {
            if (bRemoveicon)
                r = uuid; // reset icon path in registry
            else if (!sicon.empty())
                r = uuid + (sicon.empty() ? L"" : (L";" + sicon));
            else
                sicon = sep != std::wstring::npos ? sr.substr(sep + 1) : L"";
            break;
        }
        foundUUIDIndex++;
    } while (foundUUIDIndex < 20);
    if (foundUUIDIndex >= 20)
    {
        CRegStdString r = CRegStdString(L"Software\\TortoiseGit\\LastUsedUUIDsForGrouping\\1");
        r.removeKey();
    }

    HICON icon = nullptr;
    if (!sicon.empty())
    {
        if (sicon.size() >= 4 && !_wcsicmp(sicon.substr(sicon.size() - 4).c_str(), L".ico"))
            icon = (HICON)::LoadImage(nullptr, sicon.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE | LR_SHARED);
        else
        {
            ULONG_PTR gdiplusToken = 0;
            Gdiplus::GdiplusStartupInput gdiplusStartupInput;
            GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
            if (gdiplusToken)
            {
                Gdiplus::Bitmap* pBitmap = new Gdiplus::Bitmap(sicon.c_str(), FALSE);
                if (pBitmap->GetLastStatus() == Gdiplus::Status::Ok)
                    pBitmap->GetHICON(&icon);
                delete pBitmap;
                Gdiplus::GdiplusShutdown(gdiplusToken);
            }
        }
    }

    if (!icon)
    {
        DWORD colors[6] = { 0x80FF0000, 0x80FFFF00, 0x8000FF00, 0x800000FF, 0x80000000, 0x8000FFFF };

        // AND mask - monochrome - determines which pixels get drawn
        BYTE AND[32];
        for (int i = 0; i<32; i++)
        {
            AND[i] = 0xFF;
        }

        // XOR mask - 32bpp ARGB - determines the pixel values
        DWORD XOR[256];
        for (int i = 0; i<256; i++)
        {
            XOR[i] = colors[foundUUIDIndex % 6];
        }

        icon = ::CreateIcon(nullptr, 16, 16, 1, 32, AND, (BYTE*)XOR);
    }
    pTaskbarInterface->SetOverlayIcon(hWnd, icon, uuid.c_str());
    DestroyIcon(icon);
}
Example #6
0
void NativeWindow::Init(char* url, Settings* settings) {
  url_ = url;

  if( !g_handler->GetBrowserHwnd() ) {

    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    WCHAR* wSmallIconPath = icons->getString("small",L"");
    WCHAR* wBigIconPath = icons->getString("big",L"");

    Gdiplus::Bitmap* smallIconBitmap = Gdiplus::Bitmap::FromFile(wSmallIconPath);
    Gdiplus::Bitmap* bigIconBitmap = Gdiplus::Bitmap::FromFile(wBigIconPath);

    if( smallIconBitmap->GetWidth() ) {
      smallIconBitmap->GetHICON(&smallIcon);
      delete[] wSmallIconPath;
      delete smallIconBitmap;
    }

    if( bigIconBitmap->GetWidth() ) {
      bigIconBitmap->GetHICON(&bigIcon);
      delete[] wBigIconPath;
      delete bigIconBitmap;
    }
  }

  HINSTANCE hInstance = GetModuleHandle(NULL);
  strcpy(szWindowClass,"AppjsWindow");
  browserSettings = settings;


  if(!MyRegisterClass(hInstance)){
    //TODO send error to node
    if( GetLastError() != 1410 ) { //1410: Class Already Registered
      fprintf(stderr,"Error occurred: ");
      fprintf(stderr,"%d\n",GetLastError());
      return;
    }
  };

  DWORD style = show_chrome ? WS_OVERLAPPEDWINDOW : WS_SIZEBOX | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;

  if (!resizable) {
    style &= ~WS_SIZEBOX;
  }

  if (left_ < 0 || top_ < 0) {
    left_ = (GetSystemMetrics(SM_CXSCREEN) - width_) / 2;
    top_ = (GetSystemMetrics(SM_CYSCREEN) - height_) / 2;
  }
  browser_ = NULL;
  handle_ = CreateWindowEx(NULL, szWindowClass,"", style, top_, left_, width_, height_, NULL, NULL, hInstance, NULL);

  if (!handle_) {
    fprintf(stderr,"Error occurred: ");
    fprintf(stderr,"%d\n",GetLastError());
    return;
  }

  SetWindowLongPtr(handle_, GWLP_USERDATA, (LONG)this);

  if (alpha) {
    SetNCWidth(handle_, -1);
  }

  if (fullscreen) {
    SetFullscreen(handle_);
  } else if (!show_chrome) {
    UpdateStyle(handle_, GWL_STYLE, GetWindowLong(handle_, GWL_STYLE) & ~WS_CAPTION);
  }

  UpdateWindow(handle_);

  Cef::Run();
};