:
Ilmu Itu tuk berbagi Maka Amalkanlah...

Membuat MessageBox dalam Bahasa Indonesia di FoxPro

Dalam pemrograman VFP, kita pasti dan kenal betul apa yang namanya MESSAGEBOX, yaitu membuat pesan-pesan kepada user. Tapi kelemahannya : Tampilan standar VFP/windows (warna, huruf, icon) dan Tombolnya musti 'Yes' dan 'No'. Nah.. ini dia nih... biar kesannya sdikit Nasionalisme.. kita rubah aja dalam  format bentuk Bahasa Indonesia... mgkn ini cara yg bisa kita lakukan ... hahahahah.... Kambei Ambe


FUNCTION MsgBox(cMessage, nImage, nButton, nActive, cTitle)
  PUBLIC pnReturn
  LOCAL aImage, aMaxButton, aButton, cActive, nLButton, nLButton, nLMessage, nLTitle, nWidth
 

*!*     IF TYPE("oApp.oToolbar") = "O"
*!*       oApp.oToolBar.SetAll("Enabled",.F.)
*!*     ENDIF
*!*     IF TYPE("oApp.oPanel") = "O"
*!*       oApp.oPanel.SetAll("Enabled",.F.)
*!*     ENDIF
 
  ACTIVATE MENU _msysmenu NOWAIT
   
  DIMENSION aImage[4]
  aImage[1] =CURDIR()+"\graphics\icombox01.ico"     && Stop sign 
  aImage[2] =CURDIR()+"\graphics\icombox02.ico"     && Question mark
  aImage[3] =CURDIR()+"\graphics\icombox03.ico"     && Exclamation point
  aImage[4] =CURDIR()+"\graphics\icombox04.ico"     && Information (i) icon


  DIMENSION aMaxButton[5]
  aMaxButton[1] =1
  aMaxButton[2] =2
  aMaxButton[3] =3
  aMaxButton[4] =2
  aMaxButton[5] =2


  DIMENSION aButton[aMaxButton[nButton]]
  DO CASE
     CASE nButton=1
          aButton[1] ='\<Ya'
     CASE nButton=2
          aButton[1] ='\<Ya'
          aButton[2] ='\<Batal'
     CASE nButton=3
          aButton[1] ='\<Ya'
          aButton[2] ='\<Tidak'
          aButton[3] ='\<Batal'
     CASE nButton=4
          aButton[1] ='\<Ya'
          aButton[2] ='\<Tidak'
     CASE nButton=5
          aButton[1] ='\<Coba'
          aButton[2] ='\<Batal'
  ENDCASE


  IF aMaxButton[nButton] = 3
     cActive =IIF( nActive = 1, '123', IIF( nActive = 2, '231', '312' ) )
  ELSE
     cActive =IIF( nActive = 1, '12', '21' )
  ENDIF
 
  *----- perhitungan lebar windows/form
  cMessage  = ALLTRIM(cMessage)
  nLButton  = (aMaxButton[nButton] * 80) + ((aMaxButton[nButton]-1) * 10)
  nLMessage = (( TXTWIDTH(cMessage,'MS Sans Serif',9) * FONTMETRIC(6,'MS Sans Serif',9) / 5 ) * 5 )
  nLTitle   = ( TXTWIDTH(cTitle,'MS Sans Serif',9) * FONTMETRIC(6,'MS Sans Serif',9) / 5 ) * 5
  nWidth    = IIF( nLButton+40 > nLMessage+90, nLButton+40, IIF( nLMessage+90 > nLTitle, nLMessage+90, nLTitle ) )
 
*!*     nLMessage = (( TXTWIDTH(cMessage,'Arial',9) * FONTMETRIC(6,'Arial',9) / FONTMETRIC(6) ) * 5 )
*!*     nLTitle   = ( TXTWIDTH(cTitle,'Arial',9) * FONTMETRIC(6,'Arial',9) / FONTMETRIC(6) ) * 5


 
  *----- create object
  frmMyForm = CREATEOBJECT('MyForm')  && Create a Form
  frmMyForm.AddObject('Image','MyImage') 
  frmMyForm.AddObject('Label','MyLabel')
 
  frmMyForm.AddObject('cmdCmndBtn1','cmdMyCmndBtn1')  && Cmnd button #1
  frmMyForm.cmdCmndBtn1.Visible =.T.  && Command button visible #1
  IF aMaxButton[nButton] > 1 AND aMaxButton[nButton] <= 3
     frmMyForm.AddObject('cmdCmndBtn2','cmdMyCmndBtn2')  && Cmnd button #2
     frmMyForm.cmdCmndBtn2.Visible =.T.  && Command button visible #2
  ENDIF
  IF aMaxButton[nButton] = 3
     frmMyForm.AddObject('cmdCmndBtn3','cmdMyCmndBtn3')  && Cmnd button #3
     frmMyForm.cmdCmndBtn3.Visible =.T.  && Command button visible #3
  ENDIF


  *----- Properties form
  frmMyForm.FontName ="MS Sans Serif"
  frmMyForm.FontSize =9
  frmMyForm.Width =nWidth 
  frmMyForm.AutoCenter =.T.
  frmMyForm.Caption =cTitle
  frmMyForm.AlwaysOnTop =.T.


  *----- Properties image/logo
  frmMyForm.Image.Picture =aImage[nImage]
  frmMyForm.Image.Left =(nWidth-nLMessage-50)/2
 
  *----- Properties Label/Message
  frmMyForm.Label.Caption =cMessage
  frmMyForm.Label.Left =((nWidth-nLMessage-50)/2)+50


  *----- Properties command button
  frmMyForm.cmdCmndBtn1.Left = (nWidth-nLButton)/2
  frmMyForm.cmdCmndBtn1.TabIndex =VAL(LEFT(cActive,1))
  IF aMaxButton[nButton] > 1 AND aMaxButton[nButton] <= 3
     frmMyForm.cmdCmndBtn2.Left = ((nWidth-nLButton)/2)+80+10
     frmMyForm.cmdCmndBtn2.TabIndex =VAL(SUBSTR(cActive,2,1))
  ENDIF
  IF aMaxButton[nButton] = 3
     frmMyForm.cmdCmndBtn3.Left = ((nWidth-nLButton)/2)+(80*2)+(10*2)
     frmMyForm.cmdCmndBtn3.TabIndex =VAL(RIGHT(cActive,1))
  ENDIF


  SET BELL TO CURDIR()+'\sound\chimes.wav',0     &&blip.wav',0
  ??C H R (7)
  SET BELL TO
  frmMyForm.SHOW(1)    &&SHOW  && Display the form
  READ EVENTS  && Start event processing


  RETURN pnReturn
ENDFUNC


Untuk Lebih Lengkap silahkan Download disini 






Sumber

0 komentar:

Posting Komentar

Berbagi itu indah, Salam kenal dari Putera Makassar...