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

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  llamar desde una aplicación de consola una ventana win32 (del mismo proyecto)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: llamar desde una aplicación de consola una ventana win32 (del mismo proyecto)  (Leído 1,951 veces)
while

Desconectado Desconectado

Mensajes: 24


Ver Perfil
llamar desde una aplicación de consola una ventana win32 (del mismo proyecto)
« en: 13 Octubre 2010, 13:21 pm »

console.cpp:
Código
  1. #include <windows.h>
  2. #include <stdio.h>
  3.  
  4. int main(){
  5. printf("hola");
  6. ... llamarlaventana ...
  7. }

ese llamarlaventana, que tendria que ser?

ventana.cpp:
Código
  1. /*  Declare Windows procedure  */
  2. LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
  3.  
  4. /*  Make the class name into a global variable  */
  5. char szClassName[ ] = "WindowsApp";
  6.  
  7. int WINAPI WinMain (HINSTANCE hThisInstance,
  8.                    HINSTANCE hPrevInstance,
  9.                    LPSTR lpszArgument,
  10.                    int nFunsterStil)
  11.  
  12. {
  13.    HWND hwnd;               /* This is the handle for our window */
  14.    MSG messages;            /* Here messages to the application are saved */
  15.    WNDCLASSEX wincl;        /* Data structure for the windowclass */
  16.  
  17.    /* The Window structure */
  18.    wincl.hInstance = hThisInstance;
  19.    wincl.lpszClassName = szClassName;
  20.    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
  21.    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
  22.    wincl.cbSize = sizeof (WNDCLASSEX);
  23.  
  24.    /* Use default icon and mouse-pointer */
  25.    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
  26.    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
  27.    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
  28.    wincl.lpszMenuName = NULL;                 /* No menu */
  29.    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
  30.    wincl.cbWndExtra = 0;                      /* structure or the window instance */
  31.    /* Use Windows's default color as the background of the window */
  32.    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
  33.  
  34.    /* Register the window class, and if it fails quit the program */
  35.    if (!RegisterClassEx (&wincl))
  36.        return 0;
  37.  
  38.    /* The class is registered, let's create the program*/
  39.    hwnd = CreateWindowEx (
  40.           0,                   /* Extended possibilites for variation */
  41.           szClassName,         /* Classname */
  42.           "Windows App",       /* Title Text */
  43.           WS_OVERLAPPEDWINDOW, /* default window */
  44.           CW_USEDEFAULT,       /* Windows decides the position */
  45.           CW_USEDEFAULT,       /* where the window ends up on the screen */
  46.           544,                 /* The programs width */
  47.           375,                 /* and height in pixels */
  48.           HWND_DESKTOP,        /* The window is a child-window to desktop */
  49.           NULL,                /* No menu */
  50.           hThisInstance,       /* Program Instance handler */
  51.           NULL                 /* No Window Creation data */
  52.           );
  53.  
  54.    /* Make the window visible on the screen */
  55.    ShowWindow (hwnd, nFunsterStil);
  56.  
  57.    /* Run the message loop. It will run until GetMessage() returns 0 */
  58.    while (GetMessage (&messages, NULL, 0, 0))
  59.    {
  60.        /* Translate virtual-key messages into character messages */
  61.        TranslateMessage(&messages);
  62.        /* Send message to WindowProcedure */
  63.        DispatchMessage(&messages);
  64.    }
  65.  
  66.    /* The program return-value is 0 - The value that PostQuitMessage() gave */
  67.    return messages.wParam;
  68. }
  69.  
  70.  
  71. /*  This function is called by the Windows function DispatchMessage()  */
  72.  
  73. LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  74. {
  75.    switch (message)                  /* handle the messages */
  76.    {
  77.        case WM_DESTROY:
  78.            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
  79.            break;
  80.        default:                      /* for messages that we don't deal with */
  81.            return DefWindowProc (hwnd, message, wParam, lParam);
  82.    }
  83.  
  84.    return 0;
  85. }
  86.  

Es para hacer un splash screen, y quiero hacerlo de esta manera, solo que la aplicación principal es de consola, y no quiero usar wxwidgets.

Saludos y gracias.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Como llamar una ventana on focus… con batch
Scripting
Dsalomon 9 7,668 Último mensaje 12 Octubre 2013, 10:55 am
por Dsalomon
[WPF] Agregar referencia desde un recurso del mismo proyecto, es posible?
.NET (C#, VB.NET, ASP)
z3nth10n 1 3,196 Último mensaje 22 Abril 2014, 21:39 pm
por Eleкtro
Pasar comando desde CMD a aplicación de consola C#
.NET (C#, VB.NET, ASP)
HCK. 5 6,439 Último mensaje 11 Diciembre 2015, 15:02 pm
por HCK.
Leer dll en consola win32 « 1 2 3 »
Programación C/C++
Meta 21 9,655 Último mensaje 3 Julio 2020, 23:29 pm
por Meta
Ayuda ¿Cómo compilar aplicación de Windows desde consola ?
Programación C/C++
DavidTz 1 6,134 Último mensaje 8 Junio 2021, 21:43 pm
por Eternal Idol
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines