HOW PLZ !!!!!

Started by
4 comments, last by Ahmed Saleh 22 years, 10 months ago
this Code Make A Menu I need To Selcet an object With Keyboard EXAMPLE: In Start in need if i prees ENTER in it Go TO Star Gamed............. HI ALL I Make a Menu With This Code [/source] /*--------------------------------------------------------------------------*/ // ARAB SPACE // // By Ahmed Saleh Mohammed Tolba // // CopyRight(c) 2001 // // // /*--------------------------------------------------------------------------*/ //------ Include Files ------// #include #include #include #include #include #include #include "Fastfile.h" #include "stdafx.h" #define INITGUID #include #include "wave.h" #include "Main.h" #include "Ffent.h" //------ Window Class Information ------// static char szClass[] = "Arab Space"; static char szCaption[] = "ARAB SPACE"; //------ Global Interface Pointers ------// LPDIRECTDRAW7 lpDD=NULL; LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL; LPDIRECTDRAWSURFACE7 lpDDSBack=NULL; //------ Define Number of Sounds ------// #define NUMSOUNDS 1 //------ DirectSound Object and Buffers ------// //------Define number of images and set up list of file names ------// #define IMAGE_COUNT 5 char file_names[IMAGE_COUNT][256] = { "Start.bmp", "load.bmp,FFDATFILE", "cerdit.bmp,FFDATFILE", "exit.bmp,FFDATFILE", }; //------ DirectDraw Surfaces for Image Storage ------// LPDIRECTDRAWSURFACE7 lpSlides[IMAGE_COUNT]; //------ current image displayed------// int cur_image=0; //------ Error Return String ------// const char *ErrStr=NULL; //------ Error Messages ------// const char Err_Reg_Class[] = "Error Registering Window Class"; const char Err_Create_Win[] = "Error Creating Window"; const char Err_DirectDrawCreate[] = "DirectDrawCreate FAILED"; const char Err_Coop[] = "SetCooperativeLevel FAILED"; const char Err_CreateSurf[] = "CreateSurface FAILED"; const char Err_GetBack[] = "Error Retrieving Back Buffer"; const char Err_LoadBMP[] = "Error Loading Image"; const char Err_DispMode[] = "Error Setting Display Mode"; const char Err_LoadImage[] = "Error Loading Image"; const char Err_DirectSoundCreate[] = "DirectSoundCreate FAILED"; const char Err_CreateBuff[] = "CreateBuffer FAILED"; const char Err_LoadWAV[] = "Error Loading Sound"; //------ Function to Load a Bitmap into a DirectDraw Surface ------// LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name,RECT *dims=NULL) { HDC hdc; HBITMAP bit; LPDIRECTDRAWSURFACE7 surf=NULL; // load the bitmap bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0, LR_DEFAULTSIZE|LR_LOADFROMFILE); if (!bit) // failed to load, return failure to caller return NULL; // get bitmap dimensions BITMAP bitmap; GetObject( bit, sizeof(BITMAP), &bitmap ); int surf_width=bitmap.bmWidth; int surf_height=bitmap.bmHeight; // create surface HRESULT ddrval; DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof(DDSURFACEDESC2); ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT ; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = surf_width; ddsd.dwHeight = surf_height; // attempt to create surface ddrval=lpDD->CreateSurface(&ddsd,&surf,NULL); // created ok? if (ddrval!=DD_OK) { // no, release the bitmap and return failure to caller DeleteObject(bit); return NULL; } else { // yes, get a DC for the surface surf->GetDC(&hdc); // generate a compatible DC HDC bit_dc=CreateCompatibleDC(hdc); // blit the interface to the surface SelectObject(bit_dc,bit); BitBlt(hdc,0,0,surf_width,surf_height,bit_dc,0,0,SRCCOPY); // release the DCs surf->ReleaseDC(hdc); DeleteDC(bit_dc); // save the dimensions if rectangle pointer provided if (dims) { dims->left=0; dims->top=0; dims->right=surf_width; dims->bottom=surf_height; } } // clear bitmap DeleteObject(bit); // return pointer to caller return surf; } //------ Cleanup Function to Release Objects ------// #define SafeRelease(x) if (x) { x->Release(); x=NULL;} void Cleanup() { // release loaded image surfaces for (int i=0;i); // release DirectDraw interfaces SafeRelease(lpDDSPrimary); SafeRelease(lpDD); // display error if one thrown if (ErrStr) { MessageBox(NULL, ErrStr, szCaption, MB_OK); ErrStr=NULL; } } //------ Function to Draw a Slide ------// void draw_slide() { // make sure we have the current image, don't draw if we fail if (!lpSlides[cur_image]) { lpSlides[cur_image]=bitmap_surface(file_names[cur_image]); if (!lpSlides[cur_image]) return; } // draw the object to the screen lpDDSBack->BltFast(0,0,lpSlides[cur_image],NULL,DDBLTFAST_WAIT); // draw instructions for slide show HDC hdc; if (DD_OK==lpDDSBack->GetDC(&hdc)) { TextOut(hdc,320,400,"Arab Space Ver 0,1",18); SetTextColor(hdc,0x0000ffff); lpDDSBack->ReleaseDC(hdc); } // flip to the primary surface lpDDSPrimary->Flip(0,DDFLIP_WAIT); // make sure we have the next and previous image // this insures that our next selection is quickly // available, while we only need to load one image // when the program starts. int next_slide=(cur_image>=IMAGE_COUNT-1) ? 0 : cur_image+1; if (!lpSlides[next_slide]) lpSlides[next_slide]=bitmap_surface(file_names[next_slide]); int prev_slide=(cur_image<1) ? IMAGE_COUNT-1 : cur_image-1; if (!lpSlides[prev_slide]) lpSlides[prev_slide]=bitmap_surface(file_names[prev_slide]); } //------ Windows Message Handler ------// LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: Cleanup(); PostQuitMessage(0); break; case WM_KEYDOWN: switch (wParam) { case VK_UP: // Process the LEFT ARROW key. cur_image--; if (cur_image<0) cur_image=IMAGE_COUNT-1; draw_slide(); break; case VK_DOWN: // Process the RIGHT ARROW key. cur_image++; if (cur_image>IMAGE_COUNT-1) cur_image=0; draw_slide(); break; case VK_ESCAPE: // exit the program on escape DestroyWindow(hWnd); break; // Process other non-character keystrokes. default: break; } default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0L; } //------ Function to Initialize DirectDraw and the Application ------// static BOOL Init(HINSTANCE hInstance, int nCmdShow) { WNDCLASS wc; HRESULT ddrval; // Set up and register window class wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szClass; if (!RegisterClass(&wc)) { ErrStr=Err_Reg_Class; return FALSE; } // Get dimensions of display int ScreenWidth = GetSystemMetrics(SM_CXSCREEN); int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Create a window and display HWND hWnd; hWnd = CreateWindow(szClass, // class szCaption, // caption WS_VISIBLE|WS_POPUP, // style 0, // left 0, // top ScreenWidth, // width ScreenHeight, // height NULL, // parent window NULL, // menu hInstance, // instance NULL); // parms if (!hWnd) { ErrStr=Err_Create_Win; return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // clear image pointers ZeroMemory(lpSlides,sizeof(lpSlides)); // Create the main DirectDraw object ddrval = DirectDrawCreateEx(NULL, (VOID **) &lpDD, IID_IDirectDraw7, NULL); if (ddrval != DD_OK) { ErrStr=Err_DirectDrawCreate; return FALSE; } // Set our cooperative level ddrval = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ); if (ddrval != DD_OK) { ErrStr=Err_Coop; return FALSE; } // Set the display mode ddrval = lpDD->SetDisplayMode( 640, 480, 16, 0, 0); if (ddrval !=DD_OK) { ErrStr=Err_DispMode; return FALSE; } // Create the primary surface with 1 back buffer DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ); if (ddrval!=DD_OK) { ErrStr=Err_CreateSurf; return FALSE; } // Fetch back buffer interface DDSCAPS2 ddscaps; ZeroMemory(&ddscaps,sizeof(ddscaps)); ddscaps.dwCaps=DDSCAPS_BACKBUFFER; ddrval=lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack); if (ddrval!=DD_OK) { ErrStr=Err_GetBack; return FALSE; } // load the first image and display it lpSlides[0]=bitmap_surface(file_names[0]); if (!lpSlides[0]) return FALSE; draw_slide(); // return success to caller return TRUE; } //------ Application Loop ------// int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // initialize the application, exit on failure if (!Init(hInstance, nCmdShow)) { Cleanup(); return FALSE; } // run till completed MSG msg; while (GetMessage(&msg,NULL,0,0)) { // dispatch the message TranslateMessage(&msg); DispatchMessage(&msg); } // exit returning final message return (msg.wParam); } and THANKS *--------------------------------------------------------------------------*/ // ARAB SPACE // // By Ahmed Saleh Mohammed Tolba // // CopyRight(c) 2001 // // // /*--------------------------------------------------------------------------*/ //------ Include Files ------// #include #include #include #include #include #include #include "Fastfile.h" #include "stdafx.h" #define INITGUID #include #include "wave.h" #include "Main.h" #include "Ffent.h" //------ Window Class Information ------// static char szClass[] = "Arab Space"; static char szCaption[] = "ARAB SPACE"; //------ Global Interface Pointers ------// LPDIRECTDRAW7 lpDD=NULL; LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL; LPDIRECTDRAWSURFACE7 lpDDSBack=NULL; //------ Define Number of Sounds ------// #define NUMSOUNDS 1 //------ DirectSound Object and Buffers ------// //------Define number of images and set up list of file names ------// #define IMAGE_COUNT 5 char file_names[IMAGE_COUNT][256] = { "Start.bmp", "load.bmp,FFDATFILE", "cerdit.bmp,FFDATFILE", "exit.bmp,FFDATFILE", }; //------ DirectDraw Surfaces for Image Storage ------// LPDIRECTDRAWSURFACE7 lpSlides[IMAGE_COUNT]; //------ current image displayed------// int cur_image=0; //------ Error Return String ------// const char *ErrStr=NULL; //------ Error Messages ------// const char Err_Reg_Class[] = "Error Registering Window Class"; const char Err_Create_Win[] = "Error Creating Window"; const char Err_DirectDrawCreate[] = "DirectDrawCreate FAILED"; const char Err_Coop[] = "SetCooperativeLevel FAILED"; const char Err_CreateSurf[] = "CreateSurface FAILED"; const char Err_GetBack[] = "Error Retrieving Back Buffer"; const char Err_LoadBMP[] = "Error Loading Image"; const char Err_DispMode[] = "Error Setting Display Mode"; const char Err_LoadImage[] = "Error Loading Image"; const char Err_DirectSoundCreate[] = "DirectSoundCreate FAILED"; const char Err_CreateBuff[] = "CreateBuffer FAILED"; const char Err_LoadWAV[] = "Error Loading Sound"; //------ Function to Load a Bitmap into a DirectDraw Surface ------// LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name,RECT *dims=NULL) { HDC hdc; HBITMAP bit; LPDIRECTDRAWSURFACE7 surf=NULL; // load the bitmap bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0, LR_DEFAULTSIZE|LR_LOADFROMFILE); if (!bit) // failed to load, return failure to caller return NULL; // get bitmap dimensions BITMAP bitmap; GetObject( bit, sizeof(BITMAP), &bitmap ); int surf_width=bitmap.bmWidth; int surf_height=bitmap.bmHeight; // create surface HRESULT ddrval; DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof(DDSURFACEDESC2); ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT ; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = surf_width; ddsd.dwHeight = surf_height; // attempt to create surface ddrval=lpDD->CreateSurface(&ddsd,&surf,NULL); // created ok? if (ddrval!=DD_OK) { // no, release the bitmap and return failure to caller DeleteObject(bit); return NULL; } else { // yes, get a DC for the surface surf->GetDC(&hdc); // generate a compatible DC HDC bit_dc=CreateCompatibleDC(hdc); // blit the interface to the surface SelectObject(bit_dc,bit); BitBlt(hdc,0,0,surf_width,surf_height,bit_dc,0,0,SRCCOPY); // release the DCs surf->ReleaseDC(hdc); DeleteDC(bit_dc); // save the dimensions if rectangle pointer provided if (dims) { dims->left=0; dims->top=0; dims->right=surf_width; dims->bottom=surf_height; } } // clear bitmap DeleteObject(bit); // return pointer to caller return surf; } //------ Cleanup Function to Release Objects ------// #define SafeRelease(x) if (x) { x->Release(); x=NULL;} void Cleanup() { // release loaded image surfaces for (int i=0;i); // release DirectDraw interfaces SafeRelease(lpDDSPrimary); SafeRelease(lpDD); // display error if one thrown if (ErrStr) { MessageBox(NULL, ErrStr, szCaption, MB_OK); ErrStr=NULL; } } //—— Function to Draw a Slide ——// void draw_slide() { // make sure we have the current image, don't draw if we fail if (!lpSlides[cur_image]) { lpSlides[cur_image]=bitmap_surface(file_names[cur_image]); if (!lpSlides[cur_image]) return; } // draw the object to the screen lpDDSBack->BltFast(0,0,lpSlides[cur_image],NULL,DDBLTFAST_WAIT); // draw instructions for slide show HDC hdc; if (DD_OK==lpDDSBack->GetDC(&hdc)) { TextOut(hdc,320,400,"Arab Space Ver 0,1",18); SetTextColor(hdc,0x0000ffff); lpDDSBack->ReleaseDC(hdc); } // flip to the primary surface lpDDSPrimary->Flip(0,DDFLIP_WAIT); // make sure we have the next and previous image // this insures that our next selection is quickly // available, while we only need to load one image // when the program starts. int next_slide=(cur_image>=IMAGE_COUNT-1) ? 0 : cur_image+1; if (!lpSlides[next_slide]) lpSlides[next_slide]=bitmap_surface(file_names[next_slide]); int prev_slide=(cur_image<1) ? IMAGE_COUNT-1 : cur_image-1; if (!lpSlides[prev_slide]) lpSlides[prev_slide]=bitmap_surface(file_names[prev_slide]); } //—— Windows Message Handler ——// LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: Cleanup(); PostQuitMessage(0); break; case WM_KEYDOWN: switch (wParam) { case VK_UP: // Process the LEFT ARROW key. cur_image–; if (cur_image<0) cur_image=IMAGE_COUNT-1; draw_slide(); break; case VK_DOWN: // Process the RIGHT ARROW key. cur_image++; if (cur_image>IMAGE_COUNT-1) cur_image=0; draw_slide(); break; case VK_ESCAPE: // exit the program on escape DestroyWindow(hWnd); break; // Process other non-character keystrokes. default: break; } default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0L; } //—— Function to Initialize DirectDraw and the Application ——// static BOOL Init(HINSTANCE hInstance, int nCmdShow) { WNDCLASS wc; HRESULT ddrval; // Set up and register window class wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szClass; if (!RegisterClass(&wc)) { ErrStr=Err_Reg_Class; return FALSE; } // Get dimensions of display int ScreenWidth = GetSystemMetrics(SM_CXSCREEN); int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Create a window and display HWND hWnd; hWnd = CreateWindow(szClass, // class szCaption, // caption WS_VISIBLE|WS_POPUP, // style 0, // left 0, // top ScreenWidth, // width ScreenHeight, // height NULL, // parent window NULL, // menu hInstance, // instance NULL); // parms if (!hWnd) { ErrStr=Err_Create_Win; return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // clear image pointers ZeroMemory(lpSlides,sizeof(lpSlides)); // Create the main DirectDraw object ddrval = DirectDrawCreateEx(NULL, (VOID **) &lpDD, IID_IDirectDraw7, NULL); if (ddrval != DD_OK) { ErrStr=Err_DirectDrawCreate; return FALSE; } // Set our cooperative level ddrval = lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ); if (ddrval != DD_OK) { ErrStr=Err_Coop; return FALSE; } // Set the display mode ddrval = lpDD->SetDisplayMode( 640, 480, 16, 0, 0); if (ddrval !=DD_OK) { ErrStr=Err_DispMode; return FALSE; } // Create the primary surface with 1 back buffer DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL ); if (ddrval!=DD_OK) { ErrStr=Err_CreateSurf; return FALSE; } // Fetch back buffer interface DDSCAPS2 ddscaps; ZeroMemory(&ddscaps,sizeof(ddscaps)); ddscaps.dwCaps=DDSCAPS_BACKBUFFER; ddrval=lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack); if (ddrval!=DD_OK) { ErrStr=Err_GetBack; return FALSE; } // load the first image and display it lpSlides[0]=bitmap_surface(file_names[0]); if (!lpSlides[0]) return FALSE; draw_slide(); // return success to caller return TRUE; } //—— Application Loop ——// int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // initialize the application, exit on failure if (!Init(hInstance, nCmdShow)) { Cleanup(); return FALSE; } // run till completed MSG msg; while (GetMessage(&msg,NULL,0,0)) { // dispatch the message TranslateMessage(&msg); DispatchMessage(&msg); } // exit returning final message return (msg.wParam); } [/source] and THANKS </i> <!–STARTSCRIPT–><center><table border=1 cellspacing=0 cellpadding=8 bgcolor="#FFFFFF" width="90%"><tr><td><font color=black face="Courier New"><pre> <font color="gray">/*————————————————————————–*/ // ARAB SPACE // // By Ahmed Saleh Mohammed Tolba // // CopyRight© 2001 // // // /*————————————————————————–*/ //—— Include Files ——// #include &lt;windows.h&gt; #include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdarg.h&gt; #include &lt;winbase.h&gt; #include "Fastfile.h" #include "stdafx.h" #define INITGUID #include &lt;ddraw.h&gt; #include "wave.h" #include "Main.h" #include "Ffent.h" //—— Window Class Information ——// static char szClass[] = "Arab Space"; static char szCaption[] = "ARAB SPACE"; //—— Global Interface Pointers ——// LPDIRECTDRAW7 lpDD=NULL; LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL; LPDIRECTDRAWSURFACE7 lpDDSBack=NULL; //—— Define Number of Sounds ——// #define NUMSOUNDS 1 //—— DirectSound Object and Buffers ——// //——Define number of images and set up list of file names ——// #define IMAGE_COUNT 5 char file_names[IMAGE_COUNT][256] = { "Start.bmp", "load.bmp,FFDATFILE", "cerdit.bmp,FFDATFILE", "exit.bmp,FFDATFILE", }; //—— DirectDraw Surfaces for Image Storage ——// LPDIRECTDRAWSURFACE7 lpSlides[IMAGE_COUNT]; //—— current image displayed——// int cur_image=0; //—— Error Return String ——// const char *ErrStr=NULL; //—— Error Messages ——// const char Err_Reg_Class[] = "Error Registering Window Class"; const char Err_Create_Win[] = "Error Creating Window"; const char Err_DirectDrawCreate[] = "DirectDrawCreate FAILED"; const char Err_Coop[] = "SetCooperativeLevel FAILED"; const char Err_CreateSurf[] = "CreateSurface FAILED"; const char Err_GetBack[] = "Error Retrieving Back Buffer"; const char Err_LoadBMP[] = "Error Loading Image"; const char Err_DispMode[] = "Error Setting Display Mode"; const char Err_LoadImage[] = "Error Loading Image"; const char Err_DirectSoundCreate[] = "DirectSoundCreate FAILED"; const char Err_CreateBuff[] = "CreateBuffer FAILED"; const char Err_LoadWAV[] = "Error Loading Sound"; //—— Function to Load a Bitmap into a DirectDraw Surface ——// LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name,RECT *dims=NULL) { HDC hdc; HBITMAP bit; LPDIRECTDRAWSURFACE7 surf=NULL; // load the bitmap bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0, LR_DEFAULTSIZE|LR_LOADFROMFILE); if (!bit) // failed to load, return failure to caller return NULL; // get bitmap dimensions BITMAP bitmap; GetObject( bit, sizeof(BITMAP), &bitmap ); int surf_width=bitmap.bmWidth; int surf_height=bitmap.bmHeight; // create surface HRESULT ddrval; DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof(DDSURFACEDESC2); ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT ; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = surf_width; ddsd.dwHeight = surf_height; // attempt to create surface ddrval=lpDD-&gt;CreateSurface(&ddsd,&surf,NULL); // created ok? if (ddrval!=DD_OK) { // no, release the bitmap and return failure to caller DeleteObject(bit); return NULL; } else { // yes, get a DC for the surface surf-&gt;GetDC(&hdc); // generate a compatible DC HDC bit_dc=CreateCompatibleDC(hdc); // blit the interface to the surface SelectObject(bit_dc,bit); BitBlt(hdc,0,0,surf_width,surf_height,bit_dc,0,0,SRCCOPY); // release the DCs surf-&gt;ReleaseDC(hdc); DeleteDC(bit_dc); // save the dimensions if rectangle pointer provided if (dims) { dims-&gt;left=0; dims-&gt;top=0; dims-&gt;right=surf_width; dims-&gt;bottom=surf_height; } } // clear bitmap DeleteObject(bit); // return pointer to caller return surf; } //—— Cleanup Function to Release Objects ——// #define SafeRelease(x) if (x) { x-&gt;Release(); x=NULL;} void Cleanup() { // release loaded image surfaces for (int i=0;i&lt;IMAGE_COUNT;i++) SafeRelease(lpSlides); // release DirectDraw interfaces SafeRelease(lpDDSPrimary); SafeRelease(lpDD); // display error if one thrown if (ErrStr) { MessageBox(NULL, ErrStr, szCaption, MB_OK); ErrStr=NULL; } } //—— Function to Draw a Slide ——// void draw_slide() { // make sure we have the current image, don't draw if we fail if (!lpSlides[cur_image]) { lpSlides[cur_image]=bitmap_surface(file_names[cur_image]); if (!lpSlides[cur_image]) return; } // draw the object to the screen lpDDSBack-&gt;BltFast(0,0,lpSlides[cur_image],NULL,DDBLTFAST_WAIT); // draw instructions for slide show HDC hdc; if (DD_OK==lpDDSBack-&gt;GetDC(&hdc)) { TextOut(hdc,320,400,"Arab Space Ver 0,1",18); SetTextColor(hdc,0x0000ffff); lpDDSBack-&gt;ReleaseDC(hdc); } // flip to the primary surface lpDDSPrimary-&gt;Flip(0,DDFLIP_WAIT); // make sure we have the next and previous image // this insures that our next selection is quickly // available, while we only need to load one image // when the program starts. int next_slide=(cur_image&gt;=IMAGE_COUNT-1) ? 0 : cur_image+1; if (!lpSlides[next_slide]) lpSlides[next_slide]=bitmap_surface(file_names[next_slide]); int prev_slide=(cur_image&lt;1) ? IMAGE_COUNT-1 : cur_image-1; if (!lpSlides[prev_slide]) lpSlides[prev_slide]=bitmap_surface(file_names[prev_slide]); } //—— Windows Message Handler ——// LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_DESTROY: Cleanup(); PostQuitMessage(0); break; case WM_KEYDOWN: switch (wParam) { case VK_UP: // Process the LEFT ARROW key. cur_image–; if (cur_image&lt;0) cur_image=IMAGE_COUNT-1; draw_slide(); break; case VK_DOWN: // Process the RIGHT ARROW key. cur_image++; if (cur_image&gt;IMAGE_COUNT-1) cur_image=0; draw_slide(); break; case VK_ESCAPE: // exit the program on escape DestroyWindow(hWnd); break; // Process other non-character keystrokes. default: break; } default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0L; } //—— Function to Initialize DirectDraw and the Application ——// static BOOL Init(HINSTANCE hInstance, int nCmdShow) { WNDCLASS wc; HRESULT ddrval; // Set up and register window class wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = sizeof(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szClass; if (!RegisterClass(&wc)) { ErrStr=Err_Reg_Class; return FALSE; } // Get dimensions of display int ScreenWidth = GetSystemMetrics(SM_CXSCREEN); int ScreenHeight = GetSystemMetrics(SM_CYSCREEN); // Create a window and display HWND hWnd; hWnd = CreateWindow(szClass, // class szCaption, // caption WS_VISIBLE|WS_POPUP, // style 0, // left 0, // top ScreenWidth, // width ScreenHeight, // height NULL, // parent window NULL, // menu hInstance, // instance NULL); // parms if (!hWnd) { ErrStr=Err_Create_Win; return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // clear image pointers ZeroMemory(lpSlides,sizeof(lpSlides)); // Create the main DirectDraw object ddrval = DirectDrawCreateEx(NULL, (VOID **) &lpDD, IID_IDirectDraw7, NULL); if (ddrval != DD_OK) { ErrStr=Err_DirectDrawCreate; return FALSE; } // Set our cooperative level ddrval = lpDD-&gt;SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ); if (ddrval != DD_OK) { ErrStr=Err_Coop; return FALSE; } // Set the display mode ddrval = lpDD-&gt;SetDisplayMode( 640, 480, 16, 0, 0); if (ddrval !=DD_OK) { ErrStr=Err_DispMode; return FALSE; } // Create the primary surface with 1 back buffer DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,sizeof(ddsd)); ddsd.dwSize = sizeof( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; ddrval = lpDD-&gt;CreateSurface( &ddsd, &lpDDSPrimary, NULL ); if (ddrval!=DD_OK) { ErrStr=Err_CreateSurf; return FALSE; } // Fetch back buffer interface DDSCAPS2 ddscaps; ZeroMemory(&ddscaps,sizeof(ddscaps)); ddscaps.dwCaps=DDSCAPS_BACKBUFFER; ddrval=lpDDSPrimary-&gt;GetAttachedSurface(&ddscaps,&lpDDSBack); if (ddrval!=DD_OK) { ErrStr=Err_GetBack; return FALSE; } // load the first image and display it lpSlides[0]=bitmap_surface(file_names[0]); if (!lpSlides[0]) return FALSE; draw_slide(); // return success to caller return TRUE; } //—— Application Loop ——// int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // initialize the application, exit on failure if (!Init(hInstance, nCmdShow)) { Cleanup(); return FALSE; } // run till completed MSG msg; while (GetMessage(&msg,NULL,0,0)) { // dispatch the message TranslateMessage(&msg); DispatchMessage(&msg); } // exit returning final message return (msg.wParam); }/*————————————————————————–*/ // ARAB SPACE // // By Ahmed Saleh Mohammed Tolba // // CopyRight© 2001 // // // /*————————————————————————–*/</font> <font color="gray"><font color="gray">//—— Include Files ——// </font></font> <font color="green">#include &lt;windows.h&gt; </font><font color="green">#include &lt;string.h&gt; </font><font color="green">#include &lt;stdio.h&gt; </font><font color="green">#include &lt;stdlib.h&gt; </font><font color="green">#include &lt;stdarg.h&gt; </font><font color="green">#include &lt;winbase.h&gt; </font><font color="green">#include <font color="darkred">"Fastfile.h"</font> </font><font color="green">#include <font color="darkred">"stdafx.h"</font> </font><font color="green">#define INITGUID </font><font color="green">#include &lt;ddraw.h&gt; </font><font color="green">#include <font color="darkred">"wave.h"</font> </font><font color="green">#include <font color="darkred">"Main.h"</font> </font><font color="green">#include <font color="darkred">"Ffent.h"</font> </font> <font color="gray">//—— Window Class Information ——// </font> <font color="blue">static</font> <font color="blue">char</font> szClass[] = <font color="darkred">"Arab Space"</font>; <font color="blue">static</font> <font color="blue">char</font> szCaption[] = <font color="darkred">"ARAB SPACE"</font>; <font color="gray"><font color="gray">//—— Global Interface Pointers ——// </font></font> LPDIRECTDRAW7 lpDD=NULL; LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL; LPDIRECTDRAWSURFACE7 lpDDSBack=NULL; <font color="gray"><font color="gray">//—— Define Number of Sounds ——// </font></font> <font color="green">#define NUMSOUNDS 1 </font> <font color="gray"><font color="gray">//—— DirectSound Object and Buffers ——// </font></font> <font color="gray"><font color="gray">//——Define number of images and set up list of file names ——// </font></font> <font color="green">#define IMAGE_COUNT 5 </font> <font color="blue">char</font> file_names[<font color="purple">IMAGE_COUNT</font>][<font color="purple">256</font>] = { <font color="darkred">"Start.bmp"</font>, <font color="darkred">"load.bmp,FFDATFILE"</font>, <font color="darkred">"cerdit.bmp,FFDATFILE"</font>, <font color="darkred">"exit.bmp,FFDATFILE"</font>, }; <font color="gray">//—— DirectDraw Surfaces for Image Storage ——// </font> LPDIRECTDRAWSURFACE7 lpSlides[<font color="purple">IMAGE_COUNT</font>]; <font color="gray"><font color="gray">//—— current image displayed——// </font></font> <font color="blue">int</font> cur_image=0; <font color="gray">//—— Error Return String ——// </font> const <font color="blue">char</font> *ErrStr=NULL; <font color="gray"><font color="gray">//—— Error Messages ——// </font></font> const <font color="blue">char</font> Err_Reg_Class[] = <font color="darkred">"Error Registering Window Class"</font>; const <font color="blue">char</font> Err_Create_Win[] = <font color="darkred">"Error Creating Window"</font>; const <font color="blue">char</font> Err_DirectDrawCreate[] = <font color="darkred">"DirectDrawCreate FAILED"</font>; const <font color="blue">char</font> Err_Coop[] = <font color="darkred">"SetCooperativeLevel FAILED"</font>; const <font color="blue">char</font> Err_CreateSurf[] = <font color="darkred">"CreateSurface FAILED"</font>; const <font color="blue">char</font> Err_GetBack[] = <font color="darkred">"Error Retrieving Back Buffer"</font>; const <font color="blue">char</font> Err_LoadBMP[] = <font color="darkred">"Error Loading Image"</font>; const <font color="blue">char</font> Err_DispMode[] = <font color="darkred">"Error Setting Display Mode"</font>; const <font color="blue">char</font> Err_LoadImage[] = <font color="darkred">"Error Loading Image"</font>; const <font color="blue">char</font> Err_DirectSoundCreate[] = <font color="darkred">"DirectSoundCreate FAILED"</font>; const <font color="blue">char</font> Err_CreateBuff[] = <font color="darkred">"CreateBuffer FAILED"</font>; const <font color="blue">char</font> Err_LoadWAV[] = <font color="darkred">"Error Loading Sound"</font>; <font color="gray"><font color="gray">//—— Function to Load a Bitmap into a DirectDraw Surface ——// </font></font> LPDIRECTDRAWSURFACE7 bitmap_surface(LPCTSTR file_name,RECT *dims=NULL) { HDC hdc; HBITMAP bit; LPDIRECTDRAWSURFACE7 surf=NULL; <font color="gray"><font color="gray">// load the bitmap </font></font> bit=(HBITMAP) LoadImage(NULL,file_name,IMAGE_BITMAP,0,0, LR_DEFAULTSIZE|LR_LOADFROMFILE); <font color="blue">if</font> (!bit) <font color="gray">// failed to load, return failure to caller </font> <font color="blue">return</font> NULL; <font color="gray"><font color="gray">// get bitmap dimensions </font></font> BITMAP bitmap; GetObject( bit, <font color="blue">sizeof</font>(BITMAP), &bitmap ); <font color="blue">int</font> surf_width=bitmap.bmWidth; <font color="blue">int</font> surf_height=bitmap.bmHeight; <font color="gray"><font color="gray">// create surface </font></font> HRESULT ddrval; DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,<font color="blue">sizeof</font>(ddsd)); ddsd.dwSize = <font color="blue">sizeof</font>(DDSURFACEDESC2); ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT ; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.dwWidth = surf_width; ddsd.dwHeight = surf_height; <font color="gray"><font color="gray">// attempt to create surface </font></font> ddrval=lpDD-&gt;CreateSurface(&ddsd,&surf,NULL); <font color="gray"><font color="gray">// created ok? </font></font> <font color="blue">if</font> (ddrval!=DD_OK) { <font color="gray">// no, release the bitmap and return failure to caller </font> DeleteObject(bit); <font color="blue">return</font> NULL; } <font color="blue">else</font> { <font color="gray">// yes, get a DC for the surface </font> surf-&gt;GetDC(&hdc); <font color="gray"><font color="gray">// generate a compatible DC </font></font> HDC bit_dc=CreateCompatibleDC(hdc); <font color="gray"><font color="gray">// blit the interface to the surface </font></font> SelectObject(bit_dc,bit); BitBlt(hdc,0,0,surf_width,surf_height,bit_dc,0,0,SRCCOPY); <font color="gray"><font color="gray">// release the DCs </font></font> surf-&gt;ReleaseDC(hdc); DeleteDC(bit_dc); <font color="gray">// save the dimensions if rectangle pointer provided </font> <font color="blue">if</font> (dims) { dims-&gt;left=0; dims-&gt;top=0; dims-&gt;right=surf_width; dims-&gt;bottom=surf_height; } } <font color="gray"><font color="gray">// clear bitmap </font></font> DeleteObject(bit); <font color="gray">// return pointer to caller </font> <font color="blue">return</font> surf; } <font color="gray"><font color="gray">//—— Cleanup Function to Release Objects ——// </font></font> <font color="green">#define SafeRelease(x) <font color="blue">if</font> (x) { x-&gt;Release(); x=NULL;} </font> <font color="blue">void</font> Cleanup() { <font color="gray"><font color="gray">// release loaded image surfaces </font></font> <font color="blue">for</font> (<font color="blue">int</font> i=0;i&lt;IMAGE_COUNT;i++) SafeRelease(lpSlides[<font color="purple">i</font>]); <font color="gray"><font color="gray">// release DirectDraw interfaces </font></font> SafeRelease(lpDDSPrimary); SafeRelease(lpDD); <font color="gray">// display error if one thrown </font> <font color="blue">if</font> (ErrStr) { MessageBox(NULL, ErrStr, szCaption, MB_OK); ErrStr=NULL; } } <font color="gray"><font color="gray">//—— Function to Draw a Slide ——// </font></font> <font color="blue">void</font> draw_slide() { <font color="gray">// make sure we have the current image, don't draw if we fail </font> <font color="blue">if</font> (!lpSlides[<font color="purple">cur_image</font>]) { lpSlides[<font color="purple">cur_image</font>]=bitmap_surface(file_names[<font color="purple">cur_image</font>]); <font color="blue">if</font> (!lpSlides[<font color="purple">cur_image</font>]) return; } <font color="gray"><font color="gray">// draw the object to the screen </font></font> lpDDSBack-&gt;BltFast(0,0,lpSlides[<font color="purple">cur_image</font>],NULL,DDBLTFAST_WAIT); <font color="gray">// draw instructions for slide show </font> HDC hdc; <font color="blue">if</font> (DD_OK==lpDDSBack-&gt;GetDC(&hdc)) { TextOut(hdc,320,400,<font color="darkred">"Arab Space Ver 0,1"</font>,18); SetTextColor(hdc,0x0000ffff); lpDDSBack-&gt;ReleaseDC(hdc); } <font color="gray"><font color="gray">// flip to the primary surface </font></font> lpDDSPrimary-&gt;Flip(0,DDFLIP_WAIT); <font color="gray"><font color="gray">// make sure we have the next and previous image </font></font> <font color="gray">// this insures that our next selection is quickly </font> <font color="gray">// available, while we only need to load one image </font> <font color="gray"><font color="gray">// when the program starts. </font></font> <font color="blue">int</font> next_slide=(cur_image&gt;=IMAGE_COUNT-1) ? 0 : cur_image+1; <font color="blue">if</font> (!lpSlides[<font color="purple">next_slide</font>]) lpSlides[<font color="purple">next_slide</font>]=bitmap_surface(file_names[<font color="purple">next_slide</font>]); <font color="blue">int</font> prev_slide=(cur_image&lt;1) ? IMAGE_COUNT-1 : cur_image-1; <font color="blue">if</font> (!lpSlides[<font color="purple">prev_slide</font>]) lpSlides[<font color="purple">prev_slide</font>]=bitmap_surface(file_names[<font color="purple">prev_slide</font>]); } <font color="gray"><font color="gray">//—— Windows Message Handler ——// </font></font> LRESULT CALLBACK WindowProc(HWND hWnd, <font color="blue">unsigned</font> uMsg, WPARAM wParam, LPARAM lParam) { <font color="blue">switch</font> (uMsg) { <font color="blue">case</font> WM_DESTROY: Cleanup(); PostQuitMessage(0); break; <font color="blue">case</font> WM_KEYDOWN: <font color="blue">switch</font> (wParam) { <font color="blue">case</font> VK_UP: <font color="gray"><font color="gray">// Process the LEFT ARROW key. </font></font> cur_image–; <font color="blue">if</font> (cur_image&lt;0) cur_image=IMAGE_COUNT-1; draw_slide(); break; <font color="blue">case</font> VK_DOWN: <font color="gray"><font color="gray">// Process the RIGHT ARROW key. </font></font> cur_image++; <font color="blue">if</font> (cur_image&gt;IMAGE_COUNT-1) cur_image=0; draw_slide(); break; <font color="blue">case</font> VK_ESCAPE: <font color="gray"><font color="gray">// exit the program on escape </font></font> DestroyWindow(hWnd); break; <font color="gray"><font color="gray">// Process other non-character keystrokes. </font></font> default: break; } default: <font color="blue">return</font> DefWindowProc(hWnd, uMsg, wParam, lParam); } <font color="blue">return</font> 0L; } <font color="gray"><font color="gray">//—— Function to Initialize DirectDraw and the Application ——// </font></font> <font color="blue">static</font> <font color="blue">BOOL</font> Init(HINSTANCE hInstance, <font color="blue">int</font> nCmdShow) { WND<font color="blue">CLASS</font> wc; HRESULT ddrval; <font color="gray">// Set up and register window class </font> wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = <font color="blue">sizeof</font>(DWORD); wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = szClass; <font color="blue">if</font> (!Register<font color="blue">Class</font>(&wc)) { ErrStr=Err_Reg_Class; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// Get dimensions of display </font></font> <font color="blue">int</font> ScreenWidth = GetSystemMetrics(SM_CXSCREEN); <font color="blue">int</font> ScreenHeight = GetSystemMetrics(SM_CYSCREEN); <font color="gray"><font color="gray">// Create a window and display </font></font> HWND hWnd; hWnd = CreateWindow(szClass, <font color="gray">// class </font> szCaption, <font color="gray"><font color="gray">// caption </font></font> WS_VISIBLE|WS_POPUP, <font color="gray"><font color="gray">// style </font></font> 0, <font color="gray"><font color="gray">// left </font></font> 0, <font color="gray"><font color="gray">// top </font></font> ScreenWidth, <font color="gray"><font color="gray">// width </font></font> ScreenHeight, <font color="gray"><font color="gray">// height </font></font> NULL, <font color="gray"><font color="gray">// parent window </font></font> NULL, <font color="gray"><font color="gray">// menu </font></font> hInstance, <font color="gray"><font color="gray">// instance </font></font> NULL); <font color="gray"><font color="gray">// parms </font></font> <font color="blue">if</font> (!hWnd) { ErrStr=Err_Create_Win; <font color="blue">return</font> FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); <font color="gray"><font color="gray">// clear image pointers </font></font> ZeroMemory(lpSlides,<font color="blue">sizeof</font>(lpSlides)); <font color="gray"><font color="gray">// Create the main DirectDraw object </font></font> ddrval = DirectDrawCreateEx(NULL, (<font color="blue">VOID</font> **) &lpDD, IID_IDirectDraw7, NULL); <font color="blue">if</font> (ddrval != DD_OK) { ErrStr=Err_DirectDrawCreate; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// Set our cooperative level </font></font> ddrval = lpDD-&gt;SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN ); <font color="blue">if</font> (ddrval != DD_OK) { ErrStr=Err_Coop; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// Set the display mode </font></font> ddrval = lpDD-&gt;SetDisplayMode( 640, 480, 16, 0, 0); <font color="blue">if</font> (ddrval !=DD_OK) { ErrStr=Err_DispMode; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// Create the primary surface with 1 back buffer </font></font> DDSURFACEDESC2 ddsd; ZeroMemory(&ddsd,<font color="blue">sizeof</font>(ddsd)); ddsd.dwSize = <font color="blue">sizeof</font>( ddsd ); ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; ddsd.dwBackBufferCount = 1; ddrval = lpDD-&gt;CreateSurface( &ddsd, &lpDDSPrimary, NULL ); <font color="blue">if</font> (ddrval!=DD_OK) { ErrStr=Err_CreateSurf; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// Fetch back buffer interface </font></font> DDSCAPS2 ddscaps; ZeroMemory(&ddscaps,<font color="blue">sizeof</font>(ddscaps)); ddscaps.dwCaps=DDSCAPS_BACKBUFFER; ddrval=lpDDSPrimary-&gt;GetAttachedSurface(&ddscaps,&lpDDSBack); <font color="blue">if</font> (ddrval!=DD_OK) { ErrStr=Err_GetBack; <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// load the first image and display it </font></font> lpSlides[<font color="purple">0</font>]=bitmap_surface(file_names[<font color="purple">0</font>]); <font color="blue">if</font> (!lpSlides[<font color="purple">0</font>]) <font color="blue">return</font> FALSE; draw_slide(); <font color="gray">// return success to caller </font> <font color="blue">return</font> TRUE; } <font color="gray"><font color="gray">//—— Application Loop ——// </font></font> <font color="blue">int</font> APIEN<font color="blue">TRY</font> WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, <font color="blue">int</font> nCmdShow) { <font color="gray"><font color="gray">// initialize the application, exit on failure </font></font> <font color="blue">if</font> (!Init(hInstance, nCmdShow)) { Cleanup(); <font color="blue">return</font> FALSE; } <font color="gray"><font color="gray">// run till completed </font></font> MSG msg; <font color="blue">while</font> (GetMessage(&msg,NULL,0,0)) { <font color="gray"><font color="gray">// dispatch the message </font></font> TranslateMessage(&msg); DispatchMessage(&msg); } <font color="gray"><font color="gray">// exit returning final message </font></font> <font color="blue">return</font> (msg.wParam); } </pre></font></td></tr></table></center><!–ENDSCRIPT–> /[/source] Edited by - ahmed saleh on June 23, 2001 7:12:50 PM Edited by - ahmed saleh on June 23, 2001 7:17:14 PM
Advertisement
Don''t post huge amounts of source code. No one is going to look through all that and find whatever problem you''re having. I have enough of my own source code to look through all the time without having to read pages and pages of other peoples. I notice you''re asking about menu, but the first two pages of your post are include files and a function to load a bitmap into a DDSURFACE. I didn''t read past that.

