|
Mostrar Mensajes
|
Páginas: [1]
|
2
|
Programación / Programación C/C++ / Re-Post- El otro no abre! :S - Unir Interfaz con Codigo
|
en: 26 Junio 2011, 19:26 pm
|
TENGO ESTE CODIGO HECHO EN DEV C++ MI IDEA ES UNIRLO A LA INTERFAZ QUE ESTA MAS ABAJO... PUEDEN MODIFICARLA TODO LO QUE QUIERAN, LO QUE QUIERO REALIZAR ES UN CONVERTIDOR DE DEC A BINARIO Y A HEXADECIMAL CON SUS POSIBLES COMBINACION... EL CODIGO AUN NO ESTA TERMINADO PERO DE MOMENTO ASI COMO ESTA ME GUSTARIA PONERLE INTERFAZ DE MODO Q ME SIRVA PARA IR APRENDIENDO.. CREO Q HA MUCHO EN LA COMUNIDAD LES SERVIRIA DE EJEMPLO PS ES UN CODIGO SENCILLO Y UN PROGRAMA NADA COMPLICADO, PERO QUE A NIVEL DE INTERFAZ ESCAPA DE MIS CONOCIMIENTOS.. ESPERO PUEDAN AYUDARME #include<iostream.h> #include<stdio.h> #include<stdlib.h> #include<math.h> void menu(); void trans(int); main() { menu(); } void menu() { int tipo=0, opc; do { cout<<endl; cout<<" [1] Decimal-Binario"<<endl; cout<<" [2] Decimal-Hexadecimal"<<endl; cout<<" [3] Salir"<<endl; cin>>opc; }while((opc<1)||(opc>3)); switch(opc) { case 1: system("cls"); tipo=2; trans(tipo); system("cls"); menu(); break; case 2: system("cls"); tipo=16; trans(tipo); system("cls"); menu(); break; } } void trans(int tipo) { int num, resto[100], vector[100], cociente[100], i=0, j=0, ndiv=0, cont; char resp; do { cout<<" Numero: "; cin>>num; do { resto =(num%tipo); ndiv++; cociente=(num/tipo); num=cociente; i++; }while(cociente[i-1]!=0); cout<<" El numero nuevo seria: "; j=(ndiv-1); for (int z=0; z<ndiv; z++) { cont=0; do { vector[z]=resto[j]; j--; cont=1; }while(cont!=1); } for (int x=0; x<ndiv; x++) { if(tipo==16) { if((vector { cout<<vector } if(vector { cout<<"A"; } if(vector { cout<<"B"; } if(vector { cout<<"C"; } if(vector { cout<<"D"; } if(vector { cout<<"E"; } if(vector { cout<<"F"; } } else { cout<<vector } } cout<<endl; cout<<" Desea repetir [S/N]: "; cin>>resp; if ((resp=='s')||(resp=='S')) { ndiv=0; i=0; j=0; for(int c=0; c<20; c++) { vector[c]=0; resto[c]=0; cociente[c]=0; } } }while((resp=='s')||(resp=='S')); }
ACA ESTA EL CODIGO DE LA INTERFAZ TAMBIEN HECHO EN DEV C++
#include <windows.h> #include "IDS.h" #define ID_ActionButton 101
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
typedef struct stDatos { int Texto[80]; } DATOS;
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { HWND hwnd; MSG mensaje; WNDCLASSEX wincl; wincl.hInstance = hThisInstance; wincl.lpszClassName = "Ventana"; 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 = "Menu"; wincl.cbClsExtra = 0; wincl.cbWndExtra = 0;
wincl.hbrBackground = GetSysColorBrush(COLOR_BACKGROUND);
if(!RegisterClassEx(&wincl)) return 0;
hwnd = CreateWindowEx( 0, /* Posibilidades de variación */ "Ventana", /* Nombre de la clase */ "Programa Beta", /* Texto del título */ WS_OVERLAPPEDWINDOW, /* Tipo por defecto */ CW_USEDEFAULT, /* Windows decide la posición */ CW_USEDEFAULT, /* donde se coloca la ventana */ 544, /* Ancho */ 275, /* Alto en pixels */ HWND_DESKTOP, /* La ventana es hija del escritorio */ NULL, /* Sin menú */ hThisInstance, /* Manipulador de instancia */ NULL /* No hay datos de creación de ventana */ );
/* Mostrar la ventana */ ShowWindow(hwnd, SW_SHOWDEFAULT);
/* Bucle de mensajes, se ejecuta hasta que haya error o GetMessage devuelva FALSE */ while(TRUE == GetMessage(&mensaje, NULL, 0, 0)) { /* Traducir mensajes de teclas virtuales a mensajes de caracteres */ TranslateMessage(&mensaje); /* Enviar mensaje al procedimiento de ventana */ DispatchMessage(&mensaje); }
/* Salir con valor de retorno */ return mensaje.wParam; }
/* Esta función es invocada por la función DispatchMessage() */ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HINSTANCE hInstance; static HWND hwndButton = 0; /* Variables para diálogo */ static DATOS Datos; static HFONT hfont;
HWND hctrl;
switch (msg) /* manipulador del mensaje */ { case WM_CREATE: hwndButton = CreateWindow ("button","Decimal", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,50,40, 61, 20, hwnd,(HMENU)ID_ActionButton,((LPCREATESTRUCT) lParam)->hInstance,NULL); hwndButton = CreateWindow ("button","Binario", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,150,40, 61, 20, hwnd,(HMENU)ID_ActionButton,((LPCREATESTRUCT) lParam)->hInstance,NULL); hwndButton = CreateWindow ("button","Hexadecimal", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,250,40, 90, 20, hwnd,(HMENU)ID_ActionButton,((LPCREATESTRUCT) lParam)->hInstance,NULL); hInstance = ((LPCREATESTRUCT)lParam)->hInstance; /* Insertar control Edit */ hctrl = CreateWindowEx( 0, "EDIT", /* Nombre de la clase */ "", /* Texto del título, no tiene */ ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, /* Estilo */ 80, 100, /* Posición */ 100, 20, /* Tamaño */ hwnd, /* Ventana padre */ (HMENU)ID_TEXTO, /* Identificador del control */ hInstance, /* Instancia */ NULL); /* Sin datos de creación de ventana */ /* Inicialización de los datos de la aplicación */ SendMessage(hctrl, EM_SETLIMITTEXT, 10, 0L); SendMessage(hctrl, WM_SETTEXT, 0, (LPARAM)Datos.Texto); hfont = (HFONT)GetStockObject( DEFAULT_GUI_FONT ); SendMessage(hctrl, WM_SETFONT, (WPARAM)hfont, MAKELPARAM(TRUE, 0)); SetFocus(hctrl); return 0; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_ActionButton: //Datos.Texto=Datos.Texto+100; SendMessage(hctrl, WM_SETTEXT, 0, (LPARAM)Datos.Texto); break; case CM_SALIR: DestroyWindow(hwnd); break; } break; case WM_DESTROY: DeleteObject(hfont); PostQuitMessage(0); /* envía un mensaje WM_QUIT a la cola de mensajes */ break; default: /* para los mensajes de los que no nos ocupamos */ return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
ACA EL CODIGO DEL FICHERO IDS.H
/* Identificadores */
/* Identificadores de comandos */ #define CM_DIALOGO 101 #define CM_SALIR 103
/* Identificadores de diálogo */ #define ID_TEXTO 100 #define ID_ACTIVAR 101
Y ACA EL CODIGO DEL FICHERO DE RECURSOS
#include <windows.h> #include "IDS.H"
Menu MENU BEGIN POPUP "&Principal" BEGIN MENUITEM "&Salir", CM_SALIR END END
-----------------------------------------------------------------------------------------------
NO SE COMO HACER PARA UNIR AMBOS PROGRAMAS... MI IDEA ES QUE CADA BOTON "DECIMAL, BINARIO Y HEXA" TENGAN UN CUADRO DE DIALOGO DONDE ESCRIBIR EL VALOR CORRESPONDIENTE (VALIDADO) Y QUE CUANDO PULSEN SOBRE EL BOTON EN CUESTION SALGA LA CONVERION EN LOS OTROS CUADROS DE DIALOGO.. ADEMAS DE UN BOTON "CLEAR" QUE BORRE TODOS LOS CAMPOS! ESPERO Q PUEDAN AYUDARME
|
|
|
3
|
Programación / Programación C/C++ / Re: Como elimino la opcion de Maximizar
|
en: 15 Junio 2011, 15:48 pm
|
Awww aca no me funciono... me quita todo el borde por completo y no deja ningun tipo de boton.. nisiquiera el de cerrar.. ni el borde de ventana por lo q queda por defecto estatica en la esquina superior izq y sin posibilidad de mover la aplicacion Me gustaria q la ventana quedara loqueada para q de ninguna forma el usuario pueda modificar el tamaño de la ventana en si YA SOLUCIONES AGREGANDO ESTA LINEA DE CODIGO DONDE ME DIJISTE: WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, Gracias por todo!
|
|
|
4
|
Programación / Programación C/C++ / Como elimino la opcion de Maximizar
|
en: 15 Junio 2011, 05:48 am
|
Hola alguien me podria ayudar con este codigo... es algo sencillo lo que quiero... apenas estoy empezando a programar. Lo que quiero es evitar q al usuario le aparezca la opción de maximizar en la ventana.. osea quiero q ajuro use el tamaño de ventana q yo elija!
#include <windows.h> #include <stdio.h> #define ID_NOTEPAD 101 #define ID_SALIR 102 #define CM_PRUEBA 100 #define CM_SALIR 102
void InsertarMenu(HWND);
BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
/* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */ char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{ HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (NULL, IDI_WINLOGO); wincl.hIconSm = LoadIcon (NULL, IDI_WINLOGO); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ //wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; LOGBRUSH background;
background.lbStyle = BS_PATTERN; background.lbHatch = (long) LoadImage(hThisInstance,"Fondo",IMAGE_BITMAP, 0, 0, LR_SHARED); wincl.hbrBackground = CreateBrushIndirect(&background);
/* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 0;
/* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ "ANDRES FUENTES PROGRAM", /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ CW_USEDEFAULT, /* Windows decides the position */ CW_USEDEFAULT, /* where the window ends up on the screen */ 416, /* The programs width */ 217, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ );
/* Make the window visible on the screen */ InsertarMenu(hwnd); //ShowWindow(hWnd, SW_SHOWDEFAULT); ShowWindow (hwnd, nFunsterStil);
/* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { /* Translate virtual-key messages into character messages */ TranslateMessage(&messages); /* Send message to WindowProcedure */ DispatchMessage(&messages); }
/* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndButton = 0; switch (message) /* handle the messages */ { case WM_CREATE: hwndButton = CreateWindow ("button","Decimal", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,35,40, 61, 20, hwnd,(HMENU)ID_NOTEPAD,((LPCREATESTRUCT) lParam)->hInstance,NULL); hwndButton = CreateWindow ("button","Binario", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,120,40, 61, 20, hwnd,(HMENU)ID_NOTEPAD,((LPCREATESTRUCT) lParam)->hInstance,NULL); hwndButton = CreateWindow ("button","Hexadecimal", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,200,40, 90, 20, hwnd,(HMENU)ID_NOTEPAD,((LPCREATESTRUCT) lParam)->hInstance,NULL);
hwndButton = CreateWindow ("button","Salir", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,320,40, 61, 20, hwnd,(HMENU)ID_SALIR,((LPCREATESTRUCT) lParam)->hInstance,NULL); break; case WM_COMMAND: switch(LOWORD(wParam)) { case CM_PRUEBA: MessageBox(hwnd, "Programa Realizado Por: Andres Fuentes", "Informacion", MB_ICONINFORMATION); break; case ID_NOTEPAD: MessageBox(hwnd, "NO HAY NADA AQUI", "Informacion", MB_ICONINFORMATION); break; case ID_SALIR: PostQuitMessage (0); break; } break;
case WM_DESTROY: PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); }
return 0; }
void InsertarMenu(HWND hWnd) { HMENU hMenu1, hMenu2; hMenu1 = CreateMenu(); /* Manipulador de la barra de menú */ hMenu2 = CreateMenu(); /* Manipulador para el primer menú pop-up */ AppendMenu(hMenu2, MF_STRING, CM_PRUEBA, "&Informacion"); /* 1º ítem */ AppendMenu(hMenu2, MF_SEPARATOR, 0, NULL); /* 2º ítem (separador) */ AppendMenu(hMenu2, MF_STRING, CM_SALIR, "&Salir"); /* 3º ítem */ /* Inserción del menú pop-up */ AppendMenu(hMenu1, MF_STRING | MF_POPUP, (UINT)hMenu2, "&Ayuda"); SetMenu (hWnd, hMenu1); /* Asigna el menú a la ventana hWnd */ }
|
|
|
|
|
|
|