• Martes 26 de Mayo de 2026, 00:49

Mostrar Mensajes

Esta sección te permite ver todos los posts escritos por este usuario. Ten en cuenta que sólo puedes ver los posts escritos en zonas a las que tienes acceso en este momento.


Mensajes - touch

Páginas: [1]
1
C++ Builder / Re: Error
« en: Lunes 21 de Febrero de 2005, 16:03 »
Usa ShowMessage antes de aaceder al indice par ver que pasa

2
C++ Builder / Re: Dbgrid C++ Builder
« en: Lunes 21 de Febrero de 2005, 15:43 »
Aborda el enfoque desde orto punto de vista, deja dgEditing=true, y activa y desactiva ReadOnly o Enable segu nsea lo que necesitas

3
C++ Builder / Re: Enlazar Tablas
« en: Lunes 21 de Febrero de 2005, 15:37 »
Si usas el los objetos TTable usasr las propidas master u detail

De preferencia es mejor usar secuencias SQL puras con el objeto  TQuery

4
C++ Builder / Re: Ciclo While O Do C++ Builder
« en: Lunes 21 de Febrero de 2005, 15:35 »
Si te refieres  a salir del ciclo antes de que se cumpla la condicion la respuesta es break;

Si quieres que el SO haga otra cosa, el enfoque es incorecto, debeiar metre el ciclo en un hilo par que se ejecute como una aplicacion separada y continuas haciedo lo que quieras con el prograam principal

5
C++ Builder / Re: Alguien Que Sepa C++ Builder
« en: Lunes 21 de Febrero de 2005, 15:34 »
Es el post mas estupido y arrogante que he visto entre todos lo foros

6
C++ Builder / Re: Leer Desde El Puerto Paralelo
« en: Miércoles 9 de Febrero de 2005, 02:42 »
click aqui

espero te sirva

7
Visual C++ / Re: Cómo Mandar Información A Lcd En Visual C++
« en: Lunes 7 de Febrero de 2005, 05:30 »
En realidad yo uso C++ Builder, pero analizando tu pregunta inicial , entendi que querias enviar datos a una pantalla LCD (torreta, DISPLAY DE CLIENTE etc) que esta en  el puerto paralelo.

Te envio la rutina que hice en C++ Builder para enviar datos a la torreta (lcd)
ejemplo de uso:

* DEBES DEFINIR UNA IMPRESORA MODO TEXTO , LLAMADA (EN ESTE CASO) TORRERA DIREGIDA CONECTADA AL PUERTO. COM1, LPT1 etc etc

Otro problema que tendras es que la clase AnsiString no esta definida en VC, asi que  debes modificar la funcion par que te funcione. Desgracidamente no soy experto en Micro$oft por eso no puedo traducirla)


Código: Text
  1.  
  2. // Enviar Datos a la Torreta
  3. void Torreta(AnsiString vLinea)
  4. {
  5.  
  6. vLinea=vLinea+"                     ";
  7. vLinea=vLinea.SubString(1,20);
  8. // Falta Parametrizar
  9. String printerPort = "TORRETA"; // o aqui pon String printerPort = "LPT1:"
  10. HANDLE printerHandle = 0;
  11. PRINTER_DEFAULTS printerOptions;
  12. printerOptions.pDatatype = "RAW";
  13. printerOptions.pDevMode = NULL;
  14. printerOptions.DesiredAccess = PRINTER_ACCESS_USE;
  15. try
  16. {
  17.         if (!OpenPrinter(printerPort.c_str(), &printerHandle, NULL))  throw "Error when opening printer port";
  18.         DOC_INFO_1 docInfo;
  19.         docInfo.pDocName = "TORRETA";
  20.         docInfo.pOutputFile = NULL;
  21.         docInfo.pDatatype = "RAW";
  22.         if (!StartDocPrinter(printerHandle, 1, (LPBYTE)&docInfo)) throw "Error when starting printing";
  23.         if (!StartPagePrinter(printerHandle)) throw "Error when starting a new page";
  24.          char* lineToPrint = "";
  25.          DWORD numBytesWritten;
  26.          //nsiString vClear=12; // CLR de la torreta
  27.          /*lineToPrint="\x12"; //vClear.c_str(); //
  28.          BOOL correct = WritePrinter(printerHandle, (LPVOID*)lineToPrint,
  29.          strlen(lineToPrint), &numBytesWritten);
  30.          */
  31.          lineToPrint=vLinea.c_str(); // convertir linea a cadena
  32.          bool correct = WritePrinter(printerHandle, (LPVOID*)lineToPrint,
  33.          strlen(lineToPrint), &numBytesWritten);
  34.          if (!correct || numBytesWritten < DWORD(strlen(lineToPrint))) throw "Error al imprimir la linea";
  35.          if (!EndDocPrinter(printerHandle)) throw "Error al finalizr la impresion";
  36.         ClosePrinter(printerHandle);
  37. }
  38. catch (...)
  39. {
  40. // NO se pudo enviar a la torreta
  41. }
  42.  
  43.  
  44. }
  45.  
  46.  
  47.  

