elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía actualizada para evitar que un ransomware ataque tu empresa


  Mostrar Temas
Páginas: 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14
61  Programación / Programación Visual Basic / [Src-PoC] Buscar en un Array Ordenado en: 31 Diciembre 2010, 00:06 am
.
Andaba buscando la manera de buscar en un Array de la forma mas RAPIDA posible y bueno, recordando el QuickSort arme este algoritmo que busca en un Array ordenado de forma Ascendente o Desendente un valor en el mismo lo hace de forma Extremadamente rapida...

Se lo dejo en Dos versiones... Recursiva y con un Do... Loop

Aqui se los dejo:

Forma Recursiva (Gasta memoria...)

Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   //                                                         //
  5. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  6. '   //                                                         //
  7. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  8. '   //                                                         //
  9. '   //    |-> Pueden Distribuir Este Codigo siempre y cuando   //
  10. '   // no se eliminen los creditos originales de este codigo   //
  11. '   // No importando que sea modificado/editado o engrandesido //
  12. '   // o achicado, si es en base a este codigo                 //
  13. '   /////////////////////////////////////////////////////////////
  14.  
  15. option explicit
  16.  
  17. Public Function ExitsInArray(ByRef vValue As Long, ByRef vBuff() As Long, ByRef p As Long) As Boolean
  18. Dim lng_lb                      As Long
  19. Dim lng_Ub                      As Long
  20.    lng_lb = LBound(vBuff&())
  21.    lng_Ub = UBound(vBuff&())
  22.    If vBuff&(lng_Ub) > vBuff&(lng_lb) Then
  23.        ExitsInArray = ExitsInArrayR(vValue, vBuff&, lng_lb, lng_Ub, p)
  24.    Else
  25.        ExitsInArray = ExitsInArrayR(vValue, vBuff&, lng_Ub, lng_lb, p)
  26.    End If
  27. End Function
  28.  
  29. Public Function ExitsInArrayR(ByRef vValue As Long, ByRef vBuff() As Long, ByVal l As Long, ByVal u As Long, ByRef p As Long) As Boolean
  30.    Select Case vValue
  31.        Case vBuff&(l&)
  32.            p& = l&
  33.            ExitsInArrayR = True
  34.        Case vBuff&(u&)
  35.            p& = u&
  36.            ExitsInArrayR = True
  37.        Case Else
  38.            p = (l& + u&) / 2
  39.            If p <> l& And p& <> u& Then
  40.                If vBuff&(p&) < vValue& Then
  41.                    ExitsInArrayR = ExitsInArrayR(vValue, vBuff&(), p, u, p)
  42.                ElseIf vBuff&(p&) > vValue& Then
  43.                    ExitsInArrayR = ExitsInArrayR(vValue, vBuff&(), l, p, p)
  44.                ElseIf vBuff&(p&) = vValue& Then
  45.                    ExitsInArrayR = True
  46.                End If
  47.            End If
  48.    End Select
  49. End Function
  50.  
  51.  

Forma con Do ... Loop

Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   //                                                         //
  5. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  6. '   //                                                         //
  7. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  8. '   //                                                         //
  9. '   //    |-> Pueden Distribuir Este Codigo siempre y cuando   //
  10. '   // no se eliminen los creditos originales de este codigo   //
  11. '   // No importando que sea modificado/editado o engrandesido //
  12. '   // o achicado, si es en base a este codigo                 //
  13. '   /////////////////////////////////////////////////////////////
  14.  
  15. option explicit
  16.  
  17. Public Function ExitsInArrayNR(ByRef vValue As Long, ByRef vBuff() As Long, ByRef p As Long) As Boolean
  18. Dim lng_lb                      As Long
  19. Dim lng_Ub                      As Long
  20.    lng_lb = LBound(vBuff&())
  21.    lng_Ub = UBound(vBuff&())
  22.    If Not vBuff&(lng_Ub) > vBuff&(lng_lb) Then
  23.        Dim t                           As Long
  24.        t = lng_Ub
  25.        lng_Ub = lng_lb
  26.        lng_lb = t
  27.    End If
  28.    Do Until ExitsInArrayNR
  29.        Select Case vValue
  30.            Case vBuff&(lng_lb&)
  31.                p& = lng_lb&
  32.                ExitsInArrayNR = True
  33.            Case vBuff&(lng_Ub&)
  34.                p& = lng_Ub&
  35.                ExitsInArrayNR = True
  36.            Case Else
  37.                p = (lng_lb& + lng_Ub&) / 2
  38.                If p <> lng_lb& And p& <> lng_Ub& Then
  39.                    If vBuff&(p&) < vValue& Then
  40.                        lng_lb = p
  41.                    ElseIf vBuff&(p&) > vValue& Then
  42.                        lng_Ub = p
  43.                    ElseIf vBuff&(p&) = vValue& Then
  44.                        ExitsInArrayNR = True
  45.                    End If
  46.                Else
  47.                    Exit Do
  48.                End If
  49.        End Select
  50.    Loop
  51. End Function
  52.  
  53.  


