Announcement

Collapse
No announcement yet.

Graphic control focus pb9 vs. pb10

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

  • Graphic control focus pb9 vs. pb10

    Recently, while trying to update a program and compiling with 10.02 (originally compiled with ver 9) I found unexpected behavior between the 2 versions. In the original program, when the user clicked on the graphic control, and used the mousewheel, that would perform a zoom in/out function. I noticed when compiled with 10, this no longer worked.

    There seems to me, to be an issue with the graphic control recieving focus.

    Here is a simple program to illustrate. Compile with 10 and 9 and note the different behavior. Using the mouse wheel, will return a message about the focused control.


    Code:
     
    #COMPILE EXE
    #DIM ALL
    #INCLUDE ONCE "WIN32API.INC"
    %IDD_DIALOG1  =  101
    %IDC_BUTTON1  = 1001
    %IDC_GRAPHIC1 = 1002
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    FUNCTION PBMAIN()
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    CALLBACK FUNCTION ShowDIALOG1Proc()
        LOCAL BUT_HNDL AS DWORD
        LOCAL GR_HNDL AS DWORD
           IF CB.MSG = %WM_MOUSEWHEEL THEN
                CONTROL HANDLE CB.HNDL, %IDC_GRAPHIC1 TO GR_HNDL
                CONTROL HANDLE CB.HNDL, %IDC_BUTTON1  TO BUT_HNDL
                SELECT CASE getfocus()
                    CASE BUT_HNDL
                        ? "BUTTON"
                    CASE  GR_HNDL
                        ? "GRAPHIC CONTROL"
                    CASE ELSE
                        ? "H"+HEX$(GETFOCUS())
                END SELECT
        END IF
    END FUNCTION
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
        LOCAL lRslt AS LONG
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
        LOCAL hDlg  AS DWORD
        DIALOG NEW hParent, "Dialog1", 70, 70, 201, 121, %WS_POPUP OR %WS_BORDER _
            OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _
            %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
            %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
            %WS_EX_RIGHTSCROLLBAR, TO hDlg
        CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "Dummy", 2, 2, 65, 20, %WS_TABSTOP OR %WS_GROUP
        CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 2, 22, 100, 50, %WS_TABSTOP OR %SS_NOTIFY OR %WS_GROUP
        GRAPHIC ATTACH hDlg, %IDC_GRAPHIC1
        GRAPHIC COLOR -1, %BLACK
        GRAPHIC CLEAR
    #PBFORMS END DIALOG
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
        FUNCTION = lRslt
    END FUNCTION

    Upon start, the focus is on the "dummy" button as it should be.

    When compiled under PB 9.05:

    1. I can select either control with the mouse, and both will recieve the WM_MOUSEWHEEL msg.

    2. Using tab, the focus can be changed TO the graphic control (which then receives the WM_MOUSEWHEEL), but tab has no effect after that. Tab or Shift tab will not direct focus BACK to the dummy button. Where is it? Is this expected?

    When compiled under PB 10.02

    1. ONLY the dummy button seems to be selectable with the mouse. If the graphic control is clicked, focus leaves the button, but the graphic control does not seem to get it, and does not recieve WM_Mousewheel.

    2. Using tab works similar to ver 9.05., except that the graphic appears to never receive focus as it did in 9.05.

    In either version TAB / Shift + TAB do not appear to cycle correctly when a graphic control is in the mix. Further, in PB 10.02, I cannot even select the control with the mouse, and was possible in PB 9.05.

    This is unexpected behavior to me. Am I missing something?

    This is observed under Window 7 32 bit. I have not tried it on my XP machines.

    I await to hear where I am "all wet".
    "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
    "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

  • #2
    Hi Doug,
    I don't have the complete answer yet, but the code below does show that the graphic control can receive the mouse_wheel in PBWin10. I just happened to be looking at using the virtual mode of a graphic control, which uses the mouse wheel to scroll the viewport.

    I'll look at it some ... just wanted to get you my first observation.

    Run this, click on the graphic control, and spin the wheel.
    Code:
    #Compile Exe
    #Dim All
    #Include Once "WIN32API.INC"
    %IDD_DIALOG1  =  101
    %IDC_BUTTON1  = 1001
    %IDC_GRAPHIC1 = 1002
    Global GR_HNDL, BUT_HNDL As Dword
    
    Declare CallBack Function ShowDIALOG1Proc()
    Declare Function ShowDIALOG1(ByVal hParent As Dword) As Long
    Function PBMain()
        ShowDIALOG1 %HWND_Desktop
    End Function
    CallBack Function ShowDIALOG1Proc()
           If Cb.Msg = %WM_MouseWheel Then
                Select Case getfocus()
                    Case BUT_HNDL
                        ? "BUTTON"
                    Case  GR_HNDL
                        ? "GRAPHIC CONTROL"
                    Case Else
                        ? "H"+Hex$(GETFOCUS())
                End Select
        End If
    End Function
    Function ShowDIALOG1(ByVal hParent As Dword) As Long
        Local lRslt As Long
    #PBForms BEGIN DIALOG %IDD_DIALOG1->->
        Local hDlg  As Dword
        Dialog New hParent, "Dialog1", 70, 70, 201, 121, %WS_Popup Or %WS_Border _
            Or %WS_DlgFrame Or %WS_SysMenu Or %WS_ClipSiblings Or %WS_Visible Or _
            %DS_ModalFrame Or %DS_3DLook Or %DS_NoFailCreate Or %DS_SetFont, _
            %WS_Ex_ControlParent Or %WS_Ex_Left Or %WS_Ex_LtrReading Or _
            %WS_Ex_RightScrollbar, To hDlg
        Control Add Button,  hDlg, %IDC_BUTTON1, "Dummy", 2, 2, 65, 20, %WS_TabStop Or %WS_Group
        Control Add Graphic, hDlg, %IDC_GRAPHIC1, "", 2, 22, 100, 50, %WS_TabStop Or %SS_Notify Or %WS_Group
        Graphic Attach hDlg, %IDC_GRAPHIC1
        Graphic Color -1, %Black
        Graphic Clear
        Graphic Set Virtual 500,500
                Control Handle hDlg, %IDC_GRAPHIC1 To GR_HNDL
                Control Handle hDlg, %IDC_BUTTON1  To BUT_HNDL
    #PBForms END DIALOG
        Dialog Show Modal hDlg, Call ShowDIALOG1Proc To lRslt
    #PBForms BEGIN CLEANUP %IDD_DIALOG1
    #PBForms END CLEANUP
        Function = lRslt
    End Function

    Comment


    • #3
      Doug,
      While the code I posted will scroll the virtual graphic control, it's apparently not because it receives/processes the WM_WheelMouse message.

      In the code below, I open a console to look at the message traffic. Even though the mouse wheel scrolls the virtual graphics control, the WM_WheelMouse is not being received by the dialog procedure.

      Code:
      #Compile Exe
      #Dim All
      #Include Once "WIN32API.INC"
      %IDD_DIALOG1  = 1000 : %IDC_BUTTON1  = 1001 : %IDC_GRAPHIC1 = 1002
      Global hDlg, BUT_HNDL,GR_HNDL, hCOnsole As Dword
      Function PBMain()
          Dialog New Pixels, 0, "Dialog1", 670, 70, 220, 200, %WS_OverlappedWindow To hDlg
          Control Add Button,  hDlg, %IDC_BUTTON1, "Dummy", 2, 2, 65, 20, %WS_TabStop
          Control Add Graphic, hDlg, %IDC_GRAPHIC1, "", 2, 30, 160, 150, %WS_Border Or %WS_TabStop Or %SS_Notify Or %WS_Group
          Control Handle hDlg, %IDC_GRAPHIC1 To GR_HNDL
          Control Handle hDlg, %IDC_BUTTON1  To BUT_HNDL
          Graphic Attach hDlg, %IDC_GRAPHIC1
          Graphic Set Virtual 500,500
          Dialog Show Modal hDlg, Call ShowDIALOG1Proc
      End Function
      
      CallBack Function ShowDIALOG1Proc()
             If Cb.Msg = %WM_MouseWheel Then
                  Select Case GetFocus
                      Case BUT_HNDL
                          CPrint Str$(BUT_HNDL) + "  Button" + Time$
                      Case  GR_HNDL
                          CPrint Str$(GR_HNDL) +  "  GRAPHIC CONTROL  " + Time$
                      Case Else
                          CPrint Str$(GetFocus) +  "  " + Time$
                  End Select
          End If
      End Function
      
      Sub CPrint (SOut As String)
         Static cWritten, iCount As Long
         If hConsole = 0 Then AllocConsole: hConsole = GetStdHandle(-11&)
         WriteConsole hConsole, ByCopy sOut + $CrLf, Len(sOut) + 2, cWritten, ByVal 0&
      End Sub

      Comment


      • #4
        The example I posted was as simple an example as possible. I was trying to illustrate the difference between 9 and 10. In either case, I found the focus behavior "odd" when using TAB / Shift TAB.

        Yes, I can think of ways around it, and will subclass it if I have to, but what remains, is the difference in behavior between the compilers. I wonder if this is intentional. In PB 10.02 the graphic control is "improved", but in comparing the help files of both compilers, with regards to the graphic control, the functionality appears to be identical. Therefore, I would think the behavior would be the same as well.

        I'd hope not to turn this into a "work around" thread just yet.
        "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
        "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

        Comment


        • #5
          In the case of a virtual window, I can see where the the WM_Mousewheel would not be received since MSDN says:

          "Sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it."

          I would think the virtual graphic control is processing the mousewheel msg, and therefore I would suspect the message would not make it to my callback.

          My concern is that of a simple graphic control.
          "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
          "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

          Comment


          • #6
            When in doubt and no clear answer here on forums, PLEASE send it in an
            email to support. That way everyone benefits ( either in an answer from
            support as to how we should code it/expect it to work or possible change of
            some sorts in a future release ).

            Comment


            • #7
              Originally posted by Paul D. Elliott View Post
              When in doubt and no clear answer here on forums, PLEASE send it in an
              email to support. That way everyone benefits ( either in an answer from
              support as to how we should code it/expect it to work or possible change of
              some sorts in a future release ).
              Paul, I'm not a full time programmer, and may not do anything for a few months (especially during summer), so I like to throw something like this out, and see if it holds water with you more experienced programmers before I bother support.

              Of course, I'll send this to support, if there appears to be a real issue.
              "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
              "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

              Comment


              • #8
                Doug,

                Sorry, I just got a little anxious. It's just that I've had a few minor problems
                with graphic controls/windows relating to scrolling ( mostly MY problems )
                and when others notice something like this I get itchy. Especially when
                the bare-bones programs shown exhibit the same problem on at least 3
                different systems ( I see the same problem ).

                So take your time and wait to see if more people confirm or deny the problem.

                Sheesh, I'm already on purely decaf tea. Maybe I should cut back on the
                sugar and start taking long walks in the cold & dark hours of the morning.

                Comment


                • #9
                  Originally posted by Paul D. Elliott View Post
                  Doug,

                  (I see the same problem ).

                  So take your time and wait to see if more people confirm or deny the problem.
                  That's what I was looking for. Anyone else have a comment?

                  Usually when I find something odd, like you said, it's something I've done. I'm very careful to investigate further. I always snicker to myself when I see a thread title with "...found a bug...."
                  "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
                  "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

                  Comment


                  • #10
                    >..since MSDN says

                    But you are dealing with the PowerBASIC-proprietary GRAPHIC control. What MSDN says is, to be blunt, immaterial. It's also risky to "mix and match" Windows API calls with the proprietary statements used to manage proprietary objects. Even if it "works" the fact the object is proprietary means it might "not work" in the next update of the compiler.

                    PowerBASIC Inc. has a customer support department. They advertise that support as one of the features of their product line. Why don't you use it?
                    Michael Mattias
                    Tal Systems Inc.
                    Racine WI USA
                    mmattias@talsystems.com
                    http://www.talsystems.com

                    Comment

                    Working...
                    X