當前位置:首頁 » 文件管理 » 循環緩存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

熱點內容
網站架設多伺服器ip 發布:2024-10-12 07:42:15 瀏覽:187
linuxjdbc 發布:2024-10-12 07:38:10 瀏覽:197
pythonip正則表達式 發布:2024-10-12 07:30:24 瀏覽:177
xp怎麼認安卓手機 發布:2024-10-12 07:30:20 瀏覽:878
pythonmac開發工具 發布:2024-10-12 07:29:01 瀏覽:267
android字元數組 發布:2024-10-12 07:16:32 瀏覽:307
買安卓手機選什麼顏色 發布:2024-10-12 07:10:51 瀏覽:698
已經連接的wifi怎麼看密碼 發布:2024-10-12 07:06:07 瀏覽:59
sae上傳失敗 發布:2024-10-12 07:03:20 瀏覽:958
如何在伺服器上玩ai換臉 發布:2024-10-12 06:43:47 瀏覽:913