1

Konu: MessageBox

MessageBox(' Seçim Yapınız', 'Uyarı !!!!!')

bu uyarı yazısını ekranın istediğimiz bir yerine yazdırabilirmiyiz ?

2

Re: MessageBox

bildiğim kadarıyla hayır...

Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com

3

Re: MessageBox

Ücretsiz değil. İncelediğim zaman arayüzünü ve özelliklerini çok beğenmiştim :

http://news2news.com/vfp/?solution=3

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

4

Re: MessageBox

MessageBox ı kendin yazmayı düşünsene çok kolay yazarsın

5

Re: MessageBox

Konuralp, keşke 1 gün 24 saat diilde 96 saat filan olsa ve kod yazmaya daha çok zaman ayırabilsem smile

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

6

Re: MessageBox

Uğur,
Messagebox  a benzer form yapılabilir.
Mesajornek diye bir formun olsa bu forma dışarıdan gelen giriş parametreleri  "mesaj1, mesaj2, parametre1, resim1"    olsa

mesaj1       :  mesaj başlık
mesaj2       :  mesaj ayrıntı
parametre1 :   1: "evet hayır" , 2: "tamam"  ( gibi butonların hangisi çıkmalı)
resim1        :   ekrana hangi resim çıksın

Böyle bir form tanımlasan olur bence

7

Re: MessageBox

Evet, haklısın smile

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

8

Re: MessageBox

isini gorurmü bilmiyorum

Visual Fox Pro
Local lo_MsgBox

 
lo_MsgBox = CreateObject( 'cls_MessageBox' )
lo_MsgBox.ShowMsg( 'Test MessageBox', 64, 'MessageBox Title' )
 
lo_MsgBox.lChangeButton = .T. && Change MessageBox Button
lo_MsgBox.aButtons[1] = '&Good' && 1st button
lo_MsgBox.ShowMsg( 'Test MessageBox', 64, 'MessageBox Title' )
 
** lo_MsgBox.hWnd = myForm.hWnd && center MessageBox in Form
lo_MsgBox.lTransparent = .T. && transparent MessageBox
lo_MsgBox.nTransValue = 85 && 85% transparent
lo_MsgBox.aButtons[2] = '&Bad' && 2nd button
lo_MsgBox.aButtons[3] = '&Worst' && 3rd button
lo_MsgBox.ShowMsg( 'Test MessageBox', 64+2, 'MessageBox Title' )
 
lo_MsgBox = Null
Release lo_MsgBox
 
**********************
 
Define class cls_MessageBox as Custom
hWnd = 0
pOrgProc = 0
lChangeButton = .F.
lTransparent = .F.
nTransValue = 100 && in percentage, 100% = opaque
 
Dimension aButtons[3] = .F.
 
Procedure Init
Declare Long SetLayeredWindowAttributes in User32 ;
Long nhWnd, Long crKey, Short bAlpha, Long dwFlags
 
Declare Long GetWindowLong in User32 ;
Long nhWnd, Integer nIndex
 
Declare Long SetWindowLong in User32 ;
Long nhWnd, Integer nIndex, Long dwNewLong
 
Declare Long GetWindowRect in User32 ;
Long nhWnd, String @O_lpRect
 
Declare Long SetWindowPos in User32 ;
Long nhWnd, Long hWndInsertAfter, ;
Integer nX, Integer nY, Integer nWidth, Integer nHeight, Long nFlags
 
Declare Long CallWindowProc in User32 ;
Long lpPrevWndFunc, Long nhWnd, ;
Long uMsg, Long wParam, Long lParam
 
Declare Long FindWindowEx in User32 ;
Long hWndParent, Long hWndChildAfter, ;
String lpszClass, String lpszWindow
 
Declare Long SendMessage in User32 as SendMessageStr ;
Long nhWnd, Long uMsg, Long wParam, String @lParam
 
