Foros del Web » Programación para mayores de 30 ;) » C/C++ »

WINAPI c++ usando Eclipse

Estas en el tema de WINAPI c++ usando Eclipse en el foro de C/C++ en Foros del Web. Buenas estoy aprendiendo a crear ventanas en windows usando c++ y las APis de windows pero eh aqui el problema... El codigo en si dice ...
  #1 (permalink)  
Antiguo 21/02/2010, 18:31
 
Fecha de Ingreso: febrero-2010
Mensajes: 2
Antigüedad: 14 años, 2 meses
Puntos: 0
WINAPI c++ usando Eclipse

Buenas estoy aprendiendo a crear ventanas en windows usando c++ y las APis de windows pero eh aqui el problema...
El codigo en si dice que no hay problemas que esta todo en orden pero cuando ejecuto el programa no me aparece el menu... ALGUNA IDEA???

MAIN.cpp
Código:
#include <windows.h>
#include "ids.h"
*
*
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM); // Esto es una funcion
void InsertarMenu(HWND);
*
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevinstance,
* * * * LPSTR lpszCmdParam, int nCmdShow) {
*
* * HWND ventana;//manipulador para la ventana principal de la aplicacion
* * MSG mensaje; // es una VARIABLE para manipular los mensajes que lleguen a nuestra aplicacion
* * WNDCLASSEX wincl; // declaramos la estructura wincl para registrar la clase particular de ventana a usar
* * HMENU hMenu;
*
*
*
*
*
* * wincl.hInstance = hThisInstance;
* * wincl.lpszClassName = "Mi_clase";
* * wincl.lpfnWndProc = WindowProcedure;
* * wincl.style = CS_DBLCLKS;
* * wincl.cbSize = sizeof(wincl);
* * //wincl.lpszMenuName = "MenuID";
*
* * //usar icono y puntero por defecto
*
* * wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
* * wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
* * wincl.hCursor = LoadIcon(NULL, IDC_ARROW);
* * wincl.lpszMenuName = NULL;
* * wincl.cbClsExtra = 0;
* * wincl.cbWndExtra = 0;
* * wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
*
* * //registrar la clase de hwnd si falla salir del programa
* * if(!RegisterClassEx(&wincl)) return 0;
*
* * ventana = CreateWindowEx(
* * * * * * 0,
* * * * * * "Mi_clase",
* * * * * * "Ejemplo 01",
* * * * * * WS_OVERLAPPEDWINDOW,
* * * * * * CW_USEDEFAULT,
* * * * * * CW_USEDEFAULT,
* * * * * * 544,
* * * * * * 375,
* * * * * * HWND_DESKTOP,
* * * * * * NULL,//LoadMenu(hThisInstance,"MenuID"),
* * * * * * hThisInstance,
* * * * * * NULL);
*
*
* * hMenu = LoadMenu(hThisInstance,"MenuID");
* * * * SetMenu(ventana,hMenu);
*
* * * * ShowWindow(ventana,nCmdShow);
* * //Bucle de mensajes
* * while(TRUE== GetMessage(&mensaje,NULL,0,0))
* * {
* * * * TranslateMessage(&mensaje);
*
* * * * DispatchMessage(&mensaje);
*
* * }
*
*
* * return mensaje.wParam;
}
*
*
*
LRESULT CALLBACK WindowProcedure(HWND ventana, UINT mensaje,WPARAM wParam,LPARAM lParam){
* * switch (mensaje)
* * {
* * case WM_COMMAND:
* * * * switch(LOWORD(wParam)){
* * * * case CM_PRUEBA:
* * * * * * * * * * MessageBox(ventana,"Comando: Prueba","Mensaje de Menu",MB_OK);break;
* * * * case CM_DIALOGO:
* * * * * * * * * * MessageBox(ventana,"Habia una rata llamada ratatouille que era francesa","Mensaje de Menu",MB_OK);break;
* * * * case CM_SALIR:
* * * * * * * * * * MessageBox(ventana,"Comando: Salir","Mensaje de Menu",MB_OK);break;
* * * * * * * * * * PostQuitMessage(0); break;
* * * * }
* * * * break;
* * case WM_DESTROY:
* * * * PostQuitMessage(0);break;
* * default:
* * * * return DefWindowProc(ventana,mensaje,wParam,lParam);
* * }
* * return 0;
}
*
IDS.H
Código:
*
#define CM_PRUEBA 100
#define CM_SALIR 101
#define CM_PROBANDO 102
#define CM_DIALOGO 103
#define TEXTO 104
*
FICHERO DE RECURSOS WIN002.rc
Código:
#include <ids.h>
*
MenuID MENUEX
BEGIN
*POPUP "&Principal"
*BEGIN
* MENUITEM "", * CM_PRUEBA
* MENUITEM "" // MFT_SEPARATOR
* MENUITEM "&Dialogo", * CM_DIALOAGO
* MENUITEM "" // MFT_SEPARATOR
* MENUITEM "&Salir", CM_SALIR
*END
desde ya muy agradecido porque desde anteayer que estoy renegando con esto....

Si Creo una funcion
Código:
*
....InsertarMenu(ventana);
ShowWindow(ventana,SW_SHOWDEFAULT);...
Código:
*
void InsertarMenu(HWND ventana){
* * HMENU hmenu1, hmenu2;
* * hmenu1 = CreateMenu();// manipulador de la barra de menu
* * hmenu2 = CreateMenu();//Manipulador para el primer menu pop-up
* * AppendMenu(hmenu2,MF_STRING,CM_PRUEBA,"&Prueba"); //1` Item
* * AppendMenu(hmenu2,MF_SEPARATOR,0,NULL);//2` item como en el tercer espacio hay un 0. este separa
* * AppendMenu(hmenu2,MF_STRING,CM_DIALOGO,"&Dialogo");
* * AppendMenu(hmenu2,MF_SEPARATOR,0,NULL);
* * AppendMenu(hmenu2,MF_STRING,CM_SALIR,"&Salir"); //3` item
* * AppendMenu(hmenu1,MF_STRING | MF_POPUP, (UINT)hmenu2,"&Principal");
* * SetMenu(ventana,hmenu1); //asigna el menu a la ventana ventana
}
*
*
me anda joya PERO quiero aprender a crear menus de la otra forma que es mas facil y aparte lo puedo separar en otro fichero

GRACIAS

Etiquetas: c++, eclipse, ventana.grafico, winapi
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:49.