Skip to content

Instantly share code, notes, and snippets.

lniwn lniwn

Block or report user

Report or block lniwn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CMakeLists.txt
# Compatibility
cmake_minimum_required(VERSION 2.6)
if(WIN32)
# Windows XP compatible platform toolset. Must be set before project(),
# otherwise change of CMAKE_*_TOOLSET will take no effect.
# We get VS version from the generator name because neither MSVC* nor other
# variables that describe the compiler aren't available before project().
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)")
# Note: "v110_xp" is for Visual Studio 11 2012, which is unsupported.
View decss.c
/*****************************************************************************
* css_unscramble.c : unscrambling function
*****************************************************************************
* Copyright (C) 1999 Derek Fawcus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
@lniwn
lniwn / getIeHandle
Last active Dec 8, 2017
get ie hwnd
View getIeHandle
// level: IE窗口的层级,一共三级
// 0: Shell Embedding
// 1: Shell DocObject View
// 2: Internet Explorer_Server
HWND getIEHandle(QAxWidget* pWidget, int level)
{
assert(pWidget);
CComPtr<IWebBrowser2> pWebBrowser2;
pWidget->queryInterface( IID_IWebBrowser2, (void**)&pWebBrowser2 );
assert(pWebBrowser2);
@lniwn
lniwn / fstream.cpp
Created Dec 4, 2017
Read file-contents into a string in C++
View fstream.cpp
std::ifstream ifs("myfile.txt");
std::string content( (std::istreambuf_iterator<char>(ifs) ),
(std::istreambuf_iterator<char>() ) );
View DynamicCxxProperty.h
template <typename value_t>
class IProperty_Forward {
public:
virtual ~IProperty_Forward() {}
virtual const value_t& Read() = 0;
virtual void Set(const value_t& value) = 0;
};
template <typename value_t, typename owner_t, typename getter_t, typename setter_t>
class TProperty_Forwarder: public IProperty_Forward<value_t>
@lniwn
lniwn / EnableHighDPISupport.cpp
Created Oct 13, 2017
Windows应用支持高分屏
View EnableHighDPISupport.cpp
void EnableHighDPISupport() {
// Enable per-monitor DPI for Win10 or above instead of Win8.1 since Win8.1
// does not have EnableChildWindowDpiMessage, necessary for correct non-client
// area scaling across monitors.
PROCESS_DPI_AWARENESS process_dpi_awareness =
GetVersion() >= VERSION_WIN10 ? PROCESS_PER_MONITOR_DPI_AWARE
: PROCESS_SYSTEM_DPI_AWARE;
if (!SetProcessDpiAwarenessWrapper(process_dpi_awareness)) {
// For windows versions where SetProcessDpiAwareness is not available or
// failed, try its predecessor.
View macro-default-value.cpp
enum
{
plain = 0,
bold = 1,
italic = 2
};
void PrintString(const char* message, int size, int style)
{
}
@lniwn
lniwn / CreateRegionFromImage.cpp
Last active Jun 16, 2017
从图片创建窗口有效区
View CreateRegionFromImage.cpp
BYTE* Get24BitPixels(HBITMAP pBitmap, WORD *pwWidth, WORD *pwHeight)
{
// a bitmap object just to get bitmap width and height
BITMAP bmpBmp;
// pointer to original bitmap info
LPBITMAPINFO pbmiInfo;
// bitmap info will hold the new 24bit bitmap info
BITMAPINFO bmiInfo;
@lniwn
lniwn / DesktopUtils.cpp
Created Feb 8, 2017
获取桌面进程窗口句柄
View DesktopUtils.cpp
HWND WindowDeskPopUtils::GetDeskWindow()
{
HWND hSysView32 = NULL;
// 先按win7方式查找
HWND hWnd = NULL;
do
{
hSysView32 = ::FindWindowEx(NULL, hWnd, _T("Progman"), _T("Program Manager"));
if (hSysView32)
@lniwn
lniwn / CUrlEncode.h
Created Aug 22, 2016
Url编解码类
View CUrlEncode.h
#pragma once
#include <xstring>
#include <string>
//url编码类
class CUrlEncode
{
public:
void StringToWstring(std::wstring& szDst, std::string str)
You can’t perform that action at this time.