| 
 
| 
|  Author | Topic: LBB and DLL's  (Read 481 times) |  |  
| 
| 
| Alincon Full Member
 
 
 member is offline
 
  
 
 
 
 
  
 
 Posts: 147
 
 | 
|  | LBB and DLL's « Thread started on: Dec 16th, 2016, 5:55pm »
 |  |  I added a copy of LBtip.dll, that allows adding tool tips to programs, to the folder where I have LBB.exe
 
 Code:
 
    open "LBtip.dll" for Dll as #tip
    ...
    Button #main.b00, "", FlowButton,  UL, 938, 150, 40, 30  
    ... 
   
   hbutton1 = hwnd(#main.b00)
   tip$ = "Blank\Erase"
   calldll #tip, "SetTip", hbutton1 as ulong, tip$ as ptr, ret as void
 The open dll seems to work, but the calls to the dll give a 'not found' error message.
 Does this dll work with LBB?
 Are adaptations required?
 
 r.m.
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| Richard Russell Administrator
 
 
 member is offline
 
  
 
 
 
 
    
 
 Posts: 1348
 
 | 
|  | Re: LBB and DLL's « Reply #1 on: Dec 16th, 2016, 6:57pm »
 |  |  on Dec 16th, 2016, 5:55pm, Alincon  wrote:
 | | Does this dll work with LBB? | 
 | 
 I've no idea.  It's not mentioned at the DLLs compatible with LBB page, which suggests that nobody has tried it until now.
 
 Why do you need a special DLL anyway?  You can show ToolTips perfectly well by calling the appropriate Windows APIs directly (FreeForm does it, for example).  I'm not enthusiastic about 'third party' DLLs that may be of dubious quality, especially if they are unnecessary.
 
 I strongly recommend creating your tooltips using the official Windows API functions.
 
 Richard.
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| Alincon Full Member
 
 
 member is offline
 
  
 
 
 
 
  
 
 Posts: 147
 
 | 
|  | Re: LBB and DLL's « Reply #2 on: Dec 17th, 2016, 01:26am »
 |  |  The dll must be in the same folder as the program, not the LBB folder.
 This is all the code needed to use the dll:
 Code:
 
   open "LBtip.dll" for Dll as #tip
   ...
    for n = 0 to 5 
        v$ = "#main.b" + right$("0"+ str$(n),2)      
        hbutton = hwnd(#v$)
        tip$ = word$("Erase Process Alt-Process Decision Input-Output",n+1)
        calldll #tip, "SetTip", hbutton as ulong, tip$ as ptr, ret as void
    next
   ...
   close #tip
 
 Can you do it easier with your API calls?
 
 r.m.
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| Richard Russell Administrator
 
 
 member is offline
 
  
 
 
 
 
    
 
 Posts: 1348
 
 | 
|  | Re: LBB and DLL's « Reply #3 on: Dec 17th, 2016, 08:21am »
 |  |  on Dec 17th, 2016, 01:26am, Alincon  wrote:
 | | Can you do it easier with your API calls? | 
 | 
 Not easier, but that's not the point.  Even if it's a little more complicated, the Windows API code only has to be written once, and put in a library.  Then it's just as convenient to use as a third-party DLL, but without the dependence on code which isn't under your control and - as in this case seemingly - possibly not compatible with LBB.
 
 I appreciate that LB4 doesn't support code libraries, which makes the re-use of BASIC code modules a little less convenient, but LBB does and Liberty BASIC Workshop does too so that's not an issue any more.
 
 I suggest you open FreeForm404.bas or FreeForm450.bas (supplied with LB 4.04 and LB 4.5.0 respectively) and copy out the CreateToolTip and AddToolTip functions, which you can then either add to your own program or put in a library for convenient future re-use.
 
 Richard.
 
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| Alincon Full Member
 
 
 member is offline
 
  
 
 
 
 
  
 
 Posts: 147
 
 | 
|  | Re: LBB and DLL's « Reply #4 on: Dec 19th, 2016, 7:15pm »
 |  |  Is this what you are talking about?  It does work in LBB.
 
 Code:
 
SUB MakeTooltips hWin
        TTS.ALWAYSTIP = 1 : TTS.NOPREFIX = 2 : style = _WS_POPUP or TTS.NOPREFIX or TTS.ALWAYSTIP
        calldll #comctl32,"InitCommonControls", re as void
        calldll #user32, "GetWindowLongA", hWin as long, _GWL_HINSTANCE as long, hInstance as long
        calldll #user32, "CreateWindowExA", _WS_EX_TOPMOST as long,"tooltips_class32" as ptr, "" as ptr,_
            style as long, _CW_USEDEFAULT as long, _CW_USEDEFAULT as long, _CW_USEDEFAULT as long, _CW_USEDEFAULT as long,_
            hWin as long, 0 as long, hInstance as long, "" as ptr, hwndTT as long
        flags=_SWP_NOMOVE or _SWP_NOSIZE or _SWP_NOACTIVATE
        calldll #user32, "SetWindowPos", hwndTT as long,_HWND_TOPMOST as long, 0 as long, 0 as long, 0 as long, 0 as long, flags as long, r as long
 
        'create a struct for the tooltips:
        struct toolinfo, cbSize as long, uFlags as long, hWindow as long, uId as long, x as long, y as long, w as long, h as long, hInst as long, lpstrText$ as ptr
        toolinfo.cbSize.struct = len(toolinfo.struct)
        toolinfo.uFlags.struct = 1 Or 16
        toolinfo.hWindow.struct = hWin
 
    'Button Tooltip:
    tipData$ = "Erase Process Alt-Process Decision Input\Output Manual-Input Connector Delay\Wait Doc\Printer"
    tipData$ = tipData$ + " Start End Edit\Text Arrow Yes No Copy Paste File Disk Print"   
       for n = 0 to 19
        v$ = "#main.b" + right$("0"+ str$(n),2)         
        toolinfo.uId.struct = hwnd(#v$)
        toolinfo.lpstrText$.struct = word$(tipData$,n+1)
        calldll #user32, "SendMessageA", hwndTT as long, 1028 as long, 0 as long, toolinfo as struct, re as long
    next
   end sub
 
 r.m.
 |  
| 
|  |  Logged |  
 |  |  |  
 |