Autor Tema: Quitar Maximizar de un MDIFOR  (Leído 15005 veces)

0 Usuarios y 1 Visitante están viendo este tema.

wolf_kof

  • Visitante
Quitar Maximizar de un MDIFOR
« en: Julio 05, 2010, 01:37:25 am »
Alguien sabe como quitar el boton maximizar de un mdiform?

cobein

  • Moderador Global
  • Gigabyte
  • *****
  • Mensajes: 348
  • Reputación: +63/-0
  • Más Argentino que el morcipan
    • Ver Perfil
Re:Quitar Maximizar de un MDIFOR
« Respuesta #1 en: Julio 05, 2010, 01:40:58 am »
Propiedad Maxbutton = False?

wolf_kof

  • Visitante
Re:Quitar Maximizar de un MDIFOR
« Respuesta #2 en: Julio 05, 2010, 02:46:18 am »
Bueno me voy a contestar solito (YvanB  ;D), despues de mucho buscar, miren me encontre con este codigo que manipula api para quitar los bonotes minimaz y maximizar de un MDIFORM, aparte encontre un codigo que hace que el MDIFORM se ejecute en vista Maxima osea en toda la pantalla (creo que le serviria bastante a IvanB) voy con el codigo.

Codigo Sencillo para quitar los Botones Maximizar y Minimizar

se declara en el encabezado del MDIFORM
Código: (vb) [Seleccionar]
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

y esto se coloca en la propiedad load

Código: (vb) [Seleccionar]
Dim L As Long
L = GetWindowLong(Me.hwnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(Me.hwnd, GWL_STYLE, L)

increiblemente funciona

Este codigo es mejor por que pone a la resolución maxima del monitor que tengas el MDIForm y lo maximia a toda su expresión (Pantalla completa)

se declara
Código: (vb) [Seleccionar]
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
     ByVal hwnd As Long, _
     ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
     ByVal hwnd As Long, _
     ByVal nIndex As Long, _
     ByVal dwNewLong As Long) As Long

Private Const GWL_STYLE As Long = -16
Private Const GWL_EXSTYLE As Long = -20

Private Const WS_OVERLAPPEDWINDOW As Long = &HCF0000
Private Const WS_EX_APPWINDOW As Long = &H40000

y en la propiedad load se coloca lo siguiente:
Código: (vb) [Seleccionar]
Private Sub MDIForm_Load()
    SetWindowLong hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) And Not WS_OVERLAPPEDWINDOW
    SetWindowLong hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) And Not WS_EX_APPWINDOW
End Sub

Espero que a alguien le sirva

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #3 en: Julio 06, 2010, 02:39:13 am »
Hola Wolf, voy a probar tu código y ya te mande el link del servidor donde esta alojado el proyecto "VB6-Firebird" que estuvimos conversando.

Saludos.
Me encuentras en YAcosta.com

wolf_kof

  • Visitante
Re:Quitar Maximizar de un MDIFOR
« Respuesta #4 en: Julio 06, 2010, 04:30:58 am »
ok graxias YvanB prueba el codigo esta rebuenisimo a mi me sirvio genial (COOL)

ssccaann43

  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Quitar Maximizar de un MDIFOR
« Respuesta #5 en: Julio 06, 2010, 10:00:41 am »
Bueno me voy a contestar solito (YvanB  ;D)

Jajajajaja... Esto si me causo risa...!  ::)

Esta muy bueno el codigo Wolf, buen aporte...!
Miguel Núñez.

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #6 en: Julio 06, 2010, 01:35:49 pm »
jejeje, si ta buena. Lo bueno es que el tema ya esta superado y conversamos directamente con acceso remoto, "comparticion" de código y links de chicas calatas (no mentira) jejee.
Me encuentras en YAcosta.com

ssccaann43

  • Terabyte
  • *****
  • Mensajes: 970
  • Reputación: +97/-58
    • Ver Perfil
    • Sistemas Nuñez, Consultores y Soporte, C.A.
Re:Quitar Maximizar de un MDIFOR
« Respuesta #7 en: Julio 06, 2010, 03:19:55 pm »
Excelente...!
Miguel Núñez.

wolf_kof

  • Visitante