Prueba de Velocidad en comparacion a un Simple For Next...


Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   //                                                         //
  5. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  6. '   //                                                         //
  7. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  8. '   //                                                         //
  9. '   //    |-> Pueden Distribuir Este Codigo siempre y cuando   //
  10. '   // no se eliminen los creditos originales de este codigo   //
  11. '   // No importando que sea modificado/editado o engrandesido //
  12. '   // o achicado, si es en base a este codigo                 //
  13. '   /////////////////////////////////////////////////////////////
  14.  
  15. Option Explicit
  16.  
  17. Private Declare Function GetTickCount Lib "kernel32" () As Long
  18.  
  19. Private Sub Form_Load()
  20. Dim vBuff&(0 To 99999)
  21. Dim i&, p&
  22. Dim l&
  23. Dim vStr$
  24.    For i& = LBound(vBuff&()) To UBound(vBuff&())
  25.        vBuff(i&) = (99999 * 3) - (i * 3)
  26.    Next i&
  27.    l& = GetTickCount()
  28.    For i& = LBound(vBuff&()) To 999
  29.        Call ExitsInArrayLento(i&, vBuff&(), p&)
  30.    Next i&
  31.    vStr$ = GetTickCount - l&
  32.    l& = GetTickCount()
  33.    For i& = LBound(vBuff&()) To 999
  34.        ' // ExitsInArrayNR es un poquito mas rapido... que ExitsInArray
  35.        Call ExitsInArray(i&, vBuff&(), p&)
  36.    Next i&
  37.    l& = GetTickCount - l&
  38.    MsgBox "ExitsInArrayLento " & vStr$ & vbCrLf & _
  39.           "ExitsInArray " & l
  40. End Sub
  41.  
  42.  
  43. Public Function ExitsInArray(ByRef vValue As Long, ByRef vBuff() As Long, ByRef p As Long) As Boolean
  44. Dim lng_lb                      As Long
  45. Dim lng_Ub                      As Long
  46.    lng_lb = LBound(vBuff&())
  47.    lng_Ub = UBound(vBuff&())
  48.    If vBuff&(lng_Ub) > vBuff&(lng_lb) Then
  49.        ExitsInArray = ExitsInArrayR(vValue, vBuff&, lng_lb, lng_Ub, p)
  50.    Else
  51.        ExitsInArray = ExitsInArrayR(vValue, vBuff&, lng_Ub, lng_lb, p)
  52.    End If
  53. End Function
  54.  
  55. Public Function ExitsInArrayR(ByRef vValue As Long, ByRef vBuff() As Long, ByVal l As Long, ByVal u As Long, ByRef p As Long) As Boolean
  56.    Select Case vValue
  57.        Case vBuff&(l&)
  58.            p& = l&
  59.            ExitsInArrayR = True
  60.        Case vBuff&(u&)
  61.            p& = u&
  62.            ExitsInArrayR = True
  63.        Case Else
  64.            p = (l& + u&) / 2
  65.            If p <> l& And p& <> u& Then
  66.                If vBuff&(p&) < vValue& Then
  67.                    ExitsInArrayR = ExitsInArrayR(vValue, vBuff&(), p, u, p)
  68.                ElseIf vBuff&(p&) > vValue& Then
  69.                    ExitsInArrayR = ExitsInArrayR(vValue, vBuff&(), l, p, p)
  70.                ElseIf vBuff&(p&) = vValue& Then
  71.                    ExitsInArrayR = True
  72.                End If
  73.            End If
  74.    End Select
  75. End Function
  76.  
  77.  
  78.  
  79. Public Function ExitsInArrayNR(ByRef vValue As Long, ByRef vBuff() As Long, ByRef p As Long) As Boolean
  80. Dim lng_lb                      As Long
  81. Dim lng_Ub                      As Long
  82.    lng_lb = LBound(vBuff&())
  83.    lng_Ub = UBound(vBuff&())
  84.    If Not vBuff&(lng_Ub) > vBuff&(lng_lb) Then
  85.        Dim t                           As Long
  86.        t = lng_Ub
  87.        lng_Ub = lng_lb
  88.        lng_lb = t
  89.    End If
  90.    Do Until ExitsInArrayNR
  91.        Select Case vValue
  92.            Case vBuff&(lng_lb&)
  93.                p& = lng_lb&
  94.                ExitsInArrayNR = True
  95.            Case vBuff&(lng_Ub&)
  96.                p& = lng_Ub&
  97.                ExitsInArrayNR = True
  98.            Case Else
  99.                p = (lng_lb& + lng_Ub&) / 2
  100.                If p <> lng_lb& And p& <> lng_Ub& Then
  101.                    If vBuff&(p&) < vValue& Then
  102.                        lng_lb = p
  103.                    ElseIf vBuff&(p&) > vValue& Then
  104.                        lng_Ub = p
  105.                    ElseIf vBuff&(p&) = vValue& Then
  106.                        ExitsInArrayNR = True
  107.                    End If
  108.                Else
  109.                    Exit Do
  110.                End If
  111.        End Select
  112.    Loop
  113. End Function
  114.  
  115. Private Function ExitsInArrayLento(ByRef Value As Long, ByRef ArrayCollection() As Long, Optional ByRef OutInIndex As Long) As Boolean
  116.    For OutInIndex = LBound(ArrayCollection) To UBound(ArrayCollection)
  117.        If ArrayCollection(OutInIndex) = Value Then
  118.            ExitsInArrayLento = True
  119.            Exit Function
  120.        End If
  121.    Next
  122. End Function
  123.  
  124.  

Temibles Lunas!¡.
.
62  Programación / Programación Visual Basic / [Navidad] Feliz Navidad en: 25 Diciembre 2010, 06:06 am
.
Que pasen una velada agradable  :rolleyes:

Temibles Noches!¡.
.
63  Programación / Programación Visual Basic / [SRC][UC] ListViewEx en: 15 Diciembre 2010, 00:35 am
.
Este UC lo vengo haciendo en pocos ratos que tengo, esta realizado con las APIS GDI, aun no esta optimisado, pero ya esta funcional,

