在【神化世界】的开发中,在alt+table切换窗口时,提示操作窗口对于win7不兼容,直接被覆盖了。因此,采用了屏幕画图文字直接提示的方案,不需要的时候可以一键清除。
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "screentipUnit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
HWND lcxWindow(int x,int y)
{
POINT pp;
pp.x=x;
pp.y=y;
HWND hc=WindowFromPoint(pp);
return hc;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//电脑桌面直接画图,写提示文字
HDC hdc=GetWindowDC(0);
MoveToEx(
hdc,// handle of device context
100,// x-coordinate of new current position
100,// y-coordinate of new current position
NULL // address of old current position
);
LineTo(
hdc,// device context handle
600,// x-coordinate of line's ending point
600 // y-coordinate of line's ending point
);
//设置画刷
HBRUSH hBrush; //定义画刷的句柄
hBrush=CreateSolidBrush(RGB(128,164,128));
// hBrush=(HBRUSH)GetStockObject(nBrushStyle); /CreatSolidBrush(rgbColor);/CreateHatchBrush(nHctchStyle,rgbColor);//定义的画刷
// SelectObject(HDC,HBRUSH); //选择画刷
SelectObject(hdc,hBrush); //选择画刷
// DeleteObject(HBRUSH); //删除画刷
Rectangle(
hdc,// handle of device context
Screen->Width/2,// x-coord. of bounding rectangle's upper-left corner
Screen->Height-180,// y-coord. of bounding rectangle's upper-left corner
Screen->Width/2+200,// x-coord. of bounding rectangle's lower-right corner
Screen->Height-180+30 // y-coord. of bounding rectangle's lower-right corner
);
// DeleteObject(hBrush); //删除画刷
FillRect(
hdc,// handle to device context
&Rect(Screen->Width/2, Screen->Height-180, Screen->Width/2+200, Screen->Height-180+30),// pointer to structure with rectangle
hBrush // handle to brush
);
AnsiString tip;
tip="Hello,神化世界!";
SelectObject(hdc,hBrush); //选择画刷
SetTextColor(
hdc,// handle of device context
RGB(5,20,0) // text color
);
SetBkColor(
hdc,// handle of device context
RGB(128,164,128) // background color value
);
TextOut(
hdc,// handle of device context
Screen->Width/2+16,// x-coordinate of starting position
Screen->Height-180+3,// y-coordinate of starting position
tip.c_str(),// address of string
tip.Length() // number of characters in string
);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
//电脑桌面直接画图,写提示文字---一键清除
HWND hWnd,holdf;
holdf=GetForegroundWindow();
hWnd=lcxWindow(Screen->Width/2+2, Screen->Height-180+2);
UpdateWindow(hWnd);
UpdateWindow(GetParent(hWnd));
SetForegroundWindow(hWnd);
SetForegroundWindow(GetParent(hWnd));
SetForegroundWindow(holdf);
/*
InvalidateRect(
hWnd,// handle of window with changed update region
&Rect(Screen->Width/2, Screen->Height-180, 200, 200),// address of rectangle coordinates
true// erase-background flag
);
hWnd=lcxWindow(Screen->Width/2+12, Screen->Height-180+12);
UpdateWindow(hWnd);
UpdateWindow(GetParent(hWnd));
InvalidateRect(
hWnd,// handle of window with changed update region
&Rect(Screen->Width/2, Screen->Height-180, 200, 200),// address of rectangle coordinates
true// erase-background flag
);
*/
}
//---------------------------------------------------------------------------
在开发神化世界时遇到Win7系统兼容性问题,当使用alt+table切换窗口时,原生提示被覆盖。为了解决这个问题,程序采用屏幕画图的方式直接显示提示文字,并提供一键清除功能。
456

被折叠的 条评论
为什么被折叠?



