Click here to Skip to main content
15,902,832 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with C++ programing Pin
ThatsAlok24-Mar-09 19:52
ThatsAlok24-Mar-09 19:52 
QuestionRe: Help with C++ programing [modified] Pin
mimikoyan24-Mar-09 20:01
mimikoyan24-Mar-09 20:01 
Questionif(BOOL_b) vs if(BOOL_b == FALSE) Pin
fitatc24-Mar-09 16:24
fitatc24-Mar-09 16:24 
AnswerRe: if(BOOL_b) vs if(BOOL_b == FALSE) Pin
Maxwell Chen24-Mar-09 17:34
Maxwell Chen24-Mar-09 17:34 
AnswerRe: if(BOOL_b) vs if(BOOL_b == FALSE) Pin
N a v a n e e t h24-Mar-09 18:22
N a v a n e e t h24-Mar-09 18:22 
AnswerRe: if(BOOL_b) vs if(BOOL_b == FALSE) Pin
Eytukan24-Mar-09 19:35
Eytukan24-Mar-09 19:35 
AnswerRe: if(BOOL_b) vs if(BOOL_b == FALSE) Pin
Niklas L25-Mar-09 0:14
Niklas L25-Mar-09 0:14 
QuestionProblems using BI_BITFIELDS Compression with DrawDibDraw Pin
Uwe Kiwitt-Frischnbruder24-Mar-09 16:16
Uwe Kiwitt-Frischnbruder24-Mar-09 16:16 
Hallo!

I have Problems using DrawDibDraw (from msvfw32.dll) with Compression set to BI_BITFIELDS.

When I set biCompression to BI_RGB, it works, but when I set biCompression to BI_BITFIELDS, DrawDibDraw returns false and draws nothing.

Does anyone have any Ideas?

Here is my code:

#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <vfw.h>

#define WIDTH 5000
#define HEIGHT 3000
short bits[HEIGHT][WIDTH];
BITMAPINFOHEADER * bmih;
int iCnt;
HDRAWDIB hdd;
int w,h;
RECT r;

int CDECL Xpress(TCHAR * msg,...)
{
	TCHAR buf[1024];
	va_list args;
	va_start (args,msg);
	_vsnwprintf_s(buf,sizeof(buf)/sizeof(TCHAR),msg,args);
	va_end(args);
	return MessageBox(NULL,buf,NULL,NULL);
}

LRESULT CALLBACK WinProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch (msg)
	{
	case WM_PAINT:
		PAINTSTRUCT ps;
		HDC hdc;
		hdc = BeginPaint(hwnd,&ps);
		DrawDibDraw(hdd,hdc,0,0,w,h,bmih,bits,0,abs(500-iCnt%1000),w,h,DDF_JUSTDRAWIT);
		EndPaint(hwnd,&ps);
		return 0;
	case WM_SIZE:
		GetClientRect(hwnd,&r);
		w=r.right-r.left;
		h=r.bottom-r.top;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd,msg,wParam,lParam);
}

