我正在创建一个非侵入式弹出窗口,以便在处理耗时的操作时通知用户.目前我通过调用设置其透明度,SetLayeredWindowAttributes这给了我一个合理的结果:
alt text http://img6.imageshack.us/img6/3144/transparentn.jpg
但是我希望文本和关闭按钮看起来不透明(用白色文字看起来不太正确)同时保持背景透明 - 有没有办法做到这一点?
我已经创建了一个可以正常工作的动画,但是它很轻松.我需要双缓冲的帮助,因为我对它一无所知.
这是我onPaint()中的代码:
VOID onPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawEllipse(&pen, sf , 0, 10, 10);
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,但闪烁.我试过这段代码,但它不起作用:
VOID onPaint(HDC hdc,HWND hWnd)
{
HDC hDC=GetDC(hWnd);;
HDC memDC = CreateCompatibleDC(hDC);
HBITMAP hMemBmp = CreateCompatibleBitmap(hDC,10,10);
HBITMAP hOldBmp = (HBITMAP)SelectObject(memDC,hMemBmp);
BitBlt(hDC, 0, 0, 10, 10, memDC, 0, 0, SRCCOPY);
Graphics graphics(memDC);
Pen pen(Color(255, 0, 0, 255));
graphics.DrawEllipse(&pen, sf , 0, 10, 10);
// Always select the old bitmap back into the device context
SelectObject(memDC, hOldBmp);
DeleteObject(hMemBmp);
DeleteDC(memDC);
}
Run Code Online (Sandbox Code Playgroud) 好吧,我只是将它升级到visual studio c ++ 2010 express.当我使用gdi + i时,错误不在我的文件中但在gdi +头文件中,其中一个错误是这个c:\ program files(x86)\ microsoft sdks\windows\v7.0a\include\gdiplusimaging.h(74):错误C4430:缺少类型说明符 - 假定为int.注意:C++不支持default-int
这是我使用的gdi代码
VOID OnPaint(HWND hWnd)
{
GRAPHICS draw;
SolidBrush brush(Color(0, 0, 0, 255));
draw.FillEclipse(&brush, 0, 0, 25, 25);
}
使用vs 2008它工作正常
............................................ ...........................编辑
这是错误列表
1> stdafx.cpp 1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gdiplusimaging.h(74): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gdiplusimaging.h(74): error C2440: 'initializing' : cannot convert from 'const char [37]' to 'int' 1> There is no …
我正在尝试绘制一个有多个孔的多边形.我尝试了以下代码,但它无法正常工作.请指教.
PointF[] mypoly = new PointF[6 + 5 + 5];
mypoly[0] = new PointF(0, 0);
mypoly[1] = new PointF(100, 0);
mypoly[2] = new PointF(100, 100);
mypoly[3] = new PointF(0, 100);
mypoly[4] = new PointF(10, 80);
mypoly[5] = new PointF(0, 0);
mypoly[6] = new PointF(10, 10);
mypoly[7] = new PointF(10, 20);
mypoly[8] = new PointF(20, 20);
mypoly[9] = new PointF(20, 10);
mypoly[10] = new PointF(10, 10);
mypoly[11] = new PointF(40, 10);
mypoly[12] = new PointF(40, 20);
mypoly[13] = new PointF(60, 20); …Run Code Online (Sandbox Code Playgroud) 我正在使用directx绘制我的字符串,directx使用GDI绘制字符串..
我正在使用DrawText绘制我的字符串.我需要一种方法来找到字符串的宽度.
任何的想法 ?
我想学习如何生成PDF,我不想使用任何第三方工具,我想在代码中自己创建它.到目前为止我看到的唯一的例子是我在第三方dll上打开反射器时看到的代码,看看发生了什么.不幸的是DLL的,到目前为止我已经看到了似乎击中user32.dll中和gdi32.dll里面,以帮助创建PDF文档,我的问题是我不知道他们在做什么,更重要的是为什么呢?
有没有人有任何好的教程或参考,这可能指向我正确的方向.
提前致谢.
我的印象是经典的Win16图元文件没有嵌入的大小或分辨率信息(除非有METAFILEPICT标题或类似信息) - GetWinMetaFileBits()使用参考DC有什么用?
我试图在用C编写并在Windows CE 6.0上运行的应用程序中找到内存泄漏的底部.我怀疑这个问题可能与窗口的paint事件的处理有关.在伪代码中它看起来像这样.
LRESULT CALLBACK HandlePaint(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint (hWnd, &ps);
HFONT logfont;
FONTINFO font1, font2;
memset(&logfont, 0, sizeof(LOGFONT));
//set font options for font1.
font1 = CreateFontIndirect(&logfont);
memset(&logfont, 0, sizeof(LOGFONT));
//set font options for font2.
font2 = CreateFontIndirect(&logfont);
for(int i = 0; i <= SOME_NUMBER; i++)
{
DrawStuff(hdc, font1);
DrawStuff(hdc, font2);
}
EndPaint (hWnd, &ps);
}
INT DrawStuff(HDC hdc, HFONT font)
{
HPEN pen = CreatePen(PS_SOLID, borderWidth, bordercolor); …Run Code Online (Sandbox Code Playgroud) 是否可以使用alphablend函数使图像的某些部分透明?
我可以创建一个包含RGB(0,0,255)特定区域的图像,当我绘制该图像时,该区域应该是透明的.这可能是AlphaBlend函数.是的,那么如何?
我正在阅读有关alphablend的内容,但我仍然不清楚.我想我们需要在创建图像时指定alphachannel.如果某个像素不存在alphachannel,那么该像素不能透明?
我正试图在沉浸式全屏模式下绘制另一个进程.我知道这可以使用GDI,我有两个问题:
谢谢 :)