'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Template for DDT main dialog
'--------------------------------------------------------------------
#COMPILE EXE "Wallpaper.exe"
'#INCLUDE "WIN32API.INC"
'-----------------------------------------------------------------
' Equates:  42
'-----------------------------------------------------------------
%WINAPI                                         = 1
%TRUE                                           = 1
%NULL                                           = 0
%WM_USER                                        = &H400
%PS_SOLID                                       = 0
%WM_DRAWITEM                                    = &H2B
%WM_INITDIALOG                                  = &H110
%WM_COMMAND                                     = &H111
%WS_OVERLAPPED                                  = &H0
%WS_POPUP                                       = &H80000000
%WS_CHILD                                       = &H40000000
%WS_VISIBLE                                     = &H10000000
%WS_CAPTION                                     = &H00C00000  ' WS_BORDER OR WS_DLGFRAME
%WS_VSCROLL                                     = &H00200000
%WS_SYSMENU                                     = &H00080000
%WS_THICKFRAME                                  = &H00040000
%WS_TABSTOP                                     = &H00010000
%WS_MINIMIZEBOX                                 = &H00020000
%WS_MAXIMIZEBOX                                 = &H00010000
%WS_OVERLAPPEDWINDOW                            = %WS_OVERLAPPED OR %WS_CAPTION OR %WS_SYSMENU OR %WS_THICKFRAME OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX
%WS_EX_TOOLWINDOW                               = &H00000080
%WS_EX_CLIENTEDGE                               = &H00000200
%ODA_DRAWENTIRE                                 = &H1
%ODA_SELECT                                     = &H2
%ODS_SELECTED                                   = &H0001
%DT_LEFT                                        = &H0
%DT_VCENTER                                     = &H4
%DT_SINGLELINE                                  = &H20
%COLOR_WINDOW                                   = 5
%COLOR_WINDOWTEXT                               = 8
%COLOR_HIGHLIGHT                                = 13
%COLOR_HIGHLIGHTTEXT                            = 14
%COLOR_BTNFACE                                  = 15
%COLOR_3DFACE                                   = %COLOR_BTNFACE
%IDCANCEL                                       = 2
%BN_CLICKED                                     = 0
%DS_MODALFRAME                                  = &H0080& '  Can be combined with WS_CAPTION
%LB_GETTEXT                                     = &H189
%LBS_NOTIFY                                     = &H1&
%LBS_OWNERDRAWFIXED                             = &H10&
%LBS_HASSTRINGS                                 = &H40&
%LBS_NOINTEGRALHEIGHT                           = &H100&

'-----------------------------------------------------------------
' TYPE and UNION structures:  3
'-----------------------------------------------------------------
TYPE RECT
  nLeft AS LONG
  nTop AS LONG
  nRight AS LONG
  nBottom AS LONG
END TYPE

TYPE POINTAPI
  x AS LONG
  y AS LONG
END TYPE

TYPE DRAWITEMSTRUCT
  CtlType AS DWORD
  CtlID AS DWORD
  itemID AS DWORD
  itemAction AS DWORD
  itemState AS DWORD
  hwndItem AS LONG
  hDC AS DWORD
  rcItem AS RECT
  itemData AS DWORD
END TYPE

'-----------------------------------------------------------------
' Declared Functions:  11
'-----------------------------------------------------------------
DECLARE FUNCTION CreatePen LIB "GDI32.DLL" ALIAS "CreatePen" (BYVAL nPenStyle AS LONG, BYVAL nWidth AS LONG, BYVAL crColor AS DWORD) AS DWORD
DECLARE FUNCTION DeleteObject LIB "GDI32.DLL" ALIAS "DeleteObject" (BYVAL hObject AS DWORD) AS LONG
DECLARE FUNCTION DrawText LIB "USER32.DLL" ALIAS "DrawTextA" (BYVAL hDC AS DWORD, lpStr AS ASCIIZ, BYVAL nCount AS LONG, lpRect AS RECT, BYVAL uFormat AS DWORD) AS LONG
DECLARE FUNCTION FillRect LIB "USER32.DLL" ALIAS "FillRect" (BYVAL hDC AS DWORD, lpRect AS RECT, BYVAL hBrush AS DWORD) AS LONG
DECLARE FUNCTION GetSysColor LIB "USER32.DLL" ALIAS "GetSysColor" (BYVAL nIndex AS LONG) AS LONG
DECLARE FUNCTION GetSysColorBrush LIB "USER32.DLL" ALIAS "GetSysColorBrush" (BYVAL nIndex AS LONG) AS LONG
DECLARE FUNCTION LineTo LIB "GDI32.DLL" ALIAS "LineTo" (BYVAL hdc AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG) AS LONG
DECLARE FUNCTION MoveToEx LIB "GDI32.DLL" ALIAS "MoveToEx" (BYVAL hdc AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG, lpPoint AS POINTAPI) AS LONG
DECLARE FUNCTION SelectObject LIB "GDI32.DLL" ALIAS "SelectObject" (BYVAL hdc AS DWORD, BYVAL hObject AS DWORD) AS DWORD
DECLARE FUNCTION SetBkColor LIB "GDI32.DLL" ALIAS "SetBkColor" (BYVAL hdc AS DWORD, BYVAL crColor AS DWORD) AS DWORD
DECLARE FUNCTION SetTextColor LIB "GDI32.DLL" ALIAS "SetTextColor" (BYVAL hdc AS DWORD, BYVAL crColor AS DWORD) AS DWORD

'--------------------------------------------------------------------
DECLARE CALLBACK FUNCTION DlgProc() AS LONG
DECLARE CALLBACK FUNCTION PopupDlgProc2() AS LONG
DECLARE CALLBACK FUNCTION PopupDlgProc3() AS LONG

DECLARE FUNCTION ShowPopupDialog2 (BYVAL hParent AS DWORD) AS LONG
DECLARE FUNCTION ShowPopupDialog3 (BYVAL hParent AS DWORD) AS LONG

#INCLUDE "WINLIFT.INC"

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Main entrance
'--------------------------------------------------------------------
FUNCTION PBMAIN () AS LONG
  LOCAL hDlg AS DWORD
 
  DIALOG NEW 0, "Wallpaper",,, 390, 220, %WS_OVERLAPPEDWINDOW, 0 TO hDlg
 
  IF skInitEngine("Podcast.sks", "") THEN
     CALL skSkinWindow(hDlg, "Dock|Undock|Minimize|Maximize|Restore|Close")
  END IF

  DIALOG SHOW MODAL hDlg CALL DlgProc

END FUNCTION
 
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Main callback
'--------------------------------------------------------------------
CALLBACK FUNCTION DlgProc() AS LONG

  SELECT CASE CBMSG
     CASE %WM_INITDIALOG
   
          DIALOG POST CBHNDL, %WM_USER + 1, 0, 0
          DIALOG POST CBHNDL, %WM_USER + 2, 0, 0

     CASE %WM_USER + 1 : ShowPopupDialog2 CBHNDL
     CASE %WM_USER + 2 : ShowPopupDialog3 CBHNDL

     CASE %WM_COMMAND
        SELECT CASE CBCTL
           CASE %IDCANCEL
              IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN 'end prog
                 DIALOG END CBHNDL
              END IF
 
        END SELECT

  END SELECT
END FUNCTION

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Popup Dialog 2 entrance
'----------------------------------------------------------------------
FUNCTION ShowPopupDialog2 (BYVAL hParent AS DWORD) AS LONG
  LOCAL hDlg AS DWORD

  DIALOG NEW hParent, "Tools 2", 5, 20, 180, 180, _
             %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU OR %DS_MODALFRAME, %WS_EX_TOOLWINDOW TO hDlg

  DIALOG SHOW MODELESS hDlg, CALL PopupDlgProc2
  DO
     DIALOG DOEVENTS TO lRes&
  LOOP WHILE lRes&

END FUNCTION

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Popup Dialog 2 procedure
'----------------------------------------------------------------------
CALLBACK FUNCTION PopupDlgProc2() AS LONG

  SELECT CASE CBMSG
     CASE %WM_INITDIALOG
        Ret& = skSkinWindow(CBHNDL, "")

     CASE %WM_COMMAND
        SELECT CASE CBCTL
           CASE %IDCANCEL  : IF CBCTLMSG = %BN_CLICKED THEN DIALOG END CBHNDL, 0
        END SELECT

  END SELECT

END FUNCTION

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Popup Dialog 3 entrance
'----------------------------------------------------------------------
FUNCTION ShowPopupDialog3 (BYVAL hParent AS DWORD) AS LONG
  LOCAL hDlg AS DWORD, w AS LONG, h AS LONG

  DIALOG NEW hParent, "Tools 3", 200, 20, 180, 180, _
             %WS_POPUP OR %WS_CAPTION OR %WS_SYSMENU OR %DS_MODALFRAME, %WS_EX_TOOLWINDOW TO hDlg

  DIALOG GET CLIENT hDlg TO w, h
  CONTROL ADD LISTBOX, hDlg, 30,, 0, 0, w, h, %WS_CHILD OR %WS_VISIBLE OR _
              %LBS_OWNERDRAWFIXED OR %LBS_HASSTRINGS OR %LBS_NOTIFY OR _
              %LBS_NOINTEGRALHEIGHT OR %WS_TABSTOP OR %WS_VSCROLL, %WS_EX_CLIENTEDGE


  DIALOG SHOW MODELESS hDlg, CALL PopupDlgProc3
  DO
     DIALOG DOEVENTS TO lRes&
  LOOP WHILE lRes&

END FUNCTION

'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
' Popup Dialog 3 procedure
'いいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいいい
CALLBACK FUNCTION PopupDlgProc3() AS LONG

  LOCAL hPen  AS DWORD, i AS LONG
  LOCAL lpdis AS DRAWITEMSTRUCT PTR
  LOCAL szTxt AS ASCIIZ * 300

  SELECT CASE CBMSG
     CASE %WM_INITDIALOG
       FOR i = 1 TO 50
          LISTBOX ADD CBHNDL, 30, "This is item" + STR$(i)
       NEXT
       Ret& = skSkinWindow(CBHNDL, "")

     CASE %WM_COMMAND
        SELECT CASE CBCTL
           CASE %IDCANCEL  : IF CBCTLMSG = %BN_CLICKED THEN DIALOG END CBHNDL, 0
        END SELECT

     CASE %WM_DRAWITEM
        IF CBWPARAM = 30 THEN    ' CBWPARAM holds control's ID
            lpdis = CBLPARAM     ' CBLPARAM points to a DRAWITEMSTRUCT structure
            IF @lpdis.itemID = &HFFFFFFFF THEN EXIT FUNCTION 'if list is empty
 
            SELECT CASE @lpdis.itemAction
                CASE %ODA_DRAWENTIRE, %ODA_SELECT
 
                    IF (@lpdis.itemState AND %ODS_SELECTED) = 0 THEN                ' Not selected
                        FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_WINDOW) ' cls
                        SetBkColor @lpdis.hDC, GetSysColor(%COLOR_WINDOW)           ' Text background
                        SetTextColor @lpdis.hDC, GetSysColor(%COLOR_WINDOWTEXT)     ' Text color
                    ELSE                                                            ' Is Selected
                        FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_HIGHLIGHT) ' cls
                        SetBkColor @lpdis.hDC, GetSysColor(%COLOR_HIGHLIGHT)        ' Text background
                        SetTextColor @lpdis.hDC, GetSysColor(%COLOR_HIGHLIGHTTEXT)  ' Text color
                    END IF
 
                    ' Get/Draw current item's text
                    CONTROL SEND CBHNDL, 30, %LB_GETTEXT, @lpdis.itemID, VARPTR(szTxt)
                    CALL DrawText(@lpdis.hDC, szTxt, LEN(szTxt), @lpdis.rcItem, %DT_SINGLELINE OR %DT_LEFT OR %DT_VCENTER)
 
                    'Draw grid lines
                    hPen = CreatePen(%PS_SOLID, 1, GetSysColor(%COLOR_3DFACE))
                    hPen = SelectObject(@lpdis.hDC, hPen)
                    MoveToEx @lpdis.hDC, 0, @lpdis.rcItem.nBottom - 1, BYVAL %NULL
                    LineTo @lpdis.hDC, @lpdis.rcItem.nRight, @lpdis.rcItem.nBottom - 1
                    DeleteObject SelectObject(@lpdis.hDC, hPen)
 
                    FUNCTION = %TRUE
                    EXIT FUNCTION
            END SELECT
        END IF

  END SELECT

END FUNCTION