Importante: La programacion de los eventos como MouseDown estan bajo los mensajes de windows, ya que si se ponen bajo los eventos del UC salen errores como "Expresion demasiado compleja"

* ListView colorido.
* Seleccion con Click + Control
* ScrollGhost (Funciona al mantener pulsado el mouse sobre alguna de las 4 regiones disponibles)
* QuickSort como motor de Ordenacion.
* tengo weba de escribir las demas Funciones... asi que veanlo...
*- Seleccion con Shift aun no agregado.
*-Aun no tiene soporte para iconos (despues lo agrego).

http://infrangelux.hostei.com/?option=com_content&view=article&id=22:src-uc-listviewex&catid=13:controlesdeusuario&Itemid=21&

algunas imagenes...





Temibles Lunas!¡.
64  Programación / Programación Visual Basic / GetMessage() y DispatchMessage() en: 13 Diciembre 2010, 07:38 am
.
Bueno ando con un rollo en el vb6 y es que ando creando un UC ( ya tiene mucho que llevo con esto pero no he tenido mucho tiempo para terminarlo ), mi problema es que en el UC resivo los mensajes con GetMessage y los dejo fluir con DispatchMessage pero he aqui el problema en DispatchMessage cundo termino el form donde tengo el UC se queda todo el programa en dicha linea y por esta linea no se puede cerrar el programa o form en cuestion.

En pocas palabras una alternativa a estas apis cual seria?, las he usado por que estas no me traban de forma innesesaria el programa, en cambio PeekMessage tengo que hacer un Bucle pero este a diferencia de las otras dos apis se le escapan mensajes, por ende no me sirve ademas que tengo que ponerle doevents y cosillas dentro del bucle para que no se coma el procesador.

Este es el codigo, lo programe para que dejara de procesar mensajes si le llegan los mensajes WM_CLOSE o WM_DESTROY, pero esto no me gusta mucho que digamos.

