Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Mr Sticky - PB Win 7

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

  • Mr Sticky - PB Win 7

    Code:
    ' This Zipfile contains the PBR for Mr.Sticky
    ' BinBas v1.00 (Thanks Edwin!)
    ' File created at: 12-07-2004 - 14:53:41
    ' File: MrSticky.zip
    ' Len : 1809
     
    #COMPILE EXE
     
    SUB BinBas1( T AS STRING )
     
    DIM a&: FOR a& = 1 TO DATACOUNT: T = T & READ$( a& ): NEXT a&
     
    DATA 504B03041400000008006C748731B392A63B97060000D41400000C0000004D72537469636B
    DATA 792E706272ED584F6F1B45149FB4A594222A0E880342E889034D21B88E93B6D082D4C46D95
    DATA 8A8644710081F6C0EC7A6C0FD9DD5966C6714C1529E21370E40370E2C447E811A1A8678E1C
    DATA 39543D730BBFD95DDBBBEE3A34887F07C69E9D7D7FE6BD376FDE7B33367BA6B9F50C63ECC5
    DATA 39C608BD8E7E137D13BDDCCEB0D378D6193B70FC6B18CF63FC1CE3058C07E9B7D8E69813F1
    DATA 6D05BE8DE70F53F853E89FCFB1831F81D7187F99A23B595F03FF5B85BCE7CE64F657E16906
    DATA BE3E037F7306DEF9E31BF45F4F4D287BC0BF56E0FF168E79FFF404FEF91C633F3D3F81BF7B
    DATA 89B19726203BC7B6D836BBC356D82ADB601FE1FDD91CB3C66EB37B6C939D652DC07759937D
    DATA C03E65F39843E83799B3EA4C2AE3A0604FB91D649E3A38C806F7C1CB83070F303ACC51FA65
    DATA 4747D9E03E0E85C7E3BFBB3D3A9C86B3F6700A1E211EE5AF23C4A311E1F03087C713B3E161
    DATA 191EB769F8701A7E58221E16E0C332F8A80CA6E409F4B8442B183C2697C0C753E43F863344
    DATA 61DD799B3094E111E671A94DBB236FB322EA9F6A0FD88FDFB8F12CFB8CBDCABE671FA7D875
    DATA A611FD2D66996401DB6143401B2C4961C56266C0731EBC027C6DC681E1E9BCD39B99ACB36C
    DATA 815D00F5E8E880BD811C73736CAE712EE7792DE5E9E43CABD0D28596267843743DB670C4FF
    DATA 1E72F2026BE4FC1BC8D222FD9D9C7E2AA73753AB02D810A65CCFB25339DF2BEC0BF632EB81
    DATA EFEBB18E11ED2C681760C78476DFD3B6B3E8F1D8C8F41124DDC5C69586D7169D4EDD3D2DF7
    DATA AF35EAF7BD8E8AADF543BCD4BD8E19486368BD452DCCA196D0B273631FA445AFA355C463AF
    DATA 13F4B836C236A8358C7C15A6D4C6989AE82F1BB42D2361E84331A02D874D599672964AE232
    DATA 14075A263617D054910C3213D65B37F6F75F387FDF0B54A834ECF4B468D7BDAE1622AE7B7E
    DATA D817F51B0ED5B872E54964890F1C3720C92D3DE47177B17E65C94BB86E7B5F065E127219A7
    DATA EB308D77BCA0B348EBBA462D2B839D21EDD668B196B3643397964ABC8D8AF95004E154A42C
    DATA 35CA14A7BB3871196438AF270D255A75358F08AF6DD19601B7A24D565134A436EF777B5668
    DATA 3849F390063D45A6DFED0AE3582656D78ED3FC84D20D2DBB32E66138A48196D68A98644C9B
    DATA 6A20F4EA4AEB6E933A4AD327326EAB81A16BB53A7917F9BB44B74420221FB65C5BA046BDBE
    DATA 5CCB35E4C31D4C20D5B7C47DF72C88E3967AD626D72F5F1E0C06B5C4117C8E18AD052A9A36
    DATA 737964E622ADF15D419D7EBC90B3DC453C35B9D4889327D9EB342F795C0B52FACDAE88CCD5
    DATA 5A57EDD67C68E1974A4EA8A7ECB950C4C8FFF9F3EFE5CFD36549417CA005D2C3D0EB1B708E
    DATA 4A5EA7411EA7839E0C7A14C06701B60812C88A3D9BA3233E245F50E0A213519A7093A71802
    DATA DD799A94ED21B07992842EFDA48A4D6D66FE783E413926D036373B3ED7D72B4CCE6713ADD0
    DATA 3D440FADABBE11D484F81DF2B58CBB86FA09718AB1B5265B5AACACA8D1FC3ADF93513FA2C5
    DATA FAA582902D893A30534A24E2FEF5921343B97415112ADFC670DF7BD34B627CC3DDD00F2D5E
    DATA 10A1490CC789D8A6F424B67BD6F72EFAD7F6F72B16DC0F29E581435D7083CD433EEC6F24A9
    DATA A7AA968F64084560E90EF662217D224C1192A9FB5779B0D3D5AA8FD71439DBD33314DF8270
    DATA 2B68250CE94338ADDA022D22B58B48419D4B5D6BB29D6E0BB3635552A3DB9A1B478E876450
    DATA 69DA19D3896D5971D5AED2805BD2003B347431E5B94877E38E3AB1FC35112695E23F557DE2
    DATA 5A1002571C13AC33C4DEDE9363ABA7D234975FA1B3D5EB5B9C516A101753D26DA9F3A04973
    DATA C2651FC2CA90EA904A70B48C1214D9D69161C1D4EA5C7F8AB4CBF5BAADAFF4CC71226E69DE
    DATA C5E1D7BD5EB5BE3515B6B3E539354DAC44AB9076C4D0959110AE061D73272C85D45EED5BAB
    DATA E263ABC6BACBD293E975BEE5FFC9E46F094B2DF995206E7033E8F07EF807F1B4ED82A3AF35
    DATA D49271137D81F33F8F1A57060BDB8A2C4D25D62A9C75E25077966E2A235DB1FA53D626A3C9
    DATA 4F63F189CD5B97B18C9C3F2ED316EE754A5707F588CD4CA7C0823BC4F29986A4758926ADBB
    DATA 558A5D8990C99C9D1E7BA375CC0F513BDC51091E5C609ADB5BF7E82D6AB9993CE849817B97
    DATA 5362782408172014F24B275E56B16E55BBB854C0FE8A8D6E860A09522C0BD58AB7F293C115
    DATA FCEC50C07D0A379F1A6DC26769F1423D73893E2E66A3E2759C9995F50C699F33CC2C57AB22
    DATA E02EB39DCB6FB7B18159C524FC26F00D4569D6F3C0CA5D69870BE4B6AEE76EC63029DBBEE9
    DATA 9A01823FC41507ABB0D8769845F85561B3F544B845B6C7979BF93F77691FDFA79767EED653
    DATA DDE367CD39C1653E632F5FE6D3FF19895E4CFF1173FFCECDB1DF01504B0102140014000000
    DATA 08006C748731B392A63B97060000D41400000C0000000000000001002000B681000000004D
    DATA 72537469636B792E706272504B050600000000010001003A000000C10600000000
    
    END SUB
    
    FUNCTION PBMAIN
     
        DIM a AS LONG, FO AS LONG, T AS STRING
     
        FO = FREEFILE
        ERRCLEAR
        OPEN "MrSticky.zip" FOR OUTPUT AS #FO
        IF ERR THEN
            MSGBOX "Error: " & STR$( ERR ), 16, "MrSticky.zip"
            EXIT FUNCTION
        END IF
        BinBas1 T
        FOR a = 1 TO LEN( T ) STEP 2
            PRINT #FO, CHR$( VAL( "&H" & MID$( T, a , 2 ) ) );
        NEXT a
     
        CLOSE #FO
     
    END FUNCTION
    '==================
    ' Cut at this point
    '==================
    Code:
    ' File: MrSticky.INC
    ' Created by inClean v1.25, 12-07-2004, 15:01:57
    '-----------------------------------------------------------------
    ' Equates:  80
    '-----------------------------------------------------------------
    %WINAPI                                         = 1
    %TRUE                                           = 1
    %FALSE                                          = 0
    %NULL                                           = 0
    %WM_USER                                        = &H400
    %LF_FACESIZE                                    = 32
    %RT_RCDATA                                      = 10
    %MAX_PATH                                       = 260  ' max. length of full pathname
    %OPAQUE                                         = 2
    %WHITE_BRUSH                                    = 0
    %NIM_ADD                                        = &H00000000
    %NIM_DELETE                                     = &H00000002
    %NIF_MESSAGE                                    = &H00000001
    %NIF_ICON                                       = &H00000002
    %NIF_TIP                                        = &H00000004
    %SW_SHOW                                        = 5
    %VK_CONTROL                                     = &H11
    %GWL_WNDPROC                                    = -4
    %WM_NULL                                        = &H0
    %WM_CREATE                                      = &H1
    %WM_DESTROY                                     = &H2
    %WM_SETTEXT                                     = &HC
    %WM_GETTEXT                                     = &HD
    %WM_GETTEXTLENGTH                               = &HE
    %WM_PAINT                                       = &HF
    %WM_CLOSE                                       = &H10
    %WM_SETFONT                                     = &H30
    %WM_NCLBUTTONDOWN                               = &H0A1
    %WM_KEYDOWN                                     = &H100
    %WM_INITDIALOG                                  = &H110
    %WM_COMMAND                                     = &H111
    %WM_CTLCOLOREDIT                                = &H133
    %WM_LBUTTONDOWN                                 = &H201
    %WM_LBUTTONUP                                   = &H202
    %WM_RBUTTONDOWN                                 = &H204
    %WM_EXITSIZEMOVE                                = &H232
    %WM_PASTE                                       = &H302
    %HTCAPTION                                      = 2
    %MK_CONTROL                                     = &H0008
    %WS_POPUP                                       = &H80000000
    %WS_CHILD                                       = &H40000000
    %WS_VISIBLE                                     = &H10000000
    %WS_CAPTION                                     = &H00C00000  ' WS_BORDER OR WS_DLGFRAME
    %WS_VSCROLL                                     = &H00200000
    %WS_SYSMENU                                     = &H00080000
    %WS_THICKFRAME                                  = &H00040000
    %WS_TABSTOP                                     = &H00010000
    %WS_SIZEBOX                                     = %WS_THICKFRAME
    %WS_EX_TOPMOST                                  = &H00000008
    %WS_EX_TOOLWINDOW                               = &H00000080
    %WS_EX_CLIENTEDGE                               = &H00000200
    %CF_TEXT                                        =  1
    %SWP_NOSIZE                                     = &H0001
    %SWP_NOMOVE                                     = &H0002
    %HWND_TOPMOST                                   = &HFFFFFFFF???
    %TPM_CENTERALIGN                                = &H0004&
    %COLOR_APPWORKSPACE                             = 12
    %MF_ENABLED                                     = &H0&
    %MF_STRING                                      = &H0&
    %IDC_ARROW                                      = 32512&
    %IDCANCEL                                       = 2
    %ES_LEFT                                        = &H0&
    %ES_MULTILINE                                   = &H4&
    %ES_AUTOVSCROLL                                 = &H40&
    %ES_NOHIDESEL                                   = &H100&
    %ES_READONLY                                    = &H800&
    %EM_GETSEL                                      = &HB0
    %BN_CLICKED                                     = 0
    %SPI_GETWORKAREA                                = 48
    %CC_RGBINIT                                     = &H00000001???
    %CC_FULLOPEN                                    = &H00000002???
    %CF_SCREENFONTS                                 = &H00000001&
    %CF_INITTOLOGFONTSTRUCT                         = &H00000040&
    %CF_EFFECTS                                     = &H00000100&
    %CF_ANSIONLY                                    = &H00000400&
    %CF_SCRIPTSONLY                                 = %CF_ANSIONLY
    %CF_TTONLY                                      = &H00040000&
    %EM_STREAMIN                                    = %WM_USER + 73
    %ES_SAVESEL                                     = &H00008000
    %SF_RTF                                         = &H0002
    
    '-----------------------------------------------------------------
    ' TYPE and UNION structures:  10
    '-----------------------------------------------------------------
    TYPE RECT
      nLeft AS LONG
      nTop AS LONG
      nRight AS LONG
      nBottom AS LONG
    END TYPE
    
    TYPE POINTAPI
      x AS LONG
      y AS LONG
    END TYPE
    
    TYPE tagMSG
      hwnd AS DWORD
      message AS DWORD
      wParam AS LONG
      lParam AS LONG
      time AS DWORD
      pt AS POINTAPI
    END TYPE
    
    TYPE WNDCLASSEX
        cbSize AS DWORD
        style AS DWORD
        lpfnWndProc AS LONG
        cbClsExtra AS LONG
        cbWndExtra AS LONG
        hInstance AS DWORD
        hIcon AS DWORD
        hCursor AS DWORD
        hbrBackground AS DWORD
        lpszMenuName AS ASCIIZ PTR
        lpszClassName AS ASCIIZ PTR
        hIconSm AS DWORD
    END TYPE
    
    TYPE LOGFONT
      lfHeight AS LONG
      lfWidth AS LONG
      lfEscapement AS LONG
      lfOrientation AS LONG
      lfWeight AS LONG
      lfItalic AS BYTE
      lfUnderline AS BYTE
      lfStrikeOut AS BYTE
      lfCharSet AS BYTE
      lfOutPrecision AS BYTE
      lfClipPrecision AS BYTE
      lfQuality AS BYTE
      lfPitchAndFamily AS BYTE
      lfFaceName AS ASCIIZ * %LF_FACESIZE
    END TYPE
    
    TYPE PAINTSTRUCT
      hDC AS DWORD
      fErase AS LONG
      rcPaint AS RECT
      fRestore AS LONG
      fIncUpdate AS LONG
      rgbReserved(0 TO 31) AS BYTE
    END TYPE
    
    TYPE NOTIFYICONDATA
        cbSize AS DWORD
        hwnd AS DWORD
        uID AS DWORD
        uFlags AS DWORD
        uCallbackMessage AS DWORD
        hIcon AS DWORD
        szTip AS ASCIIZ * 64
    END TYPE
    
    TYPE CHOOSECOLORAPI
        lStructSize    AS DWORD
        hwndOwner      AS DWORD
        hInstance      AS DWORD
        rgbResult      AS DWORD
        lpCustColors   AS DWORD PTR
        Flags          AS DWORD
        lCustData      AS LONG
        lpfnHook       AS DWORD
        lpTemplateName AS ASCIIZ PTR
    END TYPE
    
    TYPE CHOOSEFONTAPI
        lStructSize    AS DWORD
        hWndOwner      AS DWORD
        hDC            AS DWORD
        lpLogFont      AS LOGFONT PTR
        iPointSize     AS LONG
        Flags          AS DWORD
        rgbColors      AS DWORD
        lCustData      AS LONG
        lpfnHook       AS DWORD
        lpTemplateName AS ASCIIZ PTR
        hInstance      AS DWORD
        lpszStyle      AS ASCIIZ PTR
        nFontType      AS WORD
        Alignment      AS WORD
        nSizeMin       AS LONG
        nSizeMax       AS LONG
    END TYPE
    
    TYPE EDITSTREAM DWORD
      dwCookie AS DWORD    ' user value passed to callback as first parameter
      dwError AS DWORD     ' last error
      pfnCallback AS DWORD
    END TYPE
    
    '-----------------------------------------------------------------
    ' Declared Functions:  62
    '-----------------------------------------------------------------
    DECLARE FUNCTION AppendMenu LIB "USER32.DLL" ALIAS "AppendMenuA" (BYVAL hMenu AS DWORD, BYVAL uFlags AS DWORD, BYVAL uIDNewItem AS DWORD, lpNewItem AS ASCIIZ) AS LONG
    DECLARE FUNCTION BeginPaint LIB "USER32.DLL" ALIAS "BeginPaint" (BYVAL hWnd AS DWORD, lpPaint AS PAINTSTRUCT) AS LONG
    DECLARE FUNCTION CallWindowProc LIB "USER32.DLL" ALIAS "CallWindowProcA" (BYVAL lpPrevWndFunc AS DWORD, BYVAL hWnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    DECLARE FUNCTION ChooseColor LIB "COMDLG32.DLL" ALIAS "ChooseColorA" (lpcc AS CHOOSECOLORAPI) AS LONG
    DECLARE FUNCTION ChooseFont LIB "COMDLG32.DLL" ALIAS "ChooseFontA" _
        (lpcf AS CHOOSEFONTAPI) AS LONG
    DECLARE FUNCTION CloseClipboard LIB "USER32.DLL" ALIAS "CloseClipboard" () AS LONG
    DECLARE FUNCTION CreateFontIndirect LIB "GDI32.DLL" ALIAS "CreateFontIndirectA" (lpLogFont AS LOGFONT) AS DWORD
    DECLARE FUNCTION CreatePopupMenu LIB "USER32.DLL" ALIAS "CreatePopupMenu" () AS LONG
    DECLARE FUNCTION CreateSolidBrush LIB "GDI32.DLL" ALIAS "CreateSolidBrush" (BYVAL crColor AS DWORD) AS DWORD
    DECLARE FUNCTION CreateWindowEx LIB "USER32.DLL" ALIAS "CreateWindowExA" (BYVAL dwExStyle AS DWORD, lpClassName AS ASCIIZ, lpWindowName AS ASCIIZ, BYVAL dwStyle AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG, _
        BYVAL nWidth AS LONG, BYVAL nHeight AS LONG, BYVAL hWndParent AS DWORD, BYVAL hMenu AS DWORD, BYVAL hInstance AS DWORD, lpParam AS ANY) AS DWORD
    DECLARE FUNCTION DefWindowProc LIB "USER32.DLL" ALIAS "DefWindowProcA" (BYVAL hWnd AS DWORD, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    DECLARE FUNCTION DeleteObject LIB "GDI32.DLL" ALIAS "DeleteObject" (BYVAL hObject AS DWORD) AS LONG
    DECLARE FUNCTION DestroyIcon LIB "USER32.DLL" ALIAS "DestroyIcon" (BYVAL hIcon AS DWORD) AS LONG
    DECLARE FUNCTION DestroyMenu LIB "USER32.DLL" ALIAS "DestroyMenu" (BYVAL hMenu AS DWORD) AS LONG
    DECLARE FUNCTION DestroyWindow LIB "USER32.DLL" ALIAS "DestroyWindow" (BYVAL hWnd AS DWORD) AS LONG
    DECLARE FUNCTION DialogBoxParam LIB "USER32.DLL" ALIAS "DialogBoxParamA" (BYVAL hInstance AS DWORD, lpTemplateName AS ASCIIZ, BYVAL hwndParent AS DWORD, BYVAL lpDialogFunc AS LONG, BYVAL dwInitParam AS DWORD) AS LONG
    DECLARE FUNCTION DispatchMessage LIB "USER32.DLL" ALIAS "DispatchMessageA" (lpMsg AS tagMSG) AS LONG
    DECLARE FUNCTION EndDialog LIB "USER32.DLL" ALIAS "EndDialog" (BYVAL hDlg AS DWORD, BYVAL nResult AS LONG) AS LONG
    DECLARE FUNCTION EndPaint LIB "USER32.DLL" ALIAS "EndPaint" (BYVAL hWnd AS DWORD, lpPaint AS PAINTSTRUCT) AS LONG
    DECLARE FUNCTION FillRect LIB "USER32.DLL" ALIAS "FillRect" (BYVAL hDC AS DWORD, lpRect AS RECT, BYVAL hBrush AS DWORD) AS LONG
    DECLARE FUNCTION FindResource LIB "KERNEL32.DLL" ALIAS "FindResourceA" (BYVAL hInstance AS DWORD, lpName AS ASCIIZ, lpType AS ASCIIZ) AS LONG
    DECLARE FUNCTION FindWindow LIB "USER32.DLL" ALIAS "FindWindowA" (lpClassName AS ASCIIZ, lpWindowName AS ASCIIZ) AS LONG
    DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG
    DECLARE FUNCTION GetClipboardData LIB "USER32.DLL" ALIAS "GetClipboardData" (BYVAL uFormat AS DWORD) AS DWORD
    DECLARE FUNCTION GetCursorPos LIB "USER32.DLL" ALIAS "GetCursorPos" (lpPoint AS POINTAPI) AS LONG
    DECLARE FUNCTION GetDC LIB "USER32.DLL" ALIAS "GetDC" (BYVAL hWnd AS DWORD) AS DWORD
    DECLARE FUNCTION GetDlgItem LIB "USER32.DLL" ALIAS "GetDlgItem" (BYVAL hDlg AS DWORD, BYVAL nIDDlgItem AS LONG) AS DWORD
    DECLARE FUNCTION GetKeyState LIB "USER32.DLL" ALIAS "GetKeyState" (BYVAL nVirtKey AS LONG) AS INTEGER
    DECLARE FUNCTION GetMessage LIB "USER32.DLL" ALIAS "GetMessageA" (lpMsg AS tagMSG, BYVAL hWnd AS DWORD, BYVAL uMsgFilterMin AS DWORD, BYVAL uMsgFilterMax AS DWORD) AS LONG
    DECLARE FUNCTION GetModuleFileName LIB "KERNEL32.DLL" ALIAS "GetModuleFileNameA" (BYVAL hModule AS DWORD, lpFileName AS ASCIIZ, BYVAL nSize AS DWORD) AS DWORD
    DECLARE FUNCTION GetModuleHandle LIB "KERNEL32.DLL" ALIAS "GetModuleHandleA" (lpModuleName AS ASCIIZ) AS DWORD
    DECLARE FUNCTION GetStockObject LIB "GDI32.DLL" ALIAS "GetStockObject" (BYVAL nIndex AS LONG) AS DWORD
    DECLARE FUNCTION GetWindowRect LIB "USER32.DLL" ALIAS "GetWindowRect" (BYVAL hWnd AS DWORD, lpRect AS RECT) AS LONG
    DECLARE FUNCTION GlobalLock LIB "KERNEL32.DLL" ALIAS "GlobalLock" (BYVAL hMem AS DWORD) AS DWORD
    DECLARE FUNCTION GlobalUnlock LIB "KERNEL32.DLL" ALIAS "GlobalUnlock" (BYVAL hMem AS DWORD) AS LONG
    DECLARE FUNCTION InvalidateRect LIB "USER32.DLL" ALIAS "InvalidateRect" (BYVAL hWnd AS DWORD, lpRect AS RECT, BYVAL bErase AS LONG) AS LONG
    DECLARE FUNCTION LoadCursor LIB "USER32.DLL" ALIAS "LoadCursorA" (BYVAL hInstance AS DWORD, lpCursorName AS ASCIIZ) AS DWORD
    DECLARE FUNCTION LoadIcon LIB "USER32.DLL" ALIAS "LoadIconA" (BYVAL hInstance AS DWORD, lpIconName AS ASCIIZ) AS DWORD
    DECLARE FUNCTION LoadLibrary LIB "KERNEL32.DLL" ALIAS "LoadLibraryA" (lpLibFileName AS ASCIIZ) AS LONG
    DECLARE FUNCTION LoadResource LIB "KERNEL32.DLL" ALIAS "LoadResource" (BYVAL hInstance AS DWORD, BYVAL hResInfo AS DWORD) AS LONG
    DECLARE FUNCTION LockResource LIB "KERNEL32.DLL" ALIAS "LockResource" (BYVAL hResData AS DWORD) AS DWORD
    DECLARE FUNCTION MoveWindow LIB "USER32.DLL" ALIAS "MoveWindow" (BYVAL hWnd AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL nWidth AS LONG, BYVAL nHeight AS LONG, BYVAL bRepaint AS LONG) AS LONG
    DECLARE FUNCTION OpenClipboard LIB "USER32.DLL" ALIAS "OpenClipboard" (BYVAL hWnd AS DWORD) AS LONG
    DECLARE FUNCTION PostMessage LIB "USER32.DLL" ALIAS "PostMessageA" (BYVAL hWnd AS DWORD, BYVAL dwMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    DECLARE FUNCTION RegisterClassEx LIB "USER32.DLL" ALIAS "RegisterClassExA" (pcWndClassEx AS WNDCLASSEX) AS WORD
    DECLARE FUNCTION ReleaseDC LIB "USER32.DLL" ALIAS "ReleaseDC" (BYVAL hWnd AS DWORD, BYVAL hDC AS DWORD) AS LONG
    DECLARE FUNCTION SelectObject LIB "GDI32.DLL" ALIAS "SelectObject" (BYVAL hdc AS DWORD, BYVAL hObject AS DWORD) AS DWORD
    DECLARE FUNCTION SendMessage LIB "USER32.DLL" ALIAS "SendMessageA" (BYVAL hWnd AS DWORD, BYVAL dwMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
    DECLARE FUNCTION SetBkColor LIB "GDI32.DLL" ALIAS "SetBkColor" (BYVAL hdc AS DWORD, BYVAL crColor AS DWORD) AS DWORD
    DECLARE FUNCTION SetBkMode LIB "GDI32.DLL" ALIAS "SetBkMode" (BYVAL hdc AS DWORD, BYVAL nBkMode AS LONG) AS LONG
    DECLARE FUNCTION SetForegroundWindow LIB "USER32.DLL" ALIAS "SetForegroundWindow" (BYVAL hWnd AS DWORD) AS LONG
    DECLARE FUNCTION SetTextColor LIB "GDI32.DLL" ALIAS "SetTextColor" (BYVAL hdc AS DWORD, BYVAL crColor AS DWORD) AS DWORD
    DECLARE FUNCTION SetWindowLong LIB "USER32.DLL" ALIAS "SetWindowLongA" (BYVAL hWnd AS DWORD, BYVAL nIndex AS LONG, BYVAL lNewLong AS LONG) AS LONG
    DECLARE FUNCTION SetWindowPos LIB "USER32.DLL" ALIAS "SetWindowPos" (BYVAL hWnd AS DWORD, BYVAL hWndInsertAfter AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL cx AS LONG, BYVAL cy AS LONG, BYVAL wFlags AS DWORD) AS LONG
    DECLARE FUNCTION SetWindowText LIB "USER32.DLL" ALIAS "SetWindowTextA" (BYVAL hWnd AS DWORD, lpString AS ASCIIZ) AS LONG
    DECLARE FUNCTION Shell_NotifyIcon LIB "SHELL32.DLL" ALIAS "Shell_NotifyIconA" (BYVAL dwMessage AS DWORD, lpData AS NOTIFYICONDATA) AS LONG
    DECLARE FUNCTION ShowWindow LIB "USER32.DLL" ALIAS "ShowWindow" (BYVAL hWnd AS DWORD, BYVAL nCmdShow AS LONG) AS LONG
    DECLARE FUNCTION SizeofResource LIB "KERNEL32.DLL" ALIAS "SizeofResource" (BYVAL hInstance AS DWORD, BYVAL hResInfo AS DWORD) AS LONG
    DECLARE FUNCTION SystemParametersInfo LIB "USER32.DLL" ALIAS "SystemParametersInfoA" (BYVAL uAction AS DWORD, BYVAL uParam AS DWORD, lpvParam AS ANY, BYVAL fuWinIni AS DWORD) AS LONG
    DECLARE FUNCTION TrackPopupMenu LIB "USER32.DLL" ALIAS "TrackPopupMenu" (BYVAL hMenu AS DWORD, BYVAL uFlags AS DWORD, BYVAL x AS LONG, BYVAL y AS LONG, BYVAL nReserved AS LONG, BYVAL hWnd AS DWORD, lprc AS RECT) AS LONG
    DECLARE FUNCTION TranslateMessage LIB "USER32.DLL" ALIAS "TranslateMessage" (lpMsg AS tagMSG) AS LONG
    DECLARE FUNCTION UpdateWindow LIB "USER32.DLL" ALIAS "UpdateWindow" (BYVAL hWnd AS DWORD) AS LONG
    
    '-----------------------------------------------------------------
    ' Declared Subs:  2
    '-----------------------------------------------------------------
    DECLARE SUB MoveMemory LIB "KERNEL32.DLL" ALIAS "RtlMoveMemory" (pDestination AS ANY, pSource AS ANY, BYVAL cbLength AS LONG)
    DECLARE SUB PostQuitMessage LIB "USER32.DLL" ALIAS "PostQuitMessage" (BYVAL nExitCode AS LONG)
    
    '-----------------------------------------------------------------
    ' Functions:  2  (begins with declarations)
    '-----------------------------------------------------------------
    DECLARE FUNCTION CreateWindow (lpClassName AS ASCIIZ, lpWindowName AS ASCIIZ, BYVAL dwStyle AS DWORD, BYVAL xx AS LONG, BYVAL yy AS LONG, BYVAL nWidth AS LONG, _
                         BYVAL nHeight AS LONG, BYVAL hwndParent AS DWORD, BYVAL hMenu AS DWORD, BYVAL hInstance AS DWORD, BYVAL lpParam AS DWORD) AS LONG
    DECLARE FUNCTION DialogBox (BYVAL hInstance AS DWORD, lpTemplateName AS ASCIIZ, BYVAL hwndParent AS DWORD, BYVAL lpDialogFunc AS LONG) AS LONG
    '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FUNCTION CreateWindow (lpClassName AS ASCIIZ, lpWindowName AS ASCIIZ, BYVAL dwStyle AS DWORD, BYVAL xx AS LONG, BYVAL yy AS LONG, BYVAL nWidth AS LONG, _
                 BYVAL nHeight AS LONG, BYVAL hwndParent AS DWORD, BYVAL hMenu AS DWORD, BYVAL hInstance AS DWORD, BYVAL lpParam AS DWORD) AS LONG
            FUNCTION = CreateWindowEx(0, lpClassName, lpWindowName, dwStyle, xx, yy, nWidth, nHeight, hWndParent, hMenu, hInstance, BYVAL lpParam)
    END FUNCTION
    
    FUNCTION DialogBox (BYVAL hInstance AS DWORD, lpTemplateName AS ASCIIZ, BYVAL hwndParent AS DWORD, BYVAL lpDialogFunc AS LONG) AS LONG
            FUNCTION = DialogBoxParam(hInstance, lpTemplateName, hWndParent, lpDialogFunc, 0)
    END FUNCTION
    
    '-----------------------------------------------------------------
    ' Subs:  1  (begins with declarations)
    '-----------------------------------------------------------------
    DECLARE SUB CopyMemory (BYVAL pDestination AS DWORD, BYVAL pSource AS DWORD, BYVAL cbLength AS LONG)
    '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SUB CopyMemory (BYVAL pDestination AS DWORD, BYVAL pSource AS DWORD, BYVAL cbLength AS LONG)
            MoveMemory BYVAL pDestination, BYVAL pSource, cbLength
    END SUB
    [This message has been edited by Ian Cairns (edited December 07, 2004).]
    :) IRC :)

  • #2
    released to public domain april 10, 2007
    now the main code:
    Code:
    ' Changes: Dec 6, 2004. Removed accelerator table as unnecessary
    '          Dec 6, 2004. Alteration to allow Paste to add more text than will show in one screen.
    '          Dec 7, 2004. Added minimize/restore function to notes
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' MrSticky - Copyright Ian Cairns, November 6, 2004; December 6, 2004.
    ' When invoked, Mr. Sticky sits on the taskbar. Left clicks spawn new notes. Right click for options.
    ' Creates up to 10 "on top" 'Sticky notes' that can be used to hold bits of information.
    ' You can do the standard cut/copy/paste functions, sort of like a multiple clipboard.
    ' Windows are resizeable and moveable (CTRL+LButton Drag).
    ' You can select default fonts, sizes, placement, colors.
    ' Have fun with it. Regards, Ian Cairns.
    ' Post any comments to:  [URL="http://www.powerbasic.com/support/pbforums/../forums/Forum4/HTML/011226.html"]http://www.powerbasic.com/support/forums/Forum4/HTML/011226.html[/URL] 
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    #COMPILE EXE
    '#INCLUDE "WIN32API.INC"
    #INCLUDE  "MrSticky.inc"
    #RESOURCE "MrSticky.pbr"%pb_IDOK     =  50
    %dlgOptions  = 100
    %pb_Font     = 101
    %pb_Color    = 102
    %lb_Font     = 103
    %lb_Color    = 104
    %ed_Text     = 300
    %ID_RICHEDIT = 400  ' Define RichEdit Dialog ID.
    ' Default Minimized size:
    %MinSizeX = 20
    %MinSizeY = 20
    '----------------------------
    %WM_TRAYICON = %WM_USER + 400
    %IDM_OPTIONS = %WM_USER + 401
    %IDM_DELETE  = %WM_USER + 402
    %IDM_TSIZE   = %WM_USER + 403
    %IDM_ABOUT   = %WM_USER + 404
    %IDM_EXIT    = %WM_USER + 405
    %IDM_MENU    = %WM_USER + 410
    %IDM_HELP    = %WM_USER + 411
    %IDM_DSIZE   = %WM_USER + 420
    %IDM_DPOS    = %WM_USER + 421
    %IDM_CLOSE   = %WM_USER + 422
    %SET_FRAMECONTENT  = %WM_USER + 430  ' For Painting demo color
    %ID_RestoreWindows = %WM_USER + 431  ' For restoring any previous sticky notes
    '----------------------------
    TYPE StickyDefaultTYPE    ' gStickyDefs - For All Sticky Notes
      sLogFont   AS LOGFONT   ' Selected Font
      sFontKolor AS LONG      ' and text color
      sFontSize  AS LONG      ' Point size (for display only)
      sBkgKolor  AS LONG      ' Sticky Note Background Color
      sDskPos    AS POINTAPI  ' Default desktop row,col position of upper-left window
      sWinSize   AS POINTAPI  ' Default: Width, height of Sticky Note
    END TYPE
    TYPE StickyOpsTYPE       ' gStickyOps(1:10) - For each individual Sticky Note
      hWnd      AS DWORD     ' Window Handle
      hEdit     AS DWORD     ' Edit Control handle
      sDskPos   AS POINTAPI  ' Desktop row,col position of upper-left window
      sWinSize  AS POINTAPI  ' Width, height of Sticky Note
      sMinState AS LONG      ' 0 for not minimized, 1 for minimized
    END TYPE
    TYPE NoteInfoTYPE       ' For saving info to file
      NoteLen   AS LONG      ' length of text being saved/restored
      sDskPos   AS POINTAPI  ' Desktop row,col position of upper-left window
      sWinSize  AS POINTAPI  ' Width, height of Sticky Note
    END TYPE
    GLOBAL gHinst AS DWORD, gStickyDefs AS StickyDefaultTYPE, g_hFontEd AS DWORD, _
           gDeskTop AS RECT, g_BkgBrush AS LONG, gNoNotes AS LONG, gOldEditProc AS DWORD
    'For richEdit
    GLOBAL gREpos AS LONG, gREptr AS LONG, gREtxt AS STRING
    DECLARE CALLBACK FUNCTION HelpBoxProc
    DECLARE FUNCTION FindEditHandleFromWndHandle(hWnd AS DWORD, i AS LONG) AS DWORD
    DECLARE FUNCTION FindWindowHandleFromEditHandle(hEdit AS DWORD, i AS LONG) AS DWORD
    DECLARE FUNCTION RestoreStickyNotes(szSavePath AS ASCIIZ, hWnd AS DWORD) AS LONG
    DECLARE FUNCTION SaveStickyNotes(szSavePath AS ASCIIZ) AS LONG
    DECLARE FUNCTION ReadDefaults(szDefPath AS ASCIIZ) AS LONG
    DECLARE FUNCTION WriteDefaults(szDefPath AS ASCIIZ) AS LONG
    DECLARE FUNCTION ReCreateEditWindows() AS LONG
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION WINMAIN (BYVAL hInstance AS DWORD, BYVAL hPrevInstance AS DWORD, _
                      BYVAL lpCmdLine AS ASCIIZ PTR, BYVAL iCmdShow AS LONG) AS LONG
      LOCAL hWnd      AS DWORD, _
            Msg       AS TAGMSG, _
            wc        AS WNDCLASSEX, _
            szString  AS ASCIIZ * 30
      szString = "MrSticky"
      IF FindWindow(szString, "") <> 0 THEN EXIT FUNCTION 'Prevent duplicate instances
      gHinst        = hInstance   'store instance handle in global variable for later use
      wc.cbSize        = SIZEOF(wc)
      wc.style         = %NULL
      wc.lpfnWndProc   = CODEPTR(WndProc)
      wc.cbClsExtra    = 0
      wc.cbWndExtra    = 0
      wc.hInstance     = gHinst
      wc.hIcon         = LoadIcon( gHinst, "STICKY")
      wc.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
      wc.hbrBackground = %COLOR_APPWORKSPACE + 1
      wc.lpszMenuName  = %NULL
      wc.lpszClassName = VARPTR(szString)
    
      RegisterClassEx wc
    'Create a main window On Taskbar
      hWnd  = CreateWindowEx(%WS_EX_TOOLWINDOW, szString, "MrSticky v1.0", %NULL, _
                             0, 0, 0, 0, 0, 0, gHinst, BYVAL 0&)
    'Owned Windows need their own Window Handler
      szString = "StNote"
      wc.lpfnWndProc   = CODEPTR(StickyProc)
      wc.hbrBackground = GetStockObject(%WHITE_BRUSH)
      wc.lpszClassName = VARPTR(szString)
      RegisterClassEx wc
      WHILE GetMessage(Msg, %NULL, 0, 0)
          TranslateMessage Msg
          DispatchMessage Msg
      WEND
    END FUNCTION
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION WndProc (BYVAL hWnd   AS DWORD, BYVAL wMsg   AS DWORD, _
                      BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
      LOCAL retCode   AS LONG, _
            pt        AS POINTAPI, _
            hMenu     AS DWORD, _
            rectA     AS RECT, _
            szString  AS ASCIIZ * 30
      STATIC ti         AS NOTIFYICONDATA, _
             hLib       AS DWORD, _
             szSavePath AS ASCIIZ * %MAX_PATH, _
             szDefPath  AS ASCIIZ * %MAX_PATH
      DIM gStickyOps(1:10) AS GLOBAL StickyOpsTYPE
      SELECT CASE wMsg
        CASE %WM_CREATE 'sent by CreateWindowEx, when Main window is created
    '   1~~~~~~~~~~~~~~
    ' Load RichEdit's dll
          hLib = LoadLibrary("RICHED32.DLL")
          ti.cbSize           = SIZEOF(ti) 'fill structure with proper data
          ti.hWnd             = hWnd
          ti.uID              = gHinst
          ti.uFlags           = %NIF_ICON OR %NIF_MESSAGE OR %NIF_TIP
          ti.uCallbackMessage = %WM_TRAYICON
          ti.hIcon            = LoadIcon( gHinst, "STICKY")
          ti.szTip            = " Mr.Sticky "
          Shell_NotifyIcon %NIM_ADD, ti 'add icon to Tray
    ' Set Defaults
          gNoNotes = 0
          CALL GetModuleFileName(0,szSavePath,%MAX_PATH)
          szSavePath = LEFT$(szSavePath, INSTR(-1,szSavePath, ANY "\:") )
          szDefPath = szSavePath  + "MrSticky.def"   ' Holds Overall Defaults
          szSavePath = szSavePath + "MrSticky.sav"   ' Contents of StickyNotes on exit
          CALL ReadDefaults(szDefPath)
          g_hFontEd  = CreateFontIndirect(gStickyDefs.sLogFont)
          g_BkgBrush = CreateSolidBrush(gStickyDefs.sBkgKolor)
          SystemParametersInfo %SPI_GETWORKAREA, 0, BYVAL VARPTR(gDeskTop), 0
          IF gStickyDefs.sDskPos.x < 0 THEN ' forces default to upper right side of desktop
            gStickyDefs.sDskPos.x = gDesktop.nRight - gStickyDefs.sWinSize.x
            gStickyDefs.sDskPos.y = 0
          END IF
          PostMessage hWnd, %ID_RestoreWindows, 0, 0 ' Display any saved notes
          FUNCTION = 0 : EXIT FUNCTION
        CASE %ID_RestoreWindows
    '   1~~~~~~~~~~~~~~~~~~~~~~
    ' If desktop impinges on Sticky Window, adjust defaults.
          CALL RestoreStickyNotes(szSavePath, hWnd)
        CASE %WM_TRAYICON
    '   1~~~~~~~~~~~~~~~~
          SELECT CASE LOWRD(lParam)
            CASE %WM_LBUTTONUP ' Spawn New Sticky Note
    '       2~~~~~~~~~~~~~~~~~
              IF gNoNotes < 10 THEN
                szString = "StNote"
                CreateWindowEx %WS_EX_TOOLWINDOW OR %WS_EX_TOPMOST, _
                               szString, "", %WS_POPUP OR %WS_SIZEBOX, _
                               gStickyDefs.sDskPos.x, gStickyDefs.sDskPos.y, _
                               gStickyDefs.sWinSize.x, gStickyDefs.sWinSize.y, _
                               hWnd, BYVAL %NULL, gHinst, BYVAL 0&
              END IF
            CASE %WM_RBUTTONDOWN 'create and show popup menu
    '       2~~~~~~~~~~~~~~~~~~~
                GetCursorPos pt
                SetForegroundWindow hWnd
                rectA.nTop = pt.y : rectA.nLeft = pt.x : rectA.nBottom = pt.y + 10 : rectA.nRight = pt.x +10
                hmenu = CreatePopupMenu
                AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_OPTIONS, "&Options"
                AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_DELETE,  "&Delete All Notes"
                AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_ABOUT,   "&About Mr Sticky"
                AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_HELP,   "&Help"
                AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_EXIT,    "&Exit"
                TrackPopupMenu hMenu, %TPM_CENTERALIGN, pt.x, pt.y, 0, hWnd, BYVAL %NULL ' rectA '%NULL
                Postmessage hWnd, %WM_NULL, 0, 0
                DestroyMenu hMenu
          END SELECT
        CASE %WM_COMMAND
    '   1~~~~~~~~~~~~~~~
          SELECT CASE LOWRD(wParam)
            CASE %IDM_OPTIONS
    '       2~~~~~~~~~~~~~~~~
              retCode = DialogBox (ghInst, BYVAL(CDWD(%dlgOptions)), hWnd, CODEPTR(StickyOpsProc))
              IF retCode >0  THEN  ' Save altered defaults to file
    ' Delete and recreate Font/Background Info
                IF retCode = 2 THEN
                  IF g_hFontEd > 0 THEN DeleteObject g_hFontEd
                  g_hFontEd  = CreateFontIndirect(gStickyDefs.sLogFont)
                  ReCreateEditWindows
                END IF
                IF g_BkgBrush > 0 THEN DeleteObject g_BkgBrush
                g_BkgBrush = CreateSolidBrush(gStickyDefs.sBkgKolor)
                CALL WriteDefaults(szDefPath)
                FOR retCode = 1 TO gNoNotes
                  invalidateRect gStickyOps(retCode).hWnd, BYVAL %NULL, %TRUE
                NEXT i
              END IF
            CASE %IDM_DELETE
    '       2~~~~~~~~~~~~~~~
              IF gNoNotes > 0 THEN ' Destroys Notes starting at the bottom of the stack
                DO
                  DestroyWindow gStickyOps(1).hWnd
                  IF gNoNotes = 0 OR gStickyOps(1).hWnd = 0 THEN EXIT DO
                LOOP
              END IF
            CASE %IDM_ABOUT
    '       2~~~~~~~~~~~~~~
              CALL HelpBoxMaker(BYVAL hWnd, BYVAL -1, BYVAL -1, _
                                BYVAL 360, BYVAL 140, "Mr.Sticky About", "RTFABOUT" )
            CASE %IDM_HELP
    '       2~~~~~~~~~~~~~~
              CALL HelpBoxMaker(BYVAL hWnd, BYVAL -1, BYVAL -1, _
                                BYVAL 360, BYVAL 280, "Mr.Sticky Help", "RTFHELP" )
            CASE %IDM_EXIT 'user selected Exit from menu
    '       2~~~~~~~~~~~~~
    ' Save any existing Notes before exiting
              CALL SaveStickyNotes(szSavePath)
              SendMessage hWnd, %WM_CLOSE, 0, 0
              FUNCTION = 0 : EXIT FUNCTION
          END SELECT
        CASE %WM_DESTROY 'clean up at exit
    '   1~~~~~~~~~~~~~~~
          Shell_NotifyIcon %NIM_DELETE, ti   'remove icon from Tray
          DestroyIcon ti.hIcon               ' And destroy it
          IF g_hFontEd > 0 THEN DeleteObject g_hFontEd    ' And Font
          IF g_BkgBrush > 0 THEN DeleteObject g_BkgBrush  ' And Brush
          IF gNoNotes > 0 THEN
            DO
              DestroyWindow gStickyOps(1).hWnd
              IF gNoNotes = 0 OR gStickyOps(1).hWnd = 0 THEN EXIT DO
            LOOP
          END IF
          PostQuitMessage 0
      END SELECT
      FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
    END FUNCTION
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION SaveStickyNotes(szSavePath AS ASCIIZ) AS LONG
    ' returns %FALSE for no errors, %TRUE for unable to write file
      LOCAL fhandle  AS LONG, _
            i        AS LONG, _
            txtLen   AS LONG, _
            tString  AS STRING, _
            nString  AS STRING, _
            NoteInfo AS NoteInfoTYPE
    ' Allow for existence of file/write-protected disk/Permission denied first! Exit routine if found.
      ON ERROR GOTO SaveNotesError
    ' Delete any existing file first
      IF DIR$(szSavePath) <> "" THEN
        KILL szSavePath
      END IF
    ' Exit if nothing to save
      IF gNoNotes < 1 THEN
        FUNCTION = 0
        EXIT FUNCTION
      END IF
    ' Start Save Operation
      fhandle = FREEFILE
      OPEN szSavePath FOR BINARY AS # fhandle
      PUT #fhandle, , gNoNotes
      nString = SPACE$(LEN(NoteInfo)) ' String for moving UDT in/out of file
      FOR i = 1 TO gNoNotes
        NoteInfo.sDskPos  = gStickyOps(i).sDskPos
        NoteInfo.sWinSize = gStickyOps(i).sWinSize
    ' Get Text length, create a string buffer and fill it with text
        txtLen = SendMessage( gStickyOps(i).hEdit, %WM_GETTEXTLENGTH, 0, 0)
        NoteInfo.NoteLen = txtLen
        IF txtLen > 0 THEN
          NoteInfo.NoteLen = txtLen+1
          tString = SPACE$(txtLen + 1)
          SendMessage gStickyOps(i).hEdit, %WM_GETTEXT, txtLen + 1, STRPTR(tString)
        ELSE
          tString = ""
        END IF
        LSET nString = NoteInfo
        PUT$ # fhandle, nString
        IF NoteInfo.NoteLen > 0 THEN
          PUT$ # fhandle, tString
        END IF
      NEXT i
      CLOSE #fhandle
      ON ERROR GOTO 0
      FUNCTION = 0 : EXIT FUNCTION
    SaveNotesError:
    '~~~~~~~~~~~~~~
      fhandle = ERRCLEAR
      FUNCTION = 1
    END FUNCTION
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION RestoreStickyNotes(szSavePath AS ASCIIZ, hWnd AS DWORD) AS LONG
    ' Returns 0 for success, 1 for no file/failure
      LOCAL fhandle    AS LONG, _
            tmpNoNotes AS LONG, _
            i          AS LONG, _
            tString    AS STRING, _
            nString    AS STRING, _
            NoteInfo   AS NoteInfoTYPE
      ON ERROR GOTO RestoreNotesError
      gNoNotes = 0
      IF DIR$(szSavePath) = "" THEN
        FUNCTION = 1
        EXIT FUNCTION
      END IF
      fhandle = FREEFILE
      OPEN szSavePath FOR BINARY AS # fhandle
    ' Note: You cannot fill gNoNotes with a value. This happens on window creation!
      GET #fhandle, ,tmpNoNotes
      IF tmpNoNotes = 0 OR tmpNoNotes > 10 THEN
        CLOSE # fhandle
          KILL szSavePath
        FUNCTION = 1
        EXIT FUNCTION
      END IF
      FOR i = 1 TO tmpNoNotes
        GET$ #fhandle,LEN(NoteInfo), nString
        LSET NoteInfo = nString
        gStickyOps(i).sDskPos  = NoteInfo.sDskPos
        gStickyOps(i).sWinSize = NoteInfo.sWinSize
        IF NoteInfo.NoteLen > 0 THEN
          GET$ # fhandle, NoteInfo.NoteLen, tString
        END IF
        CreateWindowEx %WS_EX_TOOLWINDOW, "stNote", "", %WS_POPUP OR %WS_SIZEBOX, _
                       gStickyOps(i).sDskPos.x, gStickyOps(i).sDskPos.y, _
                       gStickyOps(i).sWinSize.x, gStickyOps(i).sWinSize.y, _
                       hWnd, BYVAL %NULL, gHinst, BYVAL 0&
        SLEEP 0 ' Allow time for Edit Window creation
        IF NoteInfo.NoteLen > 0 THEN
          SendMessage gStickyOps(i).hEdit, %WM_SETTEXT, 0, STRPTR(tString)
        END IF
      NEXT i
      CLOSE #fhandle
      ON ERROR GOTO 0
      FUNCTION = 0 : EXIT FUNCTION
    RestoreNotesError:
    '~~~~~~~~~~~~~~~~~
      fhandle = ERRCLEAR
      FUNCTION = 1
    END FUNCTION
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION ReCreateEditWindows() AS LONG
    ' Save Window text to a buffer, destroy the Edit window, recreate the window and re-insert the text
      LOCAL i        AS LONG, _
            hEdit    AS DWORD, _
            hWnd     AS DWORD, _
            txtLen   AS LONG, _
            tString  AS STRING, _
            rectC    AS RECT
      FOR i = 1 TO gNoNotes
        hWnd = gStickyOps(i).hWnd
        hEdit = gStickyOps(i).hEdit
    ' Get Text length, create a string buffer and fill it with current text (if any)
        txtLen = SendMessage( hEdit, %WM_GETTEXTLENGTH, 0, 0)
        IF txtLen > 0 THEN
          tString = SPACE$(txtLen + 1)
          SendMessage gStickyOps(i).hEdit, %WM_GETTEXT, txtLen + 1, STRPTR(tString)
        ELSE
          tString = ""
        END IF
    ' Remove Subclass reference and destroy the current edit window
        IF gOldEditProc > 0 THEN
          CALL SetWindowLong(hEdit, %GWL_WNDPROC, gOldEditProc)
        END IF
        DestroyWindow hEdit
    ' Now recreate the window
        CALL GetClientRect(gStickyOps(i).hWnd, rectC)
        hEdit = CreateWindow("EDIT", "", %WS_CHILD OR %WS_VISIBLE OR _
                             %ES_MULTILINE OR %ES_LEFT, _ ' or %WS_VSCROLL, _
                              0,0,rectC.nRight, rectC.nBottom, _
                              hWnd, %ed_Text, gHinst, BYVAL %NULL)
        gStickyOps(i).hEdit = hEdit
        SendMessage hEdit, %WM_SETFONT, g_hFontEd, 0
    ' Subclass the Edit Control for dragging and Menu
        gOldEditProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))
    ' Put the text pack into the edit window
        IF txtLen > 0 THEN
          SendMessage hEdit, %WM_SETTEXT, 0, STRPTR(tString)
        END IF
      NEXT i
    END FUNCTION
    '-------------------------------
    '###############################
    ' ------------------------------
    FUNCTION StickyProc (BYVAL hWnd   AS DWORD, BYVAL wMsg   AS DWORD, _
                         BYVAL wParam AS DWORD, BYVAL lParam AS LONG) AS LONG
      LOCAL hEdit   AS LONG, _
            hMenu   AS DWORD, _
            i       AS LONG, _
            pt      AS POINTAPI, _
            rectC   AS RECT
      SELECT CASE wMsg
        CASE %WM_CREATE
    '   1~~~~~~~~~~~~~~
          INCR gNoNotes
          gStickyOps(gNoNotes).hWnd = hWnd  ' Save Window Handle
          IF gStickyOps(gNoNotes).sWinSize.y = 0 THEN ' Creating a new note (not restoring)
            gStickyOps(gNoNotes).sDskPos  = gStickyDefs.sDskPos
            gStickyOps(gNoNotes).sWinSize = gStickyDefs.sWinSize
          END IF
          SetWindowPos hWnd, %HWND_TOPMOST, 0,0,0,0, %SWP_NOMOVE OR %SWP_NOSIZE
          ShowWindow hWnd, %SW_SHOW
    
    ' Now give it a writing surface: Text control
          CALL GetClientRect(hWnd, rectC)
          hEdit = CreateWindow("EDIT", "", %WS_CHILD OR %WS_VISIBLE OR _
                               %ES_MULTILINE OR %ES_LEFT, _
                                0,0,rectC.nRight, rectC.nBottom, _
                                hWnd, %ed_Text, gHinst, BYVAL %NULL)
          gStickyOps(gNoNotes).hEdit = hEdit
          SendMessage hEdit, %WM_SETFONT, g_hFontEd, 0
    ' Subclass the Edit Control for dragging and Menu
          gOldEditProc = SetWindowLong(hEdit, %GWL_WNDPROC, CODEPTR(EditSubClassProc))
    ' Get a caret on our new window, get ready for text entry
          SetForegroundWindow hEdit
        CASE %WM_LBUTTONDOWN  ' Message relayed from Edit Window allows dragging note
    '   1~~~~~~~~~~~~~~~~~~~
          CALL SendMessage(hWnd, %WM_NCLBUTTONDOWN, %HTCAPTION, BYVAL %NULL)
          FUNCTION = 0 : EXIT FUNCTION
        CASE %IDM_MENU ' Menu - Delete (or Escape),
    '   1~~~~~~~~~~~~~   Set Size as default, Set Position as default, On Top checked/unchecked
          GetCursorPos pt
          SetForegroundWindow hWnd
          CALL FindEditHandleFromWndHandle(hWnd, i)
          hmenu = CreatePopupMenu
          AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_DSIZE, "Set &Size as Default"
          AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_DPOS,  "Set &Position as Default"
          IF gStickyOps(i).sMinState = 0 THEN
            AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_TSIZE,  "&Minimize Note"
          ELSE
            AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_TSIZE,  "&Restore Note"
          END IF
          AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_HELP,  "&Help"
          AppendMenu hMenu, %MF_STRING OR %MF_ENABLED, %IDM_CLOSE, "&Close Note"
          TrackPopupMenu hMenu, %TPM_CENTERALIGN, pt.x, pt.y, 0, hWnd, BYVAL %NULL
          Postmessage hWnd, %WM_NULL, 0, 0
          DestroyMenu hMenu
        CASE %WM_CTLCOLOREDIT
    '   1~~~~~~~~~~~~~~~~~~~~
          SetBkColor wParam, gStickyDefs.sBkgKolor
          SetTextColor wParam, gStickyDefs.sFontKolor
          SetBkMode wParam,%OPAQUE
          FUNCTION = g_BkgBrush : EXIT FUNCTION
        CASE %WM_EXITSIZEMOVE   ' Adjust Edit window size
    '   1~~~~~~~~~~~~~~~~~~~~
          CALL GetClientRect (hWnd, RectC) ' get current size of Client Area
          IF RectC.nBottom < %MinSizeY OR RectC.nRight < %MinSizeX THEN
    ' Resize Window to minimums
            GetWindowRect hWnd, rectC
            IF rectC.nRight - rectC.nLeft < %MinSizeX THEN rectC.nRight = rectC.nLeft + %MinSizeX
            IF rectC.nBottom - rectC.nTop < %MinSizeY THEN rectC.nBottom = rectC.nTop + %MinSizeY
            MoveWindow hWnd,rectC.nLeft, rectC.nTop, rectC.nRight-rectC.nLeft,_
                       rectC.nBottom-rectC.nTop, %TRUE
            GetClientRect hWnd, rectC
          END IF
          hEdit = FindEditHandleFromWndHandle(hWnd, i) ' Find associated Edit window
          IF hEdit > 0 THEN
            MoveWindow hEdit, rectC.nLeft, rectC.nTop, rectC.nRight, rectC.nBottom, %TRUE
            CALL GetWindowRect(hWnd, rectC)
            IF rectC.nRight - rectC.nLeft <> %MinSizeX OR rectC.nBottom - rectC.nTop <> %MinSizeY THEN
              gStickyOps(i).sMinState = 0
              gStickyOps(i).sWinSize.x = rectC.nRight - rectC.nLeft
              gStickyOps(i).sWinSize.y = rectC.nBottom - rectC.nTop
              gStickyOps(i).sDskPos.x  = rectC.nLeft
              gStickyOps(i).sDskPos.y  = rectC.nTop
            END IF
           END IF
          FUNCTION = 0
        CASE %WM_COMMAND
    '   1~~~~~~~~~~~~~~~
          SELECT CASE LOWRD(wParam)
            CASE %IDM_DSIZE ' set size as default
    '       2~~~~~~~~~~~~~~
              CALL GetWindowRect(hWnd, rectC)
              gStickyDefs.sWinSize.x = rectC.nRight - rectC.nLeft
              gStickyDefs.sWinSize.y = rectC.nBottom - rectC.nTop
            CASE %IDM_DPOS ' set desktop position as default
    '       2~~~~~~~~~~~~~~
              CALL GetWindowRect(hWnd, rectC)
              gStickyDefs.sDskPos.x = rectC.nLeft
              gStickyDefs.sDskPos.y = rectC.nTop
            CASE %IDM_TSIZE ' Toggle Window as minimized/Restored
    '       2~~~~~~~~~~~~~~
    ' Get gStickyOps() item number
              hEdit = FindEditHandleFromWndHandle(hWnd, i)
    ' Toggle minimized/restored state and Resize Window
              IF gStickyOps(i).sMinState = 1 THEN
                gStickyOps(i).sMinState = 0
                pt.x = gStickyOps(i).sWinSize.x
                pt.y = gStickyOps(i).sWinSize.y
              ELSE
                gStickyOps(i).sMinState = 1
                pt.x = %MinSizeX
                pt.y = %MinSizeY
              END IF
              MoveWindow hWnd, gStickyOps(i).sDskPos.x, gStickyOps(i).sDskPos.y, _
                          pt.x, pt.y, %TRUE
              PostMessage hWnd, %WM_EXITSIZEMOVE, 0, 0
            CASE %IDM_HELP
    '       2~~~~~~~~~~~~~~
              CALL HelpBoxMaker(BYVAL hWnd, BYVAL -1, BYVAL -1, _
                                BYVAL 360, BYVAL 280, "Help", "RTFHELP" )
            CASE %IDM_CLOSE ' Close this note
    '       2~~~~~~~~~~~~~~
              SendMessage hWnd, %WM_CLOSE, 0, 0
          END SELECT
        CASE %WM_DESTROY 'clean up at exit
    '   1~~~~~~~~~~~~~~~
          hEdit = FindEditHandleFromWndHandle(hWnd, i)
          IF hEdit > 0 THEN
            IF gOldEditProc > 0 THEN
              CALL SetWindowLong(hEdit, %GWL_WNDPROC, gOldEditProc)
    &ing ;       END IF
            DestroyWindow hEdit
    ' now remove reference to this Window
            ARRAY DELETE gStickyOps(i)
            DECR gNoNotes
          END IF
      END SELECT
      FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION FindEditHandleFromWndHandle(hWnd AS DWORD, i AS LONG) AS DWORD
    ' returns Edit handle associated with Window handle
    '         or 0 for not found
      LOCAL counter AS LONG
      FUNCTION = 0
      FOR counter = 1 TO gNoNotes
        IF gStickyOps(counter).hWnd = hWnd THEN
          FUNCTION = gStickyOps(counter).hEdit
          EXIT FOR
        END IF
      NEXT counter
      i = counter
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION FindWindowHandleFromEditHandle(hEdit AS DWORD, i AS LONG) AS DWORD
    ' returns Window handle associated with Edit handle
    '         or 0 for not found
      LOCAL counter AS LONG
      FUNCTION = 0
      FOR counter = 1 TO gNoNotes
        IF gStickyOps(counter).hEdit = hEdit THEN
          FUNCTION = gStickyOps(counter).hWnd
          EXIT FOR
        END IF
      NEXT counter
      i = counter
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION StickyOpsProc (BYVAL hDlg AS DWORD, BYVAL wMsg AS LONG, _
                        BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
      STATIC ColorStruc  AS CHOOSECOLORAPI, _
             cf          AS CHOOSEFONTAPI, _
             tStickyDefs AS StickyDefaultTYPE
      LOCAL hDC        AS LONG, _
            hBrush     AS LONG, _
            hBrushOld  AS LONG, _
            ps         AS PAINTSTRUCT,_
            cHandle    AS LONG, _
            rectA      AS RECT, _
            i          AS LONG, _
            tString    AS STRING
      DIM CustColors(0 : 15) AS STATIC DWORD
      SELECT CASE wMsg
        CASE %WM_INITDIALOG
    '   1~~~~~~~~~~~~~~~~~~
          tStickyDefs = gStickyDefs
    ' Setup Color Structure
          FOR i = 0 TO 15
            CustColors(i) = 0
          NEXT i
          ColorStruc.lStructSize    = SIZEOF(ColorStruc)
          ColorStruc.hwndOwner      = hDlg
          ColorStruc.hInstance      = %NULL
          ColorStruc.rgbResult      = %NULL
          ColorStruc.lpC breolors   = VARPTR(CustColors(0))
          ColorStruc.Flags          = %CC_RGBINIT  OR %CC_FULLOPEN
          ColorStruc.lCustData      = 0
          ColorStruc.lpfnHook       = %NULL
          ColorStruc.lpTemplateName = %NULL
    ' Setup Font Structures
          cf.lStructSize    = SIZEOF(cf)
          cf.hWndOwner      = hDlg
          cf.hDC            = %NULL
          cf.lpLogFont      = VARPTR(tStickyDefs.sLogFont)
          cf.iPointSize     = 0
          cf.Flags          = %CF_INITTOLOGFONTSTRUCT OR %CF_EFFECTS OR %CF_SCREENFONTS _
                              OR %CF_TTONLY OR %CF_SCRIPTSONLY
          cf.rgbColors      = tStickyDefs.sFontKolor
          cf.lCustData      = 0
          cf.lpfnHook       = %NULL
          cf.lpTemplateName = %NULL
          cf.hInstance      = %NULL
          cf.lpszStyle      = %NULL
          cf.nFontType      = 0
          cf.nSizeMin       = 0
          cf.nSizeMax       = 0
    ' Paint Font Name
          hdc = GetDC (hDlg)
          CALL SelectObject (hdc, CreateFontIndirect(tStickyDefs.sLogFont))
          CALL ReleaseDC (hDlg, hdc)
          tString = LTRIM$(tStickyDefs.sLogFont.lfFaceName) + ": " + FORMAT$(tStickyDefs.sFontSize) + " point"
          SetWindowText GetDlgItem(hDlg, %lb_Font), BYCOPY tString
          FUNCTION = 1
        CASE %WM_PAINT
    '   1~~~~~~~~~~~~~
          CALL BeginPaint (hDlg, ps)
          CALL EndPaint (hDlg, ps)
    'Paint Display Frame
          CALL PostMessage(hDlg, %SET_FRAMECONTENT, 0, 0)
          FUNCTION = 1
        CASE %SET_FRAMECONTENT  ' Paint contents of the display frame
    '   1~~~~~~~~~~~~~~~~~~~~~
          cHandle = GetDlgItem(hDlg, %lb_Color)
          hDC = GetDC (cHandle)
    ' Get Area in which to draw
          CALL GetClientRect (cHandle, rectA) ' Allow for edge of control.
          INCR rectA.nTop : INCR rectA.nLeft : DECR rectA.nBottom : DECR rectA.nRight
    ' Draw Background
          hBrush  = CreateSolidBrush(tStickyDefs.sBkgKolor)
          hBrushOld = SelectObject(hDC, hBrush)
          CALL FillRect(hdc, rectA, hBrush)
    ' Delete GDI objects
          CALL SelectObject (hDC, hBrushOld)
          CALL DeleteObject (hBrush)
          CALL ReleaseDC(cHandle, hdc)
          FUNCTION = 1
        CASE %WM_COMMAND
    '   1~~~~~~~~~~~~~~~
          SELECT CASE LOWRD(wParam)
            CASE %pb_Color
    '       2~~~~~~~~~~~~~
              ColorStruc.rgbResult = tStickyDefs.sBkgKolor
              IF ChooseColor ( ColorStruc )  > 0 THEN
                tStickyDefs.sBkgKolor = ColorStruc.rgbResult
    ' Paint Dialog
                CALL PostMessage(hDlg, %SET_FRAMECONTENT, 0, 0)
              END IF
              FUNCTION = 1
            CASE %pb_Font
    '       2~~~~~~~~~~~~
              IF ChooseFont (cf) THEN
                tStickyDefs.sFontKolor = cf.rgbColors
                tStickyDefs.sFontSize = cf.iPointSize/10
                hdc = GetDC (hDlg)
                CALL SelectObject (hdc, CreateFontIndirect(tStickyDefs.sLogFont))
                CALL ReleaseDC (hDlg, hdc)
                tString = LTRIM$(tStickyDefs.sLogFont.lfFaceName) + ": " _
                          + FORMAT$(tStickyDefs.sFontSize) + " point"
                SetWindowText GetDlgItem(hDlg, %lb_Font), BYCOPY tString
              END IF
              FUNCTION = 1
            CASE %pb_IDOK
    '       2~~~~~~~~~~~~
              IF gStickyDefs.sLogFont <> tStickyDefs.sLogfont THEN
                i = 2
              ELSE
                i = 1
              END IF
              gStickyDefs = tStickyDefs
              EndDialog hDlg, i
              FUNCTION = 1
            CASE %IDCANCEL
    '       2~~~~~~~~~~~~~
                EndDialog hDlg, 0
                FUNCTION = 1
          END SELECT
        END SELECT
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION ReadDefaults(szDefPath AS ASCIIZ) AS LONG
      LOCAL fhandle AS DWORD, _
            tString AS STRING
      ON ERROR GOTO ReadDefaultsError
      IF DIR$(szDefPath) = "" THEN
        GOTO makeDefaults
      END IF
      fhandle = FREEFILE
      OPEN szDefPath FOR BINARY AS # fhandle
      GET$ #fhandle, LEN(gStickyDefs), tString
      LSET gStickyDefs = tString
      CLOSE #fhandle
      ON ERROR GOTO 0
      FUNCTION = 0 : EXIT FUNCTION
    makeDefaults:
    '~~~~~~~~~~~~
    ' Defaults
    ' Default Font 10 point Verdana
      gStickyDefs.sLogFont.lfFaceName = "Verdana"
      gStickyDefs.sLogFont.lfPitchAndFamily = 34
      gStickyDefs.sLogFont.lfWeight = 400
      gStickyDefs.sLogFont.lfHeight = -13
      gStickyDefs.sLogFont.lfItalic = 0
      gStickyDefs.sBkgKolor  = RGB(204, 255, 255) ' pale blue
      gStickyDefs.sFontKolor = &H0                ' Black
      gStickyDefs.sFontSize  = 10
      gStickyDefs.sDskPos.x  =  -1   ' forces on upper right side of desktop
      gStickyDefs.sDskPos.y  =  -1
      gStickyDefs.sWinSize.x = 100
      gStickyDefs.sWinSize.y = 100
      CALL WriteDefaults(szDefPath)
      ON ERROR GOTO 0
      FUNCTION = 0 : EXIT FUNCTION
    ReadDefaultsError:
    '~~~~~~~~~~~~~~~~~
      fhandle = ERRCLEAR
      FUNCTION = 1
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION WriteDefaults(szDefPath AS ASCIIZ) AS LONG
    ' returns %FALSE for no errors, %TRUE for unable to write file
      LOCAL fhandle AS LONG
    ' Allow for existence of file/write-protected disk/Permission denied first! Exit routine if found.
      ON ERROR GOTO WriteDefaultsError
      fhandle = FREEFILE
      OPEN szDefPath FOR BINARY AS # fhandle
      PUT$ #fhandle, gStickyDefs
      CLOSE #fhandle
      ON ERROR GOTO 0
      FUNCTION = 0 : EXIT FUNCTION
    WriteDefaultsError:
    '~~~~~~~~~~~~~~~~~
      fhandle = ERRCLEAR
      FUNCTION = 1
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION EditSubClassProc(BYVAL hWnd AS LONG, BYVAL wMsg AS LONG, _
                              BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
      LOCAL xWnd        AS DWORD, _
            startPos    AS LONG, _
            endPos      AS LONG, _
            tVal        AS LONG, _
            virtVal     AS INTEGER, _
            oldString   AS STRING, _
            tString     AS STRING, _
            hMem        AS DWORD, _
            pszClipText AS ASCIIZ PTR
      SELECT CASE wMsg&
        CASE %WM_KEYDOWN  ' Control+S to toggle size minimized/restored
    '   ~~~~~~~~~~~~~~~~
          IF LOBYT(wParam) = 83 THEN
            virtVal =  LOBYT(GetKeyState(%VK_CONTROL))
            IF BIT(virtVal,7) = 1  THEN
              xWnd = FindWindowHandleFromEditHandle(hWnd, tVal)
              PostMessage xWnd, %WM_COMMAND, %IDM_TSIZE, 0
            END IF
            FUNCTION = %FALSE
            EXIT FUNCTION
          END IF
        CASE %WM_RBUTTONDOWN 'create and show popup menu
    '   ~~~~~~~~~~~~~~~~~~~~
          IF ISTRUE (%MK_CONTROL AND wParam) THEN
            xWnd = FindWindowHandleFromEditHandle(hWnd, tVal)
            IF xWnd > 0 THEN
              PostMessage xWnd, %IDM_MENU, 0, 0
            END IF
            FUNCTION = %FALSE
            EXIT FUNCTION
          END IF
        CASE %WM_LBUTTONDOWN  ' Allow dragging note
    '   ~~~~~~~~~~~~~~~~~~~~
          IF ISTRUE (%MK_CONTROL AND wParam) THEN
            xWnd = FindWindowHandleFromEditHandle(hWnd, tVal)
            IF xWnd > 0 THEN
              PostMessage xWnd, %WM_LBUTTONDOWN, BYVAL wParam, BYVAL lParam
            END IF
            FUNCTION = %FALSE
            EXIT FUNCTION
          END IF
        CASE %WM_PASTE
    '   ~~~~~~~~~~~~~~
    ' Get text, if any from the clipboard
          IF OpenClipboard(%NULL) = 0 THEN FUNCTION = 1 : EXIT FUNCTION
          hMem         = GetClipboardData (%CF_TEXT) ' get handle
          pszClipText  = GlobalLock (hMem)           ' get pointer to the data in that handle
          tString      = @pszClipText                ' move data to local variable
          GlobalUnlock hMem                          ' unlock the handle
          CloseClipboard                             ' relinquish clipboard
          IF LEN(tString) < 1 THEN FUNCTION = 1 : EXIT FUNCTION
    ' Get Old Text length, create a string buffer and fill it with current text (if any)
          tVal = SendMessage( hWnd, %WM_GETTEXTLENGTH, 0, 0)
          IF tVal > 0 THEN
            oldString = SPACE$(tVal + 1)
            SendMessage hWnd, %WM_GETTEXT, tVal + 1, STRPTR(oldString)
    ' Get the position of the caret and/or selection
            tVal =  SendMessage( hWnd, %EM_GETSEL, 0, 0 )
            startPos = LOWRD(tVal) : endPos = HIWRD(tVal) ' 0 based position of the caret and/or selection
            tString = LEFT$(oldString, startPos) + tString + MID$(oldString, endPos+1)
          END IF
    ' Paste altered text into control now.
          SendMessage hWnd, %WM_SETTEXT, 0, STRPTR(tString)
          FUNCTION = 1
          EXIT FUNCTION
      END SELECT
    ' Fall through to old event handler
      FUNCTION = CallWindowProc(gOldEditProc,hWnd, wMsg, wParam, lParam)
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    SUB RichEditSetString (BYVAL hRichEdit AS DWORD)
      LOCAL eStream AS EDITSTREAM
    ' Insert a formatted RTF string into Rich Edit
      gREpos                = 1             'position in text to start from
      gREptr                = STRPTR(gREtxt)  'pointer to global text buffer
      eStream.pfnCallback = CODEPTR(RichEditStreamInString) 'pointer to RichEdit callback procedure
      SendMessage hRichEdit, %EM_STREAMIN, %SF_RTF, VARPTR(eStream) 'stream in text
    END SUB
    '-------------------------------
    '###############################
    '-------------------------------
    FUNCTION RichEditStreamInString (BYVAL dwCookie AS DWORD, BYVAL pbBuff AS BYTE PTR, _
                                     BYVAL cb AS LONG, pcb AS LONG) AS DWORD
    ' Rich Edit stream in callback - for streaming in string contents
      pcb = cb               'number of bytes to copy
      IF pcb > 0 THEN        'copy block from global string directly into Richedit's buffer.
        CopyMemory pbBuff, (gREptr + gREpos - 1), pcb
        gREpos = gREpos + pcb   'incr pos for next callback position.
      END IF
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    SUB HelpBoxMaker(BYVAL hParent AS DWORD, BYVAL xPos AS LONG, BYVAL yPos AS LONG, _
                     BYVAL xWidth AS LONG, BYVAL yHeight AS LONG, BYVAL inTitle AS STRING, _
                     BYVAL inText AS STRING)
      LOCAL  hDlg  AS DWORD, _
             lRes  AS DWORD, _
             lRes2 AS DWORD, _
             lRes3 AS DWORD
      STATIC hModInst AS DWORD
      hModInst = GetModuleHandle("")                                    'Get Module Handle
      lRes     = FindResource(hModInst, BYCOPY inText, BYVAL %RT_RCDATA)'look for RTF text in resource
      IF lRes  THEN lRes2 = LoadResource(hModInst, lRes)                'Load it
      IF lRes2 THEN lRes3 = LockResource(lRes2)                         'Lock it
      IF lRes3 THEN gREtxt = PEEK$(lRes3, SizeofResource(hModInst, lRes)) 'Put RTF into a global string
      DIALOG NEW hParent, inTitle, xPos, yPos, xWidth, yHeight, _
                 %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
      CONTROL ADD "RichEdit", hDlg, %ID_RICHEDIT, "", 5, 5, xWidth - 9, yHeight - 32, _
                  %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %WS_VSCROLL OR _
                  %ES_AUTOVSCROLL OR %ES_MULTILINE OR %ES_NOHIDESEL OR _
                  %ES_READONLY OR %ES_SAVESEL, %WS_EX_CLIENTEDGE
      IF LEN(gREtxt) THEN RichEditSetString GetDlgItem(hDlg, %ID_RICHEDIT)
      CONTROL ADD BUTTON, hDlg, %IDCANCEL, "&Close", xWidth - 56, yHeight - 20, 50, 14
      DIALOG SHOW MODAL hDlg, CALL HelpBoxProc
    END SUB
    '-------------------------------
    '###############################
    '-------------------------------
    CALLBACK FUNCTION HelpBoxProc
      SELECT CASE CBMSG
         CASE %WM_INITDIALOG
         CASE %WM_COMMAND
            SELECT CASE CBCTL
                CASE %IDCANCEL 'respond to ESC key (or button with %IDCANCEL id)
                  IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL
            END SELECT
      END SELECT
    END FUNCTION
    '-------------------------------
    '###############################
    '-------------------------------
    'End of File
    :) IRC :)

    Comment


    • #3
      I have altered the Subclass routine for the Edit control.
      Previously, you could only paste what would fit into the edit window.
      The new routine under %WM_PASTE will paste far more text than will
      show in the edit window.
      Happy Saint Nicholas Day,
      Ian Cairns

      ------------------
      ian[dot][email protected]

      [This message has been edited by Ian Cairns (edited December 06, 2004).]
      :) IRC :)

      Comment


      • #4
        I erred in the way I handled the clipboard in the EditSubClassProc function.
        Michael Mattias pointed out that I used an asciiz pointer instead of a memory handle,
        I obtained text through an invalid handle that could cause a glitch on Win2K
        or XP machines. Sorry about that.

        Corrections have been made. Sorry for the inconvenience.
        Thanks Michael.

        ------------------
        ian[dot][email protected]
        :) IRC :)

        Comment


        • #5
          Oh no! Not another change to the file!
          Well, yes, but not because of an error in the file. I received a
          constructive criticism about the topmost window hogging the desktop,
          so I incorporated a Minimize/Restore function to the Sticky Notes.
          If you do a Control+Right Click on a Note to invoke the popup menu,
          you get an extra item, the Minimize/Restore function. You can also
          invoke the function by pressing Control+S when the note is active.
          Notes are minimized to 20x20 pixels, or restored to their previous
          states.
          I also changed the binbas file to incorporate only the .pbr file.
          Hopefully that will be it unless some error pops up.
          regards, Ian Cairns.

          ------------------
          ian[dot][email protected]
          :) IRC :)

          Comment


          • #6
            Not compile, I got error 471 on line 533

            CASE %WM_DESTROY 'clean up at exit
            ' 1~~~~~~~~~~~~~~~
            hEdit = FindEditHandleFromWndHandle(hWnd, i)
            IF hEdit > 0 THEN
            IF gOldEditProc > 0 THEN
            CALL SetWindowLong(hEdit, %GWL_WNDPROC, gOldEditProc)
            &ing ; END IF'.................................<<<<<<<<<<<<<<<<<<<<<<< this line
            DestroyWindow hEdit
            Attached Files
            Last edited by Arthur Gomide; 2 Feb 2009, 08:22 AM. Reason: quoted text
            "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

            Comment


            • #7
              Project zipped and attached

              Project zipped and attached,C/W source files, except for the RC file which wasn't on my work computer. Works OK for me.

              regards, Ian
              Attached Files
              :) IRC :)

              Comment

              Working...
              X