Announcement

Collapse
No announcement yet.

Problem with TXT.WINDOW "focus" in PBCC

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

  • Problem with TXT.WINDOW "focus" in PBCC

    'Problem with TXT.WINDOW "focus" in PBCC
    '
    '(see comments in PBMain()
    '
    Code:
    #compile exe
    #dim all
    %UNICODE = 1
    
    function TxtWindow () as long
      local hTWin as dword
      '
      txt.window ("test", 120, 120, 5, 60) to hTWin
      txt.print "Some text."$$
      '(API function SetFocus(hTWin) does not work)((tested and read learn.microsoft))
      txt.waitkey$
      txt.end
    end function
    '
    function pbmain () as long
      local hTWin as dword
      con.print "Open a TXT.WINDOW on any key."$$
      'con.waitkey$ 'REMed out the TXT.WINDOW receives keystrokes
                    'unREM the line to see the problem
                    'The caption in TXT.WINDOW "greyed" with CON.WAITKEY$ here.
                    'Click on TXT.WINDOW, then TXT.WAITKEY$ (above) works.
      TxtWindow
      '
      con.print "Close on any key."$$
      con.waitkey$
    end function '
    Any suggestions?

    Cheers,​
    Dale

  • #2
    Try SetForegroundWindow(hTWin) instead of SetFocus in FUNCTION TxtWindow. Just tested and works here.
    '
    Code:
    #COMPILE EXE
    #DIM ALL
    %UNICODE = 1
    #INCLUDE ONCE "WIN32API.INC"
    
    FUNCTION TxtWindow () AS LONG
      LOCAL hTWin AS DWORD
      '
      TXT.WINDOW ("test", 120, 320, 5, 60) TO hTWin
      TXT.PRINT "Some text."$$
      SetForegroundWindow(hTWin)
      TXT.WAITKEY$
      TXT.END
    END FUNCTION
    '
    FUNCTION PBMAIN () AS LONG
      LOCAL hTWin AS DWORD
      con.print "Open a TXT.WINDOW on any key."$$
      con.waitkey$ 'REMed out the TXT.WINDOW receives keystrokes
                    'unREM the line to see the problem
                    'The caption in TXT.WINDOW "greyed" with CON.WAITKEY$ here.
                    'Click on TXT.WINDOW, then TXT.WAITKEY$ (above) works.
      TxtWindow
      '
      con.print "Close on any key."$$
      con.waitkey$
    END FUNCTION '
    '

    Comment


    • #3
      Yes, that worked in posted code. I'll go try it in my project.

      Strange thing, the caption in the TXT.WINDOW stayed grey, but TXT.WAITKEY$ responded to a key, so who cares.

      Thanks,
      Dale

      Comment


      • #4
        Hm, that is strange. I tried some variations and other calls and Sleep, etc, but nothing seems to help. Very strange.

        Comment


        • #5
          Try SetForegroundWindow(GetParent(hTWin))
          Rgds, Dave

          Comment


          • #6
            Ok, problem solved - hTWin is text area in a parentwindow, so need to use SetForegroundWindow(GetParent(hTWin))

            Ok, we found the solution at same time. Cheers!


            Comment


            • #7
              Checked with MS Spy++ and a text window is a window named "POWERTEXT", with a static control (label) for text in its client area. Good to know.

              Comment


              • #8
                Sometimes it is useful to change the caption text
                Rgds, Dave

                Comment


                • #9
                  That is SetForegroundWindow(GetParent(hTWin)) instead of SetForegroundWindow(hTWin), not in addition to. (except I'll have red wine per my cardiologist )

                  ((I would not have suspected SetForegroundWindow because the TXT.WINDOW was created, and stayed, "on top" of the console.))

                  Thanks again guys,
                  Dale

                  Comment

                  Working...
                  X