我想制作一个透明的简单应用程序,但保留"普通"边框,关闭按钮,最小化和最大化按钮.
我知道如何使用标准使窗口透明
<Window
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent">
</Window>
Run Code Online (Sandbox Code Playgroud)
但这会删除边框和右上角的按钮.我读了这个帖子,
哪种解决方案,但实际上,我只是希望能够保持标准边框,如果我没有使窗口透明.我可以移动窗口,调整大小,关闭等等的方法......这可能吗?
今天我正在玩C++,并且遇到了这个我认为奇怪的事情,但也许更可能是由于我的误解和最近缺乏纯C编码.
我原本想要做的是将double转换为无符号字符数组.我的理解是double的64位(sizeof(double)是8)现在将表示为8个8位字符.要做到这一点,我使用reinterpret_cast.
所以这里有一些代码可以从double转换为char数组,或者至少我认为这就是它正在做的事情.问题是它从strlen而不是8返回15,为什么我不确定.
double d = 0.3;
unsigned char *c = reinterpret_cast<unsigned char*> ( &d );
std::cout << strlen( (char*)c ) << std::endl;
Run Code Online (Sandbox Code Playgroud)
因此strlen是我的第一个问题.但后来我尝试了以下内容,发现它返回了11,19,27,35.这些数字之间的差异是8,所以在某种程度上正确的事情正在发生.但为什么这不会返回15,15,15,15,(因为它在上面的代码中返回15).
double d = 0.3;
double d1 = 0.3;
double d2 = 0.3;
double d3 = 0.3;
unsigned char *c_d = reinterpret_cast<unsigned char*> ( &d );
unsigned char *c_d1 = reinterpret_cast<unsigned char*> ( &d1 );
unsigned char *c_d2 = reinterpret_cast<unsigned char*> ( &d2 );
unsigned char *c_d3 = reinterpret_cast<unsigned char*> ( &d3 );
std::cout << strlen( (char*)c_d …Run Code Online (Sandbox Code Playgroud) 我想创建一个映射,其中键是一个函数名作为字符串,值是函数本身.所以像这样......
#include <cmath>
#include <functional>
#include <map>
#include <string>
typedef std::function<double(double)> mathFunc;
int main() {
std::map< std::string, mathFunc > funcMap;
funcMap.insert( std::make_pair( "sqrt", std::sqrt ) );
double sqrt2 = (funcMap.at("sqrt"))(2.0);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
将用于在某个输入值上调用sqrt函数.然后你当然可以在地图上添加其他函数,如sin,cos,tan,acos等,然后通过一些字符串输入调用它们.我的问题是地图中的值类型应该是什么,函数指针和std :: function在std :: make_pair行给出以下错误
error: no matching function for call to 'make_pair(const char [5], <unresolved overloaded function type>)'
Run Code Online (Sandbox Code Playgroud)
那么我的值类型应该是什么样的内置函数,如std :: sqrt?
谢谢
我希望能够逐帧移动gif.在下面的示例中,我使用轨迹栏来选择我想要看到的gif的哪个帧.对于设计师我只是将一个PictureBox放在屏幕的中央,并在屏幕的底部粘贴了一个TrackBar.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace TestGifProject {
public partial class Form1 : Form {
private Image gif;
private FrameDimension fd;
public Form1() {
InitializeComponent();
gif = Image.FromFile("PATH\\TO\\SOME\\GIF.gif");
// just for this quick example...
this.Width = gif.Width + 20;
this.Height = gif.Height + 53;
pictureBox1.Width = gif.Width;
pictureBox1.Height = gif.Height;
pictureBox1.Image = gif;
fd = new FrameDimension(gif.FrameDimensionsList[0]);
trackBar1.SetRange(0, gif.GetFrameCount(fd) - 1);
}
private void trackBar1_MouseUp(object sender, MouseEventArgs e) {
gif.SelectActiveFrame(fd, trackBar1.Value);
pictureBox1.Image = gif;
}
} …Run Code Online (Sandbox Code Playgroud) 我想知道如果我想将运行时确定大小的数组传递给DLL函数,我有什么样的选项.目前我在DLL中的函数签名看起来像
#ifdef BUILDING_DLL
#define DBUILDING __declspec(dllexport)
#else
#define DBUILDING __declspec(dllimport)
#endif
void __cdecl DBUILDING myFunc(const double t, const double x[], double *xdot);
Run Code Online (Sandbox Code Playgroud)
所以我传递的是在一些类中动态分配的普通旧数据类型,然后必须手动删除.我宁愿不必调用删除并担心内存管理,所以我想看看其他选项.显而易见的选择是向量,但我知道你不应该将STL容器传递给dll,所以我还需要其他东西.我需要处理内存管理的东西,但我也可以传递给dll.
我当前的想法可能是使用boost :: scoped_array及其get()函数以指针形式返回原始数据.这看起来像是最好的主意还是有些东西我会忽略?