No announcement yet.

Source code posted: Eddy's Project Timer

  • Filter
  • Time
  • Show
Clear All
new posts

  • Source code posted: Eddy's Project Timer

    is a program i posted. place remarks/comments in this post.

    ' ept is a program that enables you to keep track of the time you
    ' work on certain projects.
    ' you don't have to fill in time tables. ept counts the hours and
    ' minutes you work on a number of projects.
    ' ept only needs the following input:
    ' - the project you are working on. you can simply switch to another project.
    ' - are you working or taking a break? this can even be set to automatic.
    ' ept calculates the flexitime if you work on flexible hours.
    ' ept calculates the average break time.
    ' it's best to put ept in your startup directory so it is automatically
    ' started up when you boot your pc.
    ' you can set ept to startup in 'working mode' or 'break mode'.
    ept does not exactly contain high tech algorithms. 90% of the code is gui related.
    i wrote it mainly as a testcase to learn pbdll. at the same time the program is useful for me and maybe to some other
    i'm sorry i had to zip the code. i tried several times to post the unzipped code but it
    was too long i guess (100k). this is mainly because it has an integrated rtf helpfile.
    kind regards

    [email protected]

    [this message has been edited by eddy van esch (edited july 20, 2001).]

  • #2
    Hi Eddy,

    Just downloaded the source file, and I noticed that the Help
    menu text is in RTF format, not the format you intended.

    It looks like it might be a handy little program.

    "It was too lonely at the top".


    • #3
      Originally posted by Bob Houle:
      I noticed that the Help
      menu text is in RTF format, not the format you intended.
      Hi Bob,
      Maybe I didn't formulate it right, but the help text is indeed in RTF
      format (as I intended), displayed in a RichEdit box. It is not in WinHelp format
      as you perhaps had expected.
      I used RTF for 2 reasons:
      - I wanted 1 executable file so I embedded the RTF text as a string in the executable
      and displayed that string in a RichEdit box. With a WinHelp file you would have to unpack it
      and store it in a file before opening the help file with WinHelp.
      - I don't (yet) master the tools to create real WinHelp helpfiles.
      Hope this clarifies things.
      Kind regards

      [email protected]


      • #4
        Hi Eddy

        the app looks very handy - thanks - I think what Bob Houle
        meant is that the Help and About richedit text boxes do not
        interpret the RTF formatting but instead display it "as is":
        {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New

        This is probably not what you intended - tested here on NT 4.0





        • #5
          Tested your prog in W2k, everything is ok.
          The RTF text displays correctly, great work !




          • #6
            Originally posted by Florent Heyworth:
            the Help and About richedit text boxes do not
            interpret the RTF formatting but instead display it "as is":
            {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New
            Hi Florent,
            Now I understand what Bob meant. This is strange, because on my W2K system
            the RTF text in the RichEdit box displays exactly as in Wordpad where I typed it in.
            Dominique also mentioned it looks fine on his W2K system.
            Don't exactly know what could be the reason it doesn't look good on your
            and Bob's PC. Probably an older version of the RichEd32.dll.
            Unfortunately I am now not on a W2K system so I can't check on the dll version
            number. Will check it later and report it so you can compare with yours.
            Unless somebody else comes up with an other solution.
            Kind regards

            [email protected]


            • #7
              Did you properly stream it in?



              • #8
                Not directly on point but...

                I downloaded the code (edit/select all/copy/change to IDE/paste), and from the PB/DLL IDE I tried to "save as" "ept.bas"

                I got this message from the Windows "Save As" dialog:

                C:\Software_Development\PBDLL60\Work\ept.bas is a reserved device name. Please choose another name.
                No problem "saving as" ept_2.bas.

                I even went back the next day (today), loaded ept_2.bas and tried to "save as" ept.bas; same message.

                Does anyone have a clue why "ept.bas" is a "reserved device name?"

                OS: Win 98 (first edition).


                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]


                • #9
                  That is apparently a Windows 98 thing as I get that in VB also. I do not see it in
                  Windows 95



                  • #10

                    Right after you richedit include:

                    Type RichEdit_CookieSet
                        Text    As Long
                        Currpos As Long
                    End Type
                    Global hRichEdit As Long
                    Function RichEdit_SetRTFText( ByVal hWnd As Long, Text As String, ByVal SetModified As Long ) As Long
                        Dim EDTS As EDITSTREAM
                        Dim RECS As RichEdit_CookieSet
                        If hWnd = 0 Then Exit Function
                        '// INIT, passed to callback.
                        RECS.Currpos        = 1
                        RECS.Text           = StrPtr( Text )
                        '// callback settings
                        EDTS.dwCookie       = VarPtr( RECS )
                        EDTS.dwError        = 0
                        EDTS.pfnCallback    = CodePtr( RichEdit_EditStreamCallback )
                        '// Freeze updates.
                        Call SendMessage( hWnd, %WM_SETREDRAW, 0, ByVal 0& )
                        '// Start reading the RTF
                        Call SendMessage( hWnd, %EM_STREAMIN, %SF_RTF, ByVal VarPtr( EDTS ) )
                        '// Set modified flag.
                        Call SendMessage( hWnd, %EM_SETMODIFY, IsTrue( SetModified ), ByVal 0& )
                        '// Set control for update.
                        Call SendMessage( hWnd, %WM_SETREDRAW, -1, ByVal 0& )
                        '// Repaint the control's contents.
                        InvalidateRect hWnd, ByVal 0&, -1
                        '// Return errors
                        Function = EDTS.dwError
                    End Function
                    Function RichEdit_EditStreamCallback( ByVal dwCookie As Dword, ByVal pbBuff As Byte Ptr, ByVal cb As Long, pcb As Dword ) As Long
                        Dim RECS As RichEdit_CookieSet Ptr
                        Dim T    As Asciiz Ptr
                        Dim tl   As Long
                        '// Set a pointer to a provided string.
                        RECS = dwCookie
                        T = @RECS.Text
                        '// Be sure we don't read past end of data.
                        If Len( @T ) - @RECS.Currpos =< 0 Then cb = Len( @T ) - @RECS.Currpos
                        tl = cb
                        If cb > Len( @T ) Then tl = Len( @T )
                        '// Copy the data into the byte buffer.
                        If tl > 0 Then Poke$ pbBuff, Mid$( @T, @RECS.Currpos, tl )
                        '// Increase static for next callback position.
                        @RECS.Currpos = @RECS.Currpos + tl
                        '// Return new buffer amount.
                        pcb = tl
                    End Function

                    A slight change to the help menu:

                    Sub PBMAIN_Help(Info As Long)
                        Local a$, x As Long, y As Long, Title As String
                        Local hRichEdit As Long
                        hRichEdit = LoadLibrary("RICHED32.DLL")
                        If Info = 1 Then Title = "EPT - Help" Else  Title = "EPT - About"
                        Dialog New %HWND_DESKTOP, Title, , , 350, 250, %WS_OVERLAPPEDWINDOW ,%WS_EX_CONTEXTHELP To hHelp&
                        Dialog Get Size hHelp& To x, y          'Get client area
                        Control Add "RICHEDIT" , hHelp&, %HLP_RICHED, "", 5,5,x-13,y-50 , _
                            %ES_READONLY ,%WS_EX_CLIENTEDGE
                        Control Add "Button", hHelp&,  %HLP_EXITBUTTON,  "Done reading", x/2-30, y-35, 50, 16, _
                        If Info = 1 Then a$ = Read_HelpText() Else a$ = Read_AboutText()
                        RichEdit_SetRTFText GetDlgItem( hHelp&, %HLP_RICHED ), a$, 0
                    '    Control Set Text hHelp&, %HLP_RICHED, a$
                        Dialog Show Modal hHelp&, Call Help_DLGPROC
                    End Sub

                    The code can be found on my site too.



                    • #11
                      On W2k I also get the warning about the "EPT.bas" filename...

                      Thanks for your code. I must look in to it first.

                      Bob, Florent,
                      About the RTF richedit box. I ran my program on win98 and I got the same
                      effect as you. All the ANSI tokens are shown.
                      I simply copied my W2k riched32.dll file to my Win98 system (in DOS mode)
                      and after that the Help and About RTF text showed fine in EPT's richedit box!
                      The dll version of my w2k riched32.dll is "5.00.2134.1".
                      Funny thing is that the w2k dll is only 4k. It seems to be a wrapper...
                      Kind regards

                      [email protected]