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

 

 


Tema destacado:


  Mostrar Mensajes
Páginas: 1 ... 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [29] 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... 254
281  Programación / .NET (C#, VB.NET, ASP) / Re: Quitar el puntero del ratón en pantalla en: 7 Julio 2020, 21:07 pm
Muchísimas gracias-
282  Programación / .NET (C#, VB.NET, ASP) / Lograr hacer bien el programa en: 7 Julio 2020, 19:58 pm
Hola:

Este código funciona a medias. Más bien, no logro situarlo. Está escrito en consola C#.

Lo que hace el programa:

Se usa solo las teclas flechas del teclado y la tecla Enter.

El programa empieza así;


Como puedes ver arriba, puedes escribir con las flechas arriba y abajo letras para poner un nombre. Por ejemplo, voy a poner Hola amigo. Lo puedes ver en la captura de abajo.



Pulsa Enter.
Se muestra el > al lado de ATRÁS. Tal como muestra abajo.


Lo que debe hace en esta parte indicado en la imagen de arriba es:
1. Si toco las flechas del teclado izquierda y derecha, me señala con > Atrás o en GUARDAR.
2. Si pulso las flecha arriba o abajo, puedes volver a editar la palabra "Hola amigo", puedes corregir o escribir otra cosa.
3. Si pulsas Enter donde estabas escribiendo "Hola amigo", vuelves en ATRÁS con el >.
4. Estando en > ATRÁS, si pulsas Enter, muestra un mensaje tal como muestra en la captura de abajo y el programa se acaba ahí.



El problema que no me funciona esta parte y la que voy a indicar ahora tampoco me funciona.
Si estoy en > ATRÁS, al pulsas las flechas derecha o izquierda, debo estar ya en > GUARDAR.

Precisamente no me sale.

A parte de esto, si pulsas Enter cuando estés en > GUARDAR. Se queda guardado el texto "Hola amigo" guardado en una variable que en este caso se llama static string guardarNombre = "";

Se tiene que mostrar la imagen de abajo.


Y se acaba el programa.

Me perdí. Alguna idea como se programa esto.

Código C#:
Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LCD_nombre_archivo_consola_08
  8. {
  9.    class Program
  10.    {
  11.        static string guardarNombre = "";
  12.        static int coordenadaX = 0;
  13.        private static ConsoleKey tecla;
  14.  
  15.        // Caracteres de este array.
  16.        static readonly char[] roALFANUMERICO = new char[]
  17.        {
  18.            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P',
  19.            'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
  20.            'i', 'j', 'k', 'l', 'm', 'n', 'ñ', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y',
  21.            'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','.', ',', '-', '_', ':', ';',
  22.            '¿', '?', '(', ')', '[', ']', '{', '}','=', '$','&', '"', ' '
  23.        };
  24.  
  25.        // Dirección del carácter del array. El 80 presenta al espacio del array roALFANUMERICO.
  26.        static readonly int[] roINDICE_ARRAY = new int[]
  27.        {
  28.            80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80
  29.        };
  30.  
  31.        private static readonly string[] roTEXTO = new string[] { "ATRÁS", "GUARDAR" };
  32.  
  33.        static int index = 0;
  34.        static void Main(string[] args)
  35.        {
  36.            // Título de la pantalla.
  37.            Console.Title = "Cambiar nombre";
  38.  
  39.            Inicio();
  40.        }
  41.  
  42.        #region Inico.
  43.        private static void Inicio()
  44.        {
  45.            // Tamaño de la ventana.
  46.            Console.SetWindowSize(20, 5); // X
  47.  
  48.            // Fondo verde, azul, gris.
  49.            Console.BackgroundColor = ConsoleColor.Gray;
  50.  
  51.            // Letras negras, blanco, negro.
  52.            Console.ForegroundColor = ConsoleColor.Black;
  53.  
  54.            // Limpiar pantalla.
  55.            Console.Clear();
  56.  
  57.            Console.SetCursorPosition(0, 0);
  58.            Console.Write("Nombre del relé 1:  ");
  59.            Console.SetCursorPosition(0, 1);
  60.            //Console.Write("AAAAAAAAAAAAAAAA");
  61.  
  62.            // Recorre todo el índice del array y el de los datos alfanumérico
  63.            // y los rellena.
  64.            for (int i = 0; i < roINDICE_ARRAY.Length; i++)
  65.            {
  66.                Console.Write(roALFANUMERICO[roINDICE_ARRAY[i]]);
  67.            }
  68.  
  69.            Console.SetCursorPosition(2, 3);
  70.            Console.Write(roTEXTO[0]); // ATRÁS.
  71.            Console.SetCursorPosition(12, 3);
  72.            Console.Write(roTEXTO[1]); // GUARDAR.
  73.  
  74.            while (true)
  75.            {
  76.                Console.SetCursorPosition(coordenadaX, 1);
  77.  
  78.                // Almacena cualquier tecla pulsada en la variable key.
  79.                tecla = Console.ReadKey(true).Key;
  80.                switch (tecla)
  81.                {
  82.                    case ConsoleKey.RightArrow:
  83.                        if (coordenadaX < 15)
  84.                        {
  85.                            coordenadaX++;
  86.                        }
  87.                        break;
  88.  
  89.                    case ConsoleKey.LeftArrow:
  90.                        if (coordenadaX > 0)
  91.                        {
  92.                            coordenadaX--;
  93.                        }
  94.                        break;
  95.  
  96.                    case ConsoleKey.UpArrow:
  97.                        roINDICE_ARRAY[coordenadaX]++;
  98.                        if (roINDICE_ARRAY[coordenadaX] >= roALFANUMERICO.Length)
  99.                        {
  100.                            roINDICE_ARRAY[coordenadaX] = 0;
  101.                        }
  102.                        Console.Write(roALFANUMERICO[roINDICE_ARRAY[coordenadaX]]);
  103.                        break;
  104.  
  105.                    case ConsoleKey.DownArrow:
  106.                        roINDICE_ARRAY[coordenadaX]--;
  107.                        if (roINDICE_ARRAY[coordenadaX] < 0)
  108.                        {
  109.                            roINDICE_ARRAY[coordenadaX] = roALFANUMERICO.Length - 1;
  110.                        }
  111.                        Console.Write(roALFANUMERICO[roINDICE_ARRAY[coordenadaX]]);
  112.                        break;
  113.  
  114.                    case ConsoleKey.Enter:
  115.                        Console.SetCursorPosition(1, 3);
  116.                        Console.CursorVisible = false;
  117.                        Console.Write(">");
  118.  
  119.                        while (true)
  120.                        {
  121.                            tecla = Console.ReadKey(true).Key;
  122.  
  123.                            switch (tecla)
  124.                            {
  125.                                case ConsoleKey.RightArrow:
  126.                                case ConsoleKey.LeftArrow:
  127.                                    index = 1 - index;
  128.                                    break;
  129.  
  130.                                case ConsoleKey.UpArrow:
  131.                                case ConsoleKey.DownArrow:
  132.                                    Console.SetCursorPosition(coordenadaX, 1);
  133.                                    break;
  134.  
  135.                                case ConsoleKey.Enter:
  136.  
  137.                                    break;
  138.                            }
  139.  
  140.                            for (int a = 0; a < 2; a++)
  141.                            {
  142.                                Console.SetCursorPosition(1 + (10 * a), 3);
  143.                                if (a == index)
  144.                                {
  145.                                    Console.Write(">");
  146.                                }
  147.                                else
  148.                                {
  149.                                    Console.Write(" ");
  150.                                }
  151.                            }
  152.  
  153.                            if (index == 0)  // se pulsó Atrás
  154.                            {
  155.                                Atras();
  156.                                //break;  // vuelve a la edición de letras
  157.                            }
  158.  
  159.                            if (index == 1)  // se pulsó Guardar
  160.                            {
  161.                                Guardar();
  162.                            }
  163.                        }
  164.                }
  165.            }
  166.        }
  167.        #endregion
  168.  
  169.        private static void Atras()
  170.        {
  171.            Console.Clear();
  172.            Console.SetCursorPosition(0, 1);
  173.            Console.Write("HAS PULSADO ATRÁS   ");
  174.            Console.ReadKey(); // Pulse cualquier tecla para salir.
  175.        }
  176.  
  177.        private static void Guardar()
  178.        {
  179.            Console.Clear();
  180.            Console.SetCursorPosition(0, 1);
  181.            Console.Write("HAS GUARDADO       ");
  182.            for (int a = 0; a < roINDICE_ARRAY.Length; a++)
  183.            {
  184.                guardarNombre += roALFANUMERICO[roINDICE_ARRAY[a]].ToString();
  185.            }
  186.            Console.SetCursorPosition(0, 2);
  187.            Console.Write(guardarNombre);
  188.        }
  189.    }
  190. }
  191.  

Gracias.
283  Programación / Programación C/C++ / Mejorar el código en C++ nativo en: 7 Julio 2020, 15:05 pm
Buenas:

Tengo este código en C++ nativo, en el cual aún no logro que funcione tal como lo quiero. Lo que hace este código es, que si pulsas la letra A o a, se abre la bandeja del lector del disco, si pulsas C o c se cierra.

Código C++ nativo:
Código
  1. #include <iostream>
  2. #include <windows.h> // Para mostrar texto en el título de la ventana.
  3.  
  4. using namespace std;
  5. //using std::cout;
  6. //using std::cin;
  7.  
  8. // Función posición del cursor.
  9. void gotoxy(int x, int y)
  10. {
  11. HANDLE hcon;
  12. hcon = GetStdHandle(STD_OUTPUT_HANDLE);
  13. COORD dwPos;
  14. dwPos.X = x;
  15. dwPos.Y = y;
  16. SetConsoleCursorPosition(hcon, dwPos);
  17. }
  18.  
  19. int main(void)
  20. {
  21. // Mostrar caracteres correctamente en pantalla y título de la ventana.
  22. SetConsoleOutputCP(65001);
  23. wchar_t titulo[128];
  24. MultiByteToWideChar(CP_UTF8, 0, "Consola C++ nativo 2019.", -1, titulo, 128);
  25. SetConsoleTitle(titulo);
  26.  
  27. // Variable.
  28. char entrada[] = "\0"; // Guarda A, a, C, y c tipo string que introduces desde la consola.
  29.  
  30. // Tamaño de la pantalla. Se cambia en los dos últimos dígitos.
  31. SMALL_RECT r = { 0, 0, 29, 8 }; // X = 29, Y = 8.
  32. SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &r);
  33.  
  34. // Ocultar cursor.
  35. CONSOLE_CURSOR_INFO cci;
  36. GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
  37. cci.bVisible = 0; // 0 oculta. 1 muestra cursor.
  38. SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
  39.  
  40. // Muestra textos en pantalla.
  41. cout << "Control bandeja del lector: " << endl << endl;
  42. cout << "A - Abrir bandeja." << endl;
  43. cout << "C - Cerrar bandeja." << endl;
  44. cout << "===========================" << endl;
  45.  
  46. while (true)
  47. {
  48.  
  49.  
  50. // Aquí introduces letras A, a, C y c.
  51. cin >> entrada;
  52. cout << "\n" << endl;
  53.  
  54. // Abrir bandeja.
  55. if ((entrada[0] == 'a') || (entrada[0] == 'A'))
  56. {
  57. // Posición del cursor.
  58. gotoxy(0, 6);
  59. cout << "Abriendo..." << endl << endl; // Muestra texto en pantalla.
  60. mciSendString(L"set cdaudio door open", nullptr, 0, nullptr);
  61. gotoxy(0, 6);
  62. cout << "Abierto.   " << endl << endl; // Muestra texto en pantalla.
  63. }
  64.  
  65. // Cerrar bandeja.
  66. else if ((entrada[0] == 'c') || (entrada[0] == 'C'))
  67. {
  68. gotoxy(0, 6);
  69. cout << "Cerrando..." << endl << endl; // Muestra texto en pantalla.
  70. mciSendString(L"set cdaudio door closed", nullptr, 0, nullptr);
  71. gotoxy(0, 6);
  72. cout << "Cerrado.   " << endl << endl; // Muestra texto en pantalla.
  73. }
  74.  
  75. // Si haz pulsado otro caracter distinto de A, C, a y c aparece
  76. else
  77. {
  78. gotoxy(0, 6);
  79. // este mensaje.
  80. cout << "Solo pulsa A o C." << endl << endl;
  81. }
  82.  
  83. }
  84. return EXIT_SUCCESS;
  85. }

En el código de C# si funciona tal como lo quiero, pongo un ejemplo abajo.

Código C#:
Código
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Text;
  4. namespace Bandeja_consola_cs
  5. {
  6.    class Program
  7.    {
  8.        [DllImport("winmm.dll")]
  9.        public static extern Int32 mciSendString(string lpstrCommand, StringBuilder lpstrReturnString,
  10.        int uReturnLength, IntPtr hwndCallback);
  11.        public static StringBuilder rt = new StringBuilder(127);
  12.        public static void DoEventsAbriendo()
  13.        {
  14.            Console.SetCursorPosition(0, 6);
  15.            Console.Write("Abriendo...");
  16.        }
  17.        public static void DoEventsCerrando()
  18.        {
  19.            Console.SetCursorPosition(0, 6);
  20.            Console.Write("Cerrando...");
  21.        }
  22.        static void Main(string[] args)
  23.        {
  24.            // Título de la ventana.
  25.            Console.Title = "Consola C# 2017";
  26.            // Tamaño ventana consola.
  27.            Console.WindowWidth = 29; // X. Ancho.
  28.            Console.WindowHeight = 8; // Y. Alto.
  29.            // Cursor invisible.
  30.            Console.CursorVisible = false;
  31.            // Posición del mansaje en la ventana.
  32.            Console.SetCursorPosition(0, 0);
  33.            Console.Write(@"Control bandeja del lector:
  34. A - Abrir bandeja.
  35. C - Cerrar bandeja.
  36. ===========================");
  37.            ConsoleKey key;
  38.            //Console.CursorVisible = false;
  39.            do
  40.            {
  41.                key = Console.ReadKey(true).Key;
  42.                string mensaje = string.Empty;
  43.                //Asignamos la tecla presionada por el usuario
  44.                switch (key)
  45.                {
  46.                    case ConsoleKey.A:
  47.                        // mensaje = "Abriendo...";
  48.                        Console.SetCursorPosition(0, 6);
  49.                        DoEventsAbriendo();
  50.                        mciSendString("set CDAudio door open", rt, 127, IntPtr.Zero);
  51.                        mensaje = "Abierto.   ";
  52.                        break;
  53.                    case ConsoleKey.C:
  54.                        // mensaje = "Cerrando...";
  55.                        Console.SetCursorPosition(0, 6);
  56.                        DoEventsCerrando();
  57.                        mciSendString("set CDAudio door closed", rt, 127, IntPtr.Zero);
  58.                        mensaje = "Cerrado.   ";
  59.                        break;
  60.                }
  61.                Console.SetCursorPosition(0, 6);
  62.                Console.Write(" ");
  63.                Console.SetCursorPosition(0, 6);
  64.                Console.Write(mensaje);
  65.            }
  66.            while (key != ConsoleKey.Escape);
  67.        }
  68.    }
  69. }

Lo que hace el código C# exactamente todos estos comportamientos.

1. Te pregunta si pulsas teclas, por ejemplo la A para abrir la bandeja y C para cerrar, independientemente si es mayúscula o no. Funciona todo.

2. Desde que pulse cualquier letra del teclado que non corresponda la A, a, C y la c, el programa no hace nada, como debe ser.

3. Si quiero abrir la bandeja del lector y pulso la tecla A, desde que pulse la tecla, se abre la bandeja.

4. Desde que pulse la tecla A, dice el mensaje "Abriendo...", cuando esté abierto la bandeja del todo, dice "Abierto.".

Lo que hace el código C++ nativo y no quiero.


1. Pulso la tecla A o la a, y aparece escrito en la consola.

2. Luego tengo que pulsar la tecla Enter para que la letra A o la a, funcione el comando. Entonces ya puede abrir la bandeja y mostrar los mensajes Abriendo... y Aabierto.

La pregunta es. ¿Se puede corregir este comportamiento de C++ nativo que sea igual al ejemplo de C#?

Saludos.
284  Programación / Programación C/C++ / Re: Prueba leer la dll nativo con interfaz C++ nativo en: 7 Julio 2020, 15:02 pm
Lo estoy haciendo. Lo que a veces me adelanto, ajjajaj.

285  Programación / Programación C/C++ / Re: MEMORIA SIN LIBERAR C++ en: 7 Julio 2020, 14:41 pm
Gracias por la explicación muy desarrollada.  ;-)
286  Programación / Programación C/C++ / Re: Prueba leer la dll nativo con interfaz C++ nativo en: 7 Julio 2020, 14:39 pm
Voy hacerlo de otra manera. Por fin funciona.

Quito de la dll este código:
Código:
float __stdcall ResultadoPorcentaje(float resultadoPorcentaje, float nivelAgua, float altura)
{
    return resultadoPorcentaje = nivelAgua * (100 / altura);
}

Este código de abajo lo pongo en la interfaz.
Código:
resultadoPorcentaje = nivelAgua * (100 / altura);

La dll si compila.
Código:
#include "pch.h"

extern "C"
{
    __declspec(dllexport) LPTSTR __stdcall Mensaje();
    __declspec(dllexport) float __stdcall Volumen(float, float, float, float);
    __declspec(dllexport) float __stdcall Litros(float, float);
    //__declspec(dllexport) float __stdcall ResultadoPorcentaje(float, float, float);
    __declspec(dllexport) float __stdcall VolumenLitros(float, float, float, float, float);
    __declspec(dllexport) float __stdcall CantidadTubosLitros(float, float, float);
    __declspec(dllexport) float __stdcall TotalLitros(float, float, float);
};

// Mensaje.
LPTSTR __stdcall Mensaje() { return LPTSTR(L"Hola. Saludos desde la dll. Versión: 1.0.0"); }

// Cálculo volumen.
float __stdcall Volumen(float volumen, float PI, float radio, float altura)
{
    return volumen = PI * (radio * radio) * altura;
}

// Cálculo litros.
float __stdcall Litros(float litros, float volumen)
{
    return litros = volumen * 1000;
}

// Cálculo porcentaje en % del litro de agua.
//float __stdcall ResultadoPorcentaje(float resultadoPorcentaje, float nivelAgua, float altura)
//{
//    return resultadoPorcentaje = nivelAgua * (100 / altura);
//}

// Cálculo litros de agua.
float __stdcall VolumenLitros(float volumenLitros, float PI, float radio, float nivelAgua, float resultadoLitros)
{
    return volumenLitros = PI * (radio * radio) * nivelAgua;
    return resultadoLitros = volumenLitros * 1000;
}

// Cálculo litros por cantidad de tubos
float __stdcall CantidadTubosLitros(float cantidadTubosLitros, float cantidadTubos, float resultadoLitros)
{
    return cantidadTubosLitros = cantidadTubos * resultadoLitros;
}

// Cálculo cantidad de litros con total de tubos.
float __stdcall TotalLitros(float totalLitros, float litros, float cantidadTubos)
{
    return totalLitros = litros * cantidadTubos;
}

Archivo .def lo dejo así:
Código:
LIBRARY DLL_al_poder
EXPORTS
Mensaje
Volumen
Litros
VolumenLitros
CantidadTubosLitros
TotalLitros

Código completo en la interfaz.
Código:
#include <iostream>
#include <windows.h> // Para mostrar texto en el título de la ventana.

using namespace std;
//using std::cout;
//using std::cin;

// Función posición del cursor.
void gotoxy(int x, int y)
{
HANDLE hcon;
hcon = GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwPos;
dwPos.X = x;
dwPos.Y = y;
SetConsoleCursorPosition(hcon, dwPos);
}

// Definir estas funciones.
typedef LPTSTR(__stdcall* Mensaje)();
typedef float(__stdcall* Volumen)(float, float, float, float);
typedef float(__stdcall* Litros)(float, float);
//typedef float(__stdcall* ResultadoPorcentaje)(float, float, float);
typedef float(__stdcall* VolumenLitros)(float, float, float, float, float);
typedef float(__stdcall* CantidadTubosLitros)(float, float, float);
typedef float(__stdcall* TotalLitros)(float, float, float);

// Variables.
const double Pi = 3.14;
float radio;
float altura;
//double volumen;
//double litros;
float nivelAgua;
float resultadoPorcentaje;
//double resultadoLitros;
//double volumenLitros;
float mitadBarra;
float cantidadTubos;
//double cantidadTubosLitros;
//double totalLitros;

int main(void)
{
// Importar dll.
HINSTANCE hDLL = 0;
Mensaje mensaje;
Volumen volumen;
Litros litros;
//ResultadoPorcentaje resultadoPorcentaje;
VolumenLitros volumenLitros;
CantidadTubosLitros cantidadTubosLitros;
TotalLitros totalLitros;

hDLL = LoadLibrary(L"C:\\Users\\Meta\\Documents\\Visual Studio 2019\\Projects\\DLL_y_interfaz_nativo_01_cpp\\Debug\\DLL_y_interfaz_nativo_01_cpp.dll");
mensaje = (Mensaje)GetProcAddress(hDLL, "Mensaje");
volumen = (Volumen)GetProcAddress(hDLL, "Volumen");
litros = (Litros)GetProcAddress(hDLL, "Litros");
//resultadoPorcentaje = (ResultadoPorcentaje)GetProcAddress(hDLL, "ResultadoPorcentaje");
volumenLitros = (VolumenLitros)GetProcAddress(hDLL, "VolumenLitros");
cantidadTubosLitros = (CantidadTubosLitros)GetProcAddress(hDLL, "CantidadTubosLitros");
totalLitros = (TotalLitros)GetProcAddress(hDLL, "totalLitros");

// Mostrar caracteres correctamente en pantalla y título de la ventana.
SetConsoleOutputCP(65001);
wchar_t titulo[128];
MultiByteToWideChar(CP_UTF8, 0, "Interfaz leer dll C++ nativo 2019.", -1, titulo, 128);
SetConsoleTitle(titulo);

// Tamaño de la pantalla. Se cambia en los dos últimos dígitos.
SMALL_RECT r = { 0, 0, 49, 35 }; // X = 49, Y = 9.
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &r);

// Ocultar cursor.
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
cci.bVisible = 1; // 0 oculta cursor. 1 muestra cursor.
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);

