5 de agosto de 2015

Formulario transparente mas no los controles contenidos

En la entrada Formularios transparentes vimos como darle distintos porcentajes de opacidad a los formularios, hasta convertirlos en transparentes.

En este caso hacemos 100% transparente el formulario, pero no así los objetos contenidos en él.


PUBLIC goMyForm
goMyForm = CREATEOBJECT("MyFormTopLevel")
goMyForm.SHOW(1)
RETURN

DEFINE CLASS MyFormTopLevel AS FORM
  HEIGHT = 266
  WIDTH = 386
  SHOWWINDOW = 2
  AUTOCENTER = .T.
  CAPTION = "Formulario Transparente"
  WINDOWTYPE = 0
  WINDOWSTATE = 0
  BACKCOLOR = RGB(255,0,255)
  NAME = "MyForm"

  ADD OBJECT text1 AS TEXTBOX WITH ;
    HEIGHT = 24, LEFT = 264, TOP = 24, WIDTH = 96, ;
    VALUE = "Hola!", ;
    NAME = "Text1"

  ADD OBJECT command1 AS COMMANDBUTTON WITH ;
    TOP = 60, LEFT = 264, HEIGHT = 48, WIDTH = 96, ;
    CAPTION = "Hola!", NAME = "Command1"

  ADD OBJECT pageframe1 AS PAGEFRAME WITH ;
    PAGECOUNT = 3, ;
    TOP = 24, LEFT = 24, WIDTH = 216, HEIGHT = 204, ;
    NAME = "Pageframe1", ;
    Page1.CAPTION = "Page1", ;
    Page1.NAME = "Page1", ;
    Page2.CAPTION = "Page2", ;
    Page2.NAME = "Page2"

  ADD OBJECT combo1 AS COMBOBOX WITH ;
    COLUMNCOUNT = 0, COLUMNWIDTHS = "", ROWSOURCETYPE = 1, ;
    ROWSOURCE = "Uno,Dos,Tres,Cuatro,Cinco", ;
    TOP = 120, WIDTH = 96, HEIGHT = 24, LEFT = 264, ;
    NUMBEROFELEMENTS = 0, STYLE = 2, ;
    FIRSTELEMENT = 3, NAME = "Combo1"

  PROCEDURE LOAD
    IF VAL(OS(3)) >= 5  && Windows 2000 o superior

      DECLARE GetWindowLong ;
        IN WIN32API ;
        AS __GetWindowLong ;
        INTEGER, ;
        INTEGER

      DECLARE SetWindowLong ;
        IN WIN32API ;
        AS __SetWindowLong ;
        INTEGER, ;
        INTEGER, ;
        INTEGER

      DECLARE SetLayeredWindowAttributes ;
        IN WIN32API ;
        AS __SetLayeredWindowAttributes ;
        INTEGER, ;
        INTEGER, ;
        INTEGER, ;
        INTEGER

      __SetWindowLong(THISFORM.HWND, -20, BITOR(IIF(__GetWindowLong(THISFORM.HWND, -20), 1, 0), 0x80000))
      __SetLayeredWindowAttributes(THISFORM.HWND, THISFORM.BACKCOLOR, 0, 1)
    ENDIF
  ENDPROC
ENDDEFINE

Luis María Guyán

No hay comentarios. :

Publicar un comentario

Los comentarios son moderados, por lo que pueden demorar varias horas para su publicación.