Minimize the window to the small icon next to the clock
Edit: Panya
Establish a main window "w_main":
The window is defined as shown in "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 Loadcon (Long Long, Long Long) Library "User32" Alias for Loadicona
Define structural variables:
S_STR:
Size unsignedlong hwnd long id unsignedlong flags unsignedlong callback measureage unsignedlong icon long tips [64] character
Define instance variables:
Private:
s_str istr_icon
The window minimizes button Click event writes the following Script:
String Ls_Resource
Long Ll_Handle
// The next three sentences are loaded into the icon resource, NotePad.exe is set to 1 icon displayed when executed when execute is executed.
Ls_Resource = "notepad.exe"
LL_HANDLE = LoadLibrary (ls_resource)
Istr_icon.icon = loading (ll_handle, 1)
// Window callback event number, PBM_CUSTOM01 is 1024, 02 is 1025, according to this type
Istr_icon.callbackMessage = 1024
Istr_ICon.tips = "Application"
Istr_icon.hwnd = handle (parent)
Istr_icon.size = 88
Istr_ICON.ID = 1
/ / Identifier, that is, to display TIPS 4, display ICON 2, activate the window corresponding event number
Istr_icon.flags = 7
/ / Display ICON key function, 0 is displayed, 1 is modified, 2 is deleted
Shell_notifyicon (0, istr_icon)
Parent.hide ()
/ / Release Resources
Freeelibrary (ll_handle)
Create user-defined events UE_EVENT for the window, Event ID is 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 to the screen to avoid Show, you can close this sentence?
THIS.MOVE (- this.width - 10, - this.Height - 10)
/ / Add this sentence to see the menu bar (menu belongs to this Windows)
This.show ()
LM_POPUP = CREATE M_POPUPLM_POPUP.M_ITEM.PopMenu (PointerX (), Pointery ())
// Restore settings
This.hide ()
THIS.MOVE (Li_X, Li_Y)
Destroy LM_POPUP
End chaoose
Among them, "m_popup" clicks the menu that pops up when you right-click when you minimize the TRAYICON icon.