📄 drawex.cpp
字号:
#include "stdafx.h"
#include "DrawEx.h"
#include "useful.h"
// Public DLL Functions ////////////////////////////////////////
#define CPU_ID _asm _emit 0x0f _asm _emit 0xa2
//#define RDTSC _asm _emit 0x0f _asm _emit 0x31
#define htuA 0x68747541 // hex value for htuA
#define itne 0x69746e65 // hex value for itne
#define DMAc 0x444d4163 // hex value for DMAc
/***************************************************************
* wincpuidsupport()
*
* Inputs: none
*
* Returns:
* 1 = CPUID opcode is supported
* 0 = CPUID opcode is not supported
***************************************************************/
WORD intel_wincpuidsupport()
{
int cpuid_support = 1;
_asm {
pushfd // Get original EFLAGS
pop eax
mov ecx, eax
xor eax, 200000h // Flip ID bit in EFLAGS
push eax // Save new EFLAGS value on
// stack
popfd // Replace current EFLAGS value
pushfd // Get new EFLAGS
pop eax // Store new EFLAGS in EAX
xor eax, ecx // Can not toggle ID bit,
jnz support // Processor=80486
mov cpuid_support,0 // Clear support flag
support:
}
return cpuid_support;
} // wincpuidsupport()
/***************************************************************
* intel_check_IDProc()
*
* Inputs: none
*
* Returns:
* CPU Family (i.e. 4 if Intel 486, 5 if Pentium(R) Processor)
*
* Note: This function also sets the global variable clone_flag
***************************************************************/
WORD intel_check_IDProc()
{
int i=0;
WORD cpu_type=0xffff;
BYTE stepping=0;
BYTE model=0;
BYTE vendor_id[13]="------------";
//BYTE intel_id[13]="GenuineIntel";
_asm {
xor eax, eax // Set up for CPUID instruction
CPU_ID // Get and save vendor ID
mov dword ptr vendor_id, ebx
mov dword ptr vendor_id[+4], edx
mov dword ptr vendor_id[+8], ecx
}
_asm {
cmp eax, 1 // Make sure 1 is valid input
// for CPUID
jl end_IDProc // If not, jump to end
xor eax, eax
inc eax
CPU_ID // Get family/model/stepping/
// features
mov stepping, al
and stepping, 0x0f //0fh
and al, 0f0h
shr al, 4
mov model, al
and eax, 0f00h
shr eax, 8 // Isolate family
and eax, 0fh
mov cpu_type, ax // Set _cpu_type with family
end_IDProc:
mov ax, cpu_type
}
return cpu_type;
} // Check_IDProc()
bool amd_isK6orLater()
{ /*
unsigned long family=0;
unsigned long model_no=0;
unsigned long stepping=0;
unsigned long mode1=0, mode2=0, mode3=0;
unsigned long save_value;
_asm{
// cpu_oK - run CPUID instruction to get cpu vendor
mov eax, 0 // function 0
db 0fh, 0a2h // CPUID opcode
mov mode1, ebx // load to string variable
mov mode2, edx // load to string variable
mov mode3, ecx // load to string variable
}
if ((mode1 == htuA) && (mode2 == itne) && (mode3 == DMAc)) // AMD CPU
{
_asm {
mov eax, 1 // function 1
db 0fh, 0a2h // CPUID opcode
mov save_value, eax // reload the whole cpu family
}
family = (save_value >> 8) & 0x0F; // find out the familu number (8 - 11 bits in EAX register)
model_no = (save_value >> 4) & 0x0F; // find out the model number (4 - 7 bits in EAX register)
stepping = save_value & 0x0F; // find out the stepping number (0 - 3 bits in EAX register)
}
if (family == 5)
{
if (model_no < 6) // K5
return false;
else // K6
return true;
}
if (family>5) // K7 or later
return true;*/
return false;
}
int DrawAniRects(CRect* rcFr, CRect* rcTo)
{
CWnd* pDesktop = CWnd::GetDesktopWindow();
CWindowDC dc(pDesktop);
int index = 10;
CRect rc(rcFr);
int oldRop = dc.SetROP2(R2_NOT);
CPen* pOldPen = (CPen*)dc.SelectStockObject(BLACK_PEN);
CBrush* pOldBrush = (CBrush*)dc.SelectStockObject(NULL_BRUSH);
int d1 = (rcTo->left - rcFr->left) / index;
int d2 = (rcTo->top - rcFr->top) / index;
int d3 = (rcTo->right - rcFr->right) / index;
int d4 = (rcTo->bottom - rcFr->bottom) / index;
for (int i=0; i<index; i++)
{
dc.Rectangle(rc);
Sleep(10);
dc.Rectangle(rc);
rc.left += d1;
rc.top += d2;
rc.right += d3;
rc.bottom += d4;
}
dc.SelectObject(pOldPen);
dc.SelectObject(pOldBrush);
dc.SetROP2(oldRop);
return 1;
}
CFadeWindow::CFadeWindow()
{
}
CFadeWindow::~CFadeWindow()
{
Close();
}
void CFadeWindow::Init(int nWidth, int nHeight)
{
m_dib1.Create(nWidth, nHeight);
m_dib2.Create(nWidth, nHeight);
m_dib3.Create(nWidth, nHeight);
m_draw.Open();
}
void CFadeWindow::Close()
{
m_dib1.Destroy();
m_dib2.Destroy();
m_dib3.Destroy();
m_draw.Close();
}
int CFadeWindow::FadeAndSwitchWindow(CWnd* pWndFrom, CWnd* pWndTo)
{
CWnd* pDesktop = CWnd::GetDesktopWindow();
//CWindowDC dc(pDesktop);
CWnd* pMain = AfxGetMainWnd();
CClientDC dc(pMain);
CRect rc;
pWndFrom->GetWindowRect(rc);
pMain->ScreenToClient(rc);
CDC *pDCFrom;
pDCFrom=pWndFrom->GetDC ();
m_dib1.PasteDC ( pDCFrom, 0, 0, rc.Width(), rc.Height());
m_dib3.PasteDC ( pDCFrom, 0, 0, rc.Width(), rc.Height());
pWndFrom->ReleaseDC ( pDCFrom );
CClientDC dcWndTo(pWndTo);
CDC dcTo;
dcTo.CreateCompatibleDC(&dcWndTo);
CBitmap bmpTo;
bmpTo.CreateCompatibleBitmap(&dcWndTo, rc.Width(), rc.Height());
CBitmap * pOldbmp = dcTo.SelectObject(&bmpTo);
SetWindowPos(pWndFrom->GetSafeHwnd(), HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE);
pWndTo->ShowWindow(SW_SHOW);
pWndTo->SendMessage(WM_PRINT, (WPARAM) dcTo.GetSafeHdc(), (LPARAM) PRF_CLIENT|PRF_CHILDREN|PRF_OWNED);
m_dib2.PasteDC ( &dcTo, 0, 0, rc.Width(), rc.Height());
dcTo.SelectObject(pOldbmp);
//m_draw.DrawDib ( &m_dib2, dc.GetSafeHdc(), 0, 0,
// rc.Width(), rc.Height(), DDF_HALFTONE );
SetWindowPos(pWndTo->GetSafeHwnd(), HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_SHOWWINDOW);
SetWindowPos(pWndFrom->GetSafeHwnd(), NULL, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_NOZORDER|SWP_HIDEWINDOW);
int index = 5;
//m_dib3.Fill(231,210,192);
for (int i=0; i<index; i++)
{
m_dib3.Paste(&m_dib1);
m_dib3.Blend(&m_dib2, i*256/index);
m_draw.DrawDib ( &m_dib3, dc.GetSafeHdc(), rc.left, rc.top,
rc.Width(), rc.Height(), DDF_HALFTONE );
//TRACE1("Finished Painting %d\n", i);
//if (i<index-1)
Sleep(10);
}
m_draw.DrawDib ( &m_dib2, dc.GetSafeHdc(), rc.left, rc.top,
rc.Width(), rc.Height(), DDF_HALFTONE );
//m_draw.DrawDib ( &m_dib2, dc.GetSafeHdc(), rc.left, rc.top,
// rc.Width(), rc.Height(), DDF_HALFTONE );
//SetWindowPos(pWndTo->GetSafeHwnd(), HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE|SWP_NOREDRAW|SWP_SHOWWINDOW);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -