Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MESSAGEBOX call not executed in command button Click

Status
Not open for further replies.

StewartUK

Programmer
Feb 19, 2001
860
GB
I have a button on my toolbar that allows the user to save the results of a search.

Here's the code from the parent class click event:
Code:
LOCAL FileName, OriginalDirectory, StartDirectory, TextBoxObject, FileType
TextBoxObject = THIS.Textbox [COLOR=green][b]&& custom property[/b][/color]
OriginalDirectory = SET([Directory]) [COLOR=green][b]&& the current directory[/b][/color]
StartDirectory = FredUser(THIS.FredUserStartDirectoryRef, [c:\temp\], [RD]) [COLOR=green][b]&& ...get, from user's preference table, the last folder they looked in[/b][/color]
IF DIRECTORY(StartDirectory)
   CHDIR (StartDirectory) [COLOR=green][b]&& change to path returned by FredUser, or...[/b][/color]
ELSE
   CHDIR c:\temp [COLOR=green][b]&& ...if that folder doesn't exist, go to one that does[/b][/color]
ENDIF
FileType = THIS.Filetypes [COLOR=green][b]&& *.dbf, *.csv etc etc[/b][/color]
FileName = GETFILE(FileType,"Letter name :-","OK",0,"Select the pic file you want") [COLOR=green][b]&& get the user to select a file / enter a new filename[/b][/color]
CHDIR (OriginalDirectory) [COLOR=green][b]&& return to original directory[/b][/color]
IF NOT EMPTY(FileName) [COLOR=green][b]&& check that a filename was returned[/b][/color]
   &TextBoxObject..Value = FileName [COLOR=green][b]&& set the Value property of the TextBox to the path/filename[/b][/color]
   &TextBoxObject..ToolTipText = IIF(LEN(FileName) > _ToolTipTextMaxLen, LEFT(FileName, _ToolTipTextMaxLen-3)+[...],FileName) [COLOR=green][b]&& set the ToolTipText the same[/b][/color]
   =FredUser(THIS.FredUserStartDirectoryRef, JUSTPATH(FileName)) [COLOR=green][b]&& update preference table[/b][/color]
   IF NOT EMPTY(THIS.FredUserFilePathName) [COLOR=green][b]&& update preference table[/b][/color]
      =FredUser(THIS.FredUserFilePathName, FileName)
   ENDIF
ENDIF

Here's the code in the instance that is causing me a problem:
Code:
DODEFAULT()
LOCAL lContinue, PreviousSafety
lContinue = .T.
IF FILE([THIS.Parent.txtResults.Value])
   SET BELL TO [C:\Program Files\Microsoft Office\OFFICE11\MEDIA\BOMB.WAV] [COLOR=green][b]&& ...this line is executed[/b][/color]
   ? _Chime [COLOR=green][b]&& this line is executed[/b][/color]
   MbResponse = MESSAGEBOX("File " + THIS.Parent.txtResults.Value + " already exists." + CR + "Are you sure you want to overwrite it?",MB_YESNO+MB_QUESTIONICON,"Foundation - saving results") [COLOR=green][b]&& this line is NOT executed - that is, no MessageBox appears[/b][/color]
   lContinue = MbResponse = MB_YES [COLOR=green][b]&& I don't know if this line runs[/b][/color]

ENDIF
IF lContinue [COLOR=green][b]&& at this point, lContinue is TRUE[/b][/color]
   PreviousSafety = SET("SAFETY")
   SET SAFETY OFF
   _SCREEN.LockScreen = .T.
   SELECT StdResults
   COPY TO (THIS.Parent.txtResults.Value)
   GO TOP
   _SCREEN.LockScreen = .F.
   SET SAFETY &PreviousSafety
ENDIF
As you can see from my comments, the MESSAGEBOX line is never executed.

Can anyone advise me why this might be?

Thanks,

Stewart
 
Have you set the values of MB_YESNO and MB_QUESTIONICON? If you have an ON ERROR clause and those vairables are not set, messagebox and the line following will not run. lContinue is true since you started with it as true so my guess is the line after messagebox is not working either. Maybe you should display the values of MB_YESNO and MB_QUESTIONICON before calling the messagebox to see what they are.
 
WCSO,

Thanks for your reply.

I went back to doing some testing and realised that I am being a dozy twit! The messagebox was running fine, it's just that the dialog that came up looked just like VFP's dialog when you try to overwrite some file and it asks if you're sure!! So I was thinking that the MB wasn't running.

Time to go home, sorry to have bothered everyone.

Stewart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top