Jump to content
Fivewin Brasil

MsgList Sample


kapiaba

Recommended Posts

Esta eu não conhecia, show de bola



// MsgList Sample

#include <fivewin.ch>

FUNCTION Main()

LOCAL nItem := Month( Date() )
LOCAL aList1 := {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }

nItem := msglist( aList1, "Selection", , , 15, 20, "&Accept", nItem, .t. )

IF nItem > 0
MsgInfo( "Selected: " + aList1[ nItem ] )
ELSE
MsgInfo( "CANCELED!!!" )
ENDIF

nItem := msglist( {"Option 1", "Option 2" }, "Select from List", , , , , "&Select")

MsgInfo( "Item Selected: " + AllTrim( Str( nItem ) ) )

return nil

Link to comment
Share on other sites

********************************************************************************************

FUNCTION oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo )

********************************************************************************************

local oFont, oDlg, oLst, oBtnClose

local nItem := 0

if aData == nil .or. len(aData) == 0

MsgStop("Os parâmetros não foram passados corretamente para o oaMsgList()","Atenção")

RETURN nItem

endif

DEFAULT nTop:=9, nLeft:=9, nBottom:=200, nRight:=400, cTitle:="Selecione:", cBtnTitle:="&OK", cCampo:=""

nItem := iif(!Empty(cCampo), aScan(aData,cCampo), 1)

DEFINE FONT oFont NAME GetSysFont() SIZE 0,-8

DEFINE DIALOG oDlg FROM nTop,nLeft TO nBottom,nRight TITLE cTitle FONT oFont ;

STYLE nOr(WS_POPUP, WS_CAPTION, WS_BORDER, WS_SYSMENU, WS_THICKFRAME, WS_MAXIMIZEBOX) Pixel

@ 004,003 LISTBOX oLst VAR nItem ITEMS aData OF oDlg SIZE 100,100 Pixel

oLst:bLDblClick := {|| oDlg:End() }

@ 078,176 BUTTON oBtnClose PROMPT cBtnTitle DEFAULT SIZE 036,013 ACTION oDlg:End() Pixel

oDlg:bResized := {|| oLst:SetSize( oDlg:nWidth() - 27, oDlg:nHeight() - iif(LargeFonts(), 89, 79) ),;

oBtnClose:nTop := oDlg:nHeight() - iif(LargeFonts(), 79, 69),;

oBtnClose:nLeft := oDlg:nWidth() - 94,;

oLst:Select(nItem),;

oDlg:Refresh() }

ACTIVATE DIALOG oDlg CENTERED ON INIT ( Eval(oDlg:bResized) )

oFont:End()

RETURN nItem

Link to comment
Share on other sites

Olá,

Fiz alterações na rotina do Oscar para que o tamanho da janela, se não for passado, seja calculado. Como não utilizo o @say, creio que tem como melhorar o cálculo.

********************************************************************************************
FUNCTION oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo )
********************************************************************************************

local x, nItem := 0, nAlt, nLarg:=0
local oFont, oDlg, oLst, oBtnClose
   
if aData == nil .or. len(aData) == 0
        MsgStop("Os parâmetros não foram passados corretamente para o oaMsgList()","Atenção")
        RETURN nItem
endif

nAlt:=len( aData )
for x=1 to nAlt
        nLarg:=max( nLarg, len( aData[x] ) )
next

DEFAULT cTitle:="Selecione", nTop:=9, nLeft:=9, nBottom:=80+(nAlt*12), nRight:=max( (len(cTitle)*12)+50, 50+(nLarg*12) ), cBtnTitle:="&Confirme", cCampo:=""

nItem := iif(!Empty(cCampo), aScan(aData,cCampo), 1)

DEFINE FONT oFont NAME GetSysFont() SIZE 0,-8
DEFINE DIALOG oDlg  FROM nTop,nLeft TO nBottom,nRight TITLE cTitle FONT oFont ;
  STYLE nOr(WS_POPUP, WS_CAPTION, WS_BORDER, WS_THICKFRAME, WS_MAXIMIZEBOX) Pixel

