- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好的,我正在创建一个游戏,但它使用了太多的 CPU,但没有使用太多的内存。 cpu确实增加和减少。我的游戏中有太多计时器,当我不再使用它时我会关闭计时器,所以这应该会导致问题,但我认为导致问题的原因是我的消息队列中有太多消息。我有 5 个月大的新笔记本电脑,它的 CPU 很高。它使用了我 40% 的 CPU。有没有办法减少它,因为当它达到 40% 时,游戏速度会变慢。
这是我的代码
// Xstrike.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Xstrike.h"
#include <vector>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
RECT *rect;
const UINT_PTR EVERYTHING_ID=0x1;
const UINT_PTR LBUTTONDOWN_ID=0x3;
const UINT_PTR TDENEMIE1_ID=0x4;
const UINT_PTR TAENEMIE1_ID=0x5;
const UINT_PTR PROTECTED_ID=0x6;
int conno=2;
int health=0;
int life=3;
int score=0;
int level=1;
int protect=0;
int cursor=0;
HCURSOR hCursor[3];
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
struct Enemies
{
int cEnemie1;
int dEnemie1;
int aEnemie1;
int sEnemie1;
int pEnemie1;
bool e1;
time_t now;
time_t tEnemie1;
vector <POINT> vS1Enemie1;
vector <POINT> vS2Enemie1;
};
vector <POINT> vRegularShots;
Enemies Enemie1;
VOID installising()
{
Enemie1.cEnemie1=0;
Enemie1.dEnemie1=1;
Enemie1.aEnemie1=0;
Enemie1.sEnemie1=1;
Enemie1.pEnemie1=550;
Enemie1.e1=true;
POINT pt;
pt.x=0;
pt.y=0;
vRegularShots.push_back(pt);
}
VOID Paint(HDC hdc, HWND hWnd)
{
int lifePos=200;
hdc=GetDC(hWnd);
HDC memDC=CreateCompatibleDC(hdc);
HBITMAP hMemMap=CreateCompatibleBitmap(hdc, 225, 350);
HBITMAP hOldMap=(HBITMAP)SelectObject(memDC, hMemMap);
Graphics draw(memDC);
// Drawing
Image bg(L"bg.jpg");
draw.DrawImage(&bg, 0, 0);
// if regular cursor
if(cursor==0)
{
// Regular shots
Image shot(L"RegularShots.png");
long s=vRegularShots.size();
// Draw shots
for(long index=0; index < (long)vRegularShots.size(); ++index)
{
draw.DrawImage(&shot, vRegularShots[index].x, vRegularShots[index].y);
}
// Update the shots
for(long index=0; index < (long)vRegularShots.size(); ++index)
{
vRegularShots[index].y--;
}
// Delete Shots
for(long index=0; index < (long)vRegularShots.size(); index++)
{
if(vRegularShots[index].y<-16)
{
vRegularShots.erase(vRegularShots.begin()+index);
}
}
// Create Enemies
if(Enemie1.dEnemie1==0)
{
if(Enemie1.cEnemie1<2)
{
if(Enemie1.aEnemie1==0)
{
SetTimer(hWnd, TAENEMIE1_ID, 550, NULL);
}
Enemie1.aEnemie1=1;
Enemie1.cEnemie1++;
}
else
{
KillTimer(hWnd, TDENEMIE1_ID);
}
Enemie1.dEnemie1=1;
}
// Draw enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); ++index)
{
Image iEnemie1(L"Enemie1.png");
draw.DrawImage(&iEnemie1, Enemie1.vS1Enemie1[index].x, Enemie1.vS1Enemie1[index].y);
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); ++index)
{
Image iEnemie1(L"Enemie1.png");
draw.DrawImage(&iEnemie1, Enemie1.vS2Enemie1[index].x, Enemie1.vS2Enemie1[index].y);
}
// Update enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); index++)
{
Enemie1.vS1Enemie1[index].x++;
Enemie1.vS1Enemie1[index].y++;
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); index++)
{
Enemie1.vS2Enemie1[index].x--;
Enemie1.vS2Enemie1[index].y++;
}
// Delete enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); index++)
{
if(Enemie1.vS1Enemie1[index].x>225)
{
Enemie1.vS1Enemie1.erase(Enemie1.vS1Enemie1.begin()+index);
}
// Stop enemie1 timer
if(Enemie1.vS1Enemie1.size()==0&&Enemie1.vS2Enemie1.size()==0)
{
KillTimer(hWnd, TAENEMIE1_ID);
}
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); index++)
{
if(Enemie1.vS2Enemie1[index].x<-21)
{
Enemie1.vS2Enemie1.erase(Enemie1.vS2Enemie1.begin()+index);
}
// Stop enemie1 timer
if(Enemie1.vS1Enemie1.size()==0&&Enemie1.vS2Enemie1.size()==0)
{
KillTimer(hWnd, TAENEMIE1_ID);
}
}
// player hits
if(Enemie1.pEnemie1==550)
{
POINT pt;
GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); index++)
{
if(((pt.x+5)>=Enemie1.vS1Enemie1[index].x&&(pt.x+5)<=(Enemie1.vS1Enemie1[index].x+17)&&pt.y>=Enemie1.vS1Enemie1[index].y&&pt.y<=(Enemie1.vS1Enemie1[index].y+17))||((pt.x+15)>=Enemie1.vS1Enemie1[index].x&&pt.y>=Enemie1.vS1Enemie1[index].y&&pt.y<=(Enemie1.vS1Enemie1[index].y+17)&&(pt.x+14)<=(Enemie1.vS1Enemie1[index].x+17))||((pt.x+21)>=Enemie1.vS1Enemie1[index].x&&(pt.y+14)>=Enemie1.vS1Enemie1[index].y&&(pt.y+14)<=(Enemie1.vS1Enemie1[index].y+17)&&(pt.x+21)<=(Enemie1.vS1Enemie1[index].x+17))||((pt.x+23)>=Enemie1.vS1Enemie1[index].x&&(pt.y+22)>=Enemie1.vS1Enemie1[index].y&&(pt.y+22)<=(Enemie1.vS1Enemie1[index].y+17)&&(pt.x+23)<=(Enemie1.vS1Enemie1[index].x+17))||((pt.x+13)>=Enemie1.vS1Enemie1[index].x&&(pt.y+31)>=Enemie1.vS1Enemie1[index].y&&(pt.y+31)<=(Enemie1.vS1Enemie1[index].y+17)&&(pt.x+13)<=(Enemie1.vS1Enemie1[index].x+17))||(pt.x>=Enemie1.vS1Enemie1[index].x&&(pt.y+22)>=Enemie1.vS1Enemie1[index].y&&(pt.y+22)<=(Enemie1.vS1Enemie1[index].y+17)&&pt.x<=(Enemie1.vS1Enemie1[index].x+21))||((pt.x+3)>=Enemie1.vS1Enemie1[index].x&&(pt.y+14)>=Enemie1.vS1Enemie1[index].y&&(pt.y+14)<=(Enemie1.vS1Enemie1[index].y+21)&&(pt.x+3)<=(Enemie1.vS1Enemie1[index].x+21)))
{
health+=30;
Enemie1.pEnemie1=0;
InvalidateRect(hWnd, rect, false);
}
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); index++)
{
if(((pt.x+5)>=Enemie1.vS2Enemie1[index].x&&(pt.x+5)<=(Enemie1.vS2Enemie1[index].x+17)&&pt.y>=Enemie1.vS2Enemie1[index].y&&pt.y<=(Enemie1.vS2Enemie1[index].y+17))||((pt.x+15)>=Enemie1.vS2Enemie1[index].x&&pt.y>=Enemie1.vS2Enemie1[index].y&&pt.y<=(Enemie1.vS2Enemie1[index].y+17)&&(pt.x+14)<=(Enemie1.vS2Enemie1[index].x+17))||((pt.x+21)>=Enemie1.vS2Enemie1[index].x&&(pt.y+14)>=Enemie1.vS2Enemie1[index].y&&(pt.y+14)<=(Enemie1.vS2Enemie1[index].y+17)&&(pt.x+21)<=(Enemie1.vS2Enemie1[index].x+17))||((pt.x+23)>=Enemie1.vS2Enemie1[index].x&&(pt.y+22)>=Enemie1.vS2Enemie1[index].y&&(pt.y+22)<=(Enemie1.vS2Enemie1[index].y+17)&&(pt.x+23)<=(Enemie1.vS2Enemie1[index].x+17))||((pt.x+13)>=Enemie1.vS2Enemie1[index].x&&(pt.y+31)>=Enemie1.vS2Enemie1[index].y&&(pt.y+31)<=(Enemie1.vS2Enemie1[index].y+17)&&(pt.x+13)<=(Enemie1.vS2Enemie1[index].x+17))||(pt.x>=Enemie1.vS2Enemie1[index].x&&(pt.y+22)>=Enemie1.vS2Enemie1[index].y&&(pt.y+22)<=(Enemie1.vS2Enemie1[index].y+17)&&pt.x<=(Enemie1.vS2Enemie1[index].x+21))||((pt.x+3)>=Enemie1.vS2Enemie1[index].x&&(pt.y+14)>=Enemie1.vS2Enemie1[index].y&&(pt.y+14)<=(Enemie1.vS2Enemie1[index].y+21)&&(pt.x+3)<=(Enemie1.vS2Enemie1[index].x+21)))
{
health+=30;
Enemie1.pEnemie1=0;
InvalidateRect(hWnd, rect, false);
}
}
}
if(health>225)
{
cursor=1;
SetTimer(hWnd, PROTECTED_ID, 1000, NULL);
life--;
health=0;
InvalidateRect(hWnd, rect, false);
}
// Hits
for(long index=0; index < (long)vRegularShots.size(); index++)
{
for(long indexs=0; indexs < (long)Enemie1.vS1Enemie1.size(); indexs++)
{
if((vRegularShots[index].x>=Enemie1.vS1Enemie1[indexs].x && vRegularShots[index].y>=Enemie1.vS1Enemie1[indexs].y && vRegularShots[index].y<=(Enemie1.vS1Enemie1[indexs].y+17) && vRegularShots[index].x<=(Enemie1.vS1Enemie1[indexs].x+17))||(Enemie1.vS1Enemie1[indexs].x>=vRegularShots[index].x && Enemie1.vS1Enemie1[indexs].y>=vRegularShots[index].y && Enemie1.vS1Enemie1[indexs].y<=(vRegularShots[index].y+16) && Enemie1.vS1Enemie1[indexs].x<=(vRegularShots[index].x+5)))
{
Enemie1.vS1Enemie1.erase(Enemie1.vS1Enemie1.begin()+indexs);
vRegularShots[index].y=-17;
score+=100;
// Stop enemie1 timer
if(Enemie1.vS1Enemie1.size()==0&&Enemie1.vS2Enemie1.size()==0)
{
KillTimer(hWnd, TAENEMIE1_ID);
}
}
}
for(long indexs=0; indexs < (long)Enemie1.vS2Enemie1.size(); indexs++)
{
if((vRegularShots[index].x>=Enemie1.vS2Enemie1[indexs].x && vRegularShots[index].y>=Enemie1.vS2Enemie1[indexs].y && vRegularShots[index].y<=(Enemie1.vS2Enemie1[indexs].y+17) && vRegularShots[index].x<=(Enemie1.vS2Enemie1[indexs].x+17))||(Enemie1.vS2Enemie1[indexs].x>=vRegularShots[index].x && Enemie1.vS2Enemie1[indexs].y>=vRegularShots[index].y && Enemie1.vS2Enemie1[indexs].y<=(vRegularShots[index].y+16) && Enemie1.vS2Enemie1[indexs].x<=(vRegularShots[index].x+5)))
{
Enemie1.vS2Enemie1.erase(Enemie1.vS2Enemie1.begin()+indexs);
vRegularShots[index].y=-17;
score+=100;
// Stop enemie1 timer
if(Enemie1.vS1Enemie1.size()==0&&Enemie1.vS2Enemie1.size()==0)
{
KillTimer(hWnd, TAENEMIE1_ID);
}
}
}
}
}
// If protected
if(cursor==1)
{
if(protect!=4)
{
// Regular shots
Image shot(L"RegularShots.png");
// Draw shots
for(long index=0; index < (long)vRegularShots.size(); ++index)
{
draw.DrawImage(&shot, vRegularShots[index].x, vRegularShots[index].y);
}
// Update the shots
for(long index=0; index < (long)vRegularShots.size(); ++index)
{
vRegularShots[index].y--;
}
// Delete Shots
for(long index=0; index < (long)vRegularShots.size(); index++)
{
if(vRegularShots[index].y<-16)
{
vRegularShots.erase(vRegularShots.begin()+index);
}
}
// Delete Shots
for(long index=0; index < (long)vRegularShots.size(); index++)
{
if(vRegularShots[index].y<-16)
{
vRegularShots.erase(vRegularShots.begin()+index);
}
}
// Create Enemies
if(Enemie1.dEnemie1==0)
{
if(Enemie1.cEnemie1<2)
{
if(Enemie1.aEnemie1==0)
{
SetTimer(hWnd, TAENEMIE1_ID, 550, NULL);
}
Enemie1.aEnemie1=1;
Enemie1.cEnemie1++;
}
else
{
KillTimer(hWnd, TDENEMIE1_ID);
}
Enemie1.dEnemie1=1;
}
// Draw enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); ++index)
{
Image iEnemie1(L"Enemie1.png");
draw.DrawImage(&iEnemie1, Enemie1.vS1Enemie1[index].x, Enemie1.vS1Enemie1[index].y);
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); ++index)
{
Image iEnemie1(L"Enemie1.png");
draw.DrawImage(&iEnemie1, Enemie1.vS2Enemie1[index].x, Enemie1.vS2Enemie1[index].y);
}
// Update enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); index++)
{
Enemie1.vS1Enemie1[index].x++;
Enemie1.vS1Enemie1[index].y++;
}
for(long index=0; index < (long)Enemie1.vS2Enemie1.size(); index++)
{
Enemie1.vS2Enemie1[index].x--;
Enemie1.vS2Enemie1[index].y++;
}
// Delete enemies
for(long index=0; index < (long)Enemie1.vS1Enemie1.size(); index++)
{
if(Enemie1.vS1Enemie1[index].x>225)
{
Enemie1.vS1Enemie1.erase(Enemie1.vS1Enemie1.begin()+index);
}
// Stop enemie1 timer
if(Enemie1.vS1Enemie1.size()==0&&Enemie1.vS2Enemie1.size()==0)
{
KillTimer(hWnd, TAENEMIE1_ID);
}
}
}
else
{
KillTimer(hWnd, PROTECTED_ID);
cursor=0;
protect=0;
}
}
// Draw Lifes
for(long index=0; index != life; index++)
{
Image lifes(L"lifes.png");
draw.DrawImage(&lifes, lifePos, 275);
lifePos-=30;
}
SolidBrush textColor(Color(255, 255, 54, 0));
LinearGradientBrush linGrBrush(
Point(1000, 20),
Point(health, 20),
Color(255, 255, 0, 0), // opaque black
Color(0, 0, 0, 0)); // opaque red
SolidBrush databrush(Color(0, 225, 0));
draw.FillRectangle(&databrush, 0, 0, 225, 30);
draw.FillRectangle(&linGrBrush, 0, 0, 225, 30);
FontFamily courieNew(L"Courier New");
Font font(&courieNew, 12, 0, UnitPixel);
PointF pLevel(5.0f, 6.0f);
PointF pScore(100.0f, 6.0f);
WCHAR wLevel[11];
WCHAR wScore[60];
_swprintf(wLevel, L"Level : %d", level);
_swprintf(wScore, L"Score : %d", score);
draw.DrawString(wLevel, -1, &font, pLevel, &textColor);
draw.DrawString(wScore, -1, &font, pScore, &textColor);
BitBlt(hdc, 0, 0, 225, 350, memDC, 0, 0, SRCCOPY);
ReleaseDC(hWnd, hdc);
SelectObject(memDC, hOldMap);
DeleteObject(hMemMap);
DeleteDC(memDC);
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Cursors
hCursor[0]=LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CURSOR));
hCursor[1]=LoadCursor(hInstance, MAKEINTRESOURCE(IDC_PROTECTED));
// Initialize GDI+.
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_XSTRIKE, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_XSTRIKE));
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
GdiplusShutdown(gdiplusToken);
return (int) msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage are only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_XSTRIKE));
wcex.hCursor = LoadCursor(hInstance, MAKEINTRESOURCE(IDC_CURSOR));
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_XSTRIKE);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HINSTANCE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX),
CW_USEDEFAULT, 0, 225, 350, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
POINT pt;
switch (message)
{
case WM_CREATE:
installising();
SetTimer(hWnd, EVERYTHING_ID, 1, NULL);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
Paint(hdc, hWnd);
EndPaint(hWnd, &ps);
break;
case WM_LBUTTONDOWN:
GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);
if(conno==1)
{
conno++;
}
else
{
pt.x+=18;
conno--;
}
vRegularShots.push_back(pt);
SetTimer(hWnd, LBUTTONDOWN_ID, 350, NULL);
InvalidateRect(hWnd, rect, false);
break;
case WM_LBUTTONUP:
KillTimer(hWnd, LBUTTONDOWN_ID);
break;
case WM_TIMER:
switch(wParam)
{
case EVERYTHING_ID:
if(Enemie1.e1==true)
{
Enemie1.now=time(NULL);
Enemie1.tEnemie1=Enemie1.now+1;
Enemie1.e1=false;
}
Enemie1.now=time(NULL);
if(Enemie1.now==Enemie1.tEnemie1)
{
SetTimer(hWnd, TDENEMIE1_ID, 550, NULL);
}
InvalidateRect(hWnd, rect, false);
break;
case LBUTTONDOWN_ID:
GetCursorPos(&pt);
ScreenToClient(hWnd, &pt);
if(conno==1)
{
if(cursor==0)
{
conno++;
}
else if(cursor==1)
{
pt.x+=2;
conno++;
}
}
else
{
if(cursor==0)
{
pt.x+=18;
}
else if(cursor==1)
{
pt.x+=15;
}
conno--;
}
vRegularShots.push_back(pt);
break;
case TDENEMIE1_ID:
pt.y=5;
pt.x=-21;
Enemie1.vS1Enemie1.push_back(pt);
pt.y=5;
pt.x=219;
Enemie1.vS2Enemie1.push_back(pt);
Enemie1.dEnemie1=0;
InvalidateRect(hWnd, rect, false);
break;
case TAENEMIE1_ID:
if(Enemie1.pEnemie1!=550)
{
Enemie1.pEnemie1+=550;
}
InvalidateRect(hWnd, rect, false);
break;
case PROTECTED_ID:
protect++;
break;
}
break;
case WM_SETCURSOR:
SetCursor(hCursor[cursor]);
return 0;
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (message)
{
case WM_INITDIALOG:
return (INT_PTR)TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE;
}
break;
}
return (INT_PTR)FALSE;
}
有什么想法吗?
最佳答案
我的猜测是您不断地重新分配和重新绘制所有内容,而不是简单地四处移动图像。我可以看到应用程序经常不得不从头开始重新分配和重新绘制,这在系统上存在瓶颈。
关于c++ 使用过多的 cpu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3561613/
我在网上搜索但没有找到任何合适的文章解释如何使用 javascript 使用 WCF 服务,尤其是 WebScriptEndpoint。 任何人都可以对此给出任何指导吗? 谢谢 最佳答案 这是一篇关于
我正在编写一个将运行 Linux 命令的 C 程序,例如: cat/etc/passwd | grep 列表 |剪切-c 1-5 我没有任何结果 *这里 parent 等待第一个 child (chi
所以我正在尝试处理文件上传,然后将该文件作为二进制文件存储到数据库中。在我存储它之后,我尝试在给定的 URL 上提供文件。我似乎找不到适合这里的方法。我需要使用数据库,因为我使用 Google 应用引
我正在尝试制作一个宏,将下面的公式添加到单元格中,然后将其拖到整个列中并在 H 列中复制相同的公式 我想在 F 和 H 列中输入公式的数据 Range("F1").formula = "=IF(ISE
问题类似于this one ,但我想使用 OperatorPrecedenceParser 解析带有函数应用程序的表达式在 FParsec . 这是我的 AST: type Expression =
我想通过使用 sequelize 和 node.js 将这个查询更改为代码取决于在哪里 select COUNT(gender) as genderCount from customers where
我正在使用GNU bash,版本5.0.3(1)-发行版(x86_64-pc-linux-gnu),我想知道为什么简单的赋值语句会出现语法错误: #/bin/bash var1=/tmp
这里,为什么我的代码在 IE 中不起作用。我的代码适用于所有浏览器。没有问题。但是当我在 IE 上运行我的项目时,它发现错误。 而且我的 jquery 类和 insertadjacentHTMl 也不
我正在尝试更改标签的innerHTML。我无权访问该表单,因此无法编辑 HTML。标签具有的唯一标识符是“for”属性。 这是输入和标签的结构:
我有一个页面,我可以在其中返回用户帖子,可以使用一些 jquery 代码对这些帖子进行即时评论,在发布新评论后,我在帖子下插入新评论以及删除 按钮。问题是 Delete 按钮在新插入的元素上不起作用,
我有一个大约有 20 列的“管道分隔”文件。我只想使用 sha1sum 散列第一列,它是一个数字,如帐号,并按原样返回其余列。 使用 awk 或 sed 执行此操作的最佳方法是什么? Accounti
我需要将以下内容插入到我的表中...我的用户表有五列 id、用户名、密码、名称、条目。 (我还没有提交任何东西到条目中,我稍后会使用 php 来做)但由于某种原因我不断收到这个错误:#1054 - U
所以我试图有一个输入字段,我可以在其中输入任何字符,但然后将输入的值小写,删除任何非字母数字字符,留下“。”而不是空格。 例如,如果我输入: 地球的 70% 是水,-!*#$^^ & 30% 土地 输
我正在尝试做一些我认为非常简单的事情,但出于某种原因我没有得到想要的结果?我是 javascript 的新手,但对 java 有经验,所以我相信我没有使用某种正确的规则。 这是一个获取输入值、检查选择
我想使用 angularjs 从 mysql 数据库加载数据。 这就是应用程序的工作原理;用户登录,他们的用户名存储在 cookie 中。该用户名显示在主页上 我想获取这个值并通过 angularjs
我正在使用 autoLayout,我想在 UITableViewCell 上放置一个 UIlabel,它应该始终位于单元格的右侧和右侧的中心。 这就是我想要实现的目标 所以在这里你可以看到我正在谈论的
我需要与 MySql 等效的 elasticsearch 查询。我的 sql 查询: SELECT DISTINCT t.product_id AS id FROM tbl_sup_price t
我正在实现代码以使用 JSON。 func setup() { if let flickrURL = NSURL(string: "https://api.flickr.com/
我尝试使用for循环声明变量,然后测试cols和rols是否相同。如果是,它将运行递归函数。但是,我在 javascript 中执行 do 时遇到问题。有人可以帮忙吗? 现在,在比较 col.1 和
我举了一个我正在处理的问题的简短示例。 HTML代码: 1 2 3 CSS 代码: .BB a:hover{ color: #000; } .BB > li:after {
我是一名优秀的程序员,十分优秀!