Click here to Skip to main content
15,911,306 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Registry handling Pin
David Crow14-Nov-08 3:26
David Crow14-Nov-08 3:26 
AnswerRe: Registry handling Pin
CPallini14-Nov-08 0:29
mveCPallini14-Nov-08 0:29 
Questionhow will i be able to show bitmap and text in a list box? Pin
puppya13-Nov-08 23:32
puppya13-Nov-08 23:32 
AnswerRe: how will i be able to show bitmap and text in a list box? Pin
CPallini13-Nov-08 23:53
mveCPallini13-Nov-08 23:53 
QuestionSample application in VC++ using XML. Pin
V K 213-Nov-08 23:32
V K 213-Nov-08 23:32 
AnswerRe: Sample application in VC++ using XML. Pin
CPallini13-Nov-08 23:49
mveCPallini13-Nov-08 23:49 
QuestionDynamic detection of UPnP devices? Pin
suren61213-Nov-08 23:31
suren61213-Nov-08 23:31 
Questionplease how to change this program for read all size for AVI file? Pin
mrlog13-Nov-08 23:11
mrlog13-Nov-08 23:11 
This program display an AVI file and its bitmqps file, but for specially file not for all size,for exemple it's for AVI file wich has a width= 48 and lenght=80
so the size is 48x80x3= 117Ko, so if we change the size it can't work.
please how to change this program for read all size for AVI file?




// Get pointers to the info structure & the bits
pointer = (BYTE *) prifffile ; the pointer here is static I think we must change into dynamic for read all size

//sstring[0] = * (pointer+4095);
pointer = pointer + 4096+11; // here we can change the color of bitmap background


hdc = BeginPaint (hwnd, &ps) ;

//draw a frame

for(i=0;i<48;i++)
for(j=0;j<80;j++)
if((0.299*(*(pointer+2+i*80*3+j*3))+0.587*(*(pointer+1+i*80*3+j*3))+0.114*(*(pointer +i*80*3+j*3)))<100)
SetPixel(hdc,j+50,i+50,RGB(255,0,0));




//draw 5 frames parally

for(m=0;m<5;m++){// this is a movie
for(i=0;i<48;i++)
for(j=0;j<80;j++)
SetPixel(hdc,j+100*m+50,i+150,RGB(*(pointer+2 + j*3 +(48-i)*80*3),
*(pointer+1 + j*3 +(48-i)*80*3),
*(pointer + j*3 +(48-i)*80*3)));



pointer = pointer + 11520*m+8*m;

}




pointer = (BYTE *) prifffile ; //let the pointer to pointer the begining again

pointer = pointer + 4096+11; //let the pointer to point at the bitmap data




//draw several frames to make a animation as movie


for(n=0;n<5;n++){ // repeat 5 times
for(m=0;m<5;m++){// this is a movie
for(i=0;i<48;i++)
for(j=0;j<80;j++)
SetPixel(hdc,j+50,i+250,RGB(*(pointer+2 + j*3 +(48-i)*80*3),
*(pointer+1 + j*3 +(48-i)*80*3),
*(pointer + j*3 +(48-i)*80*3)));
pointer = pointer + 11520*m+8*m;
Sleep(300); // set a time interval to make the movie natural

}
pointer = (BYTE *) prifffile ; //let the pointer to pointer the begining again

pointer = pointer + 4096+11; //let the pointer to point at the bitmap data

} // repeat 10 times


EndPaint (hwnd, &ps) ;

// show a dialogbox to tell you that the testing ends
MessageBox(hwnd,TEXT("displaying ends/ÑÝʾ½áÊø"),sstring,0);

return 0 ;


================================================================================================================================================


||Program||
-------
/*----------------------------------------------
SHOWDIB1.C -- Shows a DIB in the client area
(c) Charles Petzold, 1998
----------------------------------------------*/

#include <windows.h>
#include <aviriff.h>
#include <iostream.h>
#include "dibfile.h"
#include "resource.h"

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

TCHAR szAppName[] = TEXT ("ShowDib1") ;



int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HACCEL hAccel ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;

wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = szAppName ;
wndclass.lpszClassName = szAppName ;

if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}

