reman3/Rayman_X/cpa/tempgrp/GliGlou/MultiDRV/Src/GLI_Util.c

143 lines
5.0 KiB
C

/*
=======================================================================================
Name : GLI_UTIL.c
Author : vincent lhullier Date :03/09/98
Description : Utility for GLI (not used in retail version)
=======================================================================================
*/
#ifndef RETAIL
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <windows.h>
#include "TMP.h"
#include "GLD.h"
#include "GEO.h"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Extern (globals and function prototypes)
=======================================================================================
*/
HINSTANCE fn_hGetApplicationInstance(void);
/*
=======================================================================================
Globals
=======================================================================================
*/
/*
* for dialog
*/
static DLGTEMPLATE gs_a_stDialogTemplate[20];
/*
=======================================================================================
Functions for dialog
=======================================================================================
*/
/*
----------------------------------------------------------------------------------------
Description : copy char string into multibyte string
----------------------------------------------------------------------------------------
*/
static void CopyToWideChar( WCHAR** pstrOut, LPTSTR strIn )
{
long lLength = lstrlen( strIn );
WCHAR* strOut = *pstrOut;
lLength = MultiByteToWideChar( CP_ACP, 0, strIn, lLength, strOut, lLength );
strOut[lLength++] = L'\0'; /* Add the null terminator*/
*pstrOut += lLength;
}
/*
----------------------------------------------------------------------------------------
Description : add a dialog item in a Dialogtemplate
----------------------------------------------------------------------------------------
*/
static void AddDialogControl( WORD** pp, DWORD dwStyle, SHORT x, SHORT y, SHORT cx, SHORT cy, WORD id, LPTSTR strClassName, LPTSTR strTitle )
{
/* DWORD align the current ptr*/
DLGITEMTEMPLATE* p = (DLGITEMTEMPLATE*)(((((ULONG)(*pp))+3)>>2)<<2);
p->style = dwStyle | WS_CHILD | WS_VISIBLE;
p->dwExtendedStyle = 0L;
p->x = x;
p->y = y;
p->cx = cx;
p->cy = cy;
p->id = id;
*pp = (WORD*)(++p); /* Advance ptr*/
CopyToWideChar( (WCHAR**)pp, strClassName ); /* Set Class name*/
CopyToWideChar( (WCHAR**)pp, strTitle ); /* Set Title*/
(*pp)++; /* Skip Extra Stuff*/
}
/*
----------------------------------------------------------------------------------------
Description : build simple dialog box with one list
----------------------------------------------------------------------------------------
*/
DLGTEMPLATE *fn_p_stPrepareDialogBox_LB( char *szTitle )
{
DLGTEMPLATE *pdt;
WORD *pw;
/* Allocate ample memory for building the template*/
memset( gs_a_stDialogTemplate, 0, 20*sizeof(DLGTEMPLATE) );
/* Fill in the DLGTEMPLATE info*/
pdt = gs_a_stDialogTemplate;
pdt->style = DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU ;
pdt->dwExtendedStyle = 0L;
pdt->cdit = 2;
pdt->x = 0;
pdt->y = 0;
pdt->cx = 310;
pdt->cy = 110;
/* Add menu array, class array, dlg title, font size and font name*/
pw = (WORD*)(++pdt);
*pw++ = 0; /* Set Menu array to nothing*/
*pw++ = 0; /* Set Class array to nothing*/
CopyToWideChar( (WCHAR**)&pw, szTitle ); /* Dlg title*/
/*
*pw++ = 8; // Font Size
CopyToWideChar( (WCHAR**)&pw, "Arial" ); // Font Name
*/
AddDialogControl( &pw, BS_PUSHBUTTON | WS_TABSTOP, 130, 90, 50, 15, IDOK, "BUTTON", "OK" );
AddDialogControl( &pw, (LBS_STANDARD - LBS_SORT) | WS_VSCROLL | WS_TABSTOP, 5, 5, 300, 80, 1000, "LISTBOX", "");
return gs_a_stDialogTemplate;
}
/*
=======================================================================================
Function to manage a dialog box with a single list box
=======================================================================================
*/
long GLI_fn_lDoDialogBox_LB( char *_szTitle, DLGPROC _DlgProc, LPARAM _lParam )
{
DLGTEMPLATE *p_stDlgTemplate;
p_stDlgTemplate = fn_p_stPrepareDialogBox_LB( _szTitle );
return DialogBoxIndirectParam( fn_hGetApplicationInstance(), p_stDlgTemplate, NULL, (DLGPROC)_DlgProc, _lParam );
}
#endif