// Posición del cursor.
gotoxy(3, 2);

// Mostrar textos en pantalla.
wcout << mensaje() << endl;
gotoxy(0, 4);
cout << "Introduce el radio en m.: ";
cin >> radio;
cout << "Introduce la altura en m. ";
cin >> altura;
cout << "Introduce altura del agua. Máximo es de " << altura << ":";
cin >> nivelAgua;
cout << "Introduces cantidad de tubos: ";
cin >> cantidadTubos;

// ########## Dibujo de la barra.
cout << "\n";
cout << ("0 %                     50 %                   100 %") << endl;
cout << ("┌────────────────────────┬───────────────────────┐") << endl;

// Mitad de la barra para que no sea muy grande en la pantalla.
resultadoPorcentaje = nivelAgua * (100 / altura);

if (mitadBarra > 50)
{
mitadBarra = 50;
}

// Rellenar la barra.
for (float i = 1; i <= mitadBarra; i++)
{
cout << ("█");
}

// Si llega a 100 se pone el # en rojo.

if (resultadoPorcentaje > 100)
{
cout << ("#");
}
//########## Fin dibujo de la barra.

// Pisición del texto a mostrar.
gotoxy(0, 11);

cout << "\nPorcentaje: " << resultadoPorcentaje << " %.";


