当前位置:首页 » 文件管理 » 循环缓存vc

循环缓存vc

发布时间: 2022-09-05 10:07:01

A. vc++ 如何将文件分块读入缓存区,随后怎么从我读入首地址开始调用

路过

B. vc++怎样控制循环的速度

Sleep()为API函数,需要#include "windows.h"
另外函数大小写不能错

每1秒循环一次可以在循环体内部加入Sleep(1000)即可。

C. VC++ for循环

为什么要调用EndPaint( hWnd,&ps); 不理解

D. 在VC中让循环1分钟循环一次

#include <windows.h>//包含这个
while(true)
{
//循环体
Sleep(60000);//休眠60S
}

E. VC++ 缓冲技术

一般步骤是这样的:
HDC hdc = GetDC(hWnd);
HBITMAP hBitmap = CreateCompatibleBitmap(hdc,IMG_MAINWND_WIDTH,IMG_MAINWND_HEIGHT);//创建一个与设备兼容的位图
HDC hdcMem = CreateCompatibleDC(hdc);
HGDIOBJ hOldSel = SelectObject(hdcMem,hBitmap);//获得一个兼容DC
并把兼容位图选进去,以后你的作图就在hdcMem上了
然后你读入你需要贴的位图
bmp1 = (HBITMAP)LoadImage(NULL,"map1.bmp",IMAGE_BITMAP,400,300,LR_LOADFROMFILE);
SelectObject(mdc1,bmp1);
先在hdcMem上贴
BitBlt(hdcMem,0,0,IMG_MAINWND_WIDTH,
IMG_MAINWND_HEIGHT,mdc1,0,0,SRCCOPY);
...
贴完以后一次显示在hdc上
BitBlt(hdc...)
以上只是随便写写,参数这些可能有误,楼主自己斟酌调试下,大概步骤就是这样的了。

F. VC双缓存问题

使用以下的双缓冲类封装类CMenDC 来简单地实现 双缓冲绘图。
具体到你这里,只需这样。

void ***::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();

CClientDC clientdc(this);

CMenDC dc(&clientdc);
//之后就可以用dc绘图了。

DrawZDM(dc);//绘图函数
}

/****************************************************************************
以下代码复制后保存为一个头文件即可。
****************************************************************************/

#ifndef _MEMDC_H_
#define _MEMDC_H_

//////////////////////////////////////////////////
// CMemDC - memory DC
//
// Author: Keith Rule
// Email: [email protected]
// Copyright 1996-2002, Keith Rule
//
// You may freely use or modify this code provided this
// Copyright is included in all derived versions.
//
// History - 10/3/97 Fixed scrolling bug.
// Added print support. - KR
//
// 11/3/99 Fixed most common complaint. Added
// background color fill. - KR
//
// 11/3/99 Added support for mapping modes other than
// MM_TEXT as suggested by Lee Sang Hun. - KR
//
// 02/11/02 Added support for CScrollView as supplied
// by Gary Kirkham. - KR
//
// This class implements a memory Device Context which allows
// flicker free drawing.

class CMemDC : public CDC
{
private:
CBitmap m_bitmap; // Offscreen bitmap
CBitmap* m_oldBitmap; // bitmap originally found in CMemDC
CDC* m_pDC; // Saves CDC passed in constructor
CRect m_rect; // Rectangle of drawing area.
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.

public:
CMemDC(CDC* pDC, const CRect* pRect = NULL) : CDC()
{
ASSERT(pDC != NULL);

// Some initialization
m_pDC = pDC;
m_oldBitmap = NULL;
m_bMemDC = !pDC-> IsPrinting();

// Get the rectangle to draw
if (pRect == NULL) {
pDC-> GetClipBox(&m_rect);
}
else {
m_rect = *pRect;
}

if (m_bMemDC) {
// Create a Memory DC
CreateCompatibleDC(pDC);
pDC-> LPtoDP(&m_rect);

m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
m_oldBitmap = SelectObject(&m_bitmap);

SetMapMode(pDC-> GetMapMode());

SetWindowExt(pDC-> GetWindowExt());
SetViewportExt(pDC-> GetViewportExt());

pDC-> DPtoLP(&m_rect);
SetWindowOrg(m_rect.left, m_rect.top);
}
else {
// Make a of the relevent parts of the current
// DC for printing
m_bPrinting = pDC-> m_bPrinting;
m_hDC = pDC-> m_hDC;
m_hAttribDC = pDC-> m_hAttribDC;
}

// Fill background
FillSolidRect(m_rect, pDC-> GetBkColor());
}

~CMemDC()
{
if (m_bMemDC) {
// Copy the offscreen bitmap onto the screen.
m_pDC-> BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
this, m_rect.left, m_rect.top, SRCCOPY);

//Swap back the original bitmap.
SelectObject(m_oldBitmap);
}
else {
// All we need to do is replace the DC with an illegal
// value, this keeps us from accidentally deleting the
// handles associated with the CDC that was passed to
// the constructor.
m_hDC = m_hAttribDC = NULL;
}
}

// Allow usage as a pointer
CMemDC* operator-> ()
{
return this;
}

// Allow usage as a pointer
operator CMemDC*()
{
return this;
}
};

#endif

G. VC 每隔一定时间就来循环此代码

使用SetTimer()创建一个定时器
UINT_PTR SetTimer(
HWND hWnd, // 窗口句柄
UINT_PTR nIDEvent, // 定时器ID,多个定时器时,可以通过该ID判断是哪个定时器
UINT uElapse, // 时间间隔,单位为毫秒
TIMERPROC lpTimerFunc // 回调函数
);
在MFC程序中SetTimer被封装在CWnd类中,调用就不用指定窗口句柄了
于是SetTimer函数的原型变为:
UINT SetTimer(UINT nIDEvent,UINT nElapse,void(CALLBACK EXPORT *lpfnTimer)(HWND,UINT ,UINT ,DWORD))

在回调函数中写你的A的内容

H. VC如何在固定时间内进行循环

这个跟处理器有关的,在这几种cpu上结果是不一样的如单核单线程,单枋双线程,双核双线程,双核四线程等

I. 关于VC++循环语句嵌套以及CONTINUE的问题

1. CONTINUE 是结束本次循环返回到循环语句进行下一次循环,在你的程序里是返回内层循环的for语句,即当(j%2)非零时由continue语句跳过2号x++(不运行)直接从for开始下一个循环。

2. 内循环做完了才继续外部循环。

所以:
i=0
x++ //1
j=0
x++ //2
j=1
continue
j=2
x++ //2
x++ //3

i=1
x++ //1
j=0
x++ //2
j=1
continue
j=2
x++ //2
x++ //3

i=2
cout
结束
结果x=8

热点内容
网站编程培训 发布:2024-10-12 06:09:22 浏览:900
怎么看自己的电脑配置玩永劫无间 发布:2024-10-12 05:56:41 浏览:467
linuxzip文件解压命令 发布:2024-10-12 05:56:03 浏览:942
java怎么处理高并发 发布:2024-10-12 05:55:25 浏览:765
五子棋java源码 发布:2024-10-12 05:37:13 浏览:175
pythonopenstack怎么配置 发布:2024-10-12 05:16:07 浏览:929
安卓如何编辑动画 发布:2024-10-12 05:14:25 浏览:348
视频电脑配置高怎么玩游戏 发布:2024-10-12 04:35:56 浏览:731
sql复合查询 发布:2024-10-12 04:14:23 浏览:715
把文档加密 发布:2024-10-12 04:13:52 浏览:852