Auto Scrolling list box

Posts 1–10 of 10 · Page 1 of 1
Auto Scrolling list box
hey friends I use code created by SEGnosis for scrolling list box on hack menu , but does not work for me

Draw.h

Code:
class C_Draw
{
	public:
		C_Draw();
		~C_Draw();
		
		void String		( long X,  long Y,  long Color, char *szString, ...     );
		void Rect		( long X,  long Y,  long W,		long H, D3DCOLOR Color  );
		void Line		( long Xa, long Ya, long Xb,	long Yb, D3DCOLOR Color );
		
		void Load_Resources( void );

		LPD3DXLINE	m_pLine;
		LPD3DXFONT	m_pLBFont;
		D3DCOLOR	m_coLB_Item,
					m_coLB_Back,
					m_coLB_Border,
					m_coLB_SelItem,
					m_coLB_SectionItem,
					m_coLB_Stripe,
					m_coRed,
					m_coBlue,
					m_coWhite,
					m_coBlack;
		
		LPDIRECT3DDEVICE9	m_pDevice;	
						
		long		m_iLB_FontSize;
		
}CDraw;
//----------------------------------//

//----------------------------------//
C_Draw::C_Draw()
{
	m_pDevice = 0;
	m_iLB_FontSize = 14;
}
//----------------------------------//
C_Draw::~C_Draw()
{
	
}
//----------------------------------//

//----------------------------------//
void C_Draw::Load_Resources( void )
{
	m_coLB_Item			= D3DCOLOR_ARGB( 255, 0, 0,	0 );
	m_coLB_SelItem		= D3DCOLOR_ARGB( 255, 0, 200, 0 );
	m_coLB_SectionItem	= D3DCOLOR_ARGB( 255, 0, 0, 255 );
	
	m_coLB_Back			= D3DCOLOR_ARGB( 255, 255, 255,	255 );
	m_coLB_Border		= D3DCOLOR_ARGB( 255, 0, 0,	0 );
	m_coLB_Stripe		= D3DCOLOR_XRGB( 248, 248, 248 );
	
	m_coRed				= D3DCOLOR_XRGB( 255, 0, 0 );
	m_coBlue			= D3DCOLOR_XRGB( 0, 0, 255 );
	m_coWhite			= D3DCOLOR_XRGB( 255, 255, 255 );
	m_coBlack			= D3DCOLOR_XRGB( 0, 0, 0 );

	D3DXCreateFont( m_pDevice, m_iLB_FontSize, 0, FW_MEDIUM, 1, 0 ,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_SCRIPT, "Consolas", &m_pLBFont );
	D3DXCreateLine( m_pDevice, &m_pLine );
}
//----------------------------------//

//----------------------------------//
void C_Draw::String ( long X, long Y, long Color, char *szString, ... )
{
	long	W = 100, H = 40;
	char	szBuffer[ 1024 ] = { 0 };
	RECT	rtFontPos = { X, Y, X + W, Y + H };
	
	va_list va_alist;
	va_start( va_alist, szString );
	vsprintf( szBuffer, szString, va_alist);
	va_end	( va_alist );

	m_pLBFont->DrawText( NULL, szBuffer, -1, &rtFontPos, DT_LEFT | DT_NOCLIP, Color );
}
//----------------------------------//
void C_Draw::Rect   ( long X, long Y, long W, long H, D3DCOLOR Color )
{
	D3DXVECTOR2 vLine[ 2 ];
		m_pLine->SetWidth( W );
		m_pLine->SetAntialias( 0 );
		m_pLine->SetGLLines( 1 );

	m_pLine->SetWidth( W );
	m_pLine->Begin();

		vLine[ 0 ][ 0 ] = X+W/2;
		vLine[ 0 ][ 1 ] = Y;
		vLine[ 1 ][ 0 ] = X+W/2;
		vLine[ 1 ][ 1 ] = Y+H;

	m_pLine->Draw( vLine, 2, Color );
	m_pLine->End();
}
//----------------------------------//
void C_Draw::Line   ( long Xa, long Ya, long Xb, long Yb, D3DCOLOR Color )
{	
	D3DXVECTOR2 vLine[ 2 ];
		m_pLine->SetAntialias( 0 );

	m_pLine->SetWidth( 1 );
	m_pLine->Begin();

		vLine[ 0 ][ 0 ] = Xa;
		vLine[ 0 ][ 1 ] = Ya;
		vLine[ 1 ][ 0 ] = Xb;
		vLine[ 1 ][ 1 ] = Yb;

	m_pLine->Draw( vLine, 2, Color );
	m_pLine->End();
}
Menu.h