FreeLibrary(hDLL);

// Esperando pulsar Enter para salir.
cin.get();
return 0;
}



No se como se quita esos sobrantes textos que aparece al final, pero bueno, por fin ya se puede leer la dichoza dll.

Hay otra cosa que quiero hacer pero no me sale y hago esta pregunta.

Todos los cálculos matemáticos los quiero en la dll, como este de abajo, que al final tuve que ponerlo en la interfaz.
Código:
	// Mitad de la barra para que no sea muy grande en la pantalla.
resultadoPorcentaje = nivelAgua * (100 / altura);

¿Hay posibilidad de ponerlo en la dll o no?

Saludos.
287  Programación / .NET (C#, VB.NET, ASP) / Quitar el puntero del ratón en pantalla en: 7 Julio 2020, 14:13 pm
Buenas:

Usando Windows Form C# hice este código.
Código
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace prueba_cs
  12. {
  13.    public partial class Form1 : Form
  14.    {
  15.        public Form1()
  16.        {
  17.            InitializeComponent();
  18.            timer1.Start();
  19.        }
  20.  
  21.  
  22.  
  23.        void cambioColor()
  24.        {
  25.            this.BackColor = Color.Black; // Formulario negro.
  26.            //this.ForeColor = Color.White; // Cambia textos en blanco.
  27.            label1.ForeColor = Color.White;
  28.        }
  29.  
  30.        void cambioColor2()
  31.        {
  32.            this.BackColor = Color.White; // Formulario blanco.
  33.            //this.ForeColor = Color.Black; // Cambia textos en negro.
  34.            label1.ForeColor = Color.Black;
  35.        }
  36.  
  37.        private void timer1_Tick(object sender, EventArgs e)
  38.        {
  39.            cambioColor();
  40.            timer1.Stop();
  41.            timer2.Start();
  42.        }
  43.  
  44.        private void timer2_Tick(object sender, EventArgs e)
  45.        {
  46.            cambioColor2();
  47.            timer2.Stop();
  48.            timer1.Start();
  49.        }
  50.    }
  51. }

Se sale del formulario pulsando Alt + F4. Quiero que se desactive el puntero del ratón en el momento que cree este formulario.

Gracias.
288  Programación / Programación C/C++ / Re: Prueba leer la dll nativo con interfaz C++ nativo en: 6 Julio 2020, 18:51 pm
Entonces este cálculo que me hace falta debe estar en la interfaz, no en la dll.

Código
  1. mitadBarra = resultadoPorcentaje / 2;
289  Programación / Programación C/C++ / Re: MEMORIA SIN LIBERAR C++ en: 6 Julio 2020, 16:47 pm
¿Cómo puedes saber que no se liberó memoria y cuando se se liberó?
290  Programación / Programación C/C++ / Re: Prueba leer la dll nativo con interfaz C++ nativo en: 6 Julio 2020, 16:43 pm
¿Qué iba a cambiar ahí exactamente?
Páginas: 1 ... 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 [29] 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ... 254
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines