Título: Como elimino la opcion de Maximizar Publicado por: >Tyrael< 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 */ } Título: Re: Como elimino la opcion de Maximizar Publicado por: Riki_89D en 15 Junio 2011, 10:19 am muy facil,en la parte donde creas la ventana:
Código
en vez de pones la constante WS_OVERLAPPEDWINDOW pon WS_POPUPWINDOW | WS_MINIMIZEBOX de esta forma solo estara disponiblepara minimizar y obiamente cerrar saludos Título: Re: Como elimino la opcion de Maximizar Publicado por: >Tyrael< 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 :P
YA SOLUCIONES AGREGANDO ESTA LINEA DE CODIGO DONDE ME DIJISTE: WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, Gracias por todo! ;-) |