8
C++ Builder / Re: Combobox Editable
« en: Lunes 7 de Febrero de 2005, 00:20 »
Tienes 3 opciones:

1)Guarda los items en una base de datos (paradox o dbase)
2) genera un archivo de texto donde estenlos item y al iniciar el prog los lees
3) Usa el objeto TIni , para geenar un archivo ini (parecido al paso 2,pero ya encapsulado)

Suerte

9
C++ Builder / Re: Ponerle Precision A Un Float
« en: Lunes 7 de Febrero de 2005, 00:18 »
TuLabel->Caption=FloatToStrF(fNumero,ffFixed,5,1);

10
C++ Builder / Re: Timage Que Me Está Piiiiiiiiiiiiiii
« en: Lunes 7 de Febrero de 2005, 00:15 »
No estoyoen mi maquina, peo ya lo hice y es mas o menos asi:

TImage->Assign(NULL);

11
C++ Builder / Re: Dar De Baja Un Registro De Mysql
« en: Lunes 7 de Febrero de 2005, 00:14 »
Mira, lidie con ese error por casi 1 mes, verifica el tipo de campos que tienes definidos, seguro que tienes un FLOAT

antes de guardar datos que en builder esten en float, debes "limitar" el uso de decimales y/o usar en lugar de float, double

El problema es que MYSQL cuando actualizas usa todos los campos para validar la opreraciojn y por alguna razon si tienes mas decimales de los manejados pr el BDE, no funciona.

Por otro lado el codigo:

Ttable1->Edit();
Ttable1->Delete();
//Ttable1->Post(); <----esto no va

12
C++ Builder / Re: Crear Grafico
« en: Sábado 29 de Enero de 2005, 18:33 »
Usa Tchart

13
C++ Builder / Re: Capturar Imagen Videocamara
« en: Sábado 29 de Enero de 2005, 18:23 »
Clase para captura de video con webcam , me funciona muy bien

