Announcement

Collapse
No announcement yet.

cant figure out how to use SYSmonthcal32

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

  • cant figure out how to use SYSmonthcal32

    created this in PB forms and can't figure how to get the date selected into the global dterequest$ field

    I looked at the examples but not quite sure what it is doing and where I should change mine to work

    any ideas?


    thanks


    Code:
    #PBFORMS CREATED V2.01
    '------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PB/Forms metastatements are placed at the beginning and
    ' end of "Named Blocks" of code that should be edited
    ' with PBForms only. Do not manually edit or delete these
    ' metastatements or PB/Forms will not be able to reread
    ' the file correctly. See the PB/Forms documentation for
    ' more information.
    ' Named blocks begin like this: #PBFORMS BEGIN ...
    ' Named blocks end like this: #PBFORMS END ...
    ' Other PB/Forms metastatements such as:
    ' #PBFORMS DECLARATIONS
    ' are used by PB/Forms to insert additional code.
    ' Feel free to make changes anywhere else in the file.
    '------------------------------------------------------------------------------
    
    #COMPILE EXE
    #DIM ALL
    
    '------------------------------------------------------------------------------
    ' ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #RESOURCE "Vendor catalog Data Dump.pbr"
    %USEMACROS = 1
    #INCLUDE ONCE "WIN32API.INC"
    #INCLUDE ONCE "COMMCTRL.INC"
    #INCLUDE ONCE "PBForms.INC"
    
    #INCLUDE ONCE "InitCtrl.inc"
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    ' ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %IDD_DIALOG1 = 101
    %IDC_load_floppy = 1001
    %IDC_LOAD_CDrom = 1002
    %IDC_Write_data = 1004
    %IDC_date_cataloged = 1003
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    ' ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    ' ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
    GLOBAL dterequest$
    GLOBAL hdlg AS WORD
    IF InitComCtl32W(%ICC_DATE_CLASSES) < 4.70@ THEN
        MSGBOX "Sorry, this program needs a later version of COMCTL32.DLL." + $CRLF _
        + "Please install MSIE version 4 or higher, or get the file directly from: " + $CRLF _
         + $CRLF _
         + "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp", _
          %MB_ICONWARNING OR %MB_SYSTEMMODAL, "SysMonthCal32 Error"
         EXIT FUNCTION
    END IF
    
    PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
    %ICC_INTERNET_CLASSES)
    
    ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    ' ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowDIALOG1Proc()
    LOCAL pNMSC AS NMSELCHANGE PTR
    LOCAL DateStr AS WSTRING
    
    SELECT CASE AS LONG CB.MSG
        CASE %WM_INITDIALOG
        ' Initialization handler
    
        CASE %WM_NCACTIVATE
           STATIC hWndSaveFocus AS DWORD
           IF ISFALSE CB.WPARAM THEN
                 ' Save control focus
               hWndSaveFocus = GetFocus()
            ELSEIF hWndSaveFocus THEN
                 ' Restore control focus
                  SetFocus(hWndSaveFocus)
                 hWndSaveFocus = 0
            END IF
    
        CASE %WM_NOTIFY
            ' Set up the NMSELCHANGE pointer passed in CB.LPARAM
            pNMSC = CB.LPARAM
    
    ' Detect changes in the calendar control
             IF @pNMSC.hdr.code = %MCN_SELCHANGE THEN ' Get selected date/time
                    ' Here we use an international date format, just to show how it works
                      ' Tip: in a database, we can use these values to get stored
                      ' data related to the selected date..
    
                     DateStr = STR$(@pNMSC.stSelStart.wMonth) _
                                  + STR$(@pNMSC.stSelStart.wDay) + ", " _
                                  + STR$(@pNMSC.stSelStart.wYear)
                    DateStr = "Selected date: " + DateStr _
                                  + " (Right click for popup menu...)"
    
                    ' CONTROL SET TEXT CB.HNDL, %IDC_LABEL, DateStr
                      dterequest$ = datestr
             END IF
    
    
        CASE %WM_COMMAND
            ' Process control notifications
            SELECT CASE AS LONG CB.CTL
               ' /* Inserted by PB/Forms 01-10-2017 14:00:17
                  CASE %IDC_date_cataloged
                ' */
    
                   CASE %IDC_load_floppy
                         IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                              MSGBOX "%IDC_load_floppy=" + $CRLF+ _
                                                  FORMAT$(%IDC_load_floppy), %MB_TASKMODAL
                         END IF
    
               CASE %IDC_LOAD_CDrom
                      IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                          MSGBOX "%IDC_LOAD_CDrom=" + FORMAT$(%IDC_LOAD_CDrom), _
                                            %MB_TASKMODAL
                     END IF
    
               CASE %IDC_date_cataloged
                   CONTROL GET TEXT hDlg, %IDC_date_cataloged TO dterequest$
    
               CASE %IDC_Write_data
                        IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                                   CONTROL GET TEXT hDlg, %IDC_date_cataloged TO dterequest$
                                  MSGBOX "%IDC_Write_data=" + $CRLF+"dte request = "+dterequest +$CRLF+ FORMAT$(%IDC_Write_data), _
                                                  %MB_TASKMODAL
                        END IF
    
             END SELECT
       END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    ' ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    LOCAL lRslt AS LONG
    
    #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
    LOCAL hDlg AS DWORD
    LOCAL hFont1 AS DWORD
    
    DIALOG NEW hParent, "Vendor catalog Data Dump", 263, 142, 617, 150, _
    %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_load_floppy, "Load Floppy", 10, 20, 120, _
    120
    CONTROL ADD BUTTON, hDlg, %IDC_LOAD_CDrom, "Load Cd-Rom", 155, 20, 120, _
    120
    CONTROL ADD "SysMonthCal32", hDlg, %IDC_date_cataloged, "Select Date", _
    291, 20, 175, 120, %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, _
    %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
    %WS_EX_RIGHTSCROLLBAR
    CONTROL ADD BUTTON, hDlg, %IDC_Write_data, "Write Data", 480, 20, 120, _
    120
    
    FONT NEW "MS Sans Serif", 18, 0, %ANSI_CHARSET TO hFont1
    
    CONTROL SET FONT hDlg, %IDC_load_floppy, hFont1
    CONTROL SET FONT hDlg, %IDC_LOAD_CDrom, hFont1
    CONTROL SET FONT hDlg, %IDC_date_cataloged, hFont1
    CONTROL SET FONT hDlg, %IDC_Write_data, hFont1
    #PBFORMS END DIALOG
    
    DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    FONT END hFont1
    #PBFORMS END CLEANUP
    
    FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    Last edited by Michael Mattias; 11 Jan 2017, 02:07 PM. Reason: add code tags and indents

  • #2
    Since the month calendar is not a "DDT Intrinsic" control (has it's own keyword as in 'CONTROL ADD LISTBOX .') you cannot use a DDT statement (CONTROL GET TEXT) to get any text associated with that control.

    Instead, you have to use the facilities provided by the control... in this case, you get the selected date using the MCM_GETCURSEL message (or the MOthCal_GetCursel macro/function).

    I have fifty-two cents says there is code here somewhere showing you how to do this (I have not looked for it). I'd try searching here on 'MCM_GETCURSEL" and see what comes up.

    MCM


    Michael Mattias
    Tal Systems Inc.
    Racine WI USA
    mmattias@talsystems.com
    http://www.talsystems.com

    Comment


    • #3
      BTW, adding back the indents is a PITA. When you post code you should use the code tags BEFORE you save the message, or else the BBS software "helps" by removing any "useless" leading spaces from each line.

      If you are not sure how to do this, simply "EDIT" your post and see what I inserted immediately before and after the "code" section of your post.
      Michael Mattias
      Tal Systems Inc.
      Racine WI USA
      mmattias@talsystems.com
      http://www.talsystems.com

      Comment


      • #4
        Hi Ralph,

        created this in PB forms and can't figure how to get the date selected into the global dterequest$ field
        You are already setting the Global String to the selected date in the @pNMSC.hdr.code = %MCN_SELCHANGE handler. (dterequest$ = datestr)

        Unfortunately you are clearing it with the (erroneous) statement "CONTROL GET TEXT hDlg, %IDC_date_cataloged TO dterequest$" later in the callback procedure.

        You actually use the statement (Control Get Text) twice but only the one in the 'CASE %IDC_Write_data' section is having (the detrimental) effect.

        PBForms does add a "CASE %IDC_date_catalogued" in the WM_Command message handling part of the CallBack Proc - it's not required (msg never gets sent by Month Cal Control) but the PBForms engine is trying to be 'helpful'

        PBForms does not actually know which messages and/or notifications are sent by particular Custom Controls. In the case of a Month Calendar Control, it sends notifications only in the form of a WM_NOTIFY message. It responds to requests / instructions sent to it in the form of MCM_ statements (nothing to do with our bane) or sometimes an equivalent macro.

        PBForms constructs a 'generic' CallBack procedure that provides a simple skeleton best used as a starting point. It often needs adjustments!
        Rgds, Dave

        Comment


        • #5
          Thanks for noticing that

          now that I removed the the control get text it is working

          Comment

          Working...
          X