PowerBuilder Toast Notification
Code Example
n_cst_systemtray from nonvisualobject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
forward global type n_cst_systemtray from nonvisualobject end type type guid from structure within n_cst_systemtray end type type notifyicondata from structure within n_cst_systemtray end type type dllversioninfo from structure within n_cst_systemtray end type type system_info from structure within n_cst_systemtray end type end forward type guid from structure unsignedlong data1 integer data2 integer data3 byte data4[8] end type type notifyicondata from structure unsignedlong cbsize ULong hwnd unsignedlong uid unsignedlong uflags unsignedlong ucallbackmessage ULong hicon character sztip[128] unsignedlong dwstate unsignedlong dwstatemask character szinfo[256] unsignedlong utimeout character szinfotitle[64] unsignedlong ae_icons guid guiditem ULong hballoonicon end type type dllversioninfo from structure ulong cbsize ulong dwmajorversion ulong dwminorversion ulong dwbuildnumber ulong dwplatformid end type type SYSTEM_INFO from structure unsignedinteger wprocessorarchitecture unsignedinteger wreserved unsignedlong dwpagesize unsignedlong lpminimumapplicationaddress unsignedlong lpmaximumapplicationaddress unsignedlong dwactiveprocessormask unsignedlong dwnumberofprocessors unsignedlong dwprocessortype unsignedlong dwallocationgranularity unsignedinteger wprocessorlevel unsignedinteger wprocessorrevsion end type global type n_cst_systemtray from nonvisualobject end type global n_cst_systemtray n_cst_systemtray type prototypes /* Method : (Declaration) Author : Chris Pollach Scope : Public Extended : Yes Level : Extension Description : Used to control MS-Windows SYSTEM TRAY interaction Behaviour : Convets any PB App to work in the System Tray area and back out - at run-time! Note : Uses mainly SDK fuinctions mapped in the Application Controller Argument(s) : None Throws : N/A Return Value : None -------------------------------------------- CopyRight ----------------------------------------------------- Copyright © 2018 by Appeon. All rights reserved. Any distribution of this PowerBuilder® application or its source code by other than by Appeon is prohibited. ------------------------------------------- Revisions ------------------------------------------------------- 1.0 Inital Version - 2010-12-13 1.1 Moved most declarations to the "nc_app_controller_master" object class - 2019-01-01 */ // External Declarations (Local here because os structure dependancy) // Function Boolean Shell_NotifyIcon ( ulong dwMessage, Ref NOTIFYICONDATA lpData ) Library "shell32.dll" alias for "Shell_NotifyIconW" Function Boolean SetForegroundWindow ( ULong hWnd ) Library "user32.dll" Function ULong LoadImage ( ULong hInst, string lpszName, ulong uType, long cxDesired, long cyDesired, ulong fuLoad ) Library "user32.dll" Alias For "LoadImageW" Function ULong ExtractIcon ( ULong hInst, string lpszExeFileName, ulong nIconIndex ) Library "shell32.dll" Alias For "ExtractIconW" Function Boolean DestroyIcon ( ULong hIcon ) Library "user32.dll" Function Boolean RegisterHotKey ( ULong hWnd, long id, ulong fsModifiers, ulong vk ) Library "user32.dll" Function Boolean UnregisterHotKey ( ULong hWnd, long id ) Library "user32.dll" Function ULong LoadLibrary ( string lpFileName ) Library "kernel32.dll" Alias For "LoadLibraryW" Function Boolean FreeLibrary ( ULong hModule ) Library "kernel32.dll" Function ULong GetProcAddress ( ULong hModule, string lpProcName ) Library "kernel32.dll" alias for "GetProcAddress;Ansi" Function Long DllGetVersion( ref dllversioninfo pdvi ) Library "comctl32.dll" alias for "DllGetVersion;Ansi" Subroutine DebugMsg ( String lpOutputString ) Library "kernel32.dll" Alias For "OutputDebugStringW" function ulong GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo) library "kernel32.dll" end prototypes type variables /* Method : (Declaration) Author : Chris Pollach Scope : Public/Protected/Private Extended : Yes Level : Extension Description : Used for MS-Windows System Tray processing Behaviour : Work variables Note : None Argument(s) : None Throws : N/A Return Value : None -------------------------------------------- CopyRight ----------------------------------------------------- Copyright © 2018 by Appeon. All rights reserved. Any distribution of this PowerBuilder® application or its source code by other than by Appeon is prohibited. ------------------------------------------- Revisions ------------------------------------------------------- 1.0 Inital Version - 2010-12-13 1.1 Revised constants to reflect more up-to-date values - 2019-01-01 */ // Declarations Private: Boolean ib_systemtray_active = FALSE // SW 4 SYSTEM TRAY mode ULong iptr_iconhandles [] Long NOTIFYICONDATA_SIZE = 88 Long NOTIFYICON_VERSION = 1 Protected: //Ramón San Félix Ramón //rsrsystem.soft@gmail.com //https://rsrsystem.blogspot.com/ //Extract From nc_master---------------------------------------------------------------------------------------------------------------------------------------------- Boolean ib_rc // Generic BOOLEAN work var for Return Codes. //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // function constants Constant long NIF_MESSAGE = 1 Constant long NIF_ICON = 2 Constant long NIF_TIP = 4 Constant long NIF_STATE = 8 Constant long NIF_INFO = 16 Constant long NIF_GUID = 32 Constant long NIF_REALTIME = 64 Constant long NIF_SHOWTIP = 128 CONSTANT long NIM_ADD = 0 CONSTANT long NIM_MODIFY = 1 CONSTANT long NIM_DELETE = 2 CONSTANT long NIM_SETFOCUS = 3 CONSTANT long NIM_SETVERSION = 4 CONSTANT long NIM_VERSION = 5 CONSTANT long NIS_HIDDEN = 1 CONSTANT long NIS_SHAREDICON = 2 Constant long NIIF_NONE = 0 Constant long NIIF_INFO = 1 Constant long NIIF_WARNING = 2 Constant long NIIF_ERROR = 3 Constant long NIIF_USER = 4 Constant long NIIF_ICON_MASK = 15 Constant long NIIF_NOSOUND = 16 Constant long NIIF_LARGE_ICON = 32 Constant long NIIF_RESPECT_QUIET_TIME = 64 Constant long WM_USER = 1024 Constant long PBM_CUSTOMEVENT = (WM_USER - 1) + 1 Constant long NIN_SELECT = WM_USER + 0 Constant long NIN_BALLOONSHOW = WM_USER + 2 Constant long NIN_BALLOONHIDE = WM_USER + 3 Constant long NIN_BALLOONTIMEOUT = WM_USER + 4 Constant long NIN_BALLOONUSERCLICK = WM_USER + 5 Constant long NIN_POPUPOPEN = WM_USER + 6 Constant long NIN_POPUPCLOSE = WM_USER + 7 Constant ulong NOTIFYICONDATA_V1_SIZE = 88 // pre-5.0 structure size Constant ulong NOTIFYICONDATA_V2_SIZE = 488 // pre-6.0 structure size Constant ulong NOTIFYICONDATA_V3_SIZE = 504 // 6.0+ structure size Constant ulong NOTIFYICONDATA_V4_SIZE = 508 // Vista and newer structure size CONSTANT long ICON_SMALL = 0 CONSTANT long ICON_BIG = 1 CONSTANT uint IMAGE_BITMAP = 0 CONSTANT uint IMAGE_ICON = 1 CONSTANT uint IMAGE_CURSOR = 2 CONSTANT uint LR_DEFAULTCOLOR = 0 CONSTANT uint LR_MONOCHROME = 1 CONSTANT uint LR_COLOR = 2 CONSTANT uint LR_COPYRETURNORG = 4 CONSTANT uint LR_COPYDELETEORG = 8 CONSTANT uint LR_LOADFROMFILE = 16 CONSTANT uint LR_LOADTRANSPARENT = 32 CONSTANT uint LR_DEFAULTSIZE = 64 CONSTANT uint LR_VGACOLOR = 128 CONSTANT uint LR_LOADMAP3DCOLORS = 4096 CONSTANT uint LR_CREATEDIBSECTION = 8192 CONSTANT uint LR_COPYFROMRESOURCE = 16384 CONSTANT uint LR_SHARED = 32768 // hotkey values CONSTANT uint MOD_NONE = 0 CONSTANT uint MOD_ALT = 1 CONSTANT uint MOD_CONTROL = 2 CONSTANT uint MOD_SHIFT = 4 CONSTANT uint MOD_WIN = 8 uint iui_keycode = 0 uint iui_modifier = 0 // virtual keycodes CONSTANT uint KeyBack = 8 CONSTANT uint KeyTab = 9 CONSTANT uint KeyEnter = 13 CONSTANT uint KeyShift = 16 CONSTANT uint KeyControl = 17 CONSTANT uint KeyAlt = 18 CONSTANT uint KeyPause = 19 CONSTANT uint KeyCapsLock = 20 CONSTANT uint KeyEscape = 27 CONSTANT uint KeySpaceBar = 32 CONSTANT uint KeyPageUp = 33 CONSTANT uint KeyPageDown = 34 CONSTANT uint KeyEnd = 35 CONSTANT uint KeyHome = 36 CONSTANT uint KeyLeftArrow = 37 CONSTANT uint KeyUpArrow = 38 CONSTANT uint KeyRightArrow = 39 CONSTANT uint KeyDownArrow = 40 CONSTANT uint KeyPrintScreen = 44 CONSTANT uint KeyInsert = 45 CONSTANT uint KeyDelete = 46 CONSTANT uint Key0 = 48 CONSTANT uint Key1 = 49 CONSTANT uint Key2 = 50 CONSTANT uint Key3 = 51 CONSTANT uint Key4 = 52 CONSTANT uint Key5 = 53 CONSTANT uint Key6 = 54 CONSTANT uint Key7 = 55 CONSTANT uint Key8 = 56 CONSTANT uint Key9 = 57 CONSTANT uint KeyA = 65 CONSTANT uint KeyB = 66 CONSTANT uint KeyC = 67 CONSTANT uint KeyD = 68 CONSTANT uint KeyE = 69 CONSTANT uint KeyF = 70 CONSTANT uint KeyG = 71 CONSTANT uint KeyH = 72 CONSTANT uint KeyI = 73 CONSTANT uint KeyJ = 74 CONSTANT uint KeyK = 75 CONSTANT uint KeyL = 76 CONSTANT uint KeyM = 77 CONSTANT uint KeyN = 78 CONSTANT uint KeyO = 79 CONSTANT uint KeyP = 80 CONSTANT uint KeyQ = 81 CONSTANT uint KeyR = 82 CONSTANT uint KeyS = 83 CONSTANT uint KeyT = 84 CONSTANT uint KeyU = 85 CONSTANT uint KeyV = 86 CONSTANT uint KeyW = 87 CONSTANT uint KeyX = 88 CONSTANT uint KeyY = 89 CONSTANT uint KeyZ = 90 CONSTANT uint KeyLeftWindows = 91 CONSTANT uint KeyRightWindows = 92 CONSTANT uint KeyApps = 93 CONSTANT uint KeyNumPad0 = 96 CONSTANT uint KeyNumPad1 = 97 CONSTANT uint KeyNumPad2 = 98 CONSTANT uint KeyNumPad3 = 99 CONSTANT uint KeyNumPad4 = 100 CONSTANT uint KeyNumPad5 = 101 CONSTANT uint KeyNumPad6 = 102 CONSTANT uint KeyNumPad7 = 103 CONSTANT uint KeyNumPad8 = 104 CONSTANT uint KeyNumPad9 = 105 CONSTANT uint KeyMultiply = 106 CONSTANT uint KeyAdd = 107 CONSTANT uint KeySubtract = 109 CONSTANT uint KeyDecimal = 110 CONSTANT uint KeyDivide = 111 CONSTANT uint KeyF1 = 112 CONSTANT uint KeyF2 = 113 CONSTANT uint KeyF3 = 114 CONSTANT uint KeyF4 = 115 CONSTANT uint KeyF5 = 116 CONSTANT uint KeyF6 = 117 CONSTANT uint KeyF7 = 118 CONSTANT uint KeyF8 = 119 CONSTANT uint KeyF9 = 120 CONSTANT uint KeyF10 = 121 CONSTANT uint KeyF11 = 122 CONSTANT uint KeyF12 = 123 CONSTANT uint KeyNumLock = 144 CONSTANT uint KeyScrollLock = 145 CONSTANT uint KeySemiColon = 186 CONSTANT uint KeyEqual = 187 CONSTANT uint KeyComma = 188 CONSTANT uint KeyDash = 189 CONSTANT uint KeyPeriod = 190 CONSTANT uint KeySlash = 191 CONSTANT uint KeyBackQuote = 192 CONSTANT uint KeyLeftBracket = 219 CONSTANT uint KeyBackSlash = 220 CONSTANT uint KeyRightBracket = 221 CONSTANT uint KeyQuote = 222 Public: // windows messages CONSTANT long WM_GETICON = 127 CONSTANT long WM_MOUSEMOVE = 512 CONSTANT long WM_LBUTTONDOWN = 513 CONSTANT long WM_LBUTTONUP = 514 CONSTANT long WM_LBUTTONDBLCLK = 515 CONSTANT long WM_RBUTTONDOWN = 516 CONSTANT long WM_RBUTTONUP = 517 CONSTANT long WM_RBUTTONDBLCLK = 518 CONSTANT long PBM_CUSTOM75 = 1024 + 74 //Ramón San Félix Ramón //rsrsystem.soft@gmail.com //https://rsrsystem.blogspot.com/ //I add this variable to control if the main window will become invisible Boolean ib_HideWindow = FALSE //------------------------------------------------------------------------------------------------------------------------------------------------------------------ end variables forward prototypes public function boolean of_add_to_systemtray (window ao_window) public function boolean of_add_to_systemtray (window ao_window, string as_imagename) public function boolean of_add_to_systemtray (window ao_window, string as_imagename, unsignedinteger aui_index) public function boolean of_set_notification_message (window ao_window, string as_title, string as_info, icon ae_icon) private function boolean of_modify_notification (window ao_window, string as_newtip) private function boolean of_modify_tray_icon (window ao_window, string as_imagename) private function boolean of_modify_tray_icon (window ao_window, string as_imagename, unsignedinteger aui_index) private function boolean of_is_hotkey (unsignedlong wparam, long lparam) private function boolean of_register_hotkey (window ao_window, integer ai_hotkeyid, unsignedinteger aui_modifier, unsignedinteger aui_keycode) private function boolean of_unregister_hotkey (window ao_window, integer ai_hotkeyid) public function boolean of_delete_from_systemtray (window ao_window, boolean ab_show) public function boolean of_set_foreground (window ao_window) private function long of_get_dll_version () private function long of_load_image (string as_filename, unsignedlong aul_iconindex) private function unsignedlong of_load_image (string as_imagename) public function boolean of_get_systemtray_active () public function integer of_getosbits () end prototypes public function boolean of_add_to_systemtray (window ao_window);//==================================================================== // Function: n_cst_systemtray.of_add_to_systemtray() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_add_to_systemtray ( window ao_window ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle ( ao_window ) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE + NIF_showtip lstr_notify.uCallBackMessage = PBM_CUSTOM75 lstr_notify.hIcon = Send ( lstr_notify.hWnd , WM_GETICON, ICON_SMALL, 0 ) lstr_notify.szTip = ao_window.Title // add icon to system tray If Shell_NotifyIcon ( NIM_ADD, lstr_notify ) = True Then // make window invisible If ib_HideWindow Then ao_window.Hide ( ) ib_rc = True Else ib_rc = False End If ib_systemtray_active = ib_rc Return ib_rc end function public function boolean of_add_to_systemtray (window ao_window, string as_imagename);//==================================================================== // Function: n_cst_systemtray.of_add_to_systemtray() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_imagename //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_add_to_systemtray ( window ao_window, string as_imagename ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations // add loaded icon to the system tray NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle ( ao_window ) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE + NIF_SHOWTIP lstr_notify.uCallBackMessage = PBM_CUSTOM75 lstr_notify.hIcon = This.of_load_image ( as_imagename ) lstr_notify.szTip = ao_window.Title // add icon to system tray If Shell_NotifyIcon(NIM_ADD, lstr_notify) = True Then // make window invisible If ib_HideWindow Then ao_window.Hide( ) ib_rc = True Else ib_rc = False End If ib_systemtray_active = ib_rc Return ib_rc end function public function boolean of_add_to_systemtray (window ao_window, string as_imagename, unsignedinteger aui_index);//==================================================================== // Function: n_cst_systemtray.of_add_to_systemtray() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_imagename // value unsignedinteger aui_index //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_add_to_systemtray ( window ao_window, string as_imagename, unsignedinteger aui_index ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations // add loaded icon to the system tray NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle ( ao_window ) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE + NIF_SHOWTIP lstr_notify.uCallBackMessage = PBM_CUSTOM75 lstr_notify.hIcon = This.of_load_image ( as_imagename, aui_index ) lstr_notify.szTip = ao_window.Title // add icon to system tray If Shell_NotifyIcon ( NIM_ADD, lstr_notify ) = True Then // make window invisible If ib_HideWindow Then ao_window.Hide( ) ib_rc = True Else ib_rc = False End If ib_systemtray_active = ib_rc Return ib_rc end function public function boolean of_set_notification_message (window ao_window, string as_title, string as_info, icon ae_icon);//==================================================================== // Function: n_cst_systemtray.of_set_notification_message() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_title // value string as_info // value icon ae_icon //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_set_notification_message ( window ao_window, string as_title, string as_info, icon ae_icon ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations If ib_systemtray_active = True Then // modify window icon tip in the system tray NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle(ao_window) lstr_notify.uID = 1 lstr_notify.uTimeout = 15000 lstr_notify.uFlags = NIF_INFO + NIF_SHOWTIP lstr_notify.szInfoTitle = as_title lstr_notify.szInfo = as_info Choose Case ae_icon Case StopSign! lstr_notify.ae_icons = NIIF_ERROR Case Information! lstr_notify.ae_icons = NIIF_INFO Case None! lstr_notify.ae_icons = NIIF_NONE Case Exclamation! lstr_notify.ae_icons = NIIF_WARNING Case Else lstr_notify.ae_icons = NIIF_NONE lstr_notify.hIcon = Send (lstr_notify.hWnd, WM_GETICON, ICON_SMALL, 0 ) End Choose // modify icon tip ib_rc = Shell_NotifyIcon (NIM_MODIFY, lstr_notify) Else ib_rc = False End If Return ib_rc end function private function boolean of_modify_notification (window ao_window, string as_newtip);//==================================================================== // Function: n_cst_systemtray.of_modify_notification() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_newtip //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_modify_notification ( window ao_window, string as_newtip ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle ( ao_window ) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_TIP + NIF_SHOWTIP lstr_notify.szTip = as_newtip // modify icon tip ib_rc = Shell_NotifyIcon ( NIM_MODIFY, lstr_notify ) Return ib_rc end function private function boolean of_modify_tray_icon (window ao_window, string as_imagename);//==================================================================== // Function: n_cst_systemtray.of_modify_tray_icon() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_imagename //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_modify_tray_icon ( window ao_window, string as_imagename ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle(ao_window) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_ICON lstr_notify.hIcon = This.of_load_image(as_imagename) // modify icon in system tray ib_rc = Shell_NotifyIcon(NIM_MODIFY, lstr_notify) Return ib_rc end function private function boolean of_modify_tray_icon (window ao_window, string as_imagename, unsignedinteger aui_index);//==================================================================== // Function: n_cst_systemtray.of_modify_tray_icon() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value string as_imagename // value unsignedinteger aui_index //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_modify_tray_icon ( window ao_window, string as_imagename, unsignedinteger aui_index ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle(ao_window) lstr_notify.uID = 1 lstr_notify.uFlags = NIF_ICON lstr_notify.hIcon = This.of_load_image ( as_imagename, aui_index ) If lstr_notify.hIcon = 0 Then ib_rc = False Else // modify icon in system tray ib_rc = Shell_NotifyIcon ( NIM_MODIFY, lstr_notify ) End If Return ib_rc end function private function boolean of_is_hotkey (unsignedlong wparam, long lparam);//==================================================================== // Function: n_cst_systemtray.of_is_hotkey() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value unsignedlong wparam // value long lparam //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_is_hotkey ( unsignedlong wparam, long lparam ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations If wparam = 1 Then If IntHigh(lparam) = iui_keycode Then If IntLow(lparam) = iui_modifier Then ib_rc = True End If End If End If ib_rc = False Return ib_rc end function private function boolean of_register_hotkey (window ao_window, integer ai_hotkeyid, unsignedinteger aui_modifier, unsignedinteger aui_keycode);//==================================================================== // Function: n_cst_systemtray.of_register_hotkey() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value integer ai_hotkeyid // value unsignedinteger aui_modifier // value unsignedinteger aui_keycode //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_register_hotkey ( window ao_window, integer ai_hotkeyid, unsignedinteger aui_modifier, unsignedinteger aui_keycode ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations ULong lptr // remember hotkey info iui_keycode = aui_keycode iui_modifier = aui_modifier // register a system wide hotkey lptr = Handle (ao_window) ib_rc = This.Registerhotkey ( lptr, ai_hotkeyid, aui_modifier, aui_keycode ) Return ib_rc end function private function boolean of_unregister_hotkey (window ao_window, integer ai_hotkeyid);//==================================================================== // Function: n_cst_systemtray.of_unregister_hotkey() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value integer ai_hotkeyid //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_unregister_hotkey ( window ao_window, integer ai_hotkeyid ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations // unregister a system wide hotkey ULong lptr lptr = Handle ( ao_window ) ib_rc = This.unregisterhotkey ( lptr, ai_hotkeyid ) Return ib_rc end function public function boolean of_delete_from_systemtray (window ao_window, boolean ab_show);//==================================================================== // Function: n_cst_systemtray.of_delete_from_systemtray() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window // value boolean ab_show //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_delete_from_systemtray ( window ao_window, boolean ab_show ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations NOTIFYICONDATA lstr_notify // populate structure lstr_notify.cbSize = NOTIFYICONDATA_SIZE lstr_notify.hWnd = Handle(ao_window) lstr_notify.uID = 1 If ab_show Then // make window visible If ib_HideWindow Then ao_window.Show ( ) // give the window primary focus This.of_set_Foreground (ao_window ) End If // Remove icon from system tray ib_rc = Shell_NotifyIcon ( NIM_DELETE, lstr_notify ) ib_systemtray_active = Not(ib_rc) Return ib_rc end function public function boolean of_set_foreground (window ao_window);//==================================================================== // Function: n_cst_systemtray.of_set_foreground() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value window ao_window //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_set_foreground ( window ao_window ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations ULong lptr // give window proper focus lptr = Handle (ao_window ) ib_rc = This.SetForegroundWindow ( lptr ) Return ib_rc end function private function long of_get_dll_version ();//==================================================================== // Function: n_cst_systemtray.of_get_dll_version() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_get_dll_version ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations // determine NOTIFYICONDATA version to use DLLVERSIONINFO lstr_dvi String ls_libname, ls_function ULong lo_ptr ULong lptr_module ULong lptr_version lptr_version = 1 // default to original ls_libname = "comctl32.dll" ls_function = "DllGetVersion" lptr_module = This.loadlibrary ( ls_libname ) If lptr_module > 0 Then lo_ptr = This.getprocaddress ( lptr_module, ls_function ) If lo_ptr > 0 Then lstr_dvi.cbSize = 20 lo_ptr = DllGetVersion ( lstr_dvi ) Choose Case lstr_dvi.dwMajorVersion Case 6 If lstr_dvi.dwMinorVersion = 0 Then lptr_version = 3 Else lptr_version = 4 End If Case 5 lptr_version = 2 Case Else lptr_version = 1 End Choose End If This.freelibrary ( lptr_module ) End If Return lptr_version end function private function long of_load_image (string as_filename, unsignedlong aul_iconindex);//==================================================================== // Function: n_cst_systemtray.of_load_image() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value string as_filename // value unsignedlong aul_iconindex //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_load_image ( string as_filename, unsignedlong aul_iconindex ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations ULong lptr // load icon lptr = This.extracticon ( Handle(GetApplication( ) ), as_filename, aul_iconindex ) // save handle for destroy in destructor event If lptr > 0 Then iptr_iconhandles [ UpperBound ( iptr_iconhandles ) + 1 ] = lptr End If Return lptr end function private function unsignedlong of_load_image (string as_imagename);//==================================================================== // Function: n_cst_systemtray.of_load_image() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: // value string as_imagename //-------------------------------------------------------------------- // Returns: unsignedlong //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_load_image ( string as_imagename ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declarations // load image into memory from .ico, .cur or .ani file ULong lptr Choose Case Lower ( Right ( as_imagename, 4 ) ) Case ".ico" lptr = This.loadimage ( 0, as_imagename, IMAGE_ICON, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) Case ".cur", ".ani" lptr = This.loadimage ( 0, as_imagename, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) Case Else End Choose Return lptr end function public function boolean of_get_systemtray_active ();//==================================================================== // Function: n_cst_systemtray.of_get_systemtray_active() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_get_systemtray_active ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== RETURN ib_systemtray_active end function public function integer of_getosbits ();//==================================================================== // Function: n_cst_systemtray.of_getosbits() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: integer //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/05 //-------------------------------------------------------------------- // Usage: n_cst_systemtray.of_getosbits ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== // Declare variables Integer li_architecture ULong ul_platform SYSTEM_INFO ls_sysinfo GetNativeSystemInfo(ls_sysinfo) // Determine the operating system architecture li_architecture = ls_sysinfo.wProcessorArchitecture If li_architecture = 0 Then ul_platform = 32 // 32-bit architecture Else ul_platform = 64 // 64-bit architecture End If Return ul_platform end function on n_cst_systemtray.create call super::create TriggerEvent( this, "constructor" ) end on on n_cst_systemtray.destroy TriggerEvent( this, "destructor" ) call super::destroy end on event destructor;/* Method : destructor (Event) Author : Chris Pollach Scope : Public Extended : Yes Level : Extension Description : Code to Clean-up environment & deregister from O/S Behaviour : <Comments here> Note : None Argument(s) : None Throws : N/A Return Value : long -------------------------------------------- CopyRight ----------------------------------------------------- Copyright © 2018 by Appeon. All rights reserved. Any distribution of this PowerBuilder® application or its source code by other than by Appeon is prohibited. ------------------------------------------- Revisions ------------------------------------------------------- 1.0 Inital Version - 2010-12-13 */ // Declarations Integer li_cnt, li_max // destroy icon handles created by ExtractIcon function li_max = UpperBound ( iptr_iconhandles ) FOR li_cnt = 1 TO li_max THIS.destroyicon ( iptr_iconhandles [ li_cnt ] ) NEXT end event event constructor;call super::constructor;/* Method : constructor (Event) Author : Chris Pollach Scope : {Public/Protected/Private} Extended : {Yes/No} Level : {Base, Extension, Concrete} Description : Code to initialize System Tray processing Behaviour : <Comments here> Note : None Argument(s) : None Throws : N/A Return Value : long -------------------------------------------- CopyRight ----------------------------------------------------- Copyright © 2018 by Appeon. All rights reserved. Any distribution of this PowerBuilder® application or its source code by other than by Appeon is prohibited. ------------------------------------------- Revisions ------------------------------------------------------- 1.0 Inital Version - 2010-12-13 1.1 Revised the code to support 64 bit compliance! - 2022-02-23 */ // Declarations //Environment lo_env // determine version of NOTIFYICONDATA to use //GetEnvironment (lo_env) NOTIFYICON_VERSION = THIS.of_get_dll_version() // Get DLL version CHOOSE CASE NOTIFYICON_VERSION CASE 4 NOTIFYICONDATA_SIZE = NOTIFYICONDATA_V4_SIZE CASE 3 NOTIFYICONDATA_SIZE = NOTIFYICONDATA_V3_SIZE CASE 2 NOTIFYICONDATA_SIZE = NOTIFYICONDATA_V2_SIZE CASE ELSE NOTIFYICONDATA_SIZE = NOTIFYICONDATA_V1_SIZE END CHOOSE // Add Unicode string lengths NOTIFYICONDATA_SIZE = NOTIFYICONDATA_SIZE + 448 // Add Longptr size If of_getosbits() = 64 Then NOTIFYICONDATA_SIZE = NOTIFYICONDATA_SIZE + 12 End If end event |
n_cst_systemtray_shared from nonvisualobject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
forward global type n_cst_systemtray_shared from nonvisualobject end type end forward global type n_cst_systemtray_shared from nonvisualobject end type global n_cst_systemtray_shared n_cst_systemtray_shared type variables end variables forward prototypes public subroutine of_delete_from_systemtray (integer ai_messageboxtimeout, n_cst_systemtray_callback a_callback) end prototypes public subroutine of_delete_from_systemtray (integer ai_messageboxtimeout, n_cst_systemtray_callback a_callback);If ai_MessageBoxTimeout > 0 Then sleep(ai_MessageBoxTimeout) End If a_callback.Post of_delete_from_systemtray() end subroutine on n_cst_systemtray_shared.create call super::create TriggerEvent( this, "constructor" ) end on on n_cst_systemtray_shared.destroy TriggerEvent( this, "destructor" ) call super::destroy end on |
n_cst_systemtray_callback from nonvisualobject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
forward global type n_cst_systemtray_callback from nonvisualobject end type end forward global type n_cst_systemtray_callback from nonvisualobject end type global n_cst_systemtray_callback n_cst_systemtray_callback type variables w_main iw_win end variables forward prototypes public subroutine of_delete_from_systemtray () public subroutine of_register (w_main aw_win) end prototypes public subroutine of_delete_from_systemtray ();//If there is a Notification on the screen, I delete it. If iw_win.in_systemtray.of_get_systemtray_active() = True Then iw_win.in_systemtray.of_delete_from_systemtray (iw_win, False ) End If end subroutine public subroutine of_register (w_main aw_win);iw_win = aw_win end subroutine on n_cst_systemtray_callback.create call super::create TriggerEvent( this, "constructor" ) end on on n_cst_systemtray_callback.destroy TriggerEvent( this, "destructor" ) call super::destroy end on |
w_main from window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
forward global type w_main from window end type type st_icon from statictext within w_main end type type st_sleep from statictext within w_main end type type st_msg from statictext within w_main end type type st_name from statictext within w_main end type type cb_show from commandbutton within w_main end type type em_sleep from editmask within w_main end type type ddplb_icon from dropdownpicturelistbox within w_main end type type sle_msg from singlelineedit within w_main end type type sle_name from singlelineedit within w_main end type end forward global type w_main from window integer width = 2318 integer height = 748 boolean titlebar = true string title = "Toast Notification~'s Utility" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true st_icon st_icon st_sleep st_sleep st_msg st_msg st_name st_name cb_show cb_show em_sleep em_sleep ddplb_icon ddplb_icon sle_msg sle_msg sle_name sle_name end type global w_main w_main type variables n_cst_systemtray in_systemtray n_cst_systemtray_callback in_callback end variables forward prototypes public subroutine wf_set_notification_message (string as_title, string as_msg, icon a_icon, integer ai_messageboxtimeout) end prototypes public subroutine wf_set_notification_message (string as_title, string as_msg, icon a_icon, integer ai_messageboxtimeout);n_cst_systemtray_shared ln_shared1 SharedObjectRegister("n_cst_systemtray_shared","thread1") SharedObjectGet("thread1", ln_shared1) //If there is a Notification on the screen, I delete it. If in_systemtray.of_get_systemtray_active() = True Then in_systemtray.of_delete_from_systemtray (This, False ) End If in_systemtray.of_add_to_systemtray (This ) in_systemtray.of_set_notification_message (This, as_title, as_msg, a_icon) //We use a Shared Object to be able to remove the notification after a few seconds in a different thread ln_shared1.Post of_delete_from_systemtray ( ai_MessageBoxTimeout, in_callback ) SharedObjectUnRegister("thread1") end subroutine on w_main.create this.st_icon=create st_icon this.st_sleep=create st_sleep this.st_msg=create st_msg this.st_name=create st_name this.cb_show=create cb_show this.em_sleep=create em_sleep this.ddplb_icon=create ddplb_icon this.sle_msg=create sle_msg this.sle_name=create sle_name this.Control[]={this.st_icon,& this.st_sleep,& this.st_msg,& this.st_name,& this.cb_show,& this.em_sleep,& this.ddplb_icon,& this.sle_msg,& this.sle_name} end on on w_main.destroy destroy(this.st_icon) destroy(this.st_sleep) destroy(this.st_msg) destroy(this.st_name) destroy(this.cb_show) destroy(this.em_sleep) destroy(this.ddplb_icon) destroy(this.sle_msg) destroy(this.sle_name) end on event open; // For notification handling in_systemtray = Create n_cst_systemtray in_callback = Create n_cst_systemtray_callback in_callback.of_register(this) ddplb_icon.SelectItem(2) end event event closequery;If in_systemtray.of_get_systemtray_active() = True Then in_systemtray.of_delete_from_systemtray (This, False ) End If Destroy in_systemtray Destroy in_callback end event type st_icon from statictext within w_main integer x = 91 integer y = 324 integer width = 302 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Icon" alignment alignment = right! boolean focusrectangle = false end type type st_sleep from statictext within w_main integer x = 1591 integer y = 332 integer width = 311 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Show Time" alignment alignment = right! boolean focusrectangle = false end type type st_msg from statictext within w_main integer x = 91 integer y = 196 integer width = 302 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Message" alignment alignment = right! boolean focusrectangle = false end type type st_name from statictext within w_main integer x = 91 integer y = 68 integer width = 302 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Title" alignment alignment = right! boolean focusrectangle = false end type type cb_show from commandbutton within w_main integer x = 1550 integer y = 460 integer width = 576 integer height = 112 integer taborder = 40 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Show Notification" end type event clicked;String ls_name String ls_msg Int li_sleep icon le_icon Time lt_time1, lt_time2 ls_name = sle_name.text ls_msg = sle_msg.text li_sleep = integer(em_sleep.text) CHOOSE CASE ddplb_icon.text CASE "StopSign" le_icon = StopSign! CASE "Information" le_icon = Information! CASE "None" le_icon = None! CASE "Exclamation" le_icon = Exclamation! END CHOOSE wf_set_notification_message (ls_name, ls_msg, le_icon, li_sleep) end event type em_sleep from editmask within w_main integer x = 1943 integer y = 324 integer width = 174 integer height = 92 integer taborder = 20 integer textsize = -10 integer weight = 700 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string text = "5" borderstyle borderstyle = stylelowered! string mask = "#" boolean spin = true string minmax = "0~~10" end type type ddplb_icon from dropdownpicturelistbox within w_main integer x = 421 integer y = 324 integer width = 558 integer height = 400 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string item[] = {"StopSign","Information","None","Exclamation"} borderstyle borderstyle = stylelowered! integer itempictureindex[] = {1,2,3,4} string picturename[] = {"StopSign!","Information!","NotFound!","Exclamation!"} long picturemaskcolor = 536870912 end type type sle_msg from singlelineedit within w_main integer x = 411 integer y = 180 integer width = 1705 integer height = 92 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string text = "This is a notification message..." borderstyle borderstyle = stylelowered! end type type sle_name from singlelineedit within w_main integer x = 411 integer y = 48 integer width = 1705 integer height = 92 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 string text = "Title Notification" borderstyle borderstyle = stylelowered! end type |
Find Projects On Github click here
Good Luck!
PowerBuilder 2021:
Compiler Errors:
n_cst_systemtray_callback.of_delete_from_systemtray.2: Error C0019: Incompatible property in_systemtray for type w_main
n_cst_systemtray_callback.of_delete_from_systemtray.2: Error C0003: Condition for if statement must be a boolean.
w_main.open.5: Error C0052: Bad argument list for function: of_register
please. you check instance variable.
does it running on windows 11?