Page 1 of 1 1
Topic Options
#91417 - 2003-02-10 10:02 PM Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Shawn,

I don't know who to blame, maybe it is just me trying the unforeseen? (PictureBox is by the way same Size as form (PicBack contains background in original!))

Try to spot the looney here :

(To see how it should work just press P couple of times first and then try to change skill while Status running ... after MsgBox is answered the OnKey events are just ignored? Seems to be that form looses focus allthough I set it right afterwards [Frown] ... Not sure at all therefore posting here, and not in Bug tracker on Kixforms.org )



break on

$diff = 1
$P = 0

$form                  = createobject("Kixtart.Form")
$form.Caption          = "MsgBox Steals focus permanently ..."
$form.OnKeyDown        = "Form_KeyDown($$form.KeyCode)"

$picBack               = $form.PictureBox()
$picBack.Top           = 0
$picBack.Left          = 0
$picBack.ClientWidth   = $form.ClientWidth
$picBack.ClientHeight  = $form.ClientHeight
$picBack.BorderStyle   = 0
$picBack.ForeColor     = &00FF00
$picBack.BackColor     = Gray
$picBack.Enabled       = 0  ;This is a must to make it work ...

$lbl1                  = $picBack.Label("This Gray thing is a PictureBox",2,2,200,15)
$lbl2                  = $form.Label("Form: Press P to toggle Pause, ESC to Quit",2,140,200,15)
$lbl3                  = $form.Label("Status: Running",2,155,200,15)


$btnSkill1             = $form.ToolButton("       Novice",30,30,85,25)
$btnSkill1.Alignment   = 3
$btnSkill1.Icon        = 10
$btnSkill1.BackColor   = black
$btnSkill1.ForeColor   = &000FF00
$btnSkill1.ToggleStyle = 0
$btnSkill1.FlatStyle   = 1
$btnSkill1.BorderStyle = 0
$btnSkill1.ToolTip     = "Speed: Slow; Winning lines: 6"
$btnSkill1.OnClick     = "Form_Options_Skill(1)"

$btnSkill2             = $form.ToolButton("Intermediate",30,$btnSkill1.Bottom+1,85,25)
$btnSkill2.Alignment   = 3
$btnSkill2.Icon        = 49
$btnSkill2.BackColor   = black
$btnSkill2.ForeColor   = Blue
$btnSkill2.ToggleStyle = 0
$btnSkill2.FlatStyle   = 1
$btnSkill2.BorderStyle = 0
$btnSkill2.ToolTip     = "Speed: Medium; Winning lines: 10"
$btnSkill2.OnClick     = "Form_Options_Skill(2)"

$btnSkill3             = $form.ToolButton("       Expert",30,$btnSkill2.Bottom+1,85,25)
$btnSkill3.Alignment   = 3
$btnSkill3.Icon        = 49
$btnSkill3.BackColor   = black
$btnSkill3.ForeColor   = Blue
$btnSkill3.ToggleStyle = 0
$btnSkill3.FlatStyle   = 1
$btnSkill3.BorderStyle = 0
$btnSkill3.ToolTip     = "Speed: Fast; Winning lines: 15"
$btnSkill3.OnClick     = "Form_Options_Skill(3)"

$form.Center
$form.Setfocus
$form.Show
while $form.Visible
    $ = execute($form.DoEvents())
loop

exit 1

function Form_Options_Skill($d)
    dim $prev
    $prev = $diff
    $diff = $d
    if $P = 0
        $a = $form.MsgBox("Do you want to resign this game?","Whazzup?",36)
        if $a <6
            $form.SetFocus ;Allthough here is a SetFocus placed it looses Focus  [Frown]
            exit()
        endif
    endif
    if $diff = $prev exit() endif
    $ = execute("$$btnSkill$prev.Icon = 49")
    $ = execute("$$btnSkill$prev.ForeColor = Blue")
    $ = execute("$$btnSkill$diff.Icon = 10")
    $ = execute("$$btnSkill$diff.ForeColor = &000FF00")
    $form.Setfocus ; Safety SetFocus as well useless after MsgBox ...
endfunction

function Form_KeyDown($Key)
    select
        case $key = 27
            $form.Hide
        case $key = 80
            if $P = 1
                $P = 0
                $lbl3.Caption = "Status: Running"
            else
                $P = 1
                $lbl3.Caption = "Status: Paused"
            endif
    endselect
endfunction


J.

[ 10. February 2003, 22:23: Message edited by: jpols ]
_________________________



Top
#91418 - 2003-02-10 10:06 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Rocco Capra Offline
Hey THIS is FUN
*****

Registered: 2002-04-01
Posts: 380
Loc: Mansfield Ohio
I can't copy and paste into TextPad, without loosing the formatting. Isn't that posted with the fancy PostPrep??

Rocco
_________________________
I Love this board!! -------------------- My DEV PC is running KIX 4.22 WINXP Pro

