May 20, 2024, 06:34:11 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Information Window

Started by Rock Ridge Farm (Larry), June 02, 2008, 11:15:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Rock Ridge Farm (Larry)

I posted this in the wrong place - moving it here since it is an Ebasic question.
I need to be able to open a window just for information - like a messagebox that does not require user input.
The window would be used for status information
It will not be displayed till needed
The info stirng in the window needs to be updatable
It will be closed after use
It will be opened and closed several times over the life of the executing program

Anyone done something like this?
Need help as all my atempts have been awkward and ugly.
I am sure there must be an easy way.

billhsln

Sounds like the DIALOG that I use in my 100_Draw_Poker game, except I don't allow changes to the data in the DIALOG.  It is there, but requires no interaction from the user.  I would think you could modify it to allow user input and save it in the handler.

Bill
When all else fails, get a bigger hammer.

LarryMc

June 02, 2008, 11:50:12 AM #2 Last Edit: June 03, 2008, 01:44:55 PM by Larry McCaughn
I do it with a child window of my main parent window. Create it as hidden window and use the same window handler as your main window.

Put @static controls  on it just like any other window then use SHOWWINDOW to unhide it when you want it to appear and then hide it again. You can even put a button on it that you hide/unhide so that under certain situations you can make the user click to hide it.

You can update the information on it while it is hidden.

I use that technique to tell me where I'm at (which step) in my program when it takes a long time to do a step.  Sort of like a progress message box.  By making the child window global I can modify it and hide/show it from anywhere in my multi-source file projects.

I've even made a flashing red warning before by by togging the hide/show in the @idtimer portion of the parent window handler.
Larry

QuoteSHOWWINDOW

Syntax

SHOWWINDOW(win as WINDOW,nCmdShow as INT,OPT id=0 as UINT)

Description

Shows or hides a window, dialog or control.

Parameters

win - Window or dialog.

nCmdShow - Show window command.

id - Optional control identifier.

Return value

None

Remarks

nCmdShow is one of:

@SWHIDE - Hides the window, dialog or control

@SWRESTORE - Restores the window, dialog or control

@SWMINIMIZED - Minimizes the dialog or window

@SWMAXIMIZED - Maximizes the dialog or window

See Also: SETSIZE

Example usage

SHOWWINDOW mywnd, @SWHIDE

Turns out it is NOT a child of the parent window.  I mis-remembered.  Discovered it last night while making one for a new program I'm working on.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Copex

I use "OPENWINDOW w1,scrL,scrT,scrW,scrH,@NOCAPTION|@BORDER,NULL,"splash screen",&main" for a splash screen then just close the window.

-
I really should learn how to use a spell checker! though im not sure how it will help someone who can not spell?
-
Except where otherwise noted, content Posted By Copex is
licensed under a Creative Commons Attribution 3.0 License

http://creativecommons.org/licenses/by/3.0/

hugh

June 04, 2008, 03:28:11 AM #4 Last Edit: June 04, 2008, 04:58:37 PM by hugh
That is exactly what i was looking for,
I have this code in a -sub calculate()
-sub calculate()
'...
'                                   all error messages go on this row,[450]   , so they have to be erased
'...
control w1,@static,"                                                    ",0,450,800,20,0,310   'to clear any displayed error msgs
bs$ = getcontroltext w1,180         ' check if data in [book start#]
if bs$ = ""  then control w1,@static,"Nothing to calculate, enter book start number, and try again",cntr - msg1/2,450,msg1,20,0,210

'................................................................
' all calculations carried out here
'................................................................

the problem is when the book start# is entered,and the [calculate] button is clicked again, the error msg is not erased

' I have the same erase code iin the "bingonumber" -sub and it works every time
'so why is it not working when  the [calculate ] button is clicked for a 2nd time.
'going to try this  SHOWWINDOW w1, @swrestore 210

' then when button is clicked again we get to @swhide
'then                  SHOWWINDOW w1, @swrestore, 210

' naturally all the control # error messages will will have to be setup and then @swhide
' going to try it, cant see any reason why it wont work.
so i am going to give each error message a string, ie example , nsn$=" No Start Number Has Been Entered, Cant Calculate"
etc, nsn$ is the start letters of No Start Number, easy for me o remember

LarryMc

Here's what I do.
At the beginning of my program; after I create the main window and all its controls I put the following:
OPENWINDOW status,-500,0,400,50,@nocaption,0,"Status",&main
SetWindowColor status, RGB(126,181,255)
CONTROL status,@STATIC,"status",10,15,380,21,0x50000101,2000
SetControlColor status,2000,rgb(0,0,0), RGB(126,181,255)
SHOWWINDOW status, @swhide
centerwindow status

Then when I want to show a message:
SHOWWINDOW status, @swrestore
setcontroltext status,2000,"Loading Listview from File...Please Wait"

and when I'm ready for the window to go away: SHOWWINDOW status, @swhide