Code:
#define ONE_FLOAT 1.000000f
#define ZERO_FLOAT 0.000000f

#define ITEM_TYPE_OPTION 0
#define ITEM_TYPE_SECTION 1

struct _Menu_Item
{
	long	iType;
	char	szItem[ MAX_PATH ];
		 
	float	fMin,
			fMax,
			fStatus,
			fOffset;
}*Menu_Item;

//----------------------------------//
class C_Menu
{
	public:
		C_Menu();
		~C_Menu();
		
		void Create			( void );
		
		char* Extend_String	( char* szString, long iLength );
		void  Append_Item	( long iType, char* szItem, float fMin, float fMax, float fOffset );
		float GetItemByName ( char* szName );
		
		void Display_Menu	( void );
		void List_Box		( void );
		
		void Commands		( void );
		
		void Keyboard_Input	( void );
		
		void SaveSettings	( void );
		void LoadSettings	( void );
		
		bool m_bVisible;
		
	private:
		long m_iMenuItemAmount,
			 m_iCurrentIndex,
			 m_iLB_Index,
			 m_iLB_Amount;
		
		RECT  m_rtClient,
			  m_rtLB_Client;
}CMenu;
//----------------------------------//

//----------------------------------//
C_Menu::C_Menu ()
{
	Menu_Item = new _Menu_Item[ 100 ];
	ZeroMemory( Menu_Item, sizeof( _Menu_Item ) * 100 );
	
	m_iMenuItemAmount	= 0;
	m_iCurrentIndex		= 1;
	m_iLB_Index			= 0;
	m_iLB_Amount		= 6;
	
	m_bVisible = true;
	
	SetRect( &m_rtClient, 0, 0, 0, 0 );
}
//----------------------------------//
C_Menu::~C_Menu()
{
	delete Menu_Item;
}
//----------------------------------//

