No announcement yet.

Strange Lockup Problem..... Help!

  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange Lockup Problem..... Help!

    I am having a strange problem with using child windows with the %DS_CONTROL
    property along with a radio style pushbutton. Here's the problem whenever
    you place any control on the child window (ie. Label, Button, Frame) the ap
    locks up when you push one of the radio style buttons. If there is no
    controls on the child window, the radio button works fine. Here is an
    example piece of code that shows the problem.

    #Compile Exe
    #Dim All
    #Include ""
    CallBack Function DlgProc
       Select Case CbMsg
         Case %WM_COMMAND
           Select Case LoWrd(CbWparam)
             Case 100
             Case 110
             Case 120
               Dialog End CbHndl, 0
           End Select
       End Select
    End Function
    Function PbMain As Long
       Local hDlg  As Long
       Local hDlg2 As Long
       Dialog New 0, "Test W/Child Window",,,200,120 To hDlg
       ' Child Window for Start of a TAB Control - But when this
       ' Window has anything in it, and the AUTORADIOBUTTON style
       ' buttons are defined below the app locks up whenever one
       ' of those buttons is pushed!
       Dialog New hDlg,"" , 5, 55, 141, 38, %WS_CHILD Or %DS_CONTROL, 0 To hDlg2
       Dialog Show Modeless hDlg2 Call DlgProc
       ' With the label below Commented out the ap will not lock
       ' up, but with the label un-commented the ap locks up as
       ' soon as you press one of the two image buttons (blank)
       ' Anyone know why?????
       Control Add Label, hDlg2, -1, "Test Label", 3, 3, 80, 8
       Control Add ImgButton, hDlg, 100, "", 165, 20, 27, 25, _
       Control Add ImgButton, hDlg, 110, "", 165, 50, 27, 25, _
       Control Add Button, hDlg, 120, "&Quit", 165, 80, 27, 25
       Dialog Show Modal hDlg Call DlgProc
    End Function
    Anyone have any idea's why this would be locking up like this?? I have
    been playing around with this all night and have no clue...


    Scott Slater
    Summit Computer Networks, Inc.

  • #2
    (edited response!)

    First, the main dialog should have the extended style %WS_EX_CONTROLPARENT to make it work properly with the %DS_CONTROL style of the child dialog.

    I think that the order in which you are SHOWing the dialogs is also not quite right. This will require some reengineering in order to build the child dialog after the main dialog has been created and DIALOG SHOW MODAL is executed. For example, create the child dialog in the main dialog callback in response to %WM_INITDIALOG or similar.

    Next, you'll probably need to add a %WS_GROUP style to the first control *after* the radio button group, or the CANCEL button may implicitly become part of the group too.

    Finally, the use of %BS_ICON is probably not necessary for an IMGBUTTON.

    If that still does not help, post the "reengineered" code in compilable form and I'll take a look for you.

    PS: In your callback, be sure it is actually receiving a %BN_CLICKED notification (in CBCTLMSG), don't just assume that is the case before acting upon the %WM_COMMAND message.

    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    mailto:[email protected]


    • #3
      there are a few of postings about this problem
      one is
      probably not there , but you will find it in poffs..
      i reported this problem in july 1999, i dont think there has been a sulotion from pb
      my workaround was placing pushbuttons on a seperate dialog.
      other advices have been to use control add "button" and take care of the image yourself.

      mailto:[email protected][email protected]</a>

      [this message has been edited by fred oxenby (edited july 06, 2001).]
      mailto:[email protected][email protected]</A>


      • #4

        The problem with Scott's code is the lack of a %WS_GROUP style in the button that is not part of the group but follows the group. Alternatively (well, additionally really), the control before the group should have the %WS_GROUP style added too.

        The root of the problem is that only one control has the group style set, so a infinite loop occurs when the next group tab position is enumerated.

        However, the construction of the code is not what I would deem "optimal", but it does work.

        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        mailto:[email protected]


        • #5
          Lance, I hate to take up your time with this,but look at the code that follows.
          Issue No1: All buttons have the main dialog as parent.
          Issue No2: All other controls have a child-dialog to Main as parent
          This code will 'enter an endless loop'
          However, you are right, adding %WS_GROUP to any of the controls on the
          child-dialog will prevent the endless loop. !!!Not on same parent!!!
          If you place the buttons on a child-dialog it will not lock.
          So what I see, is that in a child-dialog you dont need to terminate
          the groupsetting, but in a "normal" dialog (without %WS_CHILD) you have to do it.
          [ UPDATED ]
          #Compile Exe
          #Register None
          #Include ""
          %lbSys = 1000
          %TxSys = 2000
          %DlgStyleX = %WS_EX_CONTROLPARENT
          %PgStyleX  = %WS_EX_CONTROLPARENT
          %LbStyle   = %SS_RIGHT Or %SS_SUNKEN Or %SS_CENTERIMAGE Or %SS_NOPREFIX '[b]Or %WS_GROUP[/b]
          %LbStyleX  = 0
          %TxtStyleX  = %WS_EX_STATICEDGE
          Global ghWndOpt As Long
          Global ghWndPg1 As Long
          Declare Function MakeFont(ByVal Font As String, ByVal PointSize As Long) As Long
          Function PbMain()As Long
          '..Create Dialog-font
            hFont& = MakeFont("Courier New", 9)
          '..Create Main Dialog 
            Dialog New %HWND_DESKTOP, "Spider Inställningar",77,22, 320, 220,%DlgStyle,%DlgStyleX, To ghWndOpt
            If ghWndOpt = 0 Then Exit Function
            Dialog Send ghWndOpt, %WM_SETFONT,hFont&, 1
          '..Create Toolbar like buttons......................
            Control Add Button, ghWndOpt,3000,"System" ,20,2,34,15,DSStyle& Or %WS_GROUP
            Control Add Button, ghWndOpt,3001,"DiskMap",55,2,34,15,DSStyle&
            Control Add Button, ghWndOpt,3002,"BarrLog",90,2,34,15,DSStyle&
            Control Add Button, ghWndOpt,3003,"Com-Log",125,2,34,15,DSStyle&
            Control Add Button, ghWndOpt,3004,"CD-Log" ,160,2,34,15,DSStyle&
          '..Create Child Dialog (Page one)...................
            Dialog New ghWndOpt, "", _
                        20, 20, 300, 200, _
                        %PgStyle,%PgStyleX To ghWndPg1
            Dialog Send ghWndPg1, %WM_SETFONT,hFont&, 1
            chWnd&  = ghWndPg1
            cLeft&  = 0
            cTop&   = 5
            cWidth& = 80
            cHight& = 10
            cId&    = %lbSys
            cCapt$  = "SpiderId: "
            GoSub Page1_AddLabel
            cTop&= 15:Incr cId& :cCapt$="File-Server: "     :GoSub Page1_AddLabel
            cTop&= 25:Incr cId& :cCapt$="AS400 IP-Adress: " :GoSub Page1_AddLabel
            cTop&= 35:Incr cId& :cCapt$="System Namn: "     :GoSub Page1_AddLabel
            cTop&= 45:Incr cId& :cCapt$="Library Namn: "    :GoSub Page1_AddLabel
            cTop&= 55:Incr cId& :cCapt$="Datakö BarrIn: "   :GoSub Page1_AddLabel
            cTop&= 65:Incr cId& :cCapt$="Datakö BarrUt: "   :GoSub Page1_AddLabel
            cLeft&  = 80
            cTop&   = 5
            cWidth& = 30
            cHight& = 10
            cId&    = %TxSys
            cCapt$  = ""
            TxStyle& = %TxtStyle Or %ES_NUMBER:TxStyleX& = %TxtStyleX
            GoSub Page1_AddTextBox
            cTop& = 15:cWidth&=200:Incr cId&:TxStyle&=%TxtStyle:GoSub Page1_AddTextBox
            cTop& = 25:Incr cId&:GoSub Page1_AddTextBox
            cTop& = 35:Incr cId&:GoSub Page1_AddTextBox
            cTop& = 45:Incr cId&:GoSub Page1_AddTextBox
            cTop& = 55:Incr cId&:GoSub Page1_AddTextBox
            cTop& = 65:Incr cId&:GoSub Page1_AddTextBox
            Dialog Show State ghWndPg1, %SW_SHOW
            Dialog Show Modal ghWndOpt, Call FrmOpt
            Exit Function
            Control Add Label,chWnd&,cId&,cCapt$,cLeft&,cTop&,cWidth&,cHight&,%LbStyle,%LbStyleX 
            Control Send chWnd&, cId&, %WM_SETFONT,hFont&, 1
            Control Add TextBox,chWnd&,cId&,"",cLeft&,cTop&,cWidth&,cHight&,%TxtStyle,%TxtStyleX 
            Control Send chWnd&,cId&, %WM_SETFONT,hFont&, 1
          End Function
          Function MakeFont(ByVal Font As String, ByVal PointSize As Long) As Long
            Local hDC      As Long
            Local CyPixels As Long
            hDC = GetDC(%HWND_DESKTOP)
            CyPixels  = GetDeviceCaps(hDC, %LOGPIXELSY)
            ReleaseDC %HWND_DESKTOP, hDC
            PointSize = (PointSize * CyPixels) \ 72
            Function = CreateFont(0 - PointSize, 0, 0, 0, %FW_NORMAL, 0, 0, 0, _
                      %DEFAULT_QUALITY, %FF_DONTCARE, ByCopy Font)
          End Function
          mailto:[email protected][email protected]</A>

          [This message has been edited by Fred Oxenby (edited July 06, 2001).]
          mailto:[email protected][email protected]</A>