Agregar botón a ventana
Publicado por Daniel (16 intervenciones) el 09/09/2008 23:57:53
Hola a todos
Les pido una ayudita para poder seguir.-
Lo que necesito es que alguien me diga las líneas que debo ingresar y en que lugar para agregarle a esta ventana un botón y una etiqueta (creo que así se llaman) El curso que estoy leyendo dice como hacerlo pero todos están en ventanas que son activadas a través de menúes y lo que quiero es tenerlos en la ventana principal.-
---------------------------------------------------------------------------------------------------------------------------
#include <windows.h>
#include "ids.h"
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
int iWidth = 500, iHeight = 300;
int iLeft = (GetSystemMetrics(SM_CXSCREEN ) / 2)-(iWidth / 2);
int iTop= (GetSystemMetrics(SM_CYSCREEN ) / 2)-(iHeight / 2);
HWND hwnd;
MSG mensaje;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = "NUESTRA_CLASE";
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = GetSysColorBrush(10);
if(!RegisterClassEx(&wincl)) return 0;
hwnd = CreateWindowEx(
0,
"NUESTRA_CLASE",
" Gestión comercial",
WS_OVERLAPPEDWINDOW,
iLeft, iTop, iWidth, iHeight,
HWND_DESKTOP, // La ventana es hija del escritorio
LoadMenu(hInstance, "Menu"),
hInstance,
NULL
);
ShowWindow(hwnd, SW_SHOWDEFAULT);
while(TRUE == GetMessage(&mensaje, NULL, 0, 0))
{
TranslateMessage(&mensaje);
DispatchMessage(&mensaje);
}
return mensaje.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case CM_ARTICULOS:
MessageBox(hwnd, " No desarrollado ", " Artículos ", MB_OK);
break;
case CM_CLIENTES:
MessageBox(hwnd, " No desarrollado ", " Clientes ", MB_OK);
break;
case CM_SALIR:
PostQuitMessage(0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
---------------------------------------------------------------------------------------------------------------------------
Desde ya muchas gracias
Un gran saludo
El autodidacta Daniel C++
Les pido una ayudita para poder seguir.-
Lo que necesito es que alguien me diga las líneas que debo ingresar y en que lugar para agregarle a esta ventana un botón y una etiqueta (creo que así se llaman) El curso que estoy leyendo dice como hacerlo pero todos están en ventanas que son activadas a través de menúes y lo que quiero es tenerlos en la ventana principal.-
---------------------------------------------------------------------------------------------------------------------------
#include <windows.h>
#include "ids.h"
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
int iWidth = 500, iHeight = 300;
int iLeft = (GetSystemMetrics(SM_CXSCREEN ) / 2)-(iWidth / 2);
int iTop= (GetSystemMetrics(SM_CYSCREEN ) / 2)-(iHeight / 2);
HWND hwnd;
MSG mensaje;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = "NUESTRA_CLASE";
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = GetSysColorBrush(10);
if(!RegisterClassEx(&wincl)) return 0;
hwnd = CreateWindowEx(
0,
"NUESTRA_CLASE",
" Gestión comercial",
WS_OVERLAPPEDWINDOW,
iLeft, iTop, iWidth, iHeight,
HWND_DESKTOP, // La ventana es hija del escritorio
LoadMenu(hInstance, "Menu"),
hInstance,
NULL
);
ShowWindow(hwnd, SW_SHOWDEFAULT);
while(TRUE == GetMessage(&mensaje, NULL, 0, 0))
{
TranslateMessage(&mensaje);
DispatchMessage(&mensaje);
}
return mensaje.wParam;
}
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COMMAND:
switch(LOWORD(wParam))
{
case CM_ARTICULOS:
MessageBox(hwnd, " No desarrollado ", " Artículos ", MB_OK);
break;
case CM_CLIENTES:
MessageBox(hwnd, " No desarrollado ", " Clientes ", MB_OK);
break;
case CM_SALIR:
PostQuitMessage(0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
---------------------------------------------------------------------------------------------------------------------------
Desde ya muchas gracias
Un gran saludo
El autodidacta Daniel C++
Valora esta pregunta
0