//----------------------------------//
void C_Menu::Create			( void )
{
	CMenu.Append_Item( ITEM_TYPE_SECTION,	"[Catagory 1]", 0, 0, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option1", 0, 100, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option2", 0, 1, 0.1f );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option3", 0, 10, 2 );
	CMenu.Append_Item( ITEM_TYPE_SECTION,	"[Catagory 2]", 0, 0, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option4", 0, 1, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option5", 0, 1, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option6", 0, 1, 1 );
	CMenu.Append_Item( ITEM_TYPE_OPTION,	"Option7", 0, 1, 1 );

	for( int i = 0; i < m_iMenuItemAmount; i++ )
	{
		if( strcmp( Menu_Item[ i ].szItem, "  Distance" ) == 0 ) // For setting defaults
			Menu_Item[ i ].fStatus = 100;
	}
	
	LoadSettings();
}
//----------------------------------//

//----------------------------------//
void C_Menu::SaveSettings	( void )
{
	fstream pFile( "Settings.gha", ios::out );
	
	pFile.write( ( const char* )Menu_Item, sizeof( _Menu_Item ) * ( m_iMenuItemAmount - 1 ) );
	
	pFile.close();
}
//----------------------------------//
void C_Menu::LoadSettings	( void )
{
	fstream pFile( "Settings.gha", ios::in );
	
	pFile.read( ( char* )Menu_Item, sizeof( _Menu_Item ) * ( m_iMenuItemAmount - 1 ) );
	
	pFile.close();
}
//----------------------------------//

//----------------------------------//
char* C_Menu::Extend_String	( char* szString, long iLength )
{
	static char szBuffer[ 2048 ];
	
	long iCurrentLength = strlen( szString );
	
	strcpy( szBuffer, szString );
	
	for( int i = iCurrentLength; i < iLength; i++ )
		strcat( szBuffer, " " );
	
	return szBuffer;
}
//----------------------------------//
void  C_Menu::Append_Item	( long iType, char* szItem, float fMin, float fMax, float fOffset )
{
	strcpy_s( Menu_Item[ m_iMenuItemAmount ].szItem, MAX_PATH, szItem );
	
	Menu_Item[ m_iMenuItemAmount ].fMin		= fMin;
	Menu_Item[ m_iMenuItemAmount ].fMax		= fMax;
	Menu_Item[ m_iMenuItemAmount ].iType	= iType;
	Menu_Item[ m_iMenuItemAmount ].fOffset	= fOffset;
	Menu_Item[ m_iMenuItemAmount ].fStatus	= 0;
	
	m_iMenuItemAmount++;
}
//----------------------------------//
float C_Menu::GetItemByName ( char* szName )
{
	for( int i = 0; i < m_iMenuItemAmount; i++ )
		if( strcmp( szName, Menu_Item[ i ].szItem ) == 0 )
			return Menu_Item[ i ].fStatus;
	
	return -1;
}
//----------------------------------//

//----------------------------------//
void C_Menu::Keyboard_Input	( void )
{
	if( GetAsyncKeyState( VK_LEFT )&1  && Menu_Item[ m_iCurrentIndex ].fStatus - Menu_Item[ m_iCurrentIndex ].fOffset >= Menu_Item[ m_iCurrentIndex ].fMin ) 
	{
		Menu_Item[ m_iCurrentIndex ].fStatus -= Menu_Item[ m_iCurrentIndex ].fOffset;
		SaveSettings();
	}
	if( GetAsyncKeyState( VK_RIGHT )&1 && Menu_Item[ m_iCurrentIndex ].fStatus + Menu_Item[ m_iCurrentIndex ].fOffset <= Menu_Item[ m_iCurrentIndex ].fMax )
	{
		Menu_Item[ m_iCurrentIndex ].fStatus += Menu_Item[ m_iCurrentIndex ].fOffset;
		SaveSettings();
	}
	
	if( GetAsyncKeyState( VK_UP )&1  )
		for( int i = m_iCurrentIndex - 1; i > 0; i-- )
			if( Menu_Item[ i ].iType == ITEM_TYPE_OPTION )
			{
				m_iCurrentIndex = i;
				break;
			}
	
	if( GetAsyncKeyState( VK_DOWN )&1 )
		for( int i = m_iCurrentIndex + 1; i < m_iMenuItemAmount; i++ )
			if( Menu_Item[ i ].iType == ITEM_TYPE_OPTION  )
			{
				m_iCurrentIndex = i;
				break;
			}
	
	m_iLB_Index = m_iCurrentIndex - m_iLB_Amount/2;
	
	if( m_iLB_Index < 0 )
		m_iLB_Index = 0;
	
	if( m_iLB_Index > m_iMenuItemAmount - m_iLB_Amount )
		m_iLB_Index = m_iMenuItemAmount - m_iLB_Amount;
}
//----------------------------------//

//----------------------------------//
void C_Menu::List_Box		( void )
{
	SetRect( &m_rtLB_Client, m_rtClient.left, m_rtClient.top, 210, CDraw.m_iLB_FontSize * m_iLB_Amount );
	
	CDraw.Rect( m_rtLB_Client.left - 1, m_rtLB_Client.top - 1, m_rtLB_Client.right + 2, m_rtLB_Client.bottom + 2, CDraw.m_coLB_Border );
	CDraw.Rect( m_rtLB_Client.left, m_rtLB_Client.top, m_rtLB_Client.right, m_rtLB_Client.bottom, CDraw.m_coLB_Back );
		
	for( int i = m_rtLB_Client.top; i < m_iLB_Amount * CDraw.m_iLB_FontSize + m_rtLB_Client.top; i += CDraw.m_iLB_FontSize * 2 )
		CDraw.Rect( m_rtLB_Client.left, i, 210, CDraw.m_iLB_FontSize, CDraw.m_coLB_Stripe );

	for( int i = m_iLB_Index, k = 0; i < m_iLB_Amount + m_iLB_Index; i++, k++ )
	{
		if( Menu_Item[ i ].iType == ITEM_TYPE_SECTION )
			CDraw.String( m_rtLB_Client.left + 1, m_rtLB_Client.top + ( k * CDraw.m_iLB_FontSize ) + 1, CDraw.m_coLB_SectionItem, "%s", Menu_Item[ i ].szItem );
		else
			CDraw.String( m_rtLB_Client.left + 20, m_rtLB_Client.top + ( k * CDraw.m_iLB_FontSize ) + 1, ( i == m_iCurrentIndex ? CDraw.m_coLB_SelItem : CDraw.m_coLB_Item ), "%s : %.1f", Extend_String( Menu_Item[ i ].szItem, 20 ), Menu_Item[ i ].fStatus );
	}		
}
//----------------------------------//
void C_Menu::Display_Menu	( void )
{
	Keyboard_Input();
	List_Box();
}
//----------------------------------//


//----------------------------------//
void C_Menu::Commands		( void )
{	
	if( GetAsyncKeyState( VK_HOME )&1 )
		m_bVisible = !m_bVisible;
	
	if( GetItemByName( "Option1" ) )
	{
		
	}
	
	if( GetItemByName( "Option2" ) )
	{
		
	}
	
	if( GetItemByName( "Option3" ) )
	{
		
	}
}
and use in Present

Code:
if( !CDraw.m_pDevice )
{
    CDraw.m_pDevice = pDevice;
    CDraw.Load_Resources();
    CMenu.Create();
}
works for a few seconds, but to work and never come back

please help me and sorry my bad english
code credits SEGnosis
What game is it ?
in example works on Hallo , but for me Combat Arms


Quote Originally Posted by luccss View Post
in example works on Hallo , but for me Combat Arms


you can change the function of the CA
I change , but menu not work
Quote Originally Posted by luccss View Post
I change , but menu not work
Does it start up ? Or does it just immediately crash.
oh don't crash game , only not appear the menu
I dont see this in your menu ( example for D3D menu ):
Code:
void DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
    FillRGB( x, y, w, h,        BoxColor, pDevice );
    DrawBorder( x, y, w, h, 1,    BorderColor, pDevice );
}
Menu(char * menuname, int x, int y, int h, int w, DWORD TITLECOL, DWORD BACKCOLOR, DWORD BORDERCOLOR, LPDIRECT3DDEVICE9 pDevice)
{
if(GetAsyncKeyState(VK_INSERT)&1)show=(!show); //Bring up the Menu HACK (INSERT)
if(!show) {
DrawBox(0,0, w, 20, BACKCOLOR, BORDERCOLOR, pDevice);
PrintText("Qmoainx D3D MENU", 5, 2, TITLECOL, pFont);
return;
}

// DrawBox(x,y, w, h, BACKCOLOR, BORDERCOLOR, pDevice); // Adjust the Base Menu Hack
PrintText(menuname, x+10, y+2, TITLECOL, pFont);
CreateItem(1,"Wallhack", &hack1);
CreateItem(2,"Chams", &hack2);
CreateItem(3,"Crosshair", &hack3);
CreateItem(4,"NO Smoke", &hack4);
CreateItem(5,"?????", &hack5);
RenderMenu();
}
Code:
#include <Windows.h>
#include <stdio.h>
#include <d3d9.h>
#include <d3dx9.h>

#pragma comment(lib,"d3dx9.lib")


Quote Originally Posted by luccss View Post

and use in Present

Code:
if( !CDraw.m_pDevice )
{
    CDraw.m_pDevice = pDevice;
    CDraw.Load_Resources();
    CMenu.Create();
}
works for a few seconds, but to work and never come back

please help me and sorry my bad english
code credits SEGnosis
Code:
void C_Menu::Display_Menu	( void )
Not found
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us