Top
#91419 - 2003-02-10 10:07 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
I copy, paste into Word, copy, paste into notepad. Fixes all my LF CR issues. FWIW.
_________________________
{Insert your favorite Witty Tag Line here}

Top
#91420 - 2003-02-10 10:08 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Rocco , yap !

But it was first time posted with an alpha 1.1 version (We have some serious troubles Lonk [Eek!] )

Please retry now (reposted with last released [Smile] )

Crazy ... Yes that is the old way [Wink] Please retry NOW directly into any editor !

[ 10. February 2003, 22:08: Message edited by: jpols ]
_________________________



Top
#91421 - 2003-02-10 10:16 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
Cool. (Closing Word now).

Also, with that script, I get the following:

code:
C:\scripts>kix32 test1
Script error: expected expression!
$btnSkill1 = $form.ToolButton(" Novice",30,30,85,25)


C:\scripts>

Not sure why...
_________________________
{Insert your favorite Witty Tag Line here}

Top
#91422 - 2003-02-10 10:19 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Maybe because you use build 37 ... (crap I am already used to use 38 syntax [Wink] )

ok, replace all "ToolButton" with "ToolBarButton"

not sure about the icons but it will be working then [Roll Eyes]
_________________________



Top
#91423 - 2003-02-10 10:22 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Crazy Eddie Offline
Starting to like KiXtart

Registered: 2002-11-20
Posts: 105
Loc: Sacramento, CA USA
No go.

If this is built with a KixForms Beta, can't help.

Perhaps you should preface the message with that info. Would help us lurkers who try to follow along.
_________________________
{Insert your favorite Witty Tag Line here}

Top
#91424 - 2003-02-10 10:24 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sorry, my fault ...

Ammended Topic title [Embarrassed]

[ 10. February 2003, 22:24: Message edited by: jpols ]
_________________________



Top
#91425 - 2003-02-12 04:11 AM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
BTW, the copy/past issue is explained in the FAQ Fourm under HOWTO: Submit code to / copy code from the board
_________________________
There are two types of vessels, submarines and targets.

Top
#91426 - 2003-02-12 05:17 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yes Jens !

Maybe the FAQ should be updatet with a Link to PostPrep 1.0.1 ... Kent ? Les ?
_________________________



Top
#91427 - 2003-02-12 05:44 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok,

maybe I should try to recode the 'bug sample' above to fit on latest released kixforms build ... on the other side the script I have the problem with is another game-in-progress to be released within the next major update of Kixforms (If my abilities are enough to make it work [Wink] )

Shawn, have you had time to have a look at the sample above? (The one thing that is sure is that you will have a newer version than me [Big Grin] )

Maybe I find the time next week to recode above or get online in a time that fit more the canadian timezone(s) [Roll Eyes]

l8r
J.
_________________________



Top
#91428 - 2003-02-12 06:38 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I see the problem - but the think the root cause is very complicated.

For one thing ... not too sure why your creating the ToolButtons as children of the form when in fact you have a PictureBox that is theoretically "covering" them up. In fact, in the lastest-latest build im running right now - I couldn't even see the ToolButtons. I know why they are covered in the leatest build, and not covered in the current release - but i would suggest that you try not to layer too many things on top of one another right now.

The changes I'm doing for the next build will actually enhance the layering of controls - but so long as they are created in a hierarchy as children and children of children. This is all so that I can implement the BringToFront and PushToBack type properties (that we've already discussed) and have them work correctly.

After seeing this script might have to rethink some of this stuff - not sure. The big question I have is what plans did you have for the PictureBox ($picBack) ... were you going to draw on it while the ToolButtons existed ?

But having said (and asked) all that I agree yeah - there is a problem with SetFocus it would seem. One thing I do know for sure is that the ToolButtons are stealing the focus and not releasing it ... will investigate.

[ 12. February 2003, 18:39: Message edited by: Shawn ]

Top
#91429 - 2003-02-15 12:34 AM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Shawn,

I will try then to 'activate' the PictureBox and code all subsequent controls as childs of it, hmmmm ... maybe then capture also the OnKey events of the PictureBox ?

We'll see [Smile]
_________________________



Top
#91430 - 2003-02-14 01:05 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
It was a nogo ...

Maybe the easiest way would be just the possibility to assign the form a background image (New property)

Like (just thinking out loud)

$form.BackImage = "path\image.bmp"

that would not only shorten my code (PictureBox creation and properties assignment)
but also would provide a simple and fast way of having a base skin for forms

Possible ?

J.
_________________________



Top
#91431 - 2003-02-16 04:30 PM Re: Kixforms BUILD 38A !!! - Trouble with MsgBox stealing focus irrevocably ?!
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Sure it is !

$form.Picture = ... sets a background image in a form, how could I forget that [Roll Eyes]

still need to SetFocus back on form after click on ToolButton but it now ( as the PictureBox is gone) sets it flawlessly !

Thanx Shawn [Wink]
_________________________



Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 661 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org