@ 004,003 LISTBOX oLst VAR nItem ITEMS aData OF oDlg SIZE 100,100 Pixel
oLst:bLDblClick := {|| oDlg:End() }
@ 078,176 BUTTON oBtnClose PROMPT cBtnTitle DEFAULT SIZE 036,013 ACTION oDlg:End() Pixel
oDlg:bResized := {|| oLst:SetSize( oDlg:nWidth() - 27, oDlg:nHeight() - iif(LargeFonts(), 89, 79) ),;
                oBtnClose:nTop  := oDlg:nHeight() - iif(LargeFonts(), 79, 69),;
                oBtnClose:nLeft := oDlg:nWidth() - 94,;
                oLst:Select(nItem),;
                oDlg:Refresh()  }

ACTIVATE DIALOG oDlg CENTERED ON INIT ( Eval(oDlg:bResized) )
oFont:End()

RETURN nItem

Link to comment
Share on other sites

Olá Kapi.
Nem com quote , mas vai lá veja que as variáveis estão em DEFAULT 
   if aData == nil .or. len(aData) == 0
      MsgStop("Os parâmetros não foram passados corretamente para o oaMsgList()","Atenção")
      RETURN nItem
   endif

Quem é aData???

Pô meu, dá um eskulacho no programador do Glmer!! kkkkkkkkkkkk Tá de zoeira é???

Link to comment
Share on other sites

Evandro, quando for fazer algo, faça completo pô!!!! kkkkkkkkkkkkkkkkkkkkkk



#include "FiveWin.ch"

FUNCTION Main()

LOCAL aData := {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
LOCAL cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo

oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, cCampo )

RETURN NIL

FUNCTION oaMsgList( aData, cTitle, nTop, nLeft, nBottom, nRight, cBtnTitle, ;
cCampo )

local x, nItem := 0, nAlt, nLarg:=0
local oFont, oDlg, oLst, oBtnClose

if aData == nil .or. len(aData) == 0

MsgStop("Os parâmetros não foram passados corretamente para o oaMsgList()","Atenção")

RETURN nItem

endif

nAlt:=len( aData )

for x=1 to nAlt
nLarg:=max( nLarg, len( aData[x] ) )
next

DEFAULT cTitle := "Selecione", nTop:=9, nLeft:=9, nBottom:=80+(nAlt*12), ;
nRight := max( (len(cTitle)*12)+50, 50+(nLarg*12) ), ;
cBtnTitle := "&Confirme", cCampo := ""

nItem := iif(!Empty(cCampo), aScan(aData,cCampo), 1)

DEFINE FONT oFont NAME GetSysFont() SIZE 0,-8

DEFINE DIALOG oDlg FROM nTop,nLeft TO nBottom,nRight ;
TITLE cTitle FONT oFont ;
STYLE nOr( WS_POPUP, WS_CAPTION, WS_BORDER, WS_THICKFRAME, ;
WS_MAXIMIZEBOX) COLORS CLR_BLACK, CLR_WHITE ;
TRANSPARENT Pixel

@ 004,003 LISTBOX oLst VAR nItem ITEMS aData OF oDlg SIZE 100,100 Pixel

oLst:bLDblClick := {|| oDlg:End() }

@ 078,176 BUTTON oBtnClose PROMPT cBtnTitle DEFAULT SIZE 036,013 ;
ACTION oDlg:End() Pixel CANCEL

oDlg:bResized := {|| oLst:SetSize( oDlg:nWidth() - 27, oDlg:nHeight() - iif(LargeFonts(), 89, 79) ),;
oBtnClose:nTop := oDlg:nHeight() - iif(LargeFonts(), 79, 69),;
oBtnClose:nLeft := oDlg:nWidth() - 94,;
oLst:Select(nItem), oDlg:Refresh() }

ACTIVATE DIALOG oDlg CENTERED ON INIT ( Eval(oDlg:bResized) )

oFont:End()

RETURN nItem

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...