Announcement

Collapse
No announcement yet.

Strings - Resource file or .BAS file?

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

  • Strings - Resource file or .BAS file?

    Two part question:

    Is there any more or less efficiency putting a string in a resource file?
    Ie, lets say I had a page of text I want to display in a function of some sort...


    Part two:
    If I have a help about dialog box i created, and wanted to put an easter egg in to show that page of text , how would you capture say, the F5 key or a combination of Control-F5???


    Just curious

    Scott


    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    > Is there any more or less efficiency putting
    > a string in a resource file?

    Resource files store strings as Unicode, so they take up twice as much space as a string literal.

    Runtime efficiency is a more complex issue, because of the way API functions convert Unicode to ANSI and vice versa. The "efficiency" depends on what you are doing.

    -- Eric




    ------------------
    Perfect Sync Development Tools
    Perfect Sync Web Site
    Contact Us: mailto:[email protected][email protected]</A>
    "Not my circus, not my monkeys."

    Comment


    • #3
      Scott:

      Re: Part two...
      Code:
      #COMPILE EXE
      #INCLUDE "WIN32API.INC"
      
      
      GLOBAL StopKBHook AS LONG
      
      
      CALLBACK FUNCTION DlgProc
         SELECT CASE CBMSG
         CASE %WM_DESTROY
            StopKBHook = %TRUE
            PostQuitMessage 0
         END SELECT
      END FUNCTION
      
      
      FUNCTION PBMAIN
         LOCAL hDlg AS LONG
         LOCAL Msg  AS tagMsg
      
      
         DIALOG NEW 0, "Key Catcher",,, 100, 50, %WS_CAPTION + %WS_SYSMENU TO hDlg
         CONTROL ADD LABEL, hDlg, 100, "Press  Ctrl + F5 ...", 20, 20, 60, 12
         DIALOG SHOW MODELESS hDlg CALL DlgProc
      
      
         WHILE GetMessage(Msg, hDlg, 0, 0) = %TRUE
            SELECT CASE Msg.message
            CASE %WM_KEYDOWN
               SELECT CASE Msg.wParam
               CASE %VK_F5
                  IF ISTRUE(LOWRD(GetKeyState(%VK_CONTROL)) AND &H8000) THEN
                     '
                     MSGBOX "You pressed Ctrl F5"
                     '
                  END IF
               END SELECT
            END SELECT
            IF IsDialogMessage(hDlg, Msg) = %FALSE THEN
               TranslateMessage Msg
               DispatchMessage Msg
            END IF
            IF StopKBHook = %TRUE THEN
               EXIT LOOP
            END IF
         LOOP
      END FUNCTION
      Timm
      mailto:[email protected]
      Tsunami Record Manager

      Comment


      • #4
        I have to integrate this into my help/about box, which is actually in a DLL:

        It does nto work as is though

        Code:
        'This is the end of "CCSHelpAbout" basically:
        Dialog Show Modal aDlg Call AboutProc
        Function = %TRUE
        End Function
        
        CallBack Function AboutProc() As Long
        Local wMsg   As Long
        Local wParam As Long
        Local lParam As Long
        
        wMsg = CbMsg
        lParam = CbLparam
        wparam = CbWparam
        Select Case wMsg
            Case %WM_INITDIALOG
                 Control Set Focus aDlg,%IDCANCEL
            Case %WM_DESTROY
        
            Case %WM_KEYDOWN
                 Select Case LoWrd(wParam)
                        Case %VK_F5
                             If IsTrue(LoWrd(GetKeyState(%VK_CONTROL)) And &H8000) Then
                                 MsgBox "F5 was pressed",%MB_ICONINFORMATION,"DEBUG In AboutProc"
                             end if
                 End Select
        
            Case %WM_COMMAND
                Select Case LoWrd(wParam)
                    Case %IDCANCEL
                        Dialog End aDlg, 1
                        Exit Function
                End Select
        End Select
        End Function

        ------------------
        Scott
        Scott Turchin
        MCSE, MCP+I
        http://www.tngbbs.com
        ----------------------
        True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

        Comment


        • #5
          Scott:

          You aren't going to receive a WM_KEYDOWN message in the CALLBACK FUNCTION... you need to "intercept" it
          with GetMessage() as in my previous code example. Here is your code snippet with the keyboard hook in it...
          Code:
             ' At top of DLL...
             GLOBAL aDlg       AS LONG
             GLOBAL StopKBHook AS LONG
          
          
             ' This is the end of "CCSHelpAbout" basically:
             '
             DIALOG SHOW MODELESS aDlg CALL AboutProc
             '
             LOCAL Msg AS tagMsg
             WHILE GetMessage(Msg, aDlg, 0, 0) = %TRUE
                SELECT CASE Msg.message
                CASE %WM_KEYDOWN
                   SELECT CASE Msg.wParam
                   CASE %VK_F5
                      MSGBOX "You pressed F5"
                   END SELECT
                END SELECT
                IF IsDialogMessage(aDlg, Msg) = %FALSE THEN
                   TranslateMessage Msg
                   DispatchMessage Msg
                END IF
                IF StopKBHook = %TRUE THEN EXIT LOOP
             LOOP
          END FUNCTION
          
          
          CALLBACK FUNCTION AboutProc() AS LONG
             SELECT CASE CBMSG
             CASE %WM_INITDIALOG
                CONTROL SET FOCUS aDlg, %IDCANCEL
             CASE %WM_DESTROY
                StopKBHook = %TRUE
                PostQuitMessage 0
             CASE %WM_COMMAND
                SELECT CASE LOWRD(CBWPARAM)
                CASE %IDCANCEL
                   DIALOG END aDlg, 1
                END SELECT
             END SELECT
          END FUNCTION
          Timm
          mailto:[email protected]
          Tsunami Record Manager

          Comment


          • #6
            You should make use of accellerators.
            Not hard.


            ------------------
            hellobasic

            Comment


            • #7
              I've seen accelerators in resource files before, how do you use them?
              The key board hook is a bit more than I want to tackle for this, it's really not a big issue.
              If it's easy to do I'll put the easter egg in, , if not, no prob.


              Thanks,


              ------------------
              Scott
              Scott Turchin
              MCSE, MCP+I
              http://www.tngbbs.com
              ----------------------
              True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

              Comment


              • #8
                Download FreeDDT.
                You don't have to use it but it generates a accel. table for you.
                That one is something you could investigate.
                Need VB creating the menus in this case tough.

                If you don't want that i could write a small examplke for you instead.
                No need for menues.


                ------------------
                hellobasic

                Comment

                Working...
                X