Announcement

Collapse
No announcement yet.

Need Visual Studio include for tooltips demo

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

  • Eric Pearson
    replied
    William --

    Fred's post still uses #include "afxres.h" so I was going to post it or email it to you (as you requested) but the beginning of the file says this...

    Code:
    // This is a part of the Microsoft Foundation Classes C++ library.
    // Copyright (C) 1992-1997 Microsoft Corporation
    // All rights reserved.
    ...so it's not legal for anybody except Microsoft (or somebody they authorize) to give it to you. That may be why it was not included with the original post.

    -- Eric

    -------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Fred Oxenby
    replied
    William,
    To me it seems that this posting (RC-file) is truncated.
    It does not carry any useful information.
    I have modified the program for you

    Code:
    '/**************    Tips.bas  **********************/
    
    
    'Tool Tip example showing how to put tool tips on push buttons
    'in a dialog .
    ' Written by Kerry S. Goodin           2-5-1999
    ' you may use any part or whole and use at your own risk
    
    ' this is for PB/DLL 5.0 or greater
    
    $DIM ALL
    $COMPILE EXE "TIPS.EXE"
    $OPTION VERSION4
    $RESOURCE "TIPS.PBR"
    $INCLUDE "WIN32API.INC"
    $INCLUDE "COMMCTRL.INC"
    
    '===========  [ Program controls identifiers ]  =======================
    %TIPS       = 101
    %IDC_OK     = 1000
    %IDC_CANCEL = 1001
    '===========  [ Program GLOBAL declarations ]  ========================
    GLOBAL ghInst         AS DWORD         ' Module instance handle.
    GLOBAL ghCurrentDlg   AS DWORD         ' Active modeless dlg handle.
    
    '===========  [ Program ENTRY point ]  ================================
    FUNCTION WinMain(BYVAL hCurrInstance AS LONG,_
                     BYVAL hPrevInstance AS LONG,_
                     lpCmdLine           AS ASCIIZ PTR,_
                     BYVAL nCmdShow      AS LONG) AS LONG
    
      ' Local variables.
      LOCAL  Msg            AS tagMsg
      LOCAL  wClass         AS WndClass
      LOCAL  hWnd           AS DWORD
      LOCAL  szClassName    AS ASCIIZ * 5
    
      szClassName = "TIPS"
      ghInst = hCurrInstance
    
      ' A REPLACEMENT for program PrevInstance.
      IF ISFALSE(FindWindow(szClassName, BYVAL %NULL)) THEN
         ' Fill window structure.
         wClass.style         = %CS_HREDRAW OR %CS_VREDRAW
         wClass.lpfnWndProc   = GetProcAddress(GetModuleHandle("USER32"), "DefDlgProcA")
         wClass.cbClsExtra    = 0
         wClass.cbWndExtra    = %DLGWINDOWEXTRA
         wClass.hInstance     = hCurrInstance
         wClass.hIcon         = LoadIcon(%NULL, BYVAL %IDI_APPLICATION)
         wClass.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
         wClass.hbrBackground = GetStockObject(%LTGRAY_BRUSH)
         wClass.lpszMenuName  = %NULL
         wClass.lpszClassName = VARPTR(szClassName)
    
         ' Register the window-class.
         RegisterClass wClass
      ELSE
         ' Bring prev instance to front.
         hWnd = FindWindow(szClassName, BYVAL %NULL)
         IF IsIconic(hWnd) THEN ShowWindow hWnd ,%SW_RESTORE
         SetForegroundWindow hWnd
         ' Exit.
         FUNCTION = 0
         EXIT FUNCTION
      END IF
    
      ' Create the main window as a MODELESS dialog.
      hWnd = CreateDialogParam(hCurrInstance, BYVAL CLNG(%TIPS), 0, CODEPTR(MainWndProc), 0)
      ShowWindow hWnd, nCmdShow
    
      ' Main message loop of program.
      WHILE GetMessage(Msg, %NULL, 0, 0)
          IF ISFALSE(ghCurrentDlg) OR ISFALSE(IsDialogMessage(ghCurrentDlg, Msg)) THEN
             TranslateMessage Msg
             DispatchMessage Msg
          END IF
      WEND
    
      ' Clean up and assign return value.
    
      FUNCTION = Msg.wParam
    
    END FUNCTION
    
    '===============  [ MainWnd dialog window procedure ]  =================
    FUNCTION MainWndProc(BYVAL hDlg    AS DWORD,_
                         BYVAL wMsg    AS DWORD,_
                         BYVAL wParam  AS DWORD,_
                         BYVAL lParam  AS DWORD) EXPORT AS LONG
    
      LOCAL Action         AS LONG
      LOCAL lpToolTip   AS TOOLTIPTEXT PTR
      STATIC zText      AS ASCIIZ * 255
      STATIC hwndToolTip AS LONG
      LOCAL ti AS TOOLINFO
    
      SELECT CASE wMsg
             
             CASE %WM_INITDIALOG
    
                  CALL InitCommonControls
                  'create the tooltip window
                  hwndToolTip = CreateWindowEx( 0, "TOOLTIPS_CLASS32", BYVAL %NULL, 					%TTS_ALWAYSTIP OR %WS_POPUP, _
                                        			%CW_USEDEFAULT, %CW_USEDEFAULT, _
    					 10, 10, hDlg, BYVAL %NULL, ghInst, _
    			                                  BYVAL %NULL)
    
                  'add the OK button to the tooltip. TTF_SUBCLASS causes the
                  'tooltip to automatically subclass the window and look for the
                  'messages it is interested in.
                  ti.cbSize = SIZEOF(ti)
                  ti.uFlags = %TTF_IDISHWND OR %TTF_SUBCLASS
                  ti.hwnd = hDlg
                  ti.hinst = 0
                  ti.uId = GetDlgItem (hDlg, %IDC_OK) 'OK button
                  ti.lpszText = %LPSTR_TEXTCALLBACK
                  SendMessage hwndToolTip, %TTM_ADDTOOL, 0, VARPTR(ti)
          
                  'add the Cancel button to the tooltip. TTF_SUBCLASS causes the
                  'tooltip to automatically subclass the window and look for the
                  'messages it is interested in.
                  ti.cbSize = SIZEOF(ti)
                  ti.uFlags = %TTF_IDISHWND OR %TTF_SUBCLASS
                  ti.hwnd = hDlg
                  ti.uId = GetDlgItem (hDlg, %IDC_CANCEL) 'CANCEL  button
                  ti.lpszText = %LPSTR_TEXTCALLBACK
                  SendMessage hwndToolTip, %TTM_ADDTOOL, 0, VARPTR(ti)
                  Action = %True
          
            CASE %WM_NOTIFY
                lpToolTip = lParam
                IF @lpToolTip.hdr.code = %TTN_NEEDTEXT THEN
                    IF @lpToolTip.hdr.IdFrom = GetDlgItem (hDlg, %IDC_OK) THEN
                        zText = "Ok Button"
                        @lpToolTip.lpszText = VARPTR(zText)
                    ELSEIF @lpToolTip.hdr.IdFrom = GetDlgItem (hDlg, %IDC_CANCEL) THEN
                        zText = "Cancel Button"
                        @lpToolTip.lpszText = VARPTR(zText)
                    END IF
                END IF
            Action = %False
                
            CASE %WM_MOUSEMOVE
               DIM Message AS tagMSG
               Message.Hwnd = hDlg
               Message.message =  wMsg
               Message.wParam = wParam
               Message.lParam = lParam
               Message.time = GetMessageTime
               SendMessage hwndToolTip, %TTM_RELAYEVENT, 0, VARPTR(Message)
                                 
             CASE %WM_ACTIVATE
                  IF LOWRD(wParam) = 0 THEN  ' Dialog becoming inactive.
                     ghCurrentDlg = 0
                  ELSE                       ' Dialog becoming active.
                     ghCurrentDlg = hDlg
                  END IF
    
             CASE %WM_DESTROY
                  ' Send a message to terminate message loop.
                  PostQuitMessage 0
                  Action = %TRUE
    
             CASE %WM_COMMAND
                  SELECT CASE LOWRD(wParam)
                         CASE %IDC_OK
                              IF HIWRD(wParam) = %BN_CLICKED THEN
                                'this doesn't do anything only for show
                              END IF
    
                         CASE %IDC_CANCEL
                              IF HIWRD(wParam) = %BN_CLICKED THEN
                                 SendMessage hDlg, %WM_DESTROY, wParam, lParam
                              END IF
                  END SELECT
    
             CASE %WM_SYSCOMMAND
                  SELECT CASE wParam
                         CASE %SC_CLOSE
                              ' Destroy dialog window.
                              DestroyWindow hDlg
                              Action = %TRUE
                  END SELECT
      END SELECT
    
      ' Assign function return value.
      FUNCTION = Action
    
    END FUNCTION
     
    '====RC-FILE==========================
    //Microsoft Developer Studio generated resource script.
    //
    #include "resource.h"
    
    #define APSTUDIO_READONLY_SYMBOLS
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 2 resource.
    //
    #include "afxres.h"
    
    /////////////////////////////////////////////////////////////////////////////
    #undef APSTUDIO_READONLY_SYMBOLS
    
    /////////////////////////////////////////////////////////////////////////////
    // English (U.S.) resources
    
    #if !defined(AFX_RESOURCE_DLL) &#0124; &#0124; defined(AFX_TARG_ENU)
    #ifdef _WIN32
    LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
    #pragma code_page(1252)
    #endif //_WIN32
    
    /////////////////////////////////////////////////////////////////////////////
    //
    // Dialog
    //
    
    IDD_FORM DIALOGEX 0, 0, 161, 113
    STYLE DS_MODALFRAME | DS_3DLOOK | DS_NOFAILCREATE | WS_MINIMIZEBOX | 
        WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | 
        WS_SYSMENU
    EXSTYLE WS_EX_CONTROLPARENT
    CAPTION "Tooltips Demo"
    CLASS "TIPS"
    FONT 8, "MS Sans Serif"
    BEGIN
        DEFPUSHBUTTON   "OK",IDC_OK,24,90,51,16
        PUSHBUTTON      "Cancel",IDC_CANCEL,81,90,51,16
    END
    
    
    /////////////////////////////////////////////////////////////////////////////
    //
    // DESIGNINFO
    //
    
    #ifdef APSTUDIO_INVOKED
    GUIDELINES DESIGNINFO DISCARDABLE 
    BEGIN
        IDD_FORM, DIALOG
        BEGIN
            LEFTMARGIN, 7
            RIGHTMARGIN, 154
            TOPMARGIN, 7
            BOTTOMMARGIN, 106
        END
    END
    #endif    // APSTUDIO_INVOKED
    
    #endif    // English (U.S.) resources
    /////////////////////////////////////////////////////////////////////////////
    
    
    /////////////////////////////////////////////////////////////////////////////
    // Swedish resources
    
    #if !defined(AFX_RESOURCE_DLL) &#0124; &#0124; defined(AFX_TARG_SVE)
    #ifdef _WIN32
    LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT
    #pragma code_page(1252)
    #endif //_WIN32
    
    #ifdef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // TEXTINCLUDE
    //
    
    1 TEXTINCLUDE DISCARDABLE 
    BEGIN
        "resource.h\0"
    END
    
    2 TEXTINCLUDE DISCARDABLE 
    BEGIN
        "#include ""afxres.h""\r\n"
        "\0"
    END
    
    3 TEXTINCLUDE DISCARDABLE 
    BEGIN
        "\r\n"
        "\0"
    END
    
    #endif    // APSTUDIO_INVOKED
    
    #endif    // Swedish resources
    /////////////////////////////////////////////////////////////////////////////
    
    #ifndef APSTUDIO_INVOKED
    /////////////////////////////////////////////////////////////////////////////
    //
    // Generated from the TEXTINCLUDE 3 resource.
    //
    
    
    /////////////////////////////////////////////////////////////////////////////
    #endif    // not APSTUDIO_INVOKED
    
    '====RESOURCE.H FROM VISUAL STUDIO============
    //{{NO_DEPENDENCIES}}
    // Microsoft Developer Studio generated include file.
    // Used by TIPS.RC
    //
    #define IDD_FORM                        101
    #define IDC_OK                          1000
    #define IDC_CANCEL                      1001
    
    // Next default values for new objects
    // 
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NO_MFC                     1
    #define _APS_3D_CONTROLS                     1
    #define _APS_NEXT_RESOURCE_VALUE        101
    #define _APS_NEXT_COMMAND_VALUE         40001
    #define _APS_NEXT_CONTROL_VALUE         1001
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif


    -------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Leave a comment:


  • Guest's Avatar
    Guest started a topic Need Visual Studio include for tooltips demo

    Need Visual Studio include for tooltips demo

    in the source code forum (no discussion allowed ...) a tooltip demo ("pd/dll 5 tool tips for controls other than toolbars" 2/99) is offered without an include file: afxres.h, said to be available with ms visual studio.

    can anyone post or email this for me? i'm trying to get a leg up on tooltips and every little bit helps!

    many tia.

    william fletcher
    [email protected]

    here's the forum article url:
Working...
X