'Windows onlyFunction SetIcon() ?Win32 SendMessageW(GetActiveWindow(), WM_SETICON, 0, LParam(LoadIconW(GetModuleHandleW(Null), 101))) ?End Function
SuperStrict' WndProc() based on code by grable at:' http://www.blitzbasic.com/Community/posts.php?topic=67031Const WINDOW_FLAGS:Int = WINDOW_TITLEBAR | WINDOW_RESIZABLEGlobal window:TGadget = CreateWindow( "Test", 64,64, 256,256, Null, WINDOW_FLAGS | WINDOW_CLIENTCOORDS)Global OldWindowFunc:Int = SetWindowFunc( window, WindowFunc)While WaitEvent() Select CurrentEvent.ID Case EVENT_WINDOWCLOSE If CurrentEvent.Source = window Then Exit EndSelectWendEndFunction DriveFromMask:String( unitmask:Int) Local i:Int For i = 0 Until 26 If unitmask & $1 Then Exit unitmask :Shr 1 Next Return Chr(Asc("A") + i)EndFunctionFunction WindowFunc:Int( hwnd:Int, msg:Int, wparam:Int, lparam:Int) "Win32" Local hdr:Int Ptr = Int Ptr(lparam) Select msg Case WM_DEVICECHANGE Select wparam Case DBT_DEVICEARRIVAL If hdr[1] = DBT_DEVTYP_VOLUME Then If hdr[4] & DBTF_MEDIA Then ' cdrom / disk drive Notify "Media inserted into drive " + DriveFromMask( hdr[3]) Else ' other / usb Notify "Inserted volume as drive " + DriveFromMask( hdr[3]) EndIf EndIf Case DBT_DEVICEREMOVECOMPLETE If hdr[1] = DBT_DEVTYP_VOLUME Then If hdr[4] & DBTF_MEDIA Then ' cdrom / disk drive Notify "Media removed from drive " + DriveFromMask( hdr[3]) Else ' other / usb Notify "Removed volume registered as drive " + DriveFromMask( hdr[3]) EndIf EndIf EndSelect ' this MUST be handled, otherwise MaxGUI freezes on window close. Case WM_DESTROY SetWindowLong( hwnd, GWL_WNDPROC, OldWindowFunc) EndSelect Return CallWindowProc( OldWindowFunc, hwnd, msg, wparam, Int(lparam))EndFunction'' device change notification'Const WM_DEVICECHANGE:Int = 537Const DBT_NO_DISK_SPACE:Int = $47Const DBT_CONFIGMGPRIVATE:Int = $7FFFConst DBT_DEVICEARRIVAL:Int = $8000Const DBT_DEVICEQUERYREMOVE:Int = $8001Const DBT_DEVICEQUERYREMOVEFAILED:Int = $8002Const DBT_DEVICEREMOVEPENDING:Int = $8003Const DBT_DEVICEREMOVECOMPLETE:Int = $8004Const DBT_DEVICETYPESPECIFIC:Int = $8005Const DBT_DEVTYP_OEM:Int = 0Const DBT_DEVTYP_DEVNODE:Int = 1Const DBT_DEVTYP_VOLUME:Int = 2Const DBT_DEVTYP_PORT:Int = 3Const DBT_DEVTYP_NET:Int = 4Const DBT_DEVTYP_DEVICEINTERFACE:Int = 5Const DBT_DEVTYP_HANDLE:Int = 6Const DBT_APPYBEGIN:Int = 0Const DBT_APPYEND:Int = 1Const DBT_DEVNODES_CHANGED:Int = 7Const DBT_QUERYCHANGECONFIG:Int = $17Const DBT_CONFIGCHANGED:Int = $18Const DBT_CONFIGCHANGECANCELED:Int = $19Const DBT_MONITORCHANGE:Int = $1BConst DBT_SHELLLOGGEDON:Int = 32Const DBT_CONFIGMGAPI32:Int = 34Const DBT_VXDINITCOMPLETE:Int = 35Const DBT_VOLLOCKQUERYLOCK:Int = $8041Const DBT_VOLLOCKLOCKTAKEN:Int = $8042Const DBT_VOLLOCKLOCKFAILED:Int = $8043Const DBT_VOLLOCKQUERYUNLOCK:Int = $8044Const DBT_VOLLOCKLOCKRELEASED:Int = $8045Const DBT_VOLLOCKUNLOCKFAILED:Int = $8046Const DBT_USERDEFINED:Int = $FFFFConst DBTF_MEDIA:Int = 1Const DBTF_NET:Int = 2Const DEVICE_NOTIFY_WINDOW_HANDLE:Int = 0Const DEVICE_NOTIFY_SERVICE_HANDLE:Int = 1Const DEVICE_NOTIFY_ALL_INTERFACE_CLASSES:Int = 4'' setting window function'Const GWL_WNDPROC:Int = -4Extern "Win32" Function SetWindowLong:Int(HWND:Int,nIndex:Int,dwNewLong:Int) = "SetWindowLongA@12" Function GetWindowLong:Int(HWND:Int,nIndex:Int) = "GetWindowLongA@8" Function CallWindowProc:Int( prevwndproc:Int, hwnd:Int, msg:Int, wparam:Int, lparam:Int) = "CallWindowProcA@20"EndExternFunction SetWindowFunc:Int( window:TGadget, newfunc:Int( hwnd:Int, msg:Int, wparam:Int, lparam:Int)) Local hwnd:Int = QueryGadget( window, QUERY_HWND) Local oldfunc:Int = GetWindowLong( hwnd, GWL_WNDPROC) SetWindowLong( hwnd, GWL_WNDPROC, Int(Byte Ptr newfunc)) Return oldfuncEndFunction
Hi,This is an old bit of code from my library, so I don't know if it needs updating, but it might help you with your question...Basically, you save the current WndProc and insert your own, calling the old one at the end...Code: [Select]SuperStrict' WndProc() based on code by grable at:' http://www.blitzbasic.com/Community/posts.php?topic=67031Const WINDOW_FLAGS:Int = WINDOW_TITLEBAR | WINDOW_RESIZABLEGlobal window:TGadget = CreateWindow( "Test", 64,64, 256,256, Null, WINDOW_FLAGS | WINDOW_CLIENTCOORDS)Global OldWindowFunc:Int = SetWindowFunc( window, WindowFunc)While WaitEvent() Select CurrentEvent.ID Case EVENT_WINDOWCLOSE If CurrentEvent.Source = window Then Exit EndSelectWendEndFunction DriveFromMask:String( unitmask:Int) Local i:Int For i = 0 Until 26 If unitmask & $1 Then Exit unitmask :Shr 1 Next Return Chr(Asc("A") + i)EndFunctionFunction WindowFunc:Int( hwnd:Int, msg:Int, wparam:Int, lparam:Int) "Win32" Local hdr:Int Ptr = Int Ptr(lparam) Select msg Case WM_DEVICECHANGE Select wparam Case DBT_DEVICEARRIVAL If hdr[1] = DBT_DEVTYP_VOLUME Then If hdr[4] & DBTF_MEDIA Then ' cdrom / disk drive Notify "Media inserted into drive " + DriveFromMask( hdr[3]) Else ' other / usb Notify "Inserted volume as drive " + DriveFromMask( hdr[3]) EndIf EndIf Case DBT_DEVICEREMOVECOMPLETE If hdr[1] = DBT_DEVTYP_VOLUME Then If hdr[4] & DBTF_MEDIA Then ' cdrom / disk drive Notify "Media removed from drive " + DriveFromMask( hdr[3]) Else ' other / usb Notify "Removed volume registered as drive " + DriveFromMask( hdr[3]) EndIf EndIf EndSelect ' this MUST be handled, otherwise MaxGUI freezes on window close. Case WM_DESTROY SetWindowLong( hwnd, GWL_WNDPROC, OldWindowFunc) EndSelect Return CallWindowProc( OldWindowFunc, hwnd, msg, wparam, Int(lparam))EndFunction'' device change notification'Const WM_DEVICECHANGE:Int = 537Const DBT_NO_DISK_SPACE:Int = $47Const DBT_CONFIGMGPRIVATE:Int = $7FFFConst DBT_DEVICEARRIVAL:Int = $8000Const DBT_DEVICEQUERYREMOVE:Int = $8001Const DBT_DEVICEQUERYREMOVEFAILED:Int = $8002Const DBT_DEVICEREMOVEPENDING:Int = $8003Const DBT_DEVICEREMOVECOMPLETE:Int = $8004Const DBT_DEVICETYPESPECIFIC:Int = $8005Const DBT_DEVTYP_OEM:Int = 0Const DBT_DEVTYP_DEVNODE:Int = 1Const DBT_DEVTYP_VOLUME:Int = 2Const DBT_DEVTYP_PORT:Int = 3Const DBT_DEVTYP_NET:Int = 4Const DBT_DEVTYP_DEVICEINTERFACE:Int = 5Const DBT_DEVTYP_HANDLE:Int = 6Const DBT_APPYBEGIN:Int = 0Const DBT_APPYEND:Int = 1Const DBT_DEVNODES_CHANGED:Int = 7Const DBT_QUERYCHANGECONFIG:Int = $17Const DBT_CONFIGCHANGED:Int = $18Const DBT_CONFIGCHANGECANCELED:Int = $19Const DBT_MONITORCHANGE:Int = $1BConst DBT_SHELLLOGGEDON:Int = 32Const DBT_CONFIGMGAPI32:Int = 34Const DBT_VXDINITCOMPLETE:Int = 35Const DBT_VOLLOCKQUERYLOCK:Int = $8041Const DBT_VOLLOCKLOCKTAKEN:Int = $8042Const DBT_VOLLOCKLOCKFAILED:Int = $8043Const DBT_VOLLOCKQUERYUNLOCK:Int = $8044Const DBT_VOLLOCKLOCKRELEASED:Int = $8045Const DBT_VOLLOCKUNLOCKFAILED:Int = $8046Const DBT_USERDEFINED:Int = $FFFFConst DBTF_MEDIA:Int = 1Const DBTF_NET:Int = 2Const DEVICE_NOTIFY_WINDOW_HANDLE:Int = 0Const DEVICE_NOTIFY_SERVICE_HANDLE:Int = 1Const DEVICE_NOTIFY_ALL_INTERFACE_CLASSES:Int = 4'' setting window function'Const GWL_WNDPROC:Int = -4Extern "Win32" Function SetWindowLong:Int(HWND:Int,nIndex:Int,dwNewLong:Int) = "SetWindowLongA@12" Function GetWindowLong:Int(HWND:Int,nIndex:Int) = "GetWindowLongA@8" Function CallWindowProc:Int( prevwndproc:Int, hwnd:Int, msg:Int, wparam:Int, lparam:Int) = "CallWindowProcA@20"EndExternFunction SetWindowFunc:Int( window:TGadget, newfunc:Int( hwnd:Int, msg:Int, wparam:Int, lparam:Int)) Local hwnd:Int = QueryGadget( window, QUERY_HWND) Local oldfunc:Int = GetWindowLong( hwnd, GWL_WNDPROC) SetWindowLong( hwnd, GWL_WNDPROC, Int(Byte Ptr newfunc)) Return oldfuncEndFunction