WIn32-Events & Scintilla

BlitzMax Forums/BlitzMax Programming/WIn32-Events & Scintilla

i plan to use scintilla gadget... the problem is, that i can't get scintilla-events...

i found how to do this with C++ (last topic)
http://scintilla.sourceforge.net/Steps.html

i also use AddHook(EmitEventHook, eventfunc) in blitzmax
at this way i get more events... but only few from scintilla... it looks that blitzmax eats all other events

Since Scintilla sends its events to the parent window, you could replace the WindowFunc of the parent with your own.

Either create your own parent window and handle it manually, or use a Panel.

i tested panel - but this do not work
i do not plan to create my own windows using winapi

but i have no plan how can i replace WindowFunc

Check out the example in this thread, it shows how to replace the windowfunc.
Handling WM_DEVICECHANGE

i see many times ***** CONTENT UNAVAILABLE *****
i don't know why...

can you post this code here?

SuperStrict

Const WINDOW_FLAGS:Int = WINDOW_TITLEBAR | WINDOW_RESIZABLE

Global 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
	EndSelect
Wend
End

Function 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)
EndFunction

Function 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 = 537

Const DBT_NO_DISK_SPACE:Int = $47
Const DBT_CONFIGMGPRIVATE:Int = $7FFF
Const DBT_DEVICEARRIVAL:Int = $8000
Const DBT_DEVICEQUERYREMOVE:Int = $8001
Const DBT_DEVICEQUERYREMOVEFAILED:Int = $8002
Const DBT_DEVICEREMOVEPENDING:Int = $8003
Const DBT_DEVICEREMOVECOMPLETE:Int = $8004
Const DBT_DEVICETYPESPECIFIC:Int = $8005
Const DBT_DEVTYP_OEM:Int = 0
Const DBT_DEVTYP_DEVNODE:Int = 1
Const DBT_DEVTYP_VOLUME:Int = 2
Const DBT_DEVTYP_PORT:Int = 3
Const DBT_DEVTYP_NET:Int = 4
Const DBT_DEVTYP_DEVICEINTERFACE:Int = 5
Const DBT_DEVTYP_HANDLE:Int = 6
Const DBT_APPYBEGIN:Int = 0
Const DBT_APPYEND:Int = 1
Const DBT_DEVNODES_CHANGED:Int = 7
Const DBT_QUERYCHANGECONFIG:Int = $17
Const DBT_CONFIGCHANGED:Int = $18
Const DBT_CONFIGCHANGECANCELED:Int = $19
Const DBT_MONITORCHANGE:Int = $1B
Const DBT_SHELLLOGGEDON:Int = 32
Const DBT_CONFIGMGAPI32:Int = 34
Const DBT_VXDINITCOMPLETE:Int = 35
Const DBT_VOLLOCKQUERYLOCK:Int = $8041
Const DBT_VOLLOCKLOCKTAKEN:Int = $8042
Const DBT_VOLLOCKLOCKFAILED:Int = $8043
Const DBT_VOLLOCKQUERYUNLOCK:Int = $8044
Const DBT_VOLLOCKLOCKRELEASED:Int = $8045
Const DBT_VOLLOCKUNLOCKFAILED:Int = $8046
Const DBT_USERDEFINED:Int = $FFFF

Const DBTF_MEDIA:Int = 1
Const DBTF_NET:Int = 2

Const DEVICE_NOTIFY_WINDOW_HANDLE:Int = 0
Const DEVICE_NOTIFY_SERVICE_HANDLE:Int = 1
Const DEVICE_NOTIFY_ALL_INTERFACE_CLASSES:Int = 4


'
' setting window function
'
Const GWL_WNDPROC:Int = -4

Extern "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"
EndExtern

Function 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 oldfunc
EndFunction


I have no idea why the code wont show, if i edit the posts the code is still there.

weird, anyone else having trouble like this??

In the meantime try this link http://grable0.googlepages.com/WM_DEVICECHANGE.bmx

thank you, i will check this code...