Código
  1.  
  2. '   //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //
  3. '   //  El Objetivo de este proceso es que el Control de Usuario sea Maleable,
  4. '   //  de igual forma por que lo pienso pasar a C++ y esto me ayudara despues,
  5. '   //  se que aqui no se tratan los mensajes si no mas bien en el Callback
  6. '   //  WindProc() pero bueno, es solo una obtativa para vb6 de forma cutre
  7. '   //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //
  8. '   //  ----------------------------------------------------------------------  //
  9. '   //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //
  10. '   //  No es la manera mas Ortodoxa pero asi me evito usar TODO el Procesador...
  11. '   //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //  //
  12.  
  13. Private Sub ProcessMessages()
  14. Dim vMsg                                As Msg
  15. Dim bool_MsgCancel                      As Boolean
  16. Dim Button                              As Integer
  17. Dim tPoint                              As POINTAPI
  18. Dim Shift                               As Integer
  19.  
  20.    bool_MsgCancel = False
  21.  
  22.    Do While GetMessage(vMsg, 0, 0, 0) And bool_MsgCancel = False
  23.        If vMsg.hwnd = UserControl.hwnd Or _
  24.           vMsg.hwnd = VS.hwnd Or _
  25.           vMsg.hwnd = HS.hwnd Then
  26.  
  27.            Select Case vMsg.message
  28.  
  29.                '   //  Mensajes del Mouse
  30.                Case WM.WM_MOUSEWHEEL, WM.WM_MOUSEMOVE, _
  31.                     WM.WM_LBUTTONDBLCLK, WM.WM_LBUTTONDOWN, WM.WM_LBUTTONUP, _
  32.                     WM.WM_RBUTTONDBLCLK, WM.WM_RBUTTONDOWN, WM.WM_RBUTTONUP, _
  33.                     WM.WM_MBUTTONDBLCLK, WM.WM_MBUTTONDOWN, WM.WM_MBUTTONUP
  34.  
  35.                    tPoint = GetCursorRegion
  36.  
  37.                    If vMsg.wParam = MK.MK_CONTROL Then
  38.                        Shift = 2
  39.                    ElseIf vMsg.wParam = MK.MK_SHIFT Then
  40.                        Shift = 1
  41.                    Else
  42.                        Shift = 0
  43.                    End If
  44.  
  45.                    Select Case vMsg.message
  46.                        Case WM.WM_MOUSEWHEEL
  47.                            Debug.Print "WM_MOUSEWHEEL"
  48.                            If vMsg.wParam < 0 Then
  49.                                If (DatosScrollGhost(1).Visible Or VS.Visible) Then
  50.                                    Scroll_V = Priv_SV + int_hRow
  51.                                End If
  52.                            Else
  53.                                If (DatosScrollGhost(0).Visible Or VS.Visible) Then
  54.                                    Scroll_V = Priv_SV - int_hRow
  55.                                End If
  56.                            End If
  57.  
  58.                        Case WM.WM_LBUTTONDBLCLK
  59.                            Debug.Print "WM_LBUTTONDBLCLK"
  60.                            Call lvDblClick
  61.                        Case WM.WM_RBUTTONDBLCLK
  62.                            Debug.Print "WM_RBUTTONDBLCLK"
  63.                            Call lvDblClick
  64.                        Case WM.WM_MBUTTONDBLCLK
  65.                            Debug.Print "WM_MBUTTONDBLCLK"
  66.                            Call lvDblClick
  67.  
  68.                        Case WM.WM_LBUTTONDOWN
  69.                            Debug.Print "WM_LBUTTONDOWN"
  70.                            Button = 1
  71.                            Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y)
  72.                        Case WM.WM_RBUTTONDOWN
  73.                            Debug.Print "WM_RBUTTONDOWN"
  74.                            Button = 2
  75.                            Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y)
  76.                        Case WM.WM_MBUTTONDOWN
  77.                            Debug.Print "WM_MBUTTONDOWN"
  78.                            Button = 4
  79.                            Call lvMouseDown(Button, Shift, tPoint.X, tPoint.Y)
  80.  
  81.                        Case WM.WM_LBUTTONUP, WM.WM_RBUTTONUP, WM.WM_MBUTTONUP
  82.                            Debug.Print "WM_LBUTTONUP"
  83.                            Call lvMouseUp(Button, Shift, tPoint.X, tPoint.Y)
  84.                            Call lvClick
  85.                            Button = 0
  86.  
  87.                        Case WM.WM_MOUSEMOVE
  88.                            Debug.Print "WM_MOUSEMOVE"
  89.                            Call lvMouseMove(Button, Shift, tPoint.X, tPoint.Y)
  90.  
  91.                    End Select
  92.  
  93.                '   //  Teclas Pulsadas...
  94.                Case WM.WM_KEYDOWN
  95.                    Debug.Print "WM_KEYDOWN", vMsg.wParam
  96.                    Select Case vMsg.wParam
  97.                        Case VK.VK_UP
  98.                            If DatosScrollGhost(0).Visible Or VS.Visible Then
  99.                                Scroll_V = Priv_SV - int_hRow   'Priv_SV - int_hRow
  100.                            End If
  101.  
  102.                        Case VK.VK_Down
  103.                            If DatosScrollGhost(1).Visible Or VS.Visible Then
  104.                                Scroll_V = Priv_SV + int_hRow   'Priv_SV + int_hRow
  105.                            End If
  106.  
  107.                        Case VK.VK_Left
  108.                            If DatosScrollGhost(3).Visible Or HS.Visible Then
  109.                                Scroll_H = Priv_SH - 20   'Priv_SH - 20
  110.                            End If
  111.  
  112.                        Case VK.VK_RIGHT
  113.                            If DatosScrollGhost(3).Visible Or HS.Visible Then
  114.                                Scroll_H = Priv_SH + 20   'Priv_SH + 20
  115.                            End If
  116.  
  117.                        Case VK.VK_HOME
  118.                            Scroll_V = 0
  119.  
  120.                        Case VK.VK_END
  121.                            If RowVisibleCount < CantRows Then
  122.                                Scroll_V = (CantRows * int_hRow) - (RectLista.Bottom - RectLista.Top)
  123.                            End If
  124.  
  125.                        Case VK.VK_SHIFT
  126.                            cAoDSS = True
  127.                            Shift = 1
  128.  
  129.                        Case VK.VK_CONTROL
  130.                            cAoDSC = True
  131.                            Shift = 2
  132.  
  133.                        Case VK.VK_PRIOR
  134.                            Scroll_V = Priv_SV - RowVisibleCount * int_hRow
  135.  
  136.                        Case VK.VK_NEXT
  137.                            Scroll_V = Priv_SV + RowVisibleCount * int_hRow
  138.  
  139.                    End Select
  140.                    RaiseEvent KeyDown(Int(vMsg.wParam), Shift)
  141.  
  142.                Case WM.WM_KEYUP
  143.                    Debug.Print "WM_KEYUP", vMsg.wParam
  144.                    Select Case vMsg.wParam
  145.                        Case VK.VK_SHIFT
  146.                            cAoDSS = False
  147.                            Shift = 0
  148.  
  149.                        Case VK.VK_CONTROL
  150.                            cAoDSC = False
  151.                            Shift = 0
  152.                    End Select
  153.                    RaiseEvent KeyUp(Int(vMsg.wParam), Shift)
  154.                    RaiseEvent KeyPress(Int(vMsg.wParam))
  155.  
  156.                '   //  Mesajes de la Ventana
  157.                Case WM.WM_ACTIVATE
  158.                    Debug.Print "WM_ACTIVATE"
  159.  
  160.                Case WM.WM_CLOSE, WM.WM_DESTROY
  161.                    Debug.Print "WM_CLOSE", "WM_DESTROY"
  162.                    bool_MsgCancel = True
  163.                    Exit Sub
  164.  
  165.                Case WM.WM_PAINT
  166.                    If vMsg.wParam = 0 Then
  167.                        Call Refresh
  168.                    Else
  169.                        Call RefreshCols(vMsg.lparam)
  170.                    End If
  171.  
  172.                Case WM.WM_ENABLE
  173.                    'wParam
  174.                    '   Indicates whether the window has been enabled or disabled. This parameter is TRUE if the window has been enabled or FALSE if the window has been disabled.
  175.                    'lparam
  176.                    '   This parameter is not used.
  177.                    Debug.Print "WM_ENABLE"
  178.  
  179.                Case Else
  180.  
  181.            End Select
  182.  
  183.        End If
  184.        Call DispatchMessage(vMsg)
  185.        'Call WaitMessage
  186.    Loop
  187. End Sub
  188.  
  189.  

P.D.: Que no sea por subclasificación... aun que si no tengo otra opcion...

Temibles Lunas!¡.
65  Programación / Programación C/C++ / [SRC] Lineas Aleatorias en la Pantalla en: 6 Diciembre 2010, 10:56 am
.
Linkear libreria     GDI32

