Announcement

Collapse
No announcement yet.

Popup codetips

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

  • Popup codetips

    Does someone have a piece of code showing how to implement popup windows like the one in the picture able to show plain and bold text?

    Thanks a lot
    Eros


  • #2
    Both an webcontrol as rtf control can be used for this.
    Both have a mechanism to render to a DC.
    hellobasic

    Comment


    • #3
      The Intellisense example I gave shows how to pop up a control at the cursor - a label in that example, but the example works as well for a RichEdit control (which will let you do the bolding you want to do).

      User to user discussions about the PB/Win (formerly PB/DLL) product line. Discussion topics include PowerBASIC Forms, PowerGEN and PowerTree for Windows.


      If you have trouble with it, let me know and I'll change the example. I need to modify it anyways to improve the Intellisense features to cover displaying which of several arguments in a function is being typed - similar to the example you posted in the image.
      Last edited by Gary Beene; 5 Nov 2009, 04:52 PM.

      Comment


      • #4
        Thanks but I've already developed my own popup window at the cursor position and I've used a LISTBOX.
        The problem is that a LISTBOX gives little possibility on text formatting (well I'm going into a own draw listbox and see where I can go) so I wanted to check if someone have something similar to what I want to achieve.

        Thanks anyway.

        Comment


        • #5
          You could just pop up a dialog and draw on it instead of using a control. It could be draggable if required.
          This example is derived from Chris Boss's post here.

          **** added **** Oh, I see- you just want it to follow the caret position.

          Code:
          #compile exe
          #debug display
          #include "win32api.inc"
          '------------------------------------------------------------------------------
          callback function ShowhelpProc()
              static hparent as dword
              static htext as string
              static pSQL as string ptr
              static s as string
              local l as long
              local r, rEdit, rUS as RECT
              static szText as asciiz * 2048
              local hfont, hfont2, px, py, x, y as long
              local hDC as dword
              local ps as paintstruct
              local pstr as string ptr, RV&, hBrush as long
              select case as long cbmsg
                  case %wm_initdialog
                       ' Initialization handler
                       pstr = getprop(cbhndl, "TEXT")
                       sztext = @pstr         ' store in static variable
                       getwindowrect cbhndl, r
                       x=r.nLeft
                       y=r.nTop
                       getClientrect cbhndl, r
                       hDC=GetDC(cbhndl)
                       SaveDC hDC
                       hfont = SendMessage(cbhndl, %WM_GETFONT, 0, 0)
                       hfont2 = SelectObject(hDC, hfont)
                       DrawText hDC, szText, len(szText), r, %DT_CALCRECT or %DT_LEFT or %DT_WORDBREAK
                       SelectObject hDC, hfont2
                       RestoreDC hDC, -1
                       ReleaseDC cbhndl, hDC
                       SetWindowPos cbhndl, 0, x, y, R.nRight, R.nBottom, %SWP_NOACTIVATE or %SWP_NOCOPYBITS or %SWP_NOMOVE or %SWP_NOOWNERZORDER or %SWP_NOREDRAW or %SWP_NOZORDER
                  case %wm_lbuttondown
                      SendMessage cbhndl, %wm_nclbuttondown, %HTCAPTION, byval %NULL  ' force drag
                  case %wm_mousemove ' the dialog has been dragged
          
                  case %WM_ERASEBKGND
                       hDC = cbwparam
                       SaveDC hDC
                       hBrush = SendMessage(cbhndl, %WM_CTLCOLORDLG, hDC, cbhndl)
                       SelectObject hDC, hBrush
                       getclientrect cbhndl, r
                       PatBlt hDC, 0,0, R.nRight, R.nBottom, %PATCOPY
                       hfont = SendMessage(cbhndl, %WM_GETFONT, 0, 0)
                       hfont2 = SelectObject(hDC, hfont)
                       DrawText hDC, szText, len(szText), r, %DT_LEFT or %DT_WORDBREAK
                       SelectObject hDC, hfont2
                       RestoreDC hDC, -1
                       function=1
                       exit function
              end select
          end function
          '------------------------------------------------------------------------------
          ' display expanded version of archived query
          function Showhelp(byval hParent as dword, s as string) as long
              local lRslt as long
              static sSQL as string
              local hDlg  as dword
              dialog new hParent, "", , , 190, 50, %ws_popup or %ws_clipsiblings or %ws_visible  to hDlg
              dialog  set color   hDlg, 0, rgb(155, 255,155)
              setprop hdlg, "TEXT", byval varptr(s)
              dialog show modeless hDlg, call ShowhelpProc to lRslt
              function = lRslt
          end function
          '------------------------------
          callback function maincb
              select case cb.msg
                  case %wm_initdialog
                      showhelp ( cb.hndl, "this is an example!" + $cr + "here in the green box!")
              end select
          end function
          '------------------------------
          function pbmain
              local hDlg as dword
          
              dialog new 0,"",0,0,0,0,%ws_sysmenu, to hDlg
              dialog show modal hDlg call mainCB
              sleep 5000'? "wait"
          end function
          Last edited by Chris Holbrook; 6 Nov 2009, 04:01 AM.

          Comment

          Working...
          X