Re:Quitar Maximizar de un MDIFOR
« Respuesta #8 en: Julio 07, 2010, 11:00:04 pm »
 ;) yo me apunto para lo de las chicas cuando quieras, tengo muy buenos enlaces  8)

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #9 en: Junio 12, 2011, 01:47:27 am »
Se que el tema es antiguo pero lo retomo porque en un nuevo proyecto necesito quitar el MAX del MDI, no use en su momento este codigo porque use un truco que hacia poner el form MDI mas arriba de la pantalla y no dejo ver la barra, pero para este proyecto no puedo hacer eso, asi que hice esto
Declaracion en el MDIFORM
Código: (vb) [Seleccionar]
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

y esto se coloca en el evento Load
Código: (vb) [Seleccionar]
Dim L As Long
L = GetWindowLong(Me.hwnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(Me.hwnd, GWL_STYLE, L)

Pero no funciona, es decir, los botones siguen alli... ¿que puede estar pasando?. Adicionalmente habría que comentar que el usuario tampoco pueda maximizar haciendo doble click sobre la barra.

Gracias


EDICION: Encontre en la web que faltaba poner en la declaracion esto:
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)

Pero tampoco me funciono, seguire indagando.

EDICION 2 Probe esto tambien y nada.. que raro!!!, en la declaracion:
Código: (vb) [Seleccionar]
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
' Funciones para cambiar el estilo
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Const MF_BYPOSITION = &H400&

y en el Load:
Código: (vb) [Seleccionar]
Dim Aux As Long
Dim hSysMenu As Long, nCnt As Long
'Elimina los botones
Aux = GetWindowLong(me.hwnd, GWL_STYLE)
SetWindowLong frmBASE.hwnd, GWL_STYLE, aux Xor (WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
'Elimina los elementos en el menu
hSysMenu = GetSystemMenu(me.hwnd, False)
If hSysMenu Then
   nCnt = GetMenuItemCount(hSysMenu)
   If nCnt Then
      RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION
      RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION
   End If
End If

Voy por un trago pq ya me maree.
« última modificación: Junio 12, 2011, 02:11:39 am por YvanB »
Me encuentras en YAcosta.com

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #10 en: Junio 12, 2011, 08:20:37 am »
Bien aqui completo el asunto que no pude resolver.
http://www.youtube.com/watch?v=2u1JxzSnxrU

Probe las siguientes forma encontradas en la web:
Forma 1
Código: (vb) [Seleccionar]
DECLARACION
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)

FORM LOAD
Dim L As Long
L = GetWindowLong(frmBASE.hwnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(frmBASE.hwnd, GWL_STYLE, L)

Forma 2
Código: (vb) [Seleccionar]
DECLARACION

Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_POPUP = &H80000000
Private Const WS_BORDER = &H800000
Private Const WS_SYSMENU = &H80000
Private Const WS_POPUPWINDOW = (WS_POPUP Or WS_BORDER Or WS_SYSMENU)
Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&

FORM LOAD (Solo inhabilita el cerrar)
Dim lEstilo As Long
Dim hMenu As Long
lEstilo = GetWindowLong(Me.hwnd, GWL_STYLE)
lEstilo = lEstilo And WS_POPUPWINDOW Or WS_CAPTION
Call SetWindowLong(Me.hwnd, GWL_STYLE, lEstilo)
hMenu = GetSystemMenu(Me.hwnd, 0)
Call RemoveMenu(hMenu, 3, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, 3, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, 3, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, 3, MF_REMOVE Or MF_BYPOSITION)
DrawMenuBar Me.hwnd

Forma 3
Código: (vb) [Seleccionar]
DECLARACION
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
' Funciones para cambiar el estilo
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Private Const GWL_STYLE = (-16)
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Const MF_BYPOSITION = &H400&

FORM LOAD

Dim aux As Long
Dim hSysMenu As Long, nCnt As Long
' Elimina los botones
aux = GetWindowLong(frmBASE.hwnd, GWL_STYLE)
SetWindowLong frmBASE.hwnd, GWL_STYLE, aux Xor (WS_MAXIMIZEBOX Or WS_MINIMIZEBOX)
' Elimina los elementos en el menu
hSysMenu = GetSystemMenu(frmBASE.hwnd, False)
If hSysMenu Then
   nCnt = GetMenuItemCount(hSysMenu)
   If nCnt Then
      RemoveMenu hSysMenu, nCnt - 3, MF_BYPOSITION
      RemoveMenu hSysMenu, nCnt - 4, MF_BYPOSITION
   End If
End If

Y ninguna de las 3 me funciona como lo demuestro en el video... ¿En que estoy mal? Quiero quitar solamente el boton Maximizar y que tampoco funcione el doble clic sobre la barra para maximizar
« última modificación: Junio 12, 2011, 04:58:17 pm por YvanB »
Me encuentras en YAcosta.com

raul338

  • Terabyte
  • *****
  • Mensajes: 894
  • Reputación: +62/-8
  • xD fan!!!!! xD
    • Ver Perfil
    • Raul's Weblog
Re:Quitar Maximizar de un MDIFOR
« Respuesta #11 en: Junio 12, 2011, 10:35:57 pm »
A mi este codigo (similar al primero) me anda perfecto

Código: (vb) [Seleccionar]
Option Explicit
Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const WS_MAXIMIZEBOX = &H10000
Private Const GWL_STYLE As Long = -16

Private Sub MDIForm_Load()
    Call SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) And Not WS_MAXIMIZEBOX)