Esto solo es una traduccion de VB6 a C++

Que hace? Solo dibuja miles de lineas aleatoriamente de distintos colores en el monitor ignorando todo ( o casi todo ).

Codigo Original:

(GDI32) Lineas Aleatorias On The Fly

https://foro.elhacker.net/programacion_visual_basic/lineas_al_aire-t281968.0.html;msg1389871#msg1389871

Este codigo trae corregido algunos errores que cometi en vb6... nada graves (el mi blog ya estan corregidos por obvias razones)

Codigo:

Código
  1.  
  2. ////////////////////////////////////////////////////////////////
  3. // Autor: BlackZeroX ( Ortega Avila Miguel Angel )            //
  4. //                                                            //
  5. // Web: http://InfrAngeluX.Sytes.Net/                         //
  6. //                                                            //
  7. // |-> Pueden Distribuir Este Código siempre y cuando         //
  8. // no se eliminen los créditos originales de este código      //
  9. // No importando que sea modificado/editado o engrandecido    //
  10. // o achicado, si es en base a este código                    //
  11. ////////////////////////////////////////////////////////////////
  12.  
  13. #include<iostream>
  14. #include<windows.h>
  15.  
  16. using namespace std;
  17.  
  18. struct tLineas
  19. {
  20.    POINT PuntoIni;
  21.    POINT PuntoEnd;
  22. } *PtLineas;
  23.  
  24.  
  25. HDC     HDC_dest;
  26. RECT    RECT_wmonitor;
  27.  
  28. UINT NumeroAleatorio(UINT *l,UINT *u);
  29. UINT NumeroAleatorio(UINT *l,UINT u);
  30. UINT NumeroAleatorio(UINT l,UINT *u);
  31. UINT NumeroAleatorio(UINT l,UINT u);
  32.  
  33. void Swap(UINT *l,UINT *u);
  34. void Swap(UINT *l,UINT u);
  35. void Swap(UINT l,UINT *u);
  36. void Swap(UINT l,UINT u);
  37.  
  38. VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD);
  39. VOID ProcessMessages();
  40.  
  41. int main()
  42. {
  43.  
  44.    HDC_dest                = GetDC( NULL );
  45.    SetTimer ( NULL , 0 , 10 , (TIMERPROC)TimerProc );
  46.    ProcessMessages();
  47.    ReleaseDC ( NULL , HDC_dest );
  48.    return (1);
  49. }
  50.  
  51. void Swap(UINT *l,UINT *u)
  52. {
  53.    UINT Ptmp = *l;
  54.    *l = *u;
  55.    *u = Ptmp;
  56. }
  57.  
  58. UINT NumeroAleatorio(UINT l,UINT u)
  59. {
  60.    if ( l > u)
  61.        Swap( &l , &u );
  62.    return ( rand()%(u-l+1)+l );
  63. }
  64.  
  65. VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
  66. {
  67.    tLineas     Linea;
  68.    HPEN        hPen;
  69.  
  70.    RECT_wmonitor.bottom    = GetSystemMetrics( 1 );
  71.    RECT_wmonitor.left      = 1;
  72.    RECT_wmonitor.right     = GetSystemMetrics( 0 );
  73.    RECT_wmonitor.top       = 1;
  74.  
  75.    Linea.PuntoIni.x = NumeroAleatorio((UINT)RECT_wmonitor.left,(UINT)RECT_wmonitor.right);
  76.    Linea.PuntoIni.y = NumeroAleatorio((UINT)RECT_wmonitor.top,(UINT)RECT_wmonitor.bottom);
  77.    Linea.PuntoEnd.x = NumeroAleatorio((UINT)RECT_wmonitor.left,(UINT)RECT_wmonitor.right);
  78.    Linea.PuntoEnd.y = NumeroAleatorio((UINT)RECT_wmonitor.top,(UINT)RECT_wmonitor.bottom);
  79.  
  80.    hPen = CreatePen(0, 1, (COLORREF)NumeroAleatorio((UINT)0,(UINT)3000000));
  81.    DeleteObject(SelectObject(HDC_dest, hPen));
  82.    Ellipse (HDC_dest, Linea.PuntoIni.x - 2, Linea.PuntoIni.y - 2, Linea.PuntoIni.x + 2, Linea.PuntoIni.y + 2);
  83.    Ellipse (HDC_dest, Linea.PuntoEnd.x - 2, Linea.PuntoEnd.y - 2, Linea.PuntoEnd.x + 2, Linea.PuntoEnd.y + 2);
  84.    DeleteObject(hPen);
  85.    hPen = CreatePen(0, 1, (COLORREF)NumeroAleatorio((UINT)0,(UINT)3000000));
  86.    DeleteObject(SelectObject(HDC_dest, hPen));
  87.    MoveToEx (HDC_dest, Linea.PuntoIni.x, Linea.PuntoIni.y, NULL);
  88.    LineTo (HDC_dest, Linea.PuntoEnd.x, Linea.PuntoEnd.y);
  89.    DeleteObject (hPen);
  90. }
  91.  
  92. VOID ProcessMessages()
  93. {
  94.    MSG msg;
  95.    while (GetMessage(&msg, NULL, NULL, NULL) != -1)
  96.        DispatchMessage(&msg);
  97. }
  98.  
  99.  

