Раздел посвящен программированию с использованием Power Basic.
-
Smitis-R
-
- Новичок
-
-
- Сообщения: 48
- Зарегистрирован: 26.04.2005 (Вт) 0:37
Smitis-R » 05.01.2007 (Пт) 22:27
Вывод подсказки при наведении курсора на элемент формы:
- Код: Выделить всё
#COMPILE EXE
#DIM ALL
#INCLUDE "WIN32API.INC"
%DLG_DIALOG1 = 101
%BTN_BUTTON1 = 1001
%BTN_BUTTON2 = 1002
%BTN_BUTTON3 = 1003
%LBL_TIPS = 1004
GLOBAL hDlg AS DWORD
CALLBACK FUNCTION CBMAIN()
SELECT CASE AS LONG CBMSG
CASE %WM_SETCURSOR
LOCAL status_text AS STRING
LOCAL c AS LONG
STATIC cprev AS LONG
c = GetDlgCtrlId(CBWPARAM)
IF c <> cprev THEN
cprev = c
SELECT CASE AS LONG c
CASE %BTN_BUTTON1
status_text = "This is button 1"
CASE %BTN_BUTTON2
status_text = "This is button 2"
CASE %BTN_BUTTON3
status_text = "This is button 3"
CASE %LBL_TIPS
status_text = "This is tips string"
CASE 1
status_text = ""
END SELECT
CONTROL SET TEXT hDlg, %LBL_TIPS, status_text
END IF
CASE %WM_COMMAND
SELECT CASE AS LONG CBCTL
CASE %BTN_BUTTON1
CASE %BTN_BUTTON2
CASE %BTN_BUTTON3
END SELECT
END SELECT
END FUNCTION
FUNCTION PBMAIN()
LOCAL lRslt AS LONG
DIALOG NEW 0, "Tips", 251, 116, 160, 60, _
%WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_VISIBLE, _
0, TO hDlg
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON1, "Button1", 10, 10, 40, 20
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON2, "Button2", 60, 10, 40, 20
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON3, "Button3", 110, 10, 40, 20
CONTROL ADD LABEL, hDlg, %LBL_TIPS, "", 0, 50, 160, 10, %SS_NOTIFY
DIALOG SHOW MODAL hDlg, CALL CBMAIN TO lRslt
END FUNCTION
-
volo
-
- Продвинутый пользователь
-
-
- Сообщения: 142
- Зарегистрирован: 10.12.2004 (Пт) 11:18
- Откуда: Soviet Union
-
volo » 06.01.2007 (Сб) 13:40
Дополню несколько модернизированным вариантом для ToolTip
- Код: Выделить всё
#COMPILE EXE
#DIM ALL
#INCLUDE "WIN32API.INC"
#INCLUDE "CommCtrl.INC"
%DLG_DIALOG1 = 101
%BTN_BUTTON1 = 1001
%BTN_BUTTON2 = 1002
%BTN_BUTTON3 = 1003
%LBL_TIPS = 1004
GLOBAL hDlg AS DWORD
GLOBAL hToolTip AS LONG ' handle of tooltip window
CALLBACK FUNCTION CBMAIN()
SELECT CASE AS LONG CBMSG
CASE %WM_SETCURSOR
LOCAL status_text AS ASCIIZ *128
LOCAL c AS LONG
STATIC cprev AS LONG
c = GetDlgCtrlId(CBWPARAM)
IF c <> cprev THEN
cprev = c
SELECT CASE AS LONG c
CASE %BTN_BUTTON1
status_text = "This is button 1"
CASE %BTN_BUTTON2
status_text = "This is button 2"
CASE %BTN_BUTTON3
status_text = "This is button 3"
CASE %LBL_TIPS
status_text = "This is tips string"
CASE 1
status_text = ""
END SELECT
CONTROL SET TEXT hDlg, %LBL_TIPS, status_text
CALL TTOOL (status_text,c)
END IF
CASE %WM_COMMAND
SELECT CASE AS LONG CBCTL
CASE %BTN_BUTTON1
CASE %BTN_BUTTON2
CASE %BTN_BUTTON3
END SELECT
END SELECT
END FUNCTION
SUB TTOOL(a AS ASCIIZ, BYVAL cont AS LONG)
LOCAL ti AS TOOLINFO
ti.cbSize = LEN(ti)
ti.uFlags = %TTF_SUBCLASS OR %TTF_IDISHWND
ti.hWnd = hDlg
ti.uId = GetDlgItem(hDlg, cont)
ti.lpszText = VARPTR(a)
SendMessage hToolTip, %TTM_ADDTOOL, 0&, BYVAL VARPTR(ti)
END SUB
FUNCTION PBMAIN()
LOCAL lRslt AS LONG
DIALOG NEW 0, "Tips", 251, 116, 160, 60, _
%WS_BORDER OR %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_VISIBLE, _
0, TO hDlg
InitCommonControls
hToolTip = CreateWindowEx(0&, "tooltips_class32", "", %TTS_ALWAYSTIP, 0, 0, 0, 0, 0, BYVAL 0&, GetModuleHandle(BYVAL 0&), BYVAL 0&)
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON1, "Button1", 10, 10, 40, 20
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON2, "Button2", 60, 10, 40, 20
CONTROL ADD BUTTON, hDlg, %BTN_BUTTON3, "Button3", 110, 10, 40, 20
CONTROL ADD LABEL, hDlg, %LBL_TIPS, "", 0, 50, 160, 10, %SS_NOTIFY
DIALOG SHOW MODAL hDlg, CALL CBMAIN TO lRslt
END FUNCTION
Вернуться в Power Basic
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4