|
42
|
Programación / Programación C/C++ / cls_Byte ( Funciones Binarias ) ByteReplace, ByteSplit, ByteMid, ByteExits...
|
en: 27 Abril 2011, 00:32 am
|
. Tal vez a alguien le sirva esta clase que me hice para manipular un conjunto de bytes similar como vb6 las cadenas y evitarme el ajetreo de detectar los desgraciados memory leak que a mas de uno nos frustan el desarrollo/ejecucion de un programa, aun que por hay deben haber algunos agujeros... pero aun así ya funciona y eso es lo que me interesaba realmente. para mi trabajo de universidad. Disculpen po no usar new() ni delete() para cargar las clases. cls_byte.h #ifndef _CLS_BYTE_H_ #define _CLS_BYTE_H_ #include <fstream> #include <stdlib.h> #include <string.h> #include "Bytes/modutiles.h" // #include <stdbool.h> <-- C ANSI... (C99)CLS_BYTE_CPP class cls_byte; #ifndef Struct_clsByte_ #define Struct_clsByte_ struct Struct_clsByte { cls_byte *pbyt_class; size_t szt_count; }; #endif // Struct_clsByte_ class cls_byte { private: size_t szt_len; Byte *pbyt_data; public: cls_byte(); ~cls_byte(); size_t Getlen ( ); Byte *GetBytesPtr ( ); struct Struct_Byte *GetBytes ( ); Byte *SetBytes ( Byte *pByt_Bytes , size_t szt_lnBytes ); // ok Byte *SetBytes ( cls_byte *pclsbyteFind ); Byte *SetBytes ( Struct_Byte *pclsbyteFind ); // ok bool SetBytesFromFile( const char *pcchr ); bool SetBytesFromFile( const char *pcchr , size_t szt_ini ); bool SetBytesFromFile( const char *pcchr , size_t szt_ini , long lng_len ); cls_byte *Mid ( size_t szt_start , size_t szt_len ); cls_byte *Mid ( size_t szt_start ); Struct_clsByte *Split ( Byte *pbyt_delimiter , size_t szt_lndelimiter , long lng_limit ); Struct_clsByte *Split ( Byte *pbyt_delimiter , size_t szt_lndelimiter ); Struct_clsByte *Split ( cls_byte *pclsbytelim , long lng_limit ); Struct_clsByte *Split ( cls_byte *pclsbytelim ); cls_byte *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement ); cls_byte *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start ); cls_byte *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count ); cls_byte *Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ); cls_byte *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement ); cls_byte *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start ); cls_byte *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count ); cls_byte *Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacemente , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count ); cls_byte *Replace ( Byte *pByt_Find , size_t szt_lnFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ); size_t Index ( cls_byte *pclsbyte ); size_t Index ( cls_byte *pclsbyte , size_t szt_Start ); size_t Index ( cls_byte *pclsbyte , size_t szt_Start , e_CompareMethod enum_Compare ); size_t Index ( Byte *pByt_Find , size_t szt_lsf ); size_t Index ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start ); size_t Index ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , e_CompareMethod enum_Compare ); bool Exits ( cls_byte *pclsbyte ); bool Exits ( cls_byte *pclsbyte , size_t szt_Start ); bool Exits ( cls_byte *pclsbyte , size_t szt_Start , long lng_interval ); bool Exits ( cls_byte *pclsbyte , size_t szt_Start , long lng_interval , e_CompareMethod enum_Compare ); bool Exits ( Byte *pByt_Find , size_t szt_lsf ); bool Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start ); bool Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , long lng_interval ); bool Exits ( Byte *pByt_Find , size_t szt_lsf , size_t szt_Start , long lng_interval , e_CompareMethod enum_Compare ); }; // #include "cls_byte.cpp" #endif // CLS_BYTE_H
cls_byte.cpp #ifndef _CLS_BYTE_CPP #define _CLS_BYTE_CPP 1 #include "cls_byte.h" cls_byte::cls_byte() { this->szt_len = 0; this->pbyt_data = NULL; } cls_byte::~cls_byte() { setnewptrf<Byte*>( this->pbyt_data , NULL ); } size_t cls_byte::Getlen() { return this->szt_len; } Byte *cls_byte::GetBytesPtr() { return this->pbyt_data; } bool cls_byte::SetBytesFromFile(const char *pcchr) { return this->SetBytesFromFile( pcchr , 0 , -1 ); } bool cls_byte::SetBytesFromFile(const char *pcchr, size_t szt_ini) { return this->SetBytesFromFile( pcchr , szt_ini , -1 ); } bool cls_byte::SetBytesFromFile(const char *pcchr, size_t szt_ini, long lng_len) { FILE *hfile = fopen( pcchr , "r+b" ); Struct_Byte stbyt_data = { NULL , 0 }; size_t szt_end = 0; if ( hfile != NULL ) { stbyt_data.szt_lenbytes = flen( hfile ); if ( lng_len <= -1 ) lng_len = stbyt_data.szt_lenbytes; szt_end = 0; if ( fix_numbers_range<size_t>( &szt_ini , &szt_end , &lng_len , NULL , 0 , stbyt_data.szt_lenbytes-1 ) == true ) { stbyt_data.pbyt_bytes = (Byte*)malloc(sizeof(Byte)*lng_len); fseek ( hfile , (long)szt_ini , SEEK_SET); fread ( (char*)stbyt_data.pbyt_bytes , 1 , lng_len , hfile ); } stbyt_data.szt_lenbytes = (size_t)lng_len; fclose ( hfile ); this->SetBytes( &stbyt_data ); } } Byte *cls_byte::SetBytes(Struct_Byte *pclsbyteFind) { return this->SetBytes( pclsbyteFind->pbyt_bytes , pclsbyteFind->szt_lenbytes ); } Byte *cls_byte::SetBytes(cls_byte *pclsbyteFind) { return this->SetBytes( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() ); } Byte *cls_byte::SetBytes(Byte *pByt_Bytes, size_t szt_lnBytes) { this->szt_len = szt_lnBytes; if ( setnewptrf<Byte*>( this->pbyt_data , ByteClone( pByt_Bytes , this->szt_len ) ) == NULL) { this->szt_len = 0; return pByt_Bytes; } return NULL; } Struct_Byte *cls_byte::GetBytes() { struct Struct_Byte *pstrbyt_ret = (Struct_Byte*)malloc(sizeof(Struct_Byte)); pstrbyt_ret->pbyt_bytes = ByteClone( this->pbyt_data , this->szt_len ); pstrbyt_ret->szt_lenbytes = this->szt_len; if ( pstrbyt_ret->pbyt_bytes == NULL ) pstrbyt_ret->szt_lenbytes = 0; return pstrbyt_ret; } size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf) { return ByteIndex( this->pbyt_data , this->szt_len ,pByt_Find , szt_lsf ); } size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start) { return ByteIndex( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start ); } size_t cls_byte::Index(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, e_CompareMethod enum_Compare) { return ByteIndex( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , enum_Compare ); } size_t cls_byte::Index(cls_byte *pclsbyte) { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len ); } size_t cls_byte::Index(cls_byte *pclsbyte, size_t szt_Start) { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start ); } size_t cls_byte::Index(cls_byte *pclsbyte, size_t szt_Start, e_CompareMethod enum_Compare) { return ByteIndex( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , enum_Compare ); } bool cls_byte::Exits(cls_byte *pclsbyte) { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len ); } bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start) { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start ); } bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start, long lng_interval) { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , lng_interval ); } bool cls_byte::Exits(cls_byte *pclsbyte, size_t szt_Start, long lng_interval, e_CompareMethod enum_Compare) { return ByteExits( this->pbyt_data , this->szt_len , pclsbyte->pbyt_data , pclsbyte->szt_len , szt_Start , lng_interval , enum_Compare ); } bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf) { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf ); } bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start) { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start ); } bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, long lng_interval) { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , lng_interval ); } bool cls_byte::Exits(Byte *pByt_Find, size_t szt_lsf, size_t szt_Start, long lng_interval, e_CompareMethod enum_Compare) { return ByteExits( this->pbyt_data , this->szt_len , pByt_Find , szt_lsf , szt_Start , lng_interval , enum_Compare ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , 0 , -1 , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , -1 , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , enum_Compare ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , 0 , -1 , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , -1 , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , BINARY ); } cls_byte *cls_byte::Replace ( cls_byte *pclsbyteFind , Byte *pByt_Replacement , size_t szt_lnReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ) { return this->Replace( pclsbyteFind->GetBytesPtr() , pclsbyteFind->Getlen() , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , enum_Compare ); } cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement ) { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , 0 , -1 , BINARY ); } cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start ) { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , -1 , BINARY ); } cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count ) { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , BINARY ); } cls_byte *cls_byte::Replace ( Byte *pByt_Find , size_t szt_lnFind , cls_byte *pclsbyteReplacement , size_t szt_Start , long lng_Count , e_CompareMethod enum_Compare ) { return this->Replace( pByt_Find , szt_lnFind , pclsbyteReplacement->GetBytesPtr() , pclsbyteReplacement->Getlen() , szt_Start , lng_Count , enum_Compare ); } cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement) { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , 0 , -1 , BINARY ); } cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start) { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , szt_Start , -1 , BINARY ); } cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start, long lng_Count) { return this->Replace( pByt_Find , szt_lnFind , pByt_Replacement , szt_lnReplacement , szt_Start , lng_Count , BINARY ); } cls_byte *cls_byte::Replace(Byte *pByt_Find, size_t szt_lnFind, Byte *pByt_Replacement, size_t szt_lnReplacement, size_t szt_Start, long lng_Count, e_CompareMethod enum_Compare) { cls_byte *cls_Ret = (cls_byte*)malloc(sizeof(cls_byte)); Struct_Byte *pByt_Ret = NULL; Byte *pByt_ClnF = ByteClone ( pByt_Find , szt_lnFind ); Byte *pByt_ClnR = ByteClone ( pByt_Replacement , szt_lnReplacement ); pByt_Ret = ByteReplace( this->pbyt_data , this->szt_len , pByt_ClnF , szt_lnFind , pByt_ClnR , szt_lnReplacement , szt_Start , lng_Count , enum_Compare ); cls_Ret->SetBytes ( pByt_Ret ); setnewptrf<Byte*> ( pByt_ClnF , NULL ); setnewptrf<Byte*> ( pByt_ClnR , NULL ); setnewptrf<Byte*> ( pByt_Ret->pbyt_bytes , NULL ); setnewptrf<Struct_Byte*> ( pByt_Ret , NULL ); return cls_Ret; } cls_byte *cls_byte::Mid(size_t szt_start) { return this->Mid ( szt_start , this->szt_len ); } cls_byte *cls_byte::Mid(size_t szt_start, size_t szt_len) { cls_byte *cls_Ret = (cls_byte*)malloc(sizeof(cls_byte)); Struct_Byte *pByt_Ret = NULL; pByt_Ret = ByteMid ( this->pbyt_data , this->szt_len , szt_start , szt_len ); cls_Ret->SetBytes ( pByt_Ret ); setnewptrf<Byte*> ( pByt_Ret->pbyt_bytes , NULL ); setnewptrf<Struct_Byte*> ( pByt_Ret , NULL ); return cls_Ret; } Struct_clsByte *cls_byte::Split(Byte *pbyt_delimiter, size_t szt_lndelimiter) { return this->Split ( pbyt_delimiter , szt_lndelimiter , -1 ); } Struct_clsByte *cls_byte::Split(Byte *pbyt_delimiter, size_t szt_lndelimiter, long lng_limit) { Struct_clsByte *cls_Ret = (Struct_clsByte*)malloc(sizeof(Struct_clsByte)); Struct_Byte_Split *pByt_Ret = NULL; Byte *pByt_Clone = ByteClone ( pbyt_delimiter , szt_lndelimiter ); pByt_Ret = ByteSplit ( this->pbyt_data , this->szt_len , pByt_Clone , szt_lndelimiter , lng_limit ); cls_Ret->szt_count = 0; cls_Ret->pbyt_class = (cls_byte*)malloc(sizeof(cls_byte)*pByt_Ret->szt_ln); for ( cls_Ret->szt_count=0 ; cls_Ret->szt_count<pByt_Ret->szt_ln ; ++cls_Ret->szt_count ) { cls_Ret->pbyt_class[ cls_Ret->szt_count ].SetBytes( pByt_Ret->Struct[ cls_Ret->szt_count ] ); setnewptrf<Byte*> ( pByt_Ret->Struct[ cls_Ret->szt_count ]->pbyt_bytes , NULL ); setnewptrf<Struct_Byte*> ( pByt_Ret->Struct[ cls_Ret->szt_count ] , NULL ); } setnewptrf<Byte*> ( pByt_Clone , NULL ); setnewptrf<Struct_Byte_Split*> ( pByt_Ret , NULL ); return cls_Ret; } Struct_clsByte *cls_byte::Split(cls_byte *pclsbytelim) { return this->Split ( pclsbytelim->GetBytesPtr() , pclsbytelim->Getlen() , -1 ); } Struct_clsByte *cls_byte::Split(cls_byte *pclsbytelim, long lng_limit) { return this->Split ( pclsbytelim->GetBytesPtr() , pclsbytelim->Getlen() , lng_limit ); } #endif
Temibles Lunas!¡.
|
|
|
44
|
Foros Generales / Foro Libre / Goku de tepito...
|
en: 10 Abril 2011, 07:12 am
|
. Este baboso me toco verlo hace tiempo en persona, por hay me veo... la cuestion es donde, el idiota segun se lo hizo por 20$ pesos ( como 1 dolar y medio ). Goku de Tepitoes una idiotes pero me hizo cagar de risa. Dulces Lunas!¡.
|
|
|
45
|
Foros Generales / Foro Libre / Ayuda matematica-
|
en: 9 Abril 2011, 03:14 am
|
. Coordenadas esfericas.
OJO mis ejes Z y X son el piso y mi eje Y es mi altitud., de donde Z es lo que se define como que tan seca o lejos esta de un objeto.
Como se calcula en angulo azimutal de dos puntos?
x = d * sin(a) * cos(e) y = d * sin(e) z = d * cos(a) * cos(e)
donde:
d = distancia entre dos puntos ( X,Y,Z ) a = angulo azimutal e = angulo de elevacion
hasta ahora ya pude saber como saber el angulo de elevacion de un punto con respecto al punto origen
e = csc( y/d )
Pero para el angulo de la azimutal
[Aqui empiza mi duca sigan leyendo]
llego a un punto muerto donde ya no se que rayos hacer.
El angulo azimutal involucra a el eje x y el eje z, el eje y solo es involucrado por la elevacion ( Logica Basica )
x = d * sin(a) * cos(e) z = d * cos(a) * cos(e)
Entonces empesando a despejar
Como en ambas expresiones existen d y cos(e) puedo hacer un reemplazo de terminos asi:
Quitando a cos(e) para simplificar la cosa:
cos(e) = x / ( d*sin(a) )
En la segunda formula reemplazo ( z = d * cos(a) * cos(e) )
z = d * cos(a) * x / ( d*sin(a) )
Simplificando un poco queda:
z = cos(a) * x / sin(a)
y tratando de despejar a el angulo a obtengo:
z/x = cos(a) / sin(a) siendo lo mismo a: z/x = cos(a) * csc(a)
por lo tanto:
cosec ( z/x ) = a * csc( a ) sin(cosec(z/x)) = a*a
por lo tanto
raiz( sin(cosec(z/x)) ) = a
pero al aplicar dicho despeje no me da el angulo ya mensionado. alguien sabe como solucionarlo?
Dulces Lunas!¡. .
|
|
|
47
|
Programación / Programación Visual Basic / [Source] WinCenterIn ( Centrar Objetos con respecto a otros ).
|
en: 9 Marzo 2011, 04:31 am
|
. mmm en lugar de solo criticar la funcion pondre una de mi tutela que uso para esto, es decir centrar las cosas por medio de su hWnd, Sirve con: * Objetos del form ( Botones, frames, etc... ). * Ventanas ( de la aplicacion o externas ). * Pantalla ( Centra el objeto con restecto a la pantalla ). * Funciona con TODO lo que tenga un hWnd valido. Codigo Actualizado: ' ' //////////////////////////////////////////////////////////////// ' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) // ' // // ' // Web: http://InfrAngeluX.Sytes.Net/ // ' // // ' // |-> Pueden Distribuir Este Código siempre y cuando // ' // no se eliminen los créditos originales de este código // ' // No importando que sea modificado/editado o engrandecido // ' // o achicado, si es en base a este código // ' //////////////////////////////////////////////////////////////// ' // ' //////////////////////////////////////////////////////////////// Option Explicit Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Enum WS_InCenterOpt InScreen = 0 InObject = 1 InParent = 2 InWinExtern = 3 End Enum Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long Public Function WinCenterIn(ByVal hwnd As Long, Optional ByVal InhWnd As Long = 0, Optional ByVal Opt As WS_InCenterOpt = InParent) Dim st_retm As RECT Dim st_retd As RECT Dim st_pt As POINTAPI If GetWindowRect(hwnd, st_retm) <> 0 Then Select Case Opt Case InObject, InParent, InWinExtern If Opt = InParent Then InhWnd = GetParent(hwnd) If InhWnd = 0 Then WinCenterIn = WinCenterIn(hwnd, 0, InScreen) End If End If If GetWindowRect(InhWnd, st_retd) = 0 Then Exit Function End If Case InScreen st_retd.Bottom = GetSystemMetrics(&H1) st_retd.Right = GetSystemMetrics(&H0) Case Else Exit Function End Select st_pt.x = st_retd.Left + ((st_retd.Right - st_retd.Left) - (st_retm.Right - st_retm.Left)) \ 2 st_pt.y = st_retd.Top + ((st_retd.Bottom - st_retd.Top) - (st_retm.Bottom - st_retm.Top)) \ 2 If Opt <> InWinExtern Then Call ScreenToClient(InhWnd, st_pt) End If WinCenterIn = MoveWindow(hwnd, st_pt.x, st_pt.y, (st_retm.Right - st_retm.Left), (st_retm.Bottom - st_retm.Top), 1) <> 0 End If End Function
Ejemplo: Option Explicit Private Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Sub Command2_Click() WinCenterIn Me.hwnd WinCenterIn FindWindowA(vbNullString, "Administrador de tareas de Windows"), Me.hwnd, InWinExtern 'WinCenterIn Me.hwnd, FindWindowA(vbNullString, "Administrador de tareas de Windows"), InWinExtern End Sub
Version Anterior: ' ' //////////////////////////////////////////////////////////////// ' // Autor: BlackZeroX ( Ortega Avila Miguel Angel ) // ' // // ' // Web: http://InfrAngeluX.Sytes.Net/ // ' // // ' // |-> Pueden Distribuir Este Código siempre y cuando // ' // no se eliminen los créditos originales de este código // ' // No importando que sea modificado/editado o engrandecido // ' // o achicado, si es en base a este código // ' //////////////////////////////////////////////////////////////// ' // ' ////////////////////////////////////////////////////////////////
Option Explicit
Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Public Function WinCenterIn(ByVal hwnd As Long, Optional ByVal InhWnd As Long = 0, Optional ByVal WinExterna As Boolean) Dim st_retm As RECT Dim st_retd As RECT Dim st_pt As POINTAPI
If GetWindowRect(hwnd, st_retm) = 0 Then Exit Function End If If InhWnd = 0 Then st_retd.Bottom = GetSystemMetrics(&H1) st_retd.Right = GetSystemMetrics(&H0) Else If GetWindowRect(InhWnd, st_retd) = 0 Then Exit Function End If End If st_pt.x = st_retd.Left + (Abs((st_retd.Right - st_retd.Left) - (st_retm.Right - st_retm.Left))) \ 2 st_pt.y = st_retd.Top + (Abs((st_retd.Bottom - st_retd.Top) - (st_retm.Bottom - st_retm.Top))) \ 2 If Not WinExterna And InhWnd = 0 Then Call ScreenToClient(InhWnd, st_pt) Else Call ScreenToClient(InhWnd, st_pt) st_pt.x = st_pta.x + st_pt.x st_pt.y = st_pta.y + st_pt.y End If WinCenterIn = MoveWindow(hwnd, st_pt.x, st_pt.y, (st_retm.Right - st_retm.Left), (st_retm.Bottom - st_retm.Top), 1) <> 0 End Function
La implementacion es bastante sencilla. WinCenterIn Command1.hwnd, Me.hwnd WinCenterIn Command1.hwnd, 0 WinCenterIn me.hwnd, 0
Temibles Lunas!¡.
|
|
|
48
|
Programación / Programación C/C++ / Error OpenGL.
|
en: 5 Marzo 2011, 12:23 pm
|
. bueno ando provando OpenGL en C++ y todo perfecto con GLUT, pero cuando intento usar las apis: glClearColor(0.0,0.0,0.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0); glMatrixMode(GL_MODELVIEW); glBegin(GL_TRIANGLES); glColor3f(1.0,0.0,0.0); glVertex3f(0.0,0.8,0.0); glColor3f(0.0,1.0,0.0); glVertex3f(-0.6,-0.2,0.0); glColor3f(0.0,0.0,1.0); glVertex3f(0.6,-0.2,0.0); glEnd(); glFlush();
Me sale error de undefined reference to ´...´ a cada una de estas apis. caso contrario con: glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutInitWindowPosition(20,20); glutInitWindowSize(500,500); glutCreateWindow((const char*)&argv[0]); glutDisplayFunc(display); glutMainLoop();
Que me falta linkear?. P.D.: tengo el linkeada la libreria glut32.lib, en el proyecto. Dulces Lunas!¡.
|
|
|
49
|
Programación / Programación Visual Basic / [!] Liga interesante; Programando microcontroladores.
|
en: 1 Marzo 2011, 08:07 am
|
. El compilador se llama Great Cow Basic y sirve para programar en los microchips. * Es de codigo abierto. * Free. * Instalacion en Windows y Linux. * Las variables tal y como son declaras, se ven reflejados en el codigo ASM final es decir no agrega nombres raros al codigo ASM final. Manual es Españolhttp://gcbasic.sourceforge.net/index.html 'Led parpadeante #chip 16F628A, 20 'modelo de pic y velocidad de reloj: 20 Mhz #define led PORTB.1 Main: TRISB=0 PORTB=0 led = 1 wait 500 ms led = 0 wait 500 ms goto Main
Codigo ASM generado de manera limpia. ;Program compiled by Great Cow BASIC (0.9 13/9/2008) ;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286, ;check the documentation or email w_cholmondeley@users.sourceforge.net. ;******************************************************************************** ;Set up the assembler options (Chip type, clock source, other bits and pieces) LIST p=16F628A, r=DEC #include __CONFIG _HS_OSC & _WDT_OFF & _LVP_OFF & _MCLRE_OFF ;******************************************************************************** ;Set aside memory locations for variables DELAYTEMP equ 32 DELAYTEMP2 equ 33 RANDOMSEED equ 34 RANDOMSEED_H equ 35 SysWaitTempMS equ 36 SysWaitTempMS_H equ 37 ;******************************************************************************** ;Jump to initialisation code when PIC is reset ORG 0 call INITSYS goto SystemInitialise ;******************************************************************************** ;Interrupt vector ORG 4 ;Various initialisation routines, automatically called by GCBASIC SystemInitialise ;******************************************************************************** ;Start of the main program MAIN banksel TRISB clrf TRISB banksel PORTB clrf PORTB bsf PORTB,1 movlw 244 movwf SysWaitTempMS movlw 1 movwf SysWaitTempMS_H call Delay_MS bcf PORTB,1 movlw 244 movwf SysWaitTempMS movlw 1 movwf SysWaitTempMS_H call Delay_MS goto MAIN BASPROGRAMEND sleep goto $ ;******************************************************************************** ;Subroutines included in program ;******************************************************************************** Delay_MS incf SysWaitTempMS_H, F DMS_START movlw 10 movwf DELAYTEMP2 DMS_OUTER movlw 166 movwf DELAYTEMP DMS_INNER decfsz DELAYTEMP, F goto DMS_INNER decfsz DELAYTEMP2, F goto DMS_OUTER decfsz SysWaitTempMS, F goto DMS_START decfsz SysWaitTempMS_H, F goto DMS_START return ;******************************************************************************** INITSYS movlw 7 movwf CMCON clrf PORTA clrf PORTB return ;******************************************************************************** END
Dulces Lunas!¡.
|
|
|
|
|
|
|