int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR lpCmd,int nShow)
{
	int iRet=-1;
	for (int i=0;i<HEIGHT;i++)
	{
		for (int j=0;j<WIDTH;j++)
		{
			bits[i][j]=((i&0x1f)<<10)|((j&0x1f)<<5);
		}
	}
	WNDCLASS cls;
	cls.lpszClassName=L"WINDCLS";
	cls.lpfnWndProc=WinProc;
	cls.cbClsExtra=0;
	cls.cbWndExtra=0;
	cls.hbrBackground=NULL;
	cls.hCursor=LoadCursor(NULL,IDC_ARROW);
	cls.hIcon=NULL;
	cls.lpszMenuName=NULL;
	cls.hInstance=hInst;
	cls.style=0;
	r.top=0;
	r.left=0;
	r.right=GetSystemMetrics(SM_CXSCREEN);
	r.bottom=GetSystemMetrics(SM_CYSCREEN);
	if (RegisterClass(&cls))
	{
		HWND desk = CreateWindowW(L"WINDCLS",L"Main",WS_SYSMENU,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInst,NULL);
		ShowWindow(desk,nShow);
		UpdateWindow(desk);
		bmih=(BITMAPINFOHEADER*)malloc(sizeof(BITMAPINFOHEADER)+3*sizeof(DWORD));
		bmih->biSize=sizeof(BITMAPINFOHEADER)+3*sizeof(int);
		bmih->biWidth=WIDTH;
		bmih->biHeight=HEIGHT;
		bmih->biPlanes=1;
		bmih->biBitCount=16;
		bmih->biCompression=BI_RGB;
		bmih->biSizeImage=WIDTH*HEIGHT*2;
		bmih->biXPelsPerMeter=0;
		bmih->biYPelsPerMeter=0;
		bmih->biClrUsed=0;
		bmih->biClrImportant=0;
		DWORD * col = (DWORD *)&bmih[1];
		col[0]=0xFC00;
		col[1]=0x03E0;
		col[2]=0x001F;
		MSG msg;
		hdd = DrawDibOpen();
		if (hdd==NULL)
		{
			Xpress(L"Cant get DIB");
		}
		else
		{
			long start = GetCurrentTime();
			for (iCnt=0;iCnt<10000&&GetMessage(&msg,NULL,0,0);iCnt++)
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				bits[1500+iCnt/500][iCnt%500]=0x1f;
				InvalidateRect(desk,&r,FALSE);
			}
			DrawDibClose(hdd);
			Xpress(TEXT("%i fps"),1000*iCnt/(GetCurrentTime()-start));
			iRet=(int)msg.wParam;
		}
	}
	return iRet;
}

Many thanks...

Uwe
QuestionProblem calling C++ DLL from Excel Pin
gvanto24-Mar-09 16:11
gvanto24-Mar-09 16:11 
AnswerRe: Problem calling C++ DLL from Excel Pin
Garth J Lancaster24-Mar-09 16:32
professionalGarth J Lancaster24-Mar-09 16:32 
QuestionRe: Problem calling C++ DLL from Excel Pin
gvanto24-Mar-09 16:38
gvanto24-Mar-09 16:38 
AnswerRe: Problem calling C++ DLL from Excel Pin
Garth J Lancaster24-Mar-09 16:48
professionalGarth J Lancaster24-Mar-09 16:48 
AnswerRe: Problem calling C++ DLL from Excel Pin
Garth J Lancaster24-Mar-09 17:19
professionalGarth J Lancaster24-Mar-09 17:19 
QuestionRe: Problem calling C++ DLL from Excel Pin
gvanto24-Mar-09 17:23
gvanto24-Mar-09 17:23 
AnswerRe: Problem calling C++ DLL from Excel Pin
Garth J Lancaster24-Mar-09 17:25
professionalGarth J Lancaster24-Mar-09 17:25 
GeneralRe: Problem calling C++ DLL from Excel Pin
gvanto24-Mar-09 17:35
gvanto24-Mar-09 17:35 
GeneralRe: Problem calling C++ DLL from Excel Pin
gvanto24-Mar-09 17:36
gvanto24-Mar-09 17:36 
GeneralRe: Problem calling C++ DLL from Excel Pin
Garth J Lancaster24-Mar-09 17:43
professionalGarth J Lancaster24-Mar-09 17:43 
QuestionMSVCR90.dll and MFCVC90.dll as part of wiseinstaller installation Pin
Ramchandra.kk24-Mar-09 15:40
Ramchandra.kk24-Mar-09 15:40 
QuestionUsing CViewmemebers , CDocumentmemebers in CWinThread Pin
Piction24-Mar-09 13:06
Piction24-Mar-09 13:06 
AnswerRe: Using CViewmemebers , CDocumentmemebers in CWinThread Pin
led mike25-Mar-09 5:16
led mike25-Mar-09 5:16 
QuestionCombination Algorithm Pin
Michael Hildebrand24-Mar-09 10:50
Michael Hildebrand24-Mar-09 10:50 
AnswerRe: Combination Algorithm Pin
led mike24-Mar-09 11:23
led mike24-Mar-09 11:23 
GeneralRe: Combination Algorithm Pin
Michael Hildebrand24-Mar-09 11:28
Michael Hildebrand24-Mar-09 11:28 
GeneralRe: Combination Algorithm Pin
Rick York24-Mar-09 11:45
mveRick York24-Mar-09 11:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.