This.hWnd = _VFP.hWnd
This.pOrgProc = GetWindowLong( _VFP.hWnd, -4 )
EndProc
 
 
Procedure ShowMsg( tc_Msg, tn_Type, tc_Title )
BindEvent( 0, 0x06, This, 'WndProc' )
MessageBox( tc_Msg, tn_Type, tc_Title )
UnBindEvents( 0, 0x06 )
EndProc
 
 
Procedure CenterWindow( th_WndParent, th_WndChild )
Local ls_Rect
 
ls_Rect = space( 16 )
** Get container area (parent)
GetWindowRect( th_WndParent, @ls_Rect )
ln_TargetLeft = CToBin( substr( ls_Rect, 1, 4 ), '4rs' )
ln_TargetTop = CToBin( substr( ls_Rect, 5, 4 ), '4rs' )
ln_Right = CToBin( substr( ls_Rect, 9, 4 ), '4rs' ) + 1
ln_Bottom = CToBin( substr( ls_Rect, 13, 4 ), '4rs' ) + 1
ln_Width = ln_Right - ln_TargetLeft
ln_Height = ln_Bottom - ln_TargetTop
 
** Get contained area (child)
GetWindowRect( th_WndChild, @ls_Rect )
ln_Left = CToBin( substr( ls_Rect, 1, 4 ), '4rs' )
ln_Top = CToBin( substr( ls_Rect, 5, 4 ), '4rs' )
ln_Right = CToBin( substr( ls_Rect, 9, 4 ), '4rs' ) + 1
ln_Bottom = CToBin( substr( ls_Rect, 13, 4 ), '4rs' ) + 1
 
** Get Left & Top position (XY coordinate)
ln_Left = ((ln_Width - (ln_Right - ln_Left)) / 2) + ln_TargetLeft
ln_Top = (ln_Height - (ln_Bottom - ln_Top)) / 2 + ln_TargetTop
SetWindowPos( th_WndChild, 0, ln_Left,ln_Top, 0,0, BitOr( 0x1, 0x10, 0x400 ))
EndProc
 
 
Procedure WndProc( th_Wnd, tn_Msg, t_wParam, t_lParam )
If (tn_Msg == 0x06) and (t_wParam == 0)
Local ln_X, lh_Wnd, lh_WndChild, ln_OldStyle, ln_Transparent
 
With This
If ( .lTransparent ) and (.nTransValue > 0)
ln_Transparent = int((255 * This.nTransValue) / 100)
SetWindowLong( t_lParam, -20, ;
BitOr( GetWindowLong( t_lParam, -20 ), 0x80000 ))
SetLayeredWindowAttributes( t_lParam, 0, ln_Transparent, 2 )
endif
 
If ( .lChangeButton )
lh_WndChild = 0
For ln_X = 1 to 3
lh_WndChild = FindWindowEx( t_lParam, lh_WndChild, 'Button', 0 )
If (lh_WndChild == 0)
ln_X = 4
else
If !empty( .aButtons[ ln_X ] )
SendMessageStr( lh_WndChild, 0x0C, 0, .aButtons[ ln_X ] )
endif
endif
Next
endif
 
.CenterWindow( .hWnd, t_lParam )
EndWith
Return 0
endif
 
Return CallWindowProc( This.pOrgProc, th_Wnd, tn_Msg, t_wParam, t_lParam )
EndProc
 
Procedure Destroy
Clear DLLs
EndProc
EndDefine

9

Re: MessageBox

soykan; maymuncuk gibisin

VFP9 SP2

10

Re: MessageBox

Soykan Bey'in verdiği kod çok yararlı bir kod benim için. Yalnız, messagebox'tan dönen değeri nasıl alabilirim, yani kullanıcının hangi butona bastığını gösteren değeri.

Teşekkürler.

11

Re: MessageBox

bunda öyle bir özellik var mı bilmiyorum ama:

http://weblogs.foxite.com/vfpimaging/20 … e-buttons/

kodda tırnak hataları filan var. düzelten arkadaş olursa buraya atabilirse sevinirim.

Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com

12

