April 19, 2024, 07:09:06 AM

News:

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


Any Questions

Started by GWS, June 24, 2008, 11:41:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Ok, Ok .. it's far too quiet around here ..  :)

Surely those folk new to Creative Basic (and the other languages), must have some questions now that they've downloaded the software and hopefully tried it out on their own applications.

Either that, or you're found it all absolutely clear and easy to use - which would be great of course. ;D

But even so, call in and give us your views on how you are finding these amazing Windows programming tools.
Any feedback will help with future development to improve ease of use ..

best wishes, :)

Graham
Tomorrow may be too late ..

aurelCB

Hi Graham...
I have a question.
Is this faster - setwindowcolor win1, 0x555555
then ordinary aproach?

GWS

June 24, 2008, 01:54:40 PM #2 Last Edit: June 24, 2008, 02:17:29 PM by GWS
From this little test Aurel, I can't notice any difference in execution speed ..  :)


def w:WINDOW
def wstyle,key:int
def i,start,finish:int

declare "kernel32",GetTickCount(),int
autodefine "OFF"

wstyle = @SIZE|@MINBOX|@MAXBOX

WINDOW w,50,50,500,400,wstyle,0,"Window Title",handler

start = GetTickCount()
for i = 1 to 10000
SETWINDOWCOLOR w,RGB(0,0,0)
'SETWINDOWCOLOR w,0x0
next i
finish = GetTickCount()

frontpen w,0xffffff
print w,finish-start

CONTROL w,"B, Exit, 210, 300, 70, 35, 0, 1"

WAITUNTIL w = 0
END

SUB handler
SELECT @CLASS
case @IDCLOSEWINDOW
' closing the window sets w = 0
        CLOSEWINDOW w
case @IDCHAR
' pressing the 'ESC'(ape) key will abort the program ...
    key = @CODE
if key = 27 then CLOSEWINDOW w
case @IDCONTROL
select @CONTROLID
' clicking the Exit button ...
case 1
CLOSEWINDOW w
' any other controls go here ...
endselect
ENDSELECT
RETURN



I get 2719 millisecs on my machine for both methods.

The reason I used the hex format for the color, was that I know that if all 6 digits are the same, it gives a gray.

So 0x111111 is almost black, and 0xeeeeee is almost white.  0x555555 is mid-gray.

Logically I suppose, the machine ought to be able to process a single constant for the color faster than caling the RGB function with three constants - but obviously there is no noticeable difference.

all the best, :)

Graham


Tomorrow may be too late ..

aurelCB


GWS

Well, a lot of reads of this thread, and nearly 4000 downloads of CBasic - but hardly any posts from anyone.  :)

Come on, don't be shy - did you manage to get CBasic running OK? - did you try out the included examples?, did you have a look at the Users help files? - have you had a go at writing something yourself? ..

We'd love to know ..

best wishes, :)

Graham
Tomorrow may be too late ..

mrainey

August 20, 2008, 02:09:53 PM #5 Last Edit: August 20, 2008, 02:24:15 PM by mrainey
Here's an example for you to study.  I saved it years ago, and don't remember who wrote it. (edit:  It was Fletchie, RIP)



declare "user32",SetWindowPos(Hwnd:int,HwndAfter:int,x:int,y:int,cx:int,cy:int,f lags:int)

setid "SWP_NOMOVE",2
setid "SWP_NOSIZE",1

setid "HWND_TOPMOST",-1
setid "HWND_NOTOPMOST",-2


def run:int

def w1:window
'doesn't need @toolwindow, just here to demo a tool window!!!
window w1,100,100,400,200,@TOOLWINDOW,0,"On Top",mainwin

control w1,"B,On Top,10,10,80,30,0,1"
control w1,"B,Not on Top,110,10,80,30,0,2"

SetWindowPos(w1,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)

run = 1
waituntil run=0

closewindow w1

end


sub mainwin

select @class

CASE @IDCLOSEWINDOW
   run = 0

case @idcontrol
  select @controlid

  case 1
   SetWindowPos(w1,@HWND_TOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
   setcaption w1,"On Top"
  case 2
   SetWindowPos(w1,@HWND_NOTOPMOST,0,0,0,0,@SWP_NOMOVE|@SWP_NOSIZE)
   setcaption w1,"Not 'on top'"

  endselect

endselect

return
Software For Metalworking
http://closetolerancesoftware.com

aurelCB

I dont understand what is in this example for study?
APi function SetWindowPos maby?

mrainey

There was a new question in this thread yesterday asking how to set a window to be always on top.  It appears to have been deleted.

Or, am I showing my age?   :)
Software For Metalworking
http://closetolerancesoftware.com

