Announcement

Collapse
No announcement yet.

How to toggle visible attribute in DDT control?

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

    How to toggle visible attribute in DDT control?

    I am starting my first DDT application. I am building
    a "work day" calendar in PB that is intended
    to display a calendar with Sundays, Saturdays, and
    work holidays (read from a btrieve database) grayed.
    I am having difficulty changing the attributes of my buttons.
    I can mark a hidden button visible, but rehiding a button is
    apparently impossible, and I am not able to mark buttons
    as disabled after they are created. I have even tried
    storing location and size and killing and adding a control,
    and the changes are not displayed. What would be the
    proper technique for changing attributes of existing controls?



    ------------------

    #2
    A lot of variants. For example,
    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "Win32Api.Inc"
    
       CallBack Function DlgProc
          
          Select Case CbMsg
             Case %WM_INITDIALOG
                Control Add Button, CbHndl, 101, "Hide/Show Button 2", 5, 10, 75, 15
                Control Add Button, CbHndl, 102, "Button 2", 100, 10, 75, 15
             Case %WM_COMMAND
                If CbCtl = 101 Then ' Hide/Show
                   Local hWnd As Long, newState As Long
                   hWnd = GetDlgItem(CbHndl, 102) ' Button 2
                   If IsWindowVisible(hWnd) Then newState = %SW_HIDE Else newState = %SW_SHOW
                   ShowWindow hWnd, newState
                End If
          End Select
       End Function
    
       Function PbMain
          Local hDlg As Long
          Dialog New 0, "Toggle",,, 180, 40, %WS_SYSMENU Or %WS_CAPTION To hDlg
          Dialog Show Modal hDlg Call DlgProc
       End Function
    ------------------

    Comment


      #3
      Thank you for your help. That was an excellent teaching example. I learned more than I had hoped.


      ------------------

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