是否可以使用 xlib 绘制没有标题栏、关闭按钮、鼠标按钮响应的透明窗口。所以只是用特定的颜色和宽度边框?就像是
这个橙色矩形是我需要创建的。此外,我希望有可能以编程方式移动、调整大小、关闭并使其闪烁(更改计时器的边框颜色)。
我设法创建没有标题栏的透明窗口,并在窗口的每一侧绘制矩形以制作边框效果:
#define W_WIDTH 640
#define W_HEIGHT 480
#define X_POS 100
#define Y_POS 120
#define BORDER_WIDTH 2
Display *dpy;
Window w;
XRectangle rectangles[4] =
{
{ X_POS, Y_POS, W_WIDTH, BORDER_WIDTH },
{ X_POS, Y_POS, BORDER_WIDTH, W_HEIGHT },
{ X_POS, W_HEIGHT - BORDER_WIDTH, W_WIDTH, BORDER_WIDTH },
{ W_WIDTH - BORDER_WIDTH, Y_POS, BORDER_WIDTH, W_HEIGHT }
};
int main(int argc, char *argv[])
{
GC gc;
XGCValues gcv;
int run = 1;
dpy = XOpenDisplay(NULL);
XVisualInfo vinfo;
XMatchVisualInfo(dpy, DefaultScreen(dpy), 32, TrueColor, …
Run Code Online (Sandbox Code Playgroud) 我有一个复杂的 C++ 项目。现在我将 c++ node.js 插件添加到我基于 CMake 的项目中。我想用整个项目构建这个插件,所以我需要分别修改cmake文件。在我的根 cmake 文件中,我执行了以下操作:
add_subdirectory(nodejsaddon)
add_custom_target (
npm-target
COMMAND cd nodejsaddon && npm install node-addon-api && npm run build
)
Run Code Online (Sandbox Code Playgroud)
nodejsaddon
- 包含我的插件源和相应的 .gyp 和 .json 文件的文件夹的名称。但是,当我运行时,cmake ..\\testproj\\ -G "Visual Studio 15 Win64" -T "v140, host=x64
我在 nodejsaddon 文件夹中看不到 npb 构建结果。我做错了什么?如何让npm在nodejsaddon文件夹中生成构建文件?
我正在尝试使用类似于puppeteer-recorder 的方式从网站录制视频,但我想自己停止录制,然后将其保存到文件(在我停止之后)。我为此目的编写了简单的网络服务:
var express = require('express');
var app = express();
const { spawn } = require('child_process');
const puppeteer = require('puppeteer');
var record = true;
app.get('/startRecord', function (req, res)
{
const frun_record = async () => {
console.log("Start recording");
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://worldfoodclock.com/', { waitUntil: 'networkidle2' });
var ffmpegPath = 'ffmpeg';
var fps = 60;
var outFile = 'E:\\Code\\video-record\\output.webm';
const args = ffmpegArgs(fps);
args.push(outFile);
const ffmpeg = spawn(ffmpegPath, args);
const closed …
Run Code Online (Sandbox Code Playgroud) 我需要获取 Windows 计算机上所有已安装的更新。我尝试了 WUA API,但结果与我在控制面板 - 已安装的更新中看到的不同。我的代码返回 321 更新,而在控制面板中我看到 508。这是我的代码:
IUpdateSearcher* updateSearcher = NULL;
IUpdateSession* updateSession = NULL;
IUpdateCollection* updateList = NULL;
ISearchResult* results = NULL;
IUpdate* updateItem = NULL;
BSTR criteria = NULL;
LONG updateSize = 0;
HRESULT hr;
if ((hr = CoInitialize(NULL)) != S_OK)
{
return -1;
}
if ((hr = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID*)&updateSession)) != S_OK)
{
return -1;
}
if ((hr = updateSession->CreateUpdateSearcher(&updateSearcher)) != S_OK)
{
return -1;
}
if ((hr = updateSearcher->put_ServerSelection(ssWindowsUpdate)) != S_OK) …
Run Code Online (Sandbox Code Playgroud) 我有 C++ 应用程序(用于通过网络共享应用程序的窗口)。当服务器端的大小发生更改时,我需要更新客户端的应用程序区域。为此,我每隔一段时间就会打电话GetWindowPos
检查窗口大小是否已调整。但我不想在窗口处于调整大小状态时发送信息,而仅在调整大小完成时发送信息。我注意到,在 Windows 8.1 和 Windows 10 上,GetWindowPos
当窗口处于调整大小状态时,它会返回相同的值,但是在 Windows 7 上,当窗口处于调整大小状态时,它会返回不同的值。那么问题是如何理解窗口是否处于调整大小状态?
UPD:实施WM_ENTERSIZEMOVE
-WM_EXITSIZEMOVE
变体
void WindowsDisplayHelperMasterWindow::SetMsgHook()
{
m_pThis = this;
m_msgHook = SetWindowsHookEx(WH_GETMESSAGE, MsgPoc, NULL, 0);
}
Run Code Online (Sandbox Code Playgroud)
调用类的非静态方法的静态函数:
LRESULT CALLBACK WindowsDisplayHelperMasterWindow::MsgPoc(int code, WPARAM wParam, LPARAM lParam)
{
if (m_pThis != nullptr)
{
return m_pThis->GetMsgProcHook(code, wParam, lParam);
}
return CallNextHookEx(0, code, wParam, lParam);
}
Run Code Online (Sandbox Code Playgroud)
挂钩功能:
LRESULT CALLBACK WindowsDisplayHelperMasterWindow::GetMsgProcHook(int code, WPARAM wParam, LPARAM lParam)
{
if (code < 0)
{
return CallNextHookEx(0, code, wParam, …
Run Code Online (Sandbox Code Playgroud) 这是来自 cppreference 的示例:
constexpr double power(double b, int x)
{
if (std::is_constant_evaluated() && !(b == 0.0 && x < 0)) {
// A constant-evaluation context: Use a constexpr-friendly algorithm.
if (x == 0)
return 1.0;
double r = 1.0, p = x > 0 ? b : 1.0 / b;
auto u = unsigned(x > 0 ? x : -x);
while (u != 0) {
if (u & 1) r *= p;
u /= 2;
p *= p;
}
return …
Run Code Online (Sandbox Code Playgroud)