Temibles Lunas!¡.
66  Programación / Programación C/C++ / Como Linkear? ... QT en: 25 Noviembre 2010, 08:11 am
.
Bueno le he estado buscando como salvaje desde hace tiempo a como linkeo en en IDE QT de NOKIA ( mingw ), no le encuentro las opciones para linkear librerias externas... y con el #PRAGMA ... me lo bota me dice que lo ha ignorado y a causa de esto me bota errores... caso omiso en VC++ o en CodeBlocks-10.05( que trae el mismo mingw y aquí no me da errores... pero quiero que funcione en el IDE de QT, ya que me parece muy bueno  :P por su Debugger que trae. ).

Dulces Lunas!¡.
67  Programación / Programación C/C++ / [Solucionado] -> [Ayuda] Saber el indice mayor de una rreglo (Cual sea).. en: 31 Octubre 2010, 02:07 am
.
El siguiente codigo me carga el maximo indice que es 1 cuando yo se que es 2000... cual es mi error?

Código
  1.  
  2. int *arreglo = new int[];
  3. int i = 2000;
  4. arreglo = (int*) malloc (i * sizeof(int));
  5. ::cout << ubound(arreglo) << ::endl;
  6. free(arreglo);
  7. getchar();
  8.  
  9.  

Codigo de Ubound()

Código
  1.  
  2. unsigned long __stdcall ubound (int *arr) {
  3. return(sizeof(arr) / sizeof(arr[0]));
  4. }
  5.  
  6.  

Dulce Lunas!¡.

Lh: No hagas doble post. Utiliza el botón modificar.

.
Despues de mucho probar y probar di con la solucion...

Código
  1.  
  2. #define ubound(arr) ((sizeof(arr))/(sizeof(*arr)))
  3.  
  4.  

Dulce Infierno Lunar!¡.
68  Programación / Programación Visual Basic / [DirectX8] APIS, Estructuras, constantes, Enumeraciones..... en: 27 Octubre 2010, 08:16 am
.
Lo subi porque si lo ponia aqui como publicación sencillamente se pasa de los 100000 caracteres permitidos... ademas de que es muuuuuuy largo...

Descargar APIDirectX 8
http://infrangelux.sytes.net/FileX/index.php?dir=/BlackZeroX/Programacion/vb6/DirectX/8

Dulce Infierno Lunar!¡.
69  Programación / Programación Visual Basic / [Source] Numeros a Letras (De 1 hasta Octillónes Gugol? xS). en: 23 Octubre 2010, 11:26 am
.
El siguiente codigo me costo un Ojo de la cara... es para convertir cualquier Numero a Texto Plano. lo hice por Hobby mas que por nesesidad, espero le saquen provecho!¡.

Como maximo mumero que puede leer son es: 999999999999999999999999999999

Novecientos noventa y nueve Octillónes novecientos noventa y nueve Sextillónes novecientos noventa y nueve Quintillónes novecientos noventa y nueve Cuatrillónes novecientos noventa y nueve Trillones novecientos noventa y nueve Billones novecientos noventa y nueve Mil novecientos noventa y nueve Millones novecientos noventa y nueve Mil novecientos noventa y nueve

Billon          10^12       &lt;--( 5 ).
Trillon         10^18       &lt;--( 4 ).
Cuatrillón      10^24       &lt;--( 3 ).
Quintillón      10^30       &lt;--( 2 ).
Sextillón       10^36       &lt;--( 1 ).
Octillón        10^42       &lt;--( 0 ).
&lt;--Obviamente Los siguientes numeros no los tomaremos en cuenta--&gt;
Gúgol           10^100      &lt;--(-1 ).
Googolplex      10^10^Gúgol &lt;--(-2 ).


http://infrangelux.sytes.net/Blog/index.php?option=com_content&view=article&id=8:arrtnum2string&catid=2:catprocmanager&Itemid=8