Re: MessageBox

Ben tırnak işaretlerini düzeltim, ama bu sefer de prg'yi çalıştırınca VFP'den çıkıyor hatta aynı anda çalışan programlar da çöküyor!

lnoption = msgboxex("could not find the file import.csv in the selected folder", 0, "file not found", ;
   "&abort,\&retry,change folder")

******************************************
FUNCTION MSGBOXEX
lparameters tccaption, tnicon, tctitle, tcbuttons, tciconfile
if vartype(tntimeout) = "c" and (pcount() = 4)
   tcbuttons = tntimeout
   tntimeout = 0
endif

private pnbuttoncnt, pcbuttons, pnbutttype, pciconfile, phicon
pciconfile = iif(empty(tciconfile),"", tciconfile)
pnbuttoncnt = getwordcount(tcbuttons, ",")
pcbuttons = tcbuttons
*!* stop 16
*!* question 32
*!* exclamation 48
*!* info 64
if vartype(tnicon) = "c"
   tnicon = upper(tnicon)
   do case
   case tnicon = "x"
      tnicon = 16
   case tnicon = "?"
      tnicon = 32
   case tnicon = "!"
      tnicon = 48
   case tnicon = "i"
      tnicon = 64
   otherwise
      tnicon = 0
   endcase
endif

* check if an icon will be shown
* if an icon file was passed, we need to ensure that messagebox() will
* show an icon, that will be changed further.

#define image_bitmap 0
#define image_icon 1
#define lr_loadfromfile 0×0010
#define lr_defaultsize 0×0040
phicon = 0
if not empty(pciconfile) and ;
   (not (bittest(tnicon, 4) or bittest(tnicon, 5) or bittest(tnicon, 6)))
   tnicon = tnicon + 16
   phicon = xmbloadimage(0, fullpath(pciconfile), image_icon, 0,0, lr_loadfromfile + lr_defaultsize)
endif


* windows hook constants
#define wh_cbt 5

* set library so bindeventex and unbindeventex can be used in vfp
local lcoldsetlib
lcoldsetlib = set("library")
set library to "vfpex.fll"
bindeventex("wineventhandler()", wh_cbt) && setwindowshookex

* this messagebox will be modified before it is shown
local lnoption, lnindex
do case
case pnbuttoncnt = 1
   pnbutttype = 0 && ok
case pnbuttoncnt = 2
   pnbutttype = 4 && yes / no
case pnbuttoncnt = 3
   pnbutttype = 2 && abort / retry / ignore
otherwise
endcase

lnoption = messagebox(tccaption, tnicon + pnbutttype, tctitle)

local lnoffset
lnoffset = icase(pnbuttoncnt = 3, 2, pnbuttoncnt = 2, 5 , 0)
lnindex = lnoption – lnoffset

if phicon <> 0
   =xmbdeleteobject(phicon) && clear icon handle
endif

if not empty(lcoldsetlib)
   set library to (lcoldsetlib)
endif
return lnindex


procedure wineventhandler
#define dlg_ctrlid_icon 0×0014
#define stm_seticon 0×0170
#define stm_setimage 0×0172
if ncode == 5
   if not empty(phicon)
      * changing the dialog icon
      local lhiconwindow
      lhiconwindow = xmbgetdlgitem(wparam, dlg_ctrlid_icon)
      if lhiconwindow <> 0
         if phicon <> 0
            =xmbsendmessage(lhiconwindow, stm_seticon, phicon, 0)
         endif
      endif
   endif

   * change button attributes
   local n, lnoffset, lccaption
   lnoffset = icase(pnbuttoncnt = 3, 2, pnbuttoncnt = 2, 5 , 0)
   for n = 1 to pnbuttoncnt
      lccaption = getwordnum(pcbuttons, n, ",")
      * disable current button
      if left(lccaption, 1) = "\"
         lccaption = substr(lccaption, 2) && get the rest of the string
         local lnbtnhwnd
         lnbtnhwnd = xmbgetdlgitem(wparam, lnoffset + n)
         =xmbenablewindow(lnbtnhwnd, 0)
      endif

      * change the caption
      =xmbsetdlgitemtext(wparam, lnoffset + n, lccaption)
   endfor

   =xmbcallnexthookex(hhook, ncode, wparam, lparam) && all 4 variables exist
   unbindeventex()