hwnd = CreateWindow (szAppName, TEXT ("display an avi picture and an avi movie"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL) ;

ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;

hAccel = LoadAccelerators (hInstance, szAppName) ;

while (GetMessage (&msg, NULL, 0, 0))
{
if (!TranslateAccelerator (hwnd, hAccel, &msg))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
}
return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
////////////////////////////////////
static BITMAPINFO * pbmi ;
static BYTE * pBits ;
////////////////////////////////////
static RIFFLIST * prifffile ;
static AVIMAINHEADER * pavimh;
static AVISTREAMHEADER * pavish ;
static BYTE * pointer ;
/////////////////////////////////////////////////////////////////////
static int cxClient, cyClient, cxDib, cyDib ;
static TCHAR szFileName [MAX_PATH], szTitleName [MAX_PATH] ;
BOOL bSuccess ;
HDC hdc ;
PAINTSTRUCT ps ;
int i,j,m,n;


//////////////////////////////////////////////////////////////////////
// RIFF is the first 4 letters of a riff file. avi file is a riff file
static TCHAR sstring[] = {'R','I','F','F','\0'};
//////////////////////////////////////////////////////////////////////

switch (message)
{
case WM_CREATE:
DibFileInitialize (hwnd) ;
return 0 ;

case WM_SIZE:
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
return 0 ;

case WM_INITMENUPOPUP:
EnableMenuItem ((HMENU) wParam, IDM_FILE_SAVE,
prifffile ? MF_ENABLED : MF_GRAYED) ;
return 0 ;

case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDM_FILE_OPEN:
// Show the File Open dialog box


if (!DibFileOpenDlg (hwnd, szFileName, szTitleName))
return 0 ;

// If there's an existing DIB, free the memory

MessageBox(hwnd,szFileName,TEXT("The name of the file you have opened is"),0);

if (prifffile)
{
free (prifffile) ;
prifffile = NULL ;
}
// Load the entire DIB into memory

SetCursor (LoadCursor (NULL, IDC_WAIT)) ;
ShowCursor (TRUE) ;

prifffile = DibLoadImage(szFileName) ;


ShowCursor (FALSE) ;
SetCursor (LoadCursor (NULL, IDC_ARROW)) ;

// Invalidate the client area for later update

InvalidateRect (hwnd, NULL, TRUE) ;

if (prifffile == NULL)
{
MessageBox (hwnd, TEXT ("Cannot load AVI file"),
szAppName, 0) ;
return 0 ;
}

/* ------------------------------------------------------------------------------ */








// Get pointers to the info structure & the bits
pointer = (BYTE *) prifffile ;

//sstring[0] = * (pointer+4095);
pointer = pointer + 4096; // here we can change the color of bitmap background


hdc = BeginPaint (hwnd, &ps) ;
//draw a frame
//»­Ò»Ö¡
for(i=0;i<48;i++)
for(j=0;j<80;j++)
if((0.299*(*(pointer+2+i*80*3+j*3))+0.587*(*(pointer+1+i*80*3+j*3))+0.114*(*(pointer +i*80*3+j*3)))<100)
SetPixel(hdc,j+50,i+50,RGB(255,0,0));



//draw 5 frames parally
for(m=0;m<5;m++){// this is a movie
for(i=0;i<48;i++) //»­Ò»Ö¡
for(j=0;j<80;j++)
SetPixel(hdc,j+100*m+50,i+150,RGB(*(pointer+2 + j*3 +(48-i)*80*3),
*(pointer+1 + j*3 +(48-i)*80*3),
*(pointer + j*3 +(48-i)*80*3)));
pointer = pointer + 11520*m+8*m;

}


pointer = (BYTE *) prifffile ; //let the pointer to pointer the begining again

pointer = pointer + 4096+11; //let the pointer to point at the bitmap data


//draw several frames to make a animation as movie


for(n=0;n<5;n++){ // repeat 10 times
for(m=0;m<5;m++){// this is a movie
for(i=0;i<48;i++)
for(j=0;j<80;j++)
SetPixel(hdc,j+50,i+250,RGB(*(pointer+2 + j*3 +(48-i)*80*3),
*(pointer+1 + j*3 +(48-i)*80*3),
*(pointer + j*3 +(48-i)*80*3)));
pointer = pointer + 11520*m+8*m;
Sleep(300); // set a time interval to make the movie natural

}
pointer = (BYTE *) prifffile ; //let the pointer to pointer the begining again

pointer = pointer + 4096+11; //let the pointer to point at the bitmap data

} // repeat 10 times


EndPaint (hwnd, &ps) ;

// show a dialogbox to tell you that the testing ends
MessageBox(hwnd,TEXT("displaying ends/ÑÝʾ½áÊø"),sstring,0);

return 0 ;


case IDM_FILE_SAVE:
// Show the File Save dialog box

if (!DibFileSaveDlg (hwnd, szFileName, szTitleName))
return 0 ;

// Save the DIB to memory

SetCursor (LoadCursor (NULL, IDC_WAIT)) ;
ShowCursor (TRUE) ;

bSuccess = DibSaveImage (szFileName, prifffile) ;

ShowCursor (FALSE) ;
SetCursor (LoadCursor (NULL, IDC_ARROW)) ;

if (!bSuccess)
MessageBox (hwnd, TEXT ("Cannot save AVI file"),
szAppName, 0) ;
return 0 ;
}
break ;

case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
/*if (pbmi)
SetDIBitsToDevice (hdc,
50, // xDst
100, // yDst
cxDib, // cxSrc
cyDib, // cySrc
0, // xSrc
0, // ySrc
0, // first scan line
cyDib, // number of scan lines
pBits,
pbmi,
DIB_RGB_COLORS) ; */
EndPaint (hwnd, &ps) ;
return 0 ;

case WM_DESTROY:

/*if (pointer)
free (pointer);
if (prifffile)
free (prifffile);
if (pavish)
free (pavish);
if (pbmi)
free (pbmi) ;
if (pavimh)
free (pavimh) ;
if(pBits)
free (pBits);
*/
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
QuestionUnable to use SetDllDirectory call in VS2005 - C++ Pin
LindeA13-Nov-08 22:25
LindeA13-Nov-08 22:25 
AnswerRe: Unable to use SetDllDirectory call in VS2005 - C++ Pin
CPallini13-Nov-08 22:41
mveCPallini13-Nov-08 22:41 
AnswerRe: Unable to use SetDllDirectory call in VS2005 - C++ Pin
LindeA13-Nov-08 23:11
LindeA13-Nov-08 23:11 
AnswerRe: Unable to use SetDllDirectory call in VS2005 - C++ Pin
LindeA14-Nov-08 3:31
LindeA14-Nov-08 3:31 
Questionhow can i display icons or bimaps on status bar on a dialog based application? Pin
puppya13-Nov-08 21:55
puppya13-Nov-08 21:55 
AnswerRe: how can i display icons or bimaps on status bar on a dialog based application? Pin
Roger Stoltz13-Nov-08 23:34
Roger Stoltz13-Nov-08 23:34 
Questionhow can i add and display status bar for a dialog based application? Pin
puppya13-Nov-08 21:16
puppya13-Nov-08 21:16 
AnswerRe: how can i add and display status bar for a dialog based application? Pin
Saurabh.Garg13-Nov-08 21:22
Saurabh.Garg13-Nov-08 21:22 
QuestionCRichEditCtrl not apble to display Chinese arabic and other language characters Pin
Dhiraj kumar Saini13-Nov-08 21:03
Dhiraj kumar Saini13-Nov-08 21:03 
AnswerRe: CRichEditCtrl not apble to display Chinese arabic and other language characters Pin
Iain Clarke, Warrior Programmer13-Nov-08 22:55
Iain Clarke, Warrior Programmer13-Nov-08 22:55 
QuestionByte array to image Pin
tanmay.kol13-Nov-08 20:04
tanmay.kol13-Nov-08 20:04 
AnswerRe: Byte array to image Pin
Saurabh.Garg13-Nov-08 21:19
Saurabh.Garg13-Nov-08 21:19 
GeneralRe: Byte array to image Pin
tanmay.kol13-Nov-08 21:36
tanmay.kol13-Nov-08 21:36 
GeneralRe: Byte array to image Pin
Iain Clarke, Warrior Programmer13-Nov-08 23:05
Iain Clarke, Warrior Programmer13-Nov-08 23:05 
QuestionRadio Button Transparency Problem [modified] Pin
rkshdixit13-Nov-08 19:46
rkshdixit13-Nov-08 19:46 
AnswerRe: Radio Button Transparency Problem Pin
Code-o-mat14-Nov-08 6:49
Code-o-mat14-Nov-08 6:49 
GeneralRe: Radio Button Transparency Problem Pin
rkshdixit17-Nov-08 19:09
rkshdixit17-Nov-08 19:09 

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.