Código
  1. '
  2. '   /////////////////////////////////////////////////////////////
  3. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  4. '   //                                                         //
  5. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  6. '   //                                                         //
  7. '   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
  8. '   // no se eliminen los creditos originales de este codigo   //
  9. '   // No importando que sea modificado/editado o engrandecido //
  10. '   // o achicado, si es en base a este codigo                 //
  11. '   /////////////////////////////////////////////////////////////
  12.  
  13. Public Function Number2String(ByVal VInNumber As String) As String
  14. '   //  Meximo  --> 999999999999999999999999999999 ' sección Octillón...
  15. '   //  Billon          10^12       <--( 5 ).
  16. '   //  Trillon         10^18       <--( 4 ).
  17. '   //  Cuatrillón      10^24       <--( 3 ).
  18. '   //  Quintillón      10^30       <--( 2 ).
  19. '   //  Sextillón       10^36       <--( 1 ).
  20. '   //  Octillón        10^42       <--( 0 ).
  21. '   //  <--Obviamente Los siguientes numeros no los tomaremos en cuenta-->
  22. '   //  Gúgol           10^100      <--(-1 ).
  23. '   //  Googolplex      10^10^Gúgol <--(-2 ).
  24. Dim Str_Temp                            As String
  25. Dim Byt_Index                           As Byte
  26. Dim Byt_Digito                          As Byte
  27. Dim Byt_Centena                         As Byte
  28. Dim Byt_Decena                          As Byte
  29. Dim Byt_Unidad                          As Byte
  30. Dim Str_Leyenda                         As String
  31. Dim lng_LenStr                          As Long
  32. Const clng_MaxLen = &H1E
  33.  
  34.    lng_LenStr = Len(VInNumber)
  35.    If lng_LenStr > clng_MaxLen Or lng_LenStr = 0 Then Exit Function
  36.    Str_Temp = String$(clng_MaxLen, "0")
  37.    Mid(Str_Temp, clng_MaxLen - lng_LenStr + 1) = Mid$(VInNumber, 1, lng_LenStr)
  38.  
  39.    For Byt_Index = 1 To clng_MaxLen / 3
  40.  
  41.        Byt_Centena = CByte(Mid$(Str_Temp, Byt_Index * 3 - 2, 1))
  42.        Byt_Decena = CByte(Mid$(Str_Temp, Byt_Index * 3 - 1, 1))
  43.        Byt_Unidad = CByte(Mid$(Str_Temp, Byt_Index * 3, 1))
  44.  
  45.        Select Case Byt_Index
  46.            Case 1
  47.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  48.                    Str_Leyenda = "Octillón "
  49.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  50.                    Str_Leyenda = "Octillónes "
  51.                End If
  52.            Case 2
  53.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  54.                    Str_Leyenda = "Sextillón "
  55.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  56.                    Str_Leyenda = "Sextillónes "
  57.                End If
  58.            Case 3
  59.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  60.                    Str_Leyenda = "Quintillón "
  61.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  62.                    Str_Leyenda = "Quintillónes "
  63.                End If
  64.            Case 4
  65.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  66.                    Str_Leyenda = "Cuatrillón "
  67.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  68.                    Str_Leyenda = "Cuatrillónes "
  69.                End If
  70.            Case 5
  71.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  72.                    Str_Leyenda = "Trillon "
  73.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  74.                    Str_Leyenda = "Trillones "
  75.                End If
  76.            Case 6
  77.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  78.                    Str_Leyenda = "Billón "
  79.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  80.                    Str_Leyenda = "Billones "
  81.                End If
  82.            Case 7
  83.                If Byt_Centena + Byt_Decena + Byt_Unidad >= 1 And Val(Mid$(Str_Temp, 21, 3)) = 0 Then
  84.                    Str_Leyenda = "Mil Millones "
  85.                ElseIf Byt_Centena + Byt_Decena + Byt_Unidad >= 1 Then
  86.                    Str_Leyenda = "Mil "
  87.                End If
  88.            Case 8
  89.                If Byt_Centena + Byt_Decena = 0 And Byt_Unidad = 1 Then
  90.                    Str_Leyenda = "Millón "
  91.                ElseIf Byt_Centena > 0 Or Byt_Decena > 0 Or Byt_Unidad > 1 Then
  92.                    Str_Leyenda = "Millones "
  93.                End If
  94.            Case 9
  95.                If Byt_Centena + Byt_Decena + Byt_Unidad >= 1 Then Str_Leyenda = "Mil "
  96.            Case 10
  97.                If Byt_Centena + Byt_Decena + Byt_Unidad >= 1 Then Str_Leyenda = ""
  98.        End Select
  99.        Number2String = Number2String + Centena(Byt_Unidad, Byt_Decena, Byt_Centena) + Decena(Byt_Unidad, Byt_Decena) + Unidad(Byt_Unidad, Byt_Decena) + Str_Leyenda
  100.        Str_Leyenda = ""
  101.    Next
  102.  
  103. End Function
  104.  
  105. Private Function Centena(ByVal Byt_Uni As Byte, ByVal Byt_Decimal As Byte, ByVal Byt_Centena As Byte) As String
  106.    Select Case Byt_Centena
  107.        Case 1: If Byt_Decimal + Byt_Uni = 0 Then Centena = "cien " Else Centena = "ciento "
  108.        Case 2: Centena = "doscientos "
  109.        Case 3: Centena = "trescientos "
  110.        Case 4: Centena = "cuatrocientos "
  111.        Case 5: Centena = "quinientos "
  112.        Case 6: Centena = "seiscientos "
  113.        Case 7: Centena = "setecientos "
  114.        Case 8: Centena = "ochocientos "
  115.        Case 9: Centena = "novecientos "
  116.    End Select
  117. End Function
  118.  
  119. Private Function Decena(ByVal Byt_Uni As Byte, ByVal Byt_Decimal As Byte) As String
  120.    Select Case Byt_Decimal
  121.        Case 1
  122.            Select Case Byt_Uni
  123.                Case 0: Decena = "diez "
  124.                Case 1: Decena = "once "
  125.                Case 2: Decena = "doce "
  126.                Case 3: Decena = "trece "
  127.                Case 4: Decena = "catorce "
  128.                Case 5: Decena = "quince "
  129.                Case 6 To 9: Decena = "dieci "
  130.            End Select
  131.        Case 2
  132.            If Byt_Uni = 0 Then
  133.                Decena = "veinte "
  134.            ElseIf Byt_Uni > 0 Then
  135.                Decena = "veinti "
  136.            End If
  137.        Case 3: Decena = "treinta "
  138.        Case 4: Decena = "cuarenta "
  139.        Case 5: Decena = "cincuenta "
  140.        Case 6: Decena = "sesenta "
  141.        Case 7: Decena = "setenta "
  142.        Case 8: Decena = "ochenta "
  143.        Case 9: Decena = "noventa "
  144.    End Select
  145.    If Byt_Uni > 0 And Byt_Decimal > 2 Then Decena = Decena + "y "
  146. End Function
  147.  
  148. Private Function Unidad(ByVal Byt_Uni As Byte, ByVal Byt_Decimal As Byte) As String
  149.    If Byt_Decimal <> 1 Then
  150.        Select Case Byt_Uni
  151.            Case 1: Unidad = "un "
  152.            Case 2: Unidad = "dos "
  153.            Case 3: Unidad = "tres "
  154.            Case 4: Unidad = "cuatro "
  155.            Case 5: Unidad = "cinco "
  156.        End Select
  157.    End If
  158.    Select Case Byt_Uni
  159.            Case 6: Unidad = "seis "
  160.            Case 7: Unidad = "siete "
  161.            Case 8: Unidad = "ocho "
  162.            Case 9: Unidad = "nueve "
  163.    End Select
  164. End Function
  165.  
  166.  