else
   =xmbcallnexthookex(hhook, ncode, wparam, lparam) && all 4 variables created by fll
endif

release ncode, wparam, lparam, hhook
endproc

 

*********************************************************************
function xmbsetdlgitemtext(hdlg, niddlgitem, lpstring)
*********************************************************************
declare integer setdlgitemtext in user32 as xmbsetdlgitemtext ;
   long hdlg,;
   long niddlgitem,;
   string lpstring
return xmbsetdlgitemtext(hdlg, niddlgitem, lpstring)
endfunc

*********************************************************************
function xmbcallnexthookex(hhook, ncode, wparam, lparam)
*********************************************************************
declare long callnexthookex in user32 as xmbcallnexthookex ;
   long hhook, long ncode, long wparam, long lparam
return xmbcallnexthookex(hhook, ncode, wparam, lparam)
endfunc

*********************************************************************
function xmbgetdlgitem(hdlg, niddlgitem)
*********************************************************************
* hdlg [in] handle to the dialog box that contains the control.
* niddlgitem [in] specifies the identifier of the control to be retrieved.
* [url]http://msdn.microsoft.com/en-us/library/ms645481(vs.85).aspx[/url]
declare integer getdlgitem in user32 as xmbgetdlgitem ;
   long hdlg,;
   long niddlgitem
return xmbgetdlgitem(hdlg, niddlgitem)
endfunc

*********************************************************************
function xmbenablewindow(hwnd, fenable)
*********************************************************************
declare integer enablewindow in user32 as xmbenablewindow integer hwnd, integer fenable
return xmbenablewindow(hwnd, fenable)
endfunc

*********************************************************************
function xmbsendmessage(hwindow, msg, wparam, lparam)
*********************************************************************
* [url]http://msdn.microsoft.com/en-us/library/bb760780(vs.85).aspx[/url]
* [url]http://www.news2news.com/vfp/?group=-1&function=312[/url]
declare integer sendmessage in user32 as xmbsendmessage;
   integer hwindow, integer msg,;
   integer wparam, integer lparam
return xmbsendmessage(hwindow, msg, wparam, lparam)
endfunc

*********************************************************************
function xmbloadimage(hinst, lpszname, utype, cxdesired, cydesired, fuload)
*********************************************************************
declare integer loadimage in user32 as xmbloadimage;
   integer hinst,;
   string lpszname,;
   integer utype,;
   integer cxdesired,;
   integer cydesired,;
   integer fuload
return xmbloadimage(hinst, lpszname, utype, cxdesired, cydesired, fuload)
endfunc

*********************************************************************
function xmbdeleteobject(hobject)
*********************************************************************
declare integer deleteobject in gdi32 as xmbdeleteobject integer hobject
return xmbdeleteobject(hobject)
endfunc 

13

Re: MessageBox

Ben kodu aynen kopyalayıp yapıştırdım; problemsiz çalıştı.
Erdal

14

Re: MessageBox

bu satır sizde hata vermiyor mu compile edince?
   phicon = xmbloadimage(0, fullpath(pciconfile), image_icon, 0,0, lr_loadfromfile + lr_defaultsize)

Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com

15

Re: MessageBox

sizde nasıl çalıştı anlamadım. x ve - lerde hatalar vardı. çok benzer başka karakterler vardı onların yerinde. bu çalışıyor:

Visual Fox Pro
FUNCTION MSGBOXEX

lparameters tccaption, tnicon, tctitle, tcbuttons, tciconfile
if vartype(tntimeout) = "c" and (pcount() = 4)
   tcbuttons = tntimeout
   tntimeout = 0