If you have to post code, at least work out where your problem is, narrow it down to a function or a few lines, and then post.

War Worlds - A 3D Real-Time Strategy game in development.
Well in your WindowProc function you will see some things like:

case WM_KEYDOWN:
switch (wParam)
{
case VK_UP:
cur_image--; if (cur_image<0) cur_image=IMAGE_COUNT-1; draw_slide();
break;

etc...

to handle the Enter key, add a case like:

case VK_ENTER:
//do something
break;

and replace //do something with whatever you want to happen when you hit the enter key... lol

I don''t know if this is what you were looking for. If not you might want to try again explaining what you need as it was a little rough the first time

Seeya
Krippy
hey
i will take to to u in the Yahoo Maseenger
k
bye bye
HI
download this
www.alsindibad.com/users/digiarab/menu.zip

this the menu not Include the Code the Code is up
see this menu
i need To select from the Menu
if i was in the Load game
i want if i press on it Enter go to the load game();
and if i was in the Start Game i want if i press
enter on it go to Start Game();
are understand me
I NEED TO SELECT FROM THIS MENU
if i want to start game and if i want to Exit the Game
i hope u understand me
and thanks for Help Me
Thanks
MY GOD MAN do you honestly expect people to go through PAGES AND PAGES AND PAGES of code? Please TRY and narrow down the code to the part you need help with!

This topic is closed to new replies.

Advertisement