Dulce Infierno Lunar!¡.
70  Programación / Programación Visual Basic / [Source] Invertir Ejes del Mouse. en: 20 Octubre 2010, 09:35 am
.
Solo invierte los ejeus del mouse es decir si van para arrba iran para abajo y biceversab es lo mismo si van a la derecha se ira a la izquierda y biceversa.

OJO: Sustitui las Estructuras (PointAPI) por Arrays de Long para reducir mas el codigo xD

http://infrangelux.sytes.net/blog/index.php/component/content/article/5-hooks/2-srcinvertejesmouse.html
http://visual-coders.herobo.com/blog/?p=274

Código
  1.  
  2. '
  3. '   /////////////////////////////////////////////////////////////
  4. '   // Autor:   BlackZeroX ( Ortega Avila Miguel Angel )       //
  5. '   //                                                         //
  6. '   // Web:     http://InfrAngeluX.Sytes.Net/                  //
  7. '   //                                                         //
  8. '   //    |-> Pueden Distribuir Este codigo siempre y cuando   //
  9. '   // no se eliminen los creditos originales de este codigo   //
  10. '   // No importando que sea modificado/editado o engrandecido //
  11. '   // o achicado, si es en base a este codigo                 //
  12. '   /////////////////////////////////////////////////////////////
  13.  
  14. Option Explicit
  15.  
  16. Public Const WH_MOUSE_LL = 14
  17. Public Const WM_MOUSEMOVE = &H200
  18.  
  19. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal Destination As Any, ByVal Source As Any, ByVal Length As Long)
  20.  
  21. Private Declare Function SetWindowsHookEx Lib "user32.dll" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
  22. Private Declare Function CallNextHookEx Lib "user32.dll" (ByVal hHook As Long, ByVal ncode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  23. Private Declare Function UnhookWindowsHookEx Lib "user32.dll" (ByVal hHook As Long) As Long
  24.  
  25. Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  26. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  27.  
  28. Private Ant_PosCur(0 To 1)              As Long
  29. Private lng_HookProc                    As Long
  30. Private Boo_Switch                      As Boolean
  31.  
  32. Public Sub InvertirMouse()
  33.    If lng_HookProc = 0& Then
  34.        Boo_Switch = False
  35.        lng_HookProc = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0)
  36.    End If
  37. End Sub
  38.  
  39. Public Sub DetenerInvertirMouse()
  40.    If lng_HookProc Then
  41.        Call UnhookWindowsHookEx(lng_HookProc)
  42.        lng_HookProc = 0&
  43.    End If
  44. End Sub
  45.  
  46. Private Function MouseProc(ByVal idHook As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
  47. Dim Struc_PT(0 To 1)                    As Long
  48. Dim lng_Index                           As Long
  49.  
  50.    If wParam = WM_MOUSEMOVE And Not Boo_Switch Then
  51.  
  52.        Boo_Switch = True
  53.  
  54.        Call CopyMemory(ByVal VarPtr(Struc_PT(0)), ByVal lParam, 8)
  55.  
  56.        For lng_Index = 0 To 1
  57.            If Not Struc_PT(lng_Index) = Ant_PosCur(lng_Index) _
  58.                And Ant_PosCur(lng_Index) > 0 _
  59.                And Ant_PosCur(lng_Index) <= GetSystemMetrics(lng_Index) Then
  60.                If Struc_PT(lng_Index) < Ant_PosCur(lng_Index) Then
  61.                    Struc_PT(lng_Index) = Struc_PT(lng_Index) + ((Ant_PosCur(lng_Index) - Struc_PT(lng_Index)) * 2)
  62.                ElseIf Struc_PT(lng_Index) > Ant_PosCur(lng_Index) Then
  63.                    Struc_PT(lng_Index) = Struc_PT(lng_Index) - ((Struc_PT(lng_Index) - Ant_PosCur(lng_Index)) * 2)
  64.                End If
  65.            End If
  66.        Next
  67.  
  68.        Call SetCursorPos(Struc_PT(0), Struc_PT(1))
  69.        Call CopyMemory(ByVal VarPtr(Ant_PosCur(0)), ByVal VarPtr(Struc_PT(0)), 8)
  70.        'Call CopyMemory(ByVal lParam, ByVal VarPtr(Struc_PT(0)), 8)    '   //  Esto solo actuyaliza lParam
  71.  
  72.        Boo_Switch = False
  73.        MouseProc = &H1 '   //  CallNextHookEx(lng_HookProc, idHook, wParam, lParam)   '   //  Si dejo pasar ignorara la nueva posición...
  74.    Else
  75.        MouseProc = CallNextHookEx(lng_HookProc, idHook, wParam, lParam)
  76.    End If
  77.  
  78. End Function
  79.  
  80.  

Dulce Infierno Lunar!¡.
Páginas: 1 2 3 4 5 6 [7] 8 9 10 11 12 13 14
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines