word help

Started by
6 comments, last by y2jsave 16 years ago
when we open microsoft word , first a box appears on the screen written on it microsoft word 2007 etc etc i wish my program too when executed first displays a box on which my name is written and then rest of it is being executed .............. iam making my application in dev c++ (iam using windows programming + opengl graphics) how to do that ? [Edited by - y2jsave on April 23, 2008 10:58:57 AM]
Advertisement
The term for the kind of window is a "splash screen". You can do a search for that term to get any number of code samples.
So you want a box with some info in it. The simple way to put your name or other info at the start of a program if you want to do it for windows which is what you mentioned would be something like...

MessageBox(NULL, "Name or information", "Box title", MB_OK);

Note this also waits for the user to press ok. This means that your program after this line of code won't execute until after this statement is completed.
"I would rather be in the boat with a drink on the rocks, than in the drink with a boat on the rocks" -Unknown
A side note:

As I remember it a windows application is unable to do any rendering in the WM_CREATE event. However, the WM_PAINT event is always called right after WM_CREATE so we can take advantage of that and render the splash screen from there.
Unless you find a better way to do it you can try something like this:

1. Create the main window and hide it immediately.

2. Show the splash screen in the WM_PAINT event
case WM_PAINT:  static bool firstTimeHere = true;  if(firstTimeHere)  {    // render splash screen    // sleep a few seconds    // show main window    firstTimeHere = false;  }  ...  break;
Quote:Original post by SiCrane
The term for the kind of window is a "splash screen". You can do a search for that term to get any number of code samples.


i searched the net , also found something on codeguru site , but cant suceed in adding a splash screen to my application

splash.cpp

#include <windows.h>#include <gl/gl.h>#include "splash.h"SPLASH mysplash;// Function DeclarationsLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);VOID EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC);VOID DisableOpenGL(HWND hWnd, HDC hDC, HGLRC hRC);// WinMainHINSTANCE hInst;//#define IDB_BIMAP1 "tp.bmp"int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                   LPSTR lpCmdLine, int iCmdShow){  WNDCLASS wc;  HWND hWnd;  HDC hDC;  HGLRC hRC;      MSG msg;  BOOL bQuit = FALSE;  float theta = 0.0f;  // register window class  wc.style = CS_OWNDC;  wc.lpfnWndProc = WndProc;  wc.cbClsExtra = 0;  wc.cbWndExtra = 0;  wc.hInstance = hInstance;  wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );  wc.hCursor = LoadCursor( NULL, IDC_ARROW );  wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );  wc.lpszMenuName = NULL;  wc.lpszClassName = "GLSample";  RegisterClass( &wc );  // create main window  hWnd = CreateWindow(   "GLSample", "OpenGL Sample",   WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE,  0, 0, 256, 256,  NULL, NULL, hInstance, NULL);  // enable OpenGL for the window  EnableOpenGL( hWnd, &hDC, &hRC ); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);          glClear(GL_COLOR_BUFFER_BIT);    glBegin(GL_TRIANGLES);          glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );          glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );          glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );          glEnd();          SwapBuffers( hDC );  // program main loop  while (!bQuit)     {      // check for messages      if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))         {          // handle or dispatch messages          if (msg.message == WM_QUIT)             {              bQuit = TRUE;            }           else             {              TranslateMessage(&msg);              DispatchMessage(&msg);            }         }       else         {          // OpenGL animation code goes here          SwapBuffers( hDC );        }  }  // shutdown OpenGL  DisableOpenGL( hWnd, hDC, hRC );  // destroy the window explicitly  DestroyWindow( hWnd );  return msg.wParam;}// Window ProcedureLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){  switch (message)     {      case WM_CREATE:            // mysplash.Init(hWnd,hInst,IDB_BIMAP1);             mysplash.Init(hWnd,hInst,1);                   mysplash.Show();      //simulate lengthy window initialization             Sleep(4000);             //hide the splash screen as the main window appears             mysplash.Hide();              return 0;      case WM_CLOSE:        PostQuitMessage( 0 );        return 0;      case WM_DESTROY:        return 0;      case WM_KEYDOWN:        switch (wParam)         {          case VK_ESCAPE:            PostQuitMessage( 0 );            return 0;        }        return 0;        default:          return DefWindowProc(hWnd, message, wParam, lParam);  }}// Enable OpenGLVOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC ){  PIXELFORMATDESCRIPTOR pfd;  int iFormat;  // get the device context (DC)  *hDC = GetDC( hWnd );  // set the pixel format for the DC  ZeroMemory( &pfd, sizeof( pfd ) );  pfd.nSize = sizeof( pfd );  pfd.nVersion = 1;  pfd.dwFlags = PFD_DRAW_TO_WINDOW |   PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;  pfd.iPixelType = PFD_TYPE_RGBA;  pfd.cColorBits = 24;  pfd.cDepthBits = 16;  pfd.iLayerType = PFD_MAIN_PLANE;  iFormat = ChoosePixelFormat( *hDC, &pfd );  SetPixelFormat( *hDC, iFormat, &pfd );  // create and enable the render context (RC)  *hRC = wglCreateContext( *hDC );  wglMakeCurrent( *hDC, *hRC );}// Disable OpenGLVOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC ){  wglMakeCurrent( NULL, NULL );  wglDeleteContext( hRC );  ReleaseDC( hWnd, hDC );} 


splash.h

// SPLASH.h: interface for the SPLASH class.////////////////////////////////////////////////////////////////////////#if !defined(AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_)#define AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_#if _MSC_VER > 1000#pragma once#endif // _MSC_VER > 1000class SPLASH  {public:	void Hide();	void Show();	void Init(HWND hWnd,HINSTANCE hInst,int resid);    BOOL SHOWING;	SPLASH();	virtual ~SPLASH();private:	UINT TimerID;	HWND hParentWindow;	HWND hSplashWnd;    };#endif // !defined(AFX_SPLASH_H__41182F11_BB6F_11D6_B0F5_00B0D01AD687__INCLUDED_)



rs.rc
#define IDB_BIMAP1 "tp.bmp"





i cant find the error
actually number of linker errors are coming
[Linker error] undefined reference to `SPLASH::Init(HWND__*, HINSTANCE__*, int)'


[Linker error] undefined reference to `SPLASH::Show()'
[Linker error] undefined reference to `SPLASH::Hide()'
[Linker error] undefined reference to `SPLASH::SPLASH()'
[Linker error] undefined reference to `SPLASH::~SPLASH()'
ld returned 1 exit status
Makefile.win [Build Error] [OpenGL.exe] Error 1




please someone help me
thanks


Quote:Original post by y2jsave
[Linker error] undefined reference to `SPLASH::Init(HWND__*, HINSTANCE__*, int)'


[Linker error] undefined reference to `SPLASH::Show()'
[Linker error] undefined reference to `SPLASH::Hide()'
[Linker error] undefined reference to `SPLASH::SPLASH()'
[Linker error] undefined reference to `SPLASH::~SPLASH()'
ld returned 1 exit status
Makefile.win [Build Error] [OpenGL.exe] Error 1


You need to write the code for those functions.
To expand on Zahlman:

You've defined the functions within the class: SPLASH in the header file, but you've not written any code for it in either the header or the C files...
can someone provide a example for this (with dev c++ )
please ,someone help

This topic is closed to new replies.

Advertisement