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 ]
_________________________