Código: Text
  1.  
  2. //---------------------------------------------------------------------------
  3. /*
  4.  * Copyright (c) Allan Petersen, 2001.
  5.  * This is a tutorial for a simple capture system using the win32 api
  6.  * for accessing your webcam
  7.  *
  8.  * (c) Copyright 2001, Allan Petersen
  9.  * ALL RIGHTS RESERVED
  10.  * Permission to use, copy, modify, and distribute this software for
  11.  * any purpose and without fee is hereby granted, provided that the above
  12.  * copyright notice appear in all copies and that both the copyright notice
  13.  * and this permission notice appear in supporting documentation, and that
  14.  * the name of Allan Petersen not be used in advertising
  15.  * or publicity pertaining to distribution of the software without specific,
  16.  * written prior permission.
  17.  *
  18.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU &#34;AS-IS&#34;
  19.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  20.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  21.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL ALLAN
  22.  * PETERSEN BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  23.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  24.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  25.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  26.  * THIRD PARTIES, WHETHER OR NOT ALLAN PETERSEN HAS BEEN
  27.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  28.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  29.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  30.  *
  31.  * Contact Allan Petersen at &#60;support@allanpetersen.com&#62; or visit
  32.  * www.allanpetersen.com
  33.  *
  34.  */
  35. //---------------------------------------------------------------------------
  36.  
  37. #include &#60;vcl.h&#62;
  38. #pragma hdrstop
  39.  
  40. #include &#60;stdio.h&#62;
  41. #include &#34;c_cap.h&#34;
  42.  
  43. //---------------------------------------------------------------------------
  44. #pragma package(smart_init)
  45. //---------------------------------------------------------------------------
  46. LRESULT CALLBACK fcb(HWND w, LPVIDEOHDR h)
  47. {
  48.         // En 'h-&#62;lpData' tenemos los datos del fotograma
  49.         // antes de ser visualizado. En este ejemplo a 320x240 24bits,
  50.         // por lo tanto la información de cada pixel estara del siguiente
  51.         // modo BLUE-GREEN-RED.... o sea, 3 bytes por cada pixel
  52.         // En 'h-&#62;dwBytesUsed' tenemos la cantidad de bytes de la imagen
  53.         // Para este ejemplo, como demostración vamos a poner la imagen
  54.         // en negativo. Aquí podriamos tanto modificar la imagen antes
  55.         // de ser vista o bien comprimir estos datos y enviarlos por la red...
  56.    typedef struct {BYTE b,g,r;} PIXEL;
  57.     char *DatosDib;
  58.     DatosDib=new char[h-&#62;dwBytesUsed];
  59.     int j=0;
  60.     for (DWORD i=0; i&#60;h-&#62;dwBytesUsed/3; i++)
  61.     {
  62.  
  63.         PIXEL *pixel = &((PIXEL*)h-&#62;lpData)[i];
  64.        /* pixel-&#62;r = ~pixel-&#62;r;
  65.         pixel-&#62;g = ~pixel-&#62;g;
  66.         pixel-&#62;b = ~pixel-&#62;b; */
  67.         DatosDib[j]=pixel-&#62;r;        j++;
  68.         DatosDib[j]=pixel-&#62;g;        j++;
  69.         DatosDib[j]=pixel-&#62;b;        j++;
  70.     }
  71. //    frmTomarFoto-&#62;Image1-&#62;Assig(h-&#62;lpdata);
  72.  
  73.         // devolvemos TRUE para que la función siga capturando mas fotogramas
  74.   return TRUE;
  75.  
  76. }
  77. //---------------------------------------------------------------------------
  78.  
  79.  
  80. __fastcall TCap::TCap (HWND Handle)
  81. {
  82.     // create video capture window
  83.     ParentHandle = Handle;
  84.  
  85.      hwndVideo = capCreateCaptureWindow(
  86.                     (LPSTR) &#34;0&#34;,
  87.                     WS_CHILD | WS_VISIBLE
  88.                     ,
  89.                      0, 0, 300, 200,
  90.                     (HWND) Handle,
  91.                     (int) 0);
  92.  
  93.  
  94.  
  95.     pStringCapDrivers = new TStringList;
  96.     SelectedDevice = -1;
  97. }
  98.  
  99.  
  100. __fastcall TCap::~TCap ()
  101. {
  102.  
  103.     delete pStringCapDrivers;
  104.  
  105.     capPreview(hwndVideo, FALSE); // end preview
  106.     capDriverConnect(hwndVideo, SelectedDevice);
  107.     capDriverDisconnect(hwndVideo); // disconnect from driver
  108. }
  109.  
  110. //---------------------------------------------------------------------------
  111. // enumerate the installed capture drivers
  112. //---------------------------------------------------------------------------
  113. int TCap::EnumCapDrv ()
  114. {
  115.   char szDeviceName[80]; // driver name
  116.   char szDeviceVersion[80]; // driver version
  117.   char str[161]; // concatinated string
  118.   int xcap; // counter
  119.  
  120.     xcap = 0;
  121.     pStringCapDrivers-&#62;Clear ();
  122.     do  {
  123.         if (capGetDriverDescription(xcap, szDeviceName, sizeof(szDeviceName),
  124.                   szDeviceVersion, sizeof(szDeviceVersion))){
  125.  
  126.             sprintf (str, &#34;%s, %s&#34;, szDeviceName, szDeviceVersion);
  127.             pStringCapDrivers-&#62;AddObject (str, (TObject *)xcap);
  128.             }
  129.         else {
  130.             break;
  131.             }
  132.         xcap++;
  133.         } while (true);
  134.  
  135.     return 0;
  136. }
  137.  
  138. //---------------------------------------------------------------------------
  139. //  connecting to selected device and starts preview
  140. //---------------------------------------------------------------------------
  141. void TCap::Connect (int Selected)
  142. {
  143.     CAPSTATUS CapStatus;
  144.     int       hsize;
  145.       // capDlgVideoDisplay(hwndVideo);
  146.       // connect to the driver
  147.     if (SelectedDevice != -1) {
  148.         capPreview (hwndVideo, FALSE);
  149.         capDriverConnect(hwndVideo, SelectedDevice);
  150.         }
  151.  
  152.     if (!capDriverConnect(hwndVideo, Selected)) {
  153.         // ---- Unable to connect to driver
  154.  
  155.         return;
  156.         }
  157.  
  158.     // update the driver capabilities
  159.     capDriverGetCaps (hwndVideo, sizeof(CAPDRIVERCAPS), &CapDrvCaps);
  160.     capDlgVideoFormat(ParentHandle);
  161.     // Are there new image dimensions
  162.     capGetStatus(hwndVideo, &CapStatus, sizeof(CAPSTATUS));
  163.     hsize = GetSystemMetrics(SM_CYMENU);
  164.     hsize += GetSystemMetrics(SM_CYCAPTION);
  165.  
  166.     // ---- Rescaling the windows
  167.     SetWindowPos(hwndVideo, NULL, 0, 0, CapStatus.uiImageWidth,
  168.                 CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
  169.     SetWindowPos(ParentHandle, NULL, 0, hsize, CapStatus.uiImageWidth,
  170.                 CapStatus.uiImageHeight+hsize, SWP_NOZORDER | SWP_NOMOVE);
  171.  
  172.  
  173.                         //  Cambiar formato de video a 320x240 24bits de color
  174.         // tambien podriamos ponerlo manualmente en esta
  175.         // resolución usando la función 'capDlgVideoFormat(w);'
  176.     BITMAPINFO bi;
  177.     ZeroMemory(&bi, sizeof(bi));
  178.     bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  179.     bi.bmiHeader.biWidth       = 320;
  180.     bi.bmiHeader.biHeight      = 240;
  181.     bi.bmiHeader.biPlanes      = 1;
  182.     bi.bmiHeader.biBitCount    = 24;
  183.     bi.bmiHeader.biCompression = BI_RGB;
  184.     if (!capSetVideoFormat(hwndVideo, &bi, sizeof(bi)))
  185.       throw Exception(&#34;No se puede cambiar el formato de video&#34;);
  186.         // Definimos la función que sera
  187.         // llamada antes de visualizar cada fotograma
  188.     if (!capSetCallbackOnFrame(hwndVideo, fcb))
  189.       throw Exception(&#34;callback no instalado&#34;);
  190.         // Previsualizar captura
  191.  
  192.     // set preview rate to 33.3 miliseconds, or 30 FPS
  193.     capPreviewRate (hwndVideo, 33.3);
  194.  
  195.     // start preview video
  196.     capPreview (hwndVideo, TRUE);
  197.  
  198.     // ---- Remember selected device
  199.     SelectedDevice = Selected;
  200.  
  201. }
  202.  
  203. //---------------------------------------------------------------------------
  204. //  Get access to the video source format box
  205. //---------------------------------------------------------------------------
  206. void TCap::Format ()
  207. {
  208.     int       hsize;
  209.  
  210.     CAPSTATUS CapStatus;
  211.  
  212.     capDlgVideoFormat(hwndVideo);
  213.     // Are there new image dimensions
  214.     capGetStatus(hwndVideo, &CapStatus, sizeof(CAPSTATUS));
  215.  
  216.     hsize = GetSystemMetrics(SM_CYMENU);
  217.     hsize += GetSystemMetrics(SM_CYCAPTION);
  218.  
  219.     SetWindowPos(ParentHandle, NULL, 0, hsize, CapStatus.uiImageWidth,
  220.                 CapStatus.uiImageHeight+hsize, SWP_NOZORDER | SWP_NOMOVE);
  221.     SetWindowPos(hwndVideo, NULL, 0, 0, CapStatus.uiImageWidth,
  222.                 CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
  223. }
  224. //---------------------------------------------------------------------------
  225. //  Get access to the video source dialog box
  226. //---------------------------------------------------------------------------
  227. void TCap::Source ()
  228. {
  229.     capDlgVideoSource(hwndVideo);
  230. }
  231.  
  232. //---------------------------------------------------------------------------
  233. //  capture a frame and save it
  234. //---------------------------------------------------------------------------
  235. void TCap::CaptureFrame (char *FileName)
  236. {
  237.     capFileSaveDIB (hwndVideo, FileName);
  238. }
  239.  

archivo de cabecera

Código: Text
  1.  
  2. //---------------------------------------------------------------------------
  3.  
  4. //#ifndef c_capH
  5. //#define c_capH
  6. //---------------------------------------------------------------------------
  7. #include &#60;vfw.h&#62; // video for windows library
  8.  
  9. class TCap
  10. {
  11. private:
  12.  
  13. protected:
  14.     HWND ParentHandle;
  15.     HWND hwndVideo;
  16.     CAPDRIVERCAPS CapDrvCaps; // driver capabilities
  17.  
  18.     int     SelectedDevice;
  19.  
  20. public:
  21.     TStringList     *pStringCapDrivers;
  22.  
  23.     int EnumCapDrv();
  24.     void Connect (int Selected);
  25.     void Format ();
  26.     void Source ();
  27.     void CaptureFrame (char *FileName);
  28.   __fastcall TCap(HWND Handle);
  29.   __fastcall ~TCap();
  30.  
  31. };
  32.  
  33.  
  34. //#endif
  35.  
  36.  

ejemplo de funcionamiento:

Código: Text
  1.  
  2.  
  3. HWND w;
  4.  
  5.  w = capCreateCaptureWindow(&#34;Mi Video&#34;, WS_CHILD  ,
  6.                                1, 1, 320, 240, panelCaptura-&#62;Handle, 0);
  7.  
  8.    if (!w)
  9.         throw Exception(&#34;No se pudo seleccionar una ventana de captura&#34;);
  10.         // Se conecta con el primer dispositivo de captura que encuentra
  11.     bool bRet;
  12.     for (int iCapDrv=0; iCapDrv&#60;10; iCapDrv++)
  13.     {
  14.         bRet = capDriverConnect(w, iCapDrv);
  15.         if (bRet) break;
  16.     }
  17.     if (!bRet)
  18.        {
  19.         Timer1-&#62;Enabled=false; // Desactivar Reloj
  20.         throw Exception(&#34;Error: no se encontraron dispositivos.&#34;);
  21.        }
  22.         // Mostramos en el titulo del form el nombre del driver seleccionado
  23.     char szNombreDrv[256];
  24.     /*
  25.     if ( capDriverGetName(w, szNombreDrv, sizeof(szNombreDrv)) )
  26.         Caption = szNombreDrv;
  27.       */
  28.         //  Cambiar formato de video a 320x240 24bits de color
  29.         // tambien podriamos ponerlo manualmente en esta
  30.         // resolución usando la función 'capDlgVideoFormat(w);'
  31.     BITMAPINFO bi;
  32.     ZeroMemory(&bi, sizeof(bi));
  33.     bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  34.     bi.bmiHeader.biWidth       = 320;
  35.     bi.bmiHeader.biHeight      = 240;
  36.     bi.bmiHeader.biPlanes      = 1;
  37.     bi.bmiHeader.biBitCount    = 24;
  38.     bi.bmiHeader.biCompression = BI_RGB;
  39.     if (!capSetVideoFormat(w, &bi, sizeof(bi)))
  40.       throw Exception(&#34;No se puede cambiar el formato de video&#34;);
  41.         // Definimos la función que sera
  42.         // llamada antes de visualizar cada fotograma
  43.     if (!capSetCallbackOnFrame(w, fcb))
  44.       throw Exception(&#34;callback no instalado&#34;);
  45.     capPreviewScale(w, false);
  46.     capPreviewRate(w, 1);
  47.  
  48.  
  49.  

ahora insercion de la funcion fcb que es llamada como el hook

Código: Text
  1.  
  2. LRESULT CALLBACK fcb(HWND w, LPVIDEOHDR h)
  3. {
  4.     BITMAPINFO bi;
  5.     ZeroMemory(&bi, sizeof(bi));
  6.     bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
  7.     bi.bmiHeader.biWidth       = 320;
  8.     bi.bmiHeader.biHeight      = 240;
  9.     bi.bmiHeader.biPlanes      = 1;
  10.     bi.bmiHeader.biBitCount    = 24;
  11.     bi.bmiHeader.biCompression = BI_RGB;
  12.     std::auto_ptr&#60;Graphics::TBitmap&#62; bmp(new Graphics::TBitmap);
  13.     bmp-&#62;PixelFormat = pf24bit;
  14.     bmp-&#62;Width       = bi.bmiHeader.biWidth;
  15.     bmp-&#62;Height      = bi.bmiHeader.biHeight;
  16.     SetDIBits(bmp-&#62;Canvas-&#62;Handle, bmp-&#62;Handle, 0,
  17.         bi.bmiHeader.biHeight, h-&#62;lpData, &bi, DIB_RGB_COLORS);
  18.     std::auto_ptr&#60;TJPEGImage&#62; jpg(new TJPEGImage);
  19.     jpg-&#62;CompressionQuality = 50;
  20.     jpg-&#62;Assign(bmp.get());
  21.    // aqui esta elobjeto jpg, has con el lo que quieras
  22.  
  23.  
  24. return TRUE&#59;
  25. }
  26.  

Páginas: [1]