DECLARE FUNCTION GetActiveWindow LIB "user32" ALIAS "GetActiveWindow" () AS LONG
DECLARE FUNCTION WindowFromPoint LIB "user32" ALIAS "WindowFromPoint" (X AS LONG, Y AS LONG) AS LONG
DECLARE FUNCTION DestroyWindow LIB "user32" ALIAS "DestroyWindow" (hWnd AS LONG) AS LONG
DECLARE FUNCTION ScreenToClient LIB "user32" ALIAS "ScreenToClient" (hWnd AS LONG, lpPoint AS POINTAPI) AS LONG
DECLARE FUNCTION UpdateWindow LIB "user32" ALIAS "UpdateWindow" (hWnd AS LONG) AS INTEGER
DECLARE FUNCTION InvalidateRect LIB "user32" ALIAS "InvalidateRect" (hWnd AS LONG, rect AS QRECT, bErase AS LONG) AS LONG
DECLARE FUNCTION SetBkColor LIB "gdi32" ALIAS "SetBkColor" (hdc AS LONG, crColor AS LONG) AS LONG
DECLARE FUNCTION SetWindowsHookEx LIB "user32" ALIAS "SetWindowsHookExA" (idHook AS LONG, lpFn AS LONG, _
hmod AS LONG, dwThreadId AS DWORD) AS LONG
DECLARE FUNCTION CallNextHookEx LIB "user32" ALIAS "CallNextHookEx" (hHook AS LONG, nCode AS LONG, _
wParam AS LONG, lParam AS LONG) AS LONG
DECLARE FUNCTION UnhookWindowsHookEx LIB "user32" ALIAS "UnhookWindowsHookEx" (hHook AS LONG) AS LONG
DECLARE FUNCTION GetCurrentThreadId LIB "kernel32" ALIAS "GetCurrentThreadId" () AS LONG
$DEFINE LMOUSE_BTN 1
$DEFINE RMOUSE_BTN 2
$DEFINE MMOUSE_BTN 4
DEFLNG lpHookProc, ThreadID, hHook
DEFINT gMouseBtns
FUNCTION MouseProc(idHook AS LONG, wParam AS LONG, lParam AS LONG) AS LONG
DEFLNG tmp
IF idHook >= 0 THEN
tmp=wParam AND 15
SELECT CASE tmp
CASE 1: gMouseBtns=LMOUSE_BTN
CASE 2: gMouseBtns=0
CASE 4: gMouseBtns=RMOUSE_BTN
CASE 5: gMouseBtns=0
CASE 7: gMouseBtns=MMOUSE_BTN
CASE 8: gMouseBtns=0
END SELECT
END IF
Result=CallNextHookEx(hHook, idHook, wParam, lParam)
END FUNCTION
$DEFINE cdNormal 0
$DEFINE cdFullOpen 1
$DEFINE cdNoFullOpen 2
$DEFINE CHOOSER_HEIGHT 335
$DEFINE CHOOSER_STD 225
$DEFINE CHOOSER_FULL 460
TYPE QColorDlg EXTENDS QFORM
PUBLIC:
Width AS LONG PROPERTY SET SetWidth
Height AS LONG PROPERTY SET SetHeight
Style AS LONG PROPERTY SET SetStyle
CAPTION AS STRING
COLOR AS LONG
Colors(1 TO 16) AS LONG
WindowHandle AS LONG
PRIVATE:
CC AS CHOOSECOLOR
ccTimer AS QTIMER
WITH QColorDlg
SUB SetChooserCaption
DEFLNG hWnd
DEFSTR buf=SPACE$(6)
.ccTimer.Enabled=False
hWnd=WindowFromPoint(.Left+50, .Top+50)
IF GetWindowText(hWnd,buf,6) THEN
IF INSTR(buf,"Color")>0 THEN
SetWindowText(hWnd, .CAPTION)
END IF
END IF
END SUB
PUBLIC:
FUNCTION EXECUTE() AS INTEGER
Result=0
.CC.lStructSize = SIZEOF(THIS.CC)
.CC.hWndOwner = .Handle
.CC.hInstance = 0
.CC.RGBResult = .COLOR
.CC.lpCustColors = VARPTR(THIS.Colors(1))
SELECT CASE .Style
CASE cdFullOpen, cdNormal
.CC.Flags = .CC.Flags OR CC_FULLOPEN
CASE cdNoFullOpen
.CC.Flags = .CC.Flags OR CC_PREVENTFULLOPEN
END SELECT
.ccTimer.Enabled=True
IF ChooseColorDlg(THIS.CC) THEN
.COLOR = .CC.RGBResult
Result=1
END IF
END FUNCTION
PROPERTY SET SetStyle (ccStyle AS LONG)
.Style = ccStyle
IF ccStyle = cdNoFullOpen THEN .Width = CHOOSER_STD ELSE .Width = CHOOSER_FULL
END PROPERTY
PROPERTY SET SetWidth (W AS LONG)
END PROPERTY
PROPERTY SET SetHeight (H AS LONG)
END PROPERTY
CONSTRUCTOR
Style=cdNoFullOpen
Width=CHOOSER_STD
Height=CHOOSER_HEIGHT
Left=(Screen.Width-CHOOSER_STD)\2
Top=(Screen.Height-CHOOSER_HEIGHT)\2
BorderStyle=0
CAPTION="Choose a Color"
ccTimer.OnTimer=THIS.SetChooserCaption
ccTimer.Interval=50
ccTimer.Enabled=False
WindowHandle=THIS.Handle
CC.Flags=CC_RGBINIT
Colors(1)=&H0
Colors(2)=&H808080
Colors(3)=&H000080
Colors(4)=&H008080
Colors(5)=&H008000
Colors(6)=&H808000
Colors(7)=&H800000
Colors(8)=&H800080
Colors(9)=&HFFFFFF
Colors(10)=&HC0C0C0
Colors(11)=&H0000FF
Colors(12)=&H00FFFF
Colors(13)=&H00FF00
Colors(14)=&HFFFF00
Colors(15)=&HFF0000
Colors(16)=&HFF00FF
END CONSTRUCTOR
END WITH
END TYPE
$DEFINE TCM_SETIMAGELIST &H1303
$DEFINE TCM_GETITEMCOUNT &H1304
$DEFINE TCM_SETITEM &H1306
$DEFINE TCM_INSERTITEM &H1307
$DEFINE TCM_DELETEITEM &H1308
$DEFINE TCM_DELETEALLITEMS &H1309
$DEFINE TCM_GETITEMRECT &H130A
$DEFINE TCIF_TEXT &H1
$DEFINE TCIF_IMAGE &H2
$DEFINE TCIF_RTLREADING &H4
$DEFINE TCIF_PARAM &H8
$DEFINE TCIF_STATE &H10
TYPE TabTCITEMHEADER
mask AS LONG
Reserved1 AS LONG
Reserved2 AS LONG
lpszText AS LONG
cchTextMax AS INTEGER
iImage AS INTEGER
END TYPE
FUNCTION GetTabCount(TabHandle AS LONG) AS INTEGER
Result=SendMessageAPI(TabHandle, TCM_GETITEMCOUNT, 0, 0)
END FUNCTION
FUNCTION DelAllTabs(TabHandle AS LONG) AS INTEGER
Result=0
IF GetTabCount(TabHandle)>0 THEN
Result=SendMessageAPI(TabHandle, TCM_DELETEALLITEMS, 0, 0)
END IF
END FUNCTION
FUNCTION AddNewTab(TabHandle AS LONG, TabIndex AS INTEGER, TabText AS STRING) AS INTEGER
DEFSTR tmpString
DIM TabHdr AS TabTCITEMHEADER
Result=0
IF TabIndex<0 THEN EXIT FUNCTION
tmpString=TabText+CHR$(0)
TabHdr.lpszText=VARPTR(tmpString)
TabHdr.mask=TCIF_TEXT
TabHdr.iImage=-1
Result=SendMessageAPI(TabHandle, TCM_INSERTITEM, TabIndex, TabHdr)
END FUNCTION
|