End Sub

Será que lo estas volviendo a poner despues del Form_Load?

PD: Poniendo el mismo codigo del Form_Load, en un boton, el cambio no "se ve" hasta que mueva el form :P

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #12 en: Junio 12, 2011, 10:46:59 pm »
Hola Raul

Tu código funciono perfecto al 66.66% (jeje)

Mira:
Punto 1: El botón sale inhabilitado: Perfecto.
Punto 2: Al hacer doble clic sobre la barra del MDI no se maximiza: Perfecto.
Punto 3: Al hacer click derecho y sale el menú emergente, en ese menú hay la opción de maximizar y se maximiza.

Solo bastaría que hacer desaparecer esa opción del menú emergente y quedaría de 100. Estuve viendo esto ayer casi todo el dia y como no lo pude resolver tome el consejo de xkiz y ya empece a usar formularios con parents en picture, es un poco mas de trabajo pero ni modo, solo me queda la duda si haciéndolo así pierdo algo: performance, memoria, o es igual, si me pudieran aclarar eso les agradecería.

Me encuentras en YAcosta.com

seba123neo

  • Terabyte
  • *****
  • Mensajes: 763
  • Reputación: +88/-5
    • Ver Perfil
Re:Quitar Maximizar de un MDIFOR
« Respuesta #13 en: Junio 12, 2011, 11:06:34 pm »
solo hay que hacerle un agregado al codigo de raul, obtener el menu del form a traves de la api GetSystemMenu y eliminar la opcion maximizar a traves de su id SC_MAXIMIZE.

Código: [Seleccionar]
Option Explicit

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const MF_BYCOMMAND = &H0
Private Const SC_MAXIMIZE As Long = &HF030&
Private Const GWL_STYLE& = (-16)
Private Const WS_MAXIMIZEBOX As Long = &H10000

Private Sub MDIForm_Load()
    DisableMaxButton
End Sub

Public Sub DisableMaxButton()

    Dim hMenu As Long
    Dim OldStyle As Long

    OldStyle = GetWindowLong(Me.hWnd, GWL_STYLE)
    SetWindowLong Me.hWnd, GWL_STYLE, OldStyle And (Not WS_MAXIMIZEBOX)

    hMenu = GetSystemMenu(Me.hWnd, 0&)
    If hMenu Then
        Call DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
        Call DrawMenuBar(Me.hWnd)
    End If
End Sub

Fuente: removing max button on mdi parent

saludos.

YAcosta

  • Moderador Global
  • Exabyte
  • *****
  • Mensajes: 2853
  • Reputación: +160/-38
  • Daddy de Qüentas y QüeryFull
    • Ver Perfil
    • Personal
Re:Quitar Maximizar de un MDIFOR
« Respuesta #14 en: Junio 12, 2011, 11:09:07 pm »
Ya por fin: 100%, el codigo va perfecto y cubre los 3 casos.

Como ya vengo avanzando con setparent, pregunta:

Sebas y usar el setparent?? (para evitar el midform) tendria algun problema'?? aparte de un poquito mas de chamba, algun inconveniente podre tener??? o debo cuidar algo??
« última modificación: Junio 12, 2011, 11:18:29 pm por YvanB »
Me encuentras en YAcosta.com