Pretty straightforward.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Hugh,
I know you're still getting use to the forums.

In the buttons above the editing window is a # button.

If you highlite text that represents code by dragging your mouse over text and then pressing that # button it will show it all in one of those code boxes.

doing so sure makes your postings a lot easier to read. ;)

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

June 04, 2008, 04:50:24 AM #7 Last Edit: June 04, 2008, 04:53:05 AM by Larry McCaughn
Hugh
Noticed in your post above this line:if bs$ = ""  then control w1,@static,"Nothing to calculate, enter book start number, and try again",cntr - msg1/2,450,msg1,20,0,210


That would imply that you are creating the same control over and over.
You don't really want to do that. That's not the way you're suppose to use that command.
It's a thing about the internals of EBasic and Windows.
The thing to do is use the SETCONTROLTEXT command there.  The CONTROL command show have been created elsewhere like my example above.

BTW, I'm not picking on you.  I'm just trying to keep you from running into some of the problems I did when I was learning the language.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

hugh

thanks Larry, I know you are trying to steer me in the right direction, i appreciate that.
In part of my program i have the following code

This is in main Window, w1, with all the other controls and buttons

Control w1,@Static,"Sorry,  Cant Calculate, Need Book Start and Book End# ",sw/2-200,450,400,20,0,700,|@swhide
SetControlColor (w1,700,Rgb(255,0,0),Rgb(0,0,0))
Showwindow w1,@swhide,700
Control w1,@Static,"Check Your Book End#, it is the same as your start#, this =  negative number, cant calculate",710
SetControlColor (w1,710,Rgb(255,0,0),Rgb(0,0,0))
Showwindow w1,@swhide,710



This is is the part of the sub sub Calculate()

sub calculate()
sn$ = GetControlText w1,200        'book start number
en$ = GetControlText w1,210        'book end number
bc$ = GetControlText w1,230        'charge per 1 book of 3 tickets or 1 single flyer ticket,preset to 00.20
if bc$ <> "00.20" then setcontroltext w1,230,"00.20"
sn = val (sn$)
en = val (en$)
bc = val (bc$)
if sn < 1 and en < 1 Then Showwindow w1,@swrestore,700                          'no data to calculate
if sn < 1 and en > 1 then Showwindow w1,@swrestore,710                           'this leaves a negative #
if sn > 1 and en > 1 and sn = en then Showwindow w1,@swrestore,720         'two numbers cant be the same


the problem i had was knowing were to put the @swhide after the @swrestore, im getting there,,slowly!

Would i be correct in assuming that i could set up 1 Control, with null string, on row 450, were al messages are displayed
and the use this,

showwindow w1,@swrestore,700
SetControlText w1,700,"Any Of my messages can be entered here and re-used over and over again ?"
' user has corrected error so hide the control until needed ?
Showwindow w1,@swhide,700


If Yes, that would be a miracle, because you have no idea how many, @swhides, @swrestores i have, i am getting lost with
them at the moment, because when i click on a button, lets say, "LINECALL", the previous Control Just Stayed there,
Although i had made it ,@swhide.

hope this explains in a little more detail .
is there any special formulae for Random Numbers, im not happy with the way numbers are being selected.
That is why i wanted the Timer, Clicked <START> at diferent times and on different occassions, seems numbers
can be predicted.

regards.
Hugh

LarryMc

Hugh

Based upon your further explanation you're not using the correct tool.

What I have been describing is a window that pops up with a message saying something like "Busy" maybe loading a file and goes away without any user input when it is through loading.  Those type never require any action from the operator and they are really just to let the user know that there computer hasn't died.

What I'm getting out of what you are describing above is you are wanting to show error messages to the user and that you need to really make sure the user reads it.

The command to use for that is MESSAGEBOX then you can have a line of code like this(in it's simplest form):
if sn < 1 and en < 1 Then  MESSAGEBOX(w1,"You messed up..Redo","error")
A box will appear in the middle of the screen with the message and a OK button.
The user reads the message and then presses the ok button and the box disappears.
There's no other code required and you can have as many different MESSAGEBOX as you need placed where ever you need them.

It's really straight-forward.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Forgot this:
Quoteis there any special formulae for Random Numbers
As it says in the help the RND command generates a pseudo random number
Also in the help for SEEDRND
QuoteSyntax

SEEDRND(num as INT)

Description

Seeds the random number generator with a specific value.

Parameters

num - The random seed.

Return value

None

Remarks

On program execution the random number generator seed is set to the current Windows tick count guaranteeing that a repeating random sequence is unlikely to occur. If you use the same seed every time then the random sequence will be identical on successive runs.

There are are all sorts of random number generation algorithms.  You should be able to find one you like on the internet and then code it into EBasic.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

hugh

Thanks larry
working on it now.
will be getting rid of a lot of controls now.
at a quick glance, I should only  need two for the line and house calls
and one for the [Ready] after board reset.

regards
hugh