User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 456,607 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,492 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 5189 | Replies: 23
Reply
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Question How to make a popup window

  #1  
Nov 7th, 2007
Hello DaniWeb. I'm new to this site and will just have to say some words before asking my question. I'm Loyen and I am 14 years old and lives in Sweden. I've just started on an upper secondary school about IT and there I'm going one class that's called "programming" there we're learning the basics in Pascal.

Now, I'm really interested in this, and just wanted to know, how do I do a basic popup window that just gives you a message? Can I make one that has no buttons just a clean window without any "minimazers, closers" and all?

Write it here.

Thank you all for your time and hopefully somebody knows how to do a basic popup window.

//Loyen
Last edited by Loyen : Nov 7th, 2007 at 12:28 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 15
Reputation: RDWilson2 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
RDWilson2 RDWilson2 is offline Offline
Newbie Poster

Re: How to make a popup window

  #2  
Nov 7th, 2007
Loyen,

Are you using Delphi for this class?

If so, there are several ways to go about doing this, although I would suggest having at least an "OK" button for closing the pop-up window.

One approach, in Delphi, would be to use a MessageDlg.

MessageDlg('Test with no buttons',mtInformation,[],0);

A question for you to consider is, if you create a pop-up window
that has no buttons just a clean window without any "minimazers, closers" and all
, how do you plan to close the window and exit the program?
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to make a popup window

  #3  
Nov 7th, 2007
I didn't plan to close it. ^^
through taskbar if I wanted some time though.

No, we don't use delphi. We are just using Pascal. :/
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: How to make a popup window

  #4  
Nov 7th, 2007
Which Pascal are you using?
Reply With Quote  
Join Date: Nov 2007
Posts: 15
Reputation: RDWilson2 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
RDWilson2 RDWilson2 is offline Offline
Newbie Poster

Re: How to make a popup window

  #5  
Nov 7th, 2007
Regrettably, it has been far too many years since I worked in base-level Pascal. Sorry.

Also, it really depends on the implimentation of Pascal (i.e. the compiler) with which you are working.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to make a popup window

  #6  
Nov 7th, 2007
I work with the free Pascal version. (1.9.2)
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,878
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 13
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: How to make a popup window

  #7  
Nov 7th, 2007
OK, FP is very compatible with Delphi.

Add the Dialogs unit to your uses clause. The procedure that fits your requirement best is the first in this list:

procedure ShowMessage( const msg: string );
function MessageDlg( const msg: string; dlgType: tMsgDlgType; buttons: tMsgDlgButtons; helpctx: longint ): word;
function MessageDlgPos( ... x, y: integer ): word; //same args as MessageDlg
function InputBox( const aCaption, aPrompt, aDefault: string ): string;
function InputQuery( const aCaption, aPrompt: string; var value: string ): boolean;

The ShowMessage function just displays your message with a little OK button.
The MessageDlg displays a message with the desired icon and buttons.
The InputBox and InputQuery functions get a string from the user. The latter returns false if the user canceled.

type TMsgDlgType = (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);

type TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore, mbAll, mnNoToAll, mbYesToAll, mbHelp);

return values for MessageDlg:
mrNone mrAbort mrYes mrOk mrRetry mrNo mrCancel mrIgnore mrAll

If none of those work for you, create a new form that does what you want and set its border style to bsDialog. Display the form using the ShowModal function. Close the form and return a value by setting its ModalResult.

Good luck.
Last edited by Duoas : Nov 7th, 2007 at 6:14 pm.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to make a popup window

  #8  
Nov 9th, 2007
Now.. How do I make it work and where should I write the message? xD.. don't really know cause we have pretty much just worked with console programs..
Reply With Quote  
Join Date: Nov 2007
Posts: 15
Reputation: RDWilson2 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
RDWilson2 RDWilson2 is offline Offline
Newbie Poster

Re: How to make a popup window

  #9  
Nov 9th, 2007
If you use the
<code>
function MessageDlg( const msg: string; dlgType: tMsgDlgType; buttons: tMsgDlgButtons; helpctx: longint ): word;
</code>
approach and you do NOT want any buttons (which is still a most curious concept), you would write something like:
<code>
MessageDlg('your message goes here', mtInformation,[],0);
</code>
wherever you want it in your project and then, when that line is executed, it will pop up the message box.
Reply With Quote  
Join Date: Nov 2007
Posts: 44
Reputation: Loyen is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Loyen Loyen is offline Offline
Light Poster

Re: How to make a popup window

  #10  
Nov 9th, 2007
Got this error?
J:\Pascal program\Message programs\Popup1\Popup.pas:5: parse error before `Begin'
J:\Pascal program\Message programs\Popup1\Popup.pas:7: module/unit `code' could not be compiled


Noticed that my program isn't free pascal.. it's called "Dev-Pascal" or something like that.. hmm..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 7:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC