Announcement

Collapse
No announcement yet.

How do I get the date from the PBForms Calendar Control?

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

  • StanHelton
    replied
    Thanks to all 3 of you.

    Roy Cline: Yes, I like Bjorge's calendar routine, but it would not compile in my application.

    Chris Holbrook: Thank you for that code. It compiles and does exactly what I need it to do right up until I try to integrate it into my application.

    Adam J. Drake: Thank you for reminding me about how MACROs work. I was beginning to focus on this problem too much.

    In general:

    Thank you all for your input. Based on what you have given me, I have decided the problem must lie somewhere else in my code. The application is too big to post, but at least I know the calendar function is right.

    Sincerely grateful,
    Stan

    Leave a comment:


  • Adam J. Drake
    replied
    No need to use pst. Just send DataStructure.

    In both the MACRO and FUNCTION definition of MonthCal_GetCurSel inside COMMCTRL.INC, it takes care of sending the variable declared as SYSTEMTIME as a pointer by using VARPTR.

    Leave a comment:


  • Chris Holbrook
    replied
    BYVAL pst?

    Anyroad, this works, not sure if it answers your question though!


    Code:
    #PBFORMS CREATED V1.51
    #COMPILE EXE
    #DIM ALL
    
    #PBFORMS BEGIN INCLUDES
    #IF NOT %DEF(%WINAPI)
        #INCLUDE "WIN32API.INC"
    #ENDIF
    #IF NOT %DEF(%COMMCTRL_INC)
        #INCLUDE "COMMCTRL.INC"
    #ENDIF
    #INCLUDE "PBForms.INC"
    #PBFORMS END INCLUDES
    
    #PBFORMS BEGIN CONSTANTS
    %IDD_DIALOG1         =  101
    %IDC_SYSMONTHCAL32_1 = 1001
    %IDC_LABEL1          = 1002
    #PBFORMS END CONSTANTS
    
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    
    FUNCTION PBMAIN()
        PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES)
    
        ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    
    CALLBACK FUNCTION ShowDIALOG1Proc()
      LOCAL DataStructure AS SYSTEMTIME
    
        SELECT CASE AS LONG CBMSG
    
            CASE %WM_notify
                MonthCal_GetCurSel(getdlgitem(CBHNDL, %IDC_SYSMONTHCAL32_1), BYREF DataStructure)
                CONTROL SET TEXT CBHNDL, %IDC_LABEL1, _
                     TRIM$(STR$(DataStructure.wMonth)) & "/" _
                   & TRIM$(STR$(DataStructure.wDay)) & "/" _
                   & TRIM$(STR$(DataStructure.wYear))
    
        END SELECT
    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, "Stan Helton's Calendar Problem", 70, 70, 265, 162, %WS_SYSMENU OR %WS_VISIBLE OR %DS_3DLOOK OR _
            %DS_NOFAILCREATE OR %DS_SETFONT, %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR OR %WS_EX_CONTROLPARENT, TO _
            hDlg
        CONTROL ADD "SysMonthCal32", hDlg, %IDC_SYSMONTHCAL32_1, "SysMonthCal32_1", 5, 5, 120, 75, %WS_CHILD OR %WS_VISIBLE OR _
            %WS_TABSTOP, %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR OR %WS_EX_CLIENTEDGE
        CONTROL ADD LABEL,  hDlg, %IDC_LABEL1, "Label1", 140, 75, 110, 65
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION

    Leave a comment:


  • Roy Cline
    replied
    http://www.powerbasic.com/support/pb...lendar+control

    Leave a comment:


  • How do I get the date from the PBForms Calendar Control?

    Okay, I'm sure this sounds like a beginner question, but when I run into problems it's always something that looks very easy AFTER I know the answer.


    Code:
    CALLBACK FUNCTION ShowCalendarProc()
       LOCAL DataStructure AS SYSTEMTIME
       LOCAL pst AS SYSTEMTIME POINTER
    
       CalendarHandle = CBHNDL
       pst = VARPTR(DataStructure)
    
       SELECT CASE AS LONG CBMSG
          CASE %WM_INITDIALOG
             ' Initialization handler
    
          CASE %WM_NCACTIVATE
             STATIC hWndSaveFocus AS DWORD
             IF ISFALSE CBWPARAM THEN
                ' Save control focus
                hWndSaveFocus = GetFocus()
             ELSEIF hWndSaveFocus THEN
                ' Restore control focus
                SetFocus(hWndSaveFocus)
                hWndSaveFocus = 0
             END IF
    
          CASE %WM_COMMAND
             ' Process control notifications
             MonthCal_GetCurSel(CalendarHandle, pst)
             MailingDate = TRIM$(STR$(DateStructure.wMonth)) & "/" _
                           & TRIM$(STR$(DateStructure.wDay)) & "/" _
                           & TRIM$(STR$(DateStructure.wYear))
    
       END SELECT
    END FUNCTION
    According to the debug watch, DataStructure doesn't get initialized.

    I've tried using "@pst." in place of "DataStructure." but the debug watch shows the value of the pointer (not the variable) in wMonth, wDay, and wYear.

    I don't really care which message is being processed. If anything happens in the calendar window I want to update the GLOBAL MailingDate.

    Thank you for looking at this for me.
    Stan
Working...
X