endif
 
private pnbuttoncnt, pcbuttons, pnbutttype, pciconfile, phicon
pciconfile = iif(empty(tciconfile),"", tciconfile)
pnbuttoncnt = getwordcount(tcbuttons, ",")
pcbuttons = tcbuttons
*!* stop 16
*!* question 32
*!* exclamation 48
*!* info 64
if vartype(tnicon) = "c"
   tnicon = upper(tnicon)
   do case
   case tnicon = "x"
      tnicon = 16
   case tnicon = "?"
      tnicon = 32
   case tnicon = "!"
      tnicon = 48
   case tnicon = "i"
      tnicon = 64
   otherwise
      tnicon = 0
   endcase
endif
 
* check if an icon will be shown
* if an icon file was passed, we need to ensure that messagebox() will
* show an icon, that will be changed further.
 
#define image_bitmap 0
#define image_icon 1
#define lr_loadfromfile 0x0010
#define lr_defaultsize 0x0040
phicon = 0
if not empty(pciconfile) and ;
   (not (bittest(tnicon, 4) or bittest(tnicon, 5) or bittest(tnicon, 6)))
   tnicon = tnicon + 16
 
 
*   phicon = xmbloadimage(0, fullpath(pciconfile), image_icon, 0,0, lr_loadfromfile + lr_defaultsize)
*function xmbloadimage(hinst, lpszname, utype, cxdesired, cydesired, fuload)
 
endif
 
 
* windows hook constants
#define wh_cbt 5
 
* set library so bindeventex and unbindeventex can be used in vfp
local lcoldsetlib
lcoldsetlib = set("library")
set library to "vfpex.fll"
bindeventex("wineventhandler()", wh_cbt) && setwindowshookex
 
* this messagebox will be modified before it is shown
local lnoption, lnindex
do case
case pnbuttoncnt = 1
   pnbutttype = 0 && ok
case pnbuttoncnt = 2
   pnbutttype = 4 && yes / no
case pnbuttoncnt = 3
   pnbutttype = 2 && abort / retry / ignore
otherwise
endcase
 
lnoption = messagebox(tccaption, tnicon + pnbutttype, tctitle)
 
local lnoffset
lnoffset = icase(pnbuttoncnt = 3, 2, pnbuttoncnt = 2, 5 , 0)
lnindex = lnoption - lnoffset
 
if phicon <> 0
   =xmbdeleteobject(phicon) && clear icon handle
endif
 
if not empty(lcoldsetlib)
   set library to (lcoldsetlib)
endif
return lnindex
 
 
procedure wineventhandler
#define dlg_ctrlid_icon 0x0014
#define stm_seticon 0x0170
#define stm_setimage 0x0172
if ncode == 5
   if not empty(phicon)
      * changing the dialog icon
      local lhiconwindow
      lhiconwindow = xmbgetdlgitem(wparam, dlg_ctrlid_icon)
      if lhiconwindow <> 0
         if phicon <> 0
            =xmbsendmessage(lhiconwindow, stm_seticon, phicon, 0)
         endif
      endif
   endif
 
   * change button attributes
   local n, lnoffset, lccaption
   lnoffset = icase(pnbuttoncnt = 3, 2, pnbuttoncnt = 2, 5 , 0)
   for n = 1 to pnbuttoncnt
      lccaption = getwordnum(pcbuttons, n, ",")
      * disable current button
      if left(lccaption, 1) = "\"
         lccaption = substr(lccaption, 2) && get the rest of the string
         local lnbtnhwnd
         lnbtnhwnd = xmbgetdlgitem(wparam, lnoffset + n)
         =xmbenablewindow(lnbtnhwnd, 0)
      endif
 
      * change the caption
      =xmbsetdlgitemtext(wparam, lnoffset + n, lccaption)
   endfor
 
   =xmbcallnexthookex(hhook, ncode, wparam, lparam) && all 4 variables exist
   unbindeventex()
