Announcement

Collapse
No announcement yet.

Graphic Set Focus

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Graphic Set Focus

    The GRAPHIC SET FOCUS is (according to the help file) supposed to bring the selected graphic window to the foreground, and set focus to it. But it seems that, while it DOES set focus to the graphics window (as opposed to the console window), it does NOT bring the specific graphic window to the foreground, on top of other graphic windows. Only after drawing to the window (any drawing) does it then get set to the foreground. You don't have to REDRAW the whole window, just setting a pixel will do it (although that would create an undesirable artifact).

    Here's a little test routine that shows it:

    Code:
    #COMPILE EXE
    FUNCTION PBMAIN () AS LONG
    
        DIM MyWindow???(10)
    
        CONSOLE SET SCREEN 10, 20
        CONSOLE SET LOC -1000, -1000
    
        FOR count% = 1 TO 10
            GRAPHIC WINDOW "", 10, 10, 1000, 1000 TO MyWindow???(count%)
            GRAPHIC ATTACH MyWindow???(count%), 0
            Background& = RGB(RND(0,255), RND(0,255), RND(0,255))
            GRAPHIC CLEAR Background&
            GRAPHIC COLOR RGB(255, 255, 255), Background&
            GRAPHIC SET POS (440, 500)
            GRAPHIC PRINT "This is window ";count%
            GRAPHIC SET POS (440, 520)
            GRAPHIC PRINT "Press any key for next window"
            GRAPHIC SET POS (440, 540)
            GRAPHIC PRINT "Press 'e' to end"
        NEXT
        
    
        DO
            FOR count% = 1 TO 10
                GRAPHIC ATTACH MyWindow???(count%), 0
                GRAPHIC SET FOCUS
                GRAPHIC SET PIXEL (1, 1), RGB(255, 255, 255)  'Should still work without this line
                                                              'REM it out to test
                
                DO
                    CONSOLE SET FOCUS
                    I$ = INKEY$
                LOOP UNTIL I$ <> ""
                IF I$ = "e"  OR I$ = "E" THEN END
    
            NEXT
        LOOP
    
    END FUNCTION

    If a graphic window will come to the foreground automatically with ANY drawing to it, then why won't it do so with just the GRAPHIC SET FOCUS command, so that I don't have to output something to it to get it to come forward (or REDRAW the whole window)?


    Thanks.

  • #2
    I do not have a specific answer for your application, but '[keyboard] focus' and 'foreground' are two independent attributes of any window. This is an important fundamental fact of Windows' programming.

    You can try the 'SetForegroundWindow' and/or 'SetActiveWindow' Windows API functions.. they do slightly different things and one or the other may be better for your application.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Update

      As with my other test program, I reran this test program under PB/CC 5.0, and it also runs PERFECTLY!!!


      Awesome job with PB/CC 5.0, thank you VERY MUCH!!!

      Comment

      Working...
      X