LarryMc

Come to think of it, I seen it too.

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

Ionic Wind Support Team

Either the original poster deleted his message or there was a DB hickup.  Thought I noticed the post count go down by one at the time.
Ionic Wind Support Team

REDEBOLT

Ok, Graham.
Since you asked,   ;D

What is the difference between a window and a dialog?

Should a window be first in a series of displays and the rest are dialogs spawned from that first window?

Can all of the displays be all windows or all dialogs?

Under what conditions should a window be used?

Under what conditions should a dialog be used?

Thanks.
Regards,
Bob

GWS

August 24, 2008, 01:32:49 AM #11 Last Edit: August 24, 2008, 07:09:35 AM by GWS
Yikes! ..  :o .. I did ask didn't I ..  :)

Windows are wall to wall windows .. even a 'Button' is a window of sorts ..

So a Dialog is just another window.  If you create one in the 'File - New - GUI Dialog Editor', all the code it generates can easily be assigned to a window instead, by just changing the reference from Dialog to Window.

Some folk work with Dialogs all the time - I rarely use them, I prefer a normal Window.  Why? ..

A Dialog will not be shown until you execute either a 'DOMODAL'  or 'SHOWDIALOG' command.  Any controls in the dialog cannot be changed until it is being displayed. 

The idea of the Modal display, is that your program is halted until the Dialog gets the users responses and is closed with one of it's Cancel, Yes, No buttons.  If you were requesting a Password for instance, the user would enter it before the program continues.

I prefer to have the full control of a small window to achieve that kind of 'reply and go' response. 

So the difference is, a Window is created and shown with one statement - a Dialog is only defined, but is neither created or shown until the DOMODAL or SHOWDIALOG commands are excuted.  When it is shown, you get a @IDINITDIALOG message, and this part of your message handling routine is used to preset controls, or center the Dialog.

All a bit too much fuss for me - so I usually use Windows exclusively.

You don't need a window in order to have a Dialog.  A program can use just a dialog if you wish.

So yes, you can use all Windows, or all Dialogs, or a mixture of each.

I would always use a Window - but it can't be 'Modal' (ie requiring completion before the program continues).  But I like that.
It enables me to deign the program to ensure valid data has been entered before continuing, and display appropriate error messages if necessary.  Of course you could do error checking with a Dialog as well - just a matter of preference I guess.

Use a Dialog if you want to adhere to standard window's Modal display methods - but I never do ..  I'm a rebel .. :)

Tomorrow may be too late ..

REDEBOLT

Thank you, Graham.  That was very informative.
Regards,
Bob

aurelCB

One more thing .
You can not use drawing comands like circle,line etc on dialog.
Dialog support only controls.

GWS

Thanks Aurel, I forgot to mention Dialogs don't do graphics or images ..  ::)

So they're a bit of a second class window really ..  :)

best wishes,

Graham
Tomorrow may be too late ..

Allan

August 24, 2008, 05:06:48 PM #15 Last Edit: August 24, 2008, 05:08:59 PM by Allan
Well here is my two cents worth regarding Dialogs/Windows - I sorta prefer dialogs. Most of the work I do is 'business style' progs rather than games etc. They handle controls well. Easy to use as windows.

You can do some fancy things in Dialogs even though you dont have the facility for RECT and LINE.

ControlEx d1, "Static", "", 13, 13, 230, 36, SS_GRAYFRAME, 0, 100
ControlEx d1, "Static", "", 13, 11, 230, 33, SS_SUNKEN, 0, 100


The ControlEx with Static control is handy when you use different Styles.

Some of the styles I have found are:

' Static Control Constants that can be used for Lines and Boxes..
CONST SS_GRAYFRAME = &H8
CONST SS_SUNKEN = &H1000
Const SS_ETCHEDHORZ = 0x0010
Const SS_ETCHEDVERT = 0x0011
CONST SS_GRAYRECT = &H5
CONST SS_BLACKFRAME = &H7
CONST SS_BLACKRECT = &H4
CONST SS_ETCHEDFRAME = &H12
CONST SS_PATHELLIPSIS = &H8000


I have attached an eba file in a zip which shows an extract of a program I made using Dialogs. The menu option is left out and most of the code is not there. Just a skeleton to show the ControlEx Static's.

Guess I just got used to dialogs and go with them most of the time.

PS - I know this is CREATIVE and it should not be hard to use these controls in it.

Allan