else
   =xmbcallnexthookex(hhook, ncode, wparam, lparam) && all 4 variables created by fll
endif
 
release ncode, wparam, lparam, hhook
endproc
 
 
 
*********************************************************************
function xmbsetdlgitemtext(hdlg, niddlgitem, lpstring)
*********************************************************************
declare integer setdlgitemtext in user32 as xmbsetdlgitemtext ;
   long hdlg,;
   long niddlgitem,;
   string lpstring
return xmbsetdlgitemtext(hdlg, niddlgitem, lpstring)
endfunc
 
*********************************************************************
function xmbcallnexthookex(hhook, ncode, wparam, lparam)
*********************************************************************
declare long callnexthookex in user32 as xmbcallnexthookex ;
   long hhook, long ncode, long wparam, long lparam
return xmbcallnexthookex(hhook, ncode, wparam, lparam)
endfunc
 
*********************************************************************
function xmbgetdlgitem(hdlg, niddlgitem)
*********************************************************************
* hdlg [in] handle to the dialog box that contains the control.
* niddlgitem [in] specifies the identifier of the control to be retrieved.
* http://msdn.microsoft.com/en-us/library … s.85).aspx
declare integer getdlgitem in user32 as xmbgetdlgitem ;
   long hdlg,;
   long niddlgitem
return xmbgetdlgitem(hdlg, niddlgitem)
endfunc
 
*********************************************************************
function xmbenablewindow(hwnd, fenable)
*********************************************************************
declare integer enablewindow in user32 as xmbenablewindow integer hwnd, integer fenable
return xmbenablewindow(hwnd, fenable)
endfunc
 
*********************************************************************
function xmbsendmessage(hwindow, msg, wparam, lparam)
*********************************************************************
* http://msdn.microsoft.com/en-us/library … s.85).aspx
* http://www.news2news.com/vfp/?group=-1&function=312
declare integer sendmessage in user32 as xmbsendmessage;
   integer hwindow, integer msg,;
   integer wparam, integer lparam
return xmbsendmessage(hwindow, msg, wparam, lparam)
endfunc
 
*********************************************************************
function xmbloadimage(hinst, lpszname, utype, cxdesired, cydesired, fuload)
*********************************************************************
declare integer loadimage in user32 as xmbloadimage;
   integer hinst,;
   string lpszname,;
   integer utype,;
   integer cxdesired,;
   integer cydesired,;
   integer fuload
return xmbloadimage(hinst, lpszname, utype, cxdesired, cydesired, fuload)
endfunc
 
*********************************************************************
function xmbdeleteobject(hobject)
*********************************************************************
declare integer deleteobject in gdi32 as xmbdeleteobject integer hobject
return xmbdeleteobject(hobject)
endfunc
Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com

16

Re: MessageBox

Metin Bey, o satırda hata vermiyor.
Bende hiç bir biçimde çalışmıyor. Ancak önce Windows'un daha doğrusu normal messagebox'ın sesi duyuluyor (sanırım windows default wav) sonra da zeminde çalışan başka program varsa onlar da çöküyor ve VFP'den çıkıyor

17

Re: MessageBox

.fll dosyası gerektirmeyen ve göçmeyen güncel versiyonu bu  linkte http://weblogs.foxite.com/vfpimaging/20 … -reviewed/ . ayrıca download linki de var sayfada. yani copy-paste edip hataları düzeltmeniz gerekmiyor!!!

Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com

18

Re: MessageBox

Çok işime yarayacak  smile

Çok teşekkürler...

19

Re: MessageBox

Sevgili Arkadaşlar,
Aşağıdaki bağlantıyı isterseniz bir deneyin. Programlar ve çalışmaları var. İşinize yarayabilir.
Sevgilerimle.
Erdal

http://www.mediafire.com/?n51tq6b85b6yinv

20

Re: MessageBox

verdiğim linkteki program bugün tekrar güncellenmiş...

Haksızlıklar karşısında susanlar, dilsiz şeytanlardır!
www.metinemre.com