Minimize the window to a small icon next to the clock (powerbulider)
Last Update:2017-02-28
Source: Internet
Author: User
Minimize the window to a small icon next to the clock
Set up the main window "W_main", the port is defined as follows "local External fuctions":
function long LoadLibrary (ref string string) LIBRARY "KERNEL32" Alias for LoadLibraryA
function Long FreeLibrary (long Long) LIBRARY "KERNEL32"
function Boolean Shell_NotifyIcon (ulong long, ref s_str str) LIBRARY "SHELL32" Alias for "Shell_notifyicona"
function Long LoadIcon (long long, long long) LIBRARY "USER32" Alias for Loadicona
To define a struct type variable:
S_STR:
Size
Unsignedlong
Hwnd
Long
Id
Unsignedlong
Flags
Unsignedlong
Callbackmessage
Unsignedlong
Icon
Long
TIPS[64]
Character
To define an instance variable:
Private
S_str Istr_icon
The Window minimized button click event is written to the following script:
String Ls_resource
Long Ll_handle
The next three sentences for the loading icon resources, notepad.exe is WordPad, exe execution when the icon to display the default is 1
Ls_resource = "notepad.exe"
Ll_handle = LoadLibrary (Ls_resource)
Istr_icon.icon = LoadIcon (Ll_handle, 1)
Window callback event number, PBM_CUSTOM01 is 1024,02 1025, and so on
Istr_icon.callbackmessage = 1024
Istr_icon.tips = "Application"
Istr_icon.hwnd = handle (parent)
Istr_icon.size = 88
Istr_icon.id = 1
Identification value, that is, to display tips 4, Display icon 2, activate the window corresponding to the event number
Istr_icon.flags = 7
Display icon key function, 0 for display, 1 for modification, 2 for deletion
Shell_NotifyIcon (0, Istr_icon)
Parent.hide ()
Releasing resources
FreeLibrary (Ll_handle)
Create a user-defined event ue_event,event ID for the window pbm_custom01, write script for it:
M_popup Lm_popup
Integer li_x, Li_y
Choose Case lparam
Case 513//Lbuttonup
Delete icon
Shell_NotifyIcon (2, Istr_icon)
Display window
This.show ()
Case 517//Rbuttonup
li_x = this.x
Li_y = This.y
Move out of the screen to avoid show when you can turn off this sentence to see what effect
This.move (-this.width-10,-this.height-10)
Add this to see the menu bar (the menu bar belongs to this windows)
This.show ()
Lm_popup = CREATE M_popup
Lm_popup.m_item. Popmenu (Pointerx (), Pointery ())
Restore settings
This.hide ()
This.move (li_x, li_y)
DESTROY Lm_popup
End Choose
In which, "m_popup" to minimize the TrayIcon icon when you right-click when the menu pops up.