Click here to Skip to main content
15,915,600 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSocket error Pin
Jamal Abdul Nasir1-Jul-10 10:53
Jamal Abdul Nasir1-Jul-10 10:53 
AnswerRe: Socket error Pin
Dave Kreskowiak1-Jul-10 12:41
mveDave Kreskowiak1-Jul-10 12:41 
QuestionWhy is it so hard to set button text for DataGridViewButtonColumn button cell Pin
Andraw Tang1-Jul-10 6:27
Andraw Tang1-Jul-10 6:27 
AnswerRe: Why is it so hard to set button text for DataGridViewButtonColumn button cell Pin
Andraw Tang1-Jul-10 6:41
Andraw Tang1-Jul-10 6:41 
AnswerRe: Why is it so hard to set button text for DataGridViewButtonColumn button cell Pin
Scubapro1-Jul-10 21:09
Scubapro1-Jul-10 21:09 
GeneralRe: Why is it so hard to set button text for DataGridViewButtonColumn button cell Pin
Andraw Tang2-Jul-10 3:21
Andraw Tang2-Jul-10 3:21 
QuestionMulti threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Аslam Iqbal1-Jul-10 0:36
professionalАslam Iqbal1-Jul-10 0:36 
AnswerRe: Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Luc Pattyn1-Jul-10 1:49
sitebuilderLuc Pattyn1-Jul-10 1:49 
Hi,

I don't think multi-threading is involved; however shaking your Form will create new objects, possibly causing the GC to run and remove a delegate that is still in use as you have stored it in unmanaged memory (SetWindowLong) so the CG cannot work out it is still in use. This is not the right way to handle this.

I do have similar functionality implemented in C#, without using any shell hooks: Windows will always broadcast Windows messages whenever a device gets added or removed, there is no need to subscribe to anything; all it takes is overriding WndProc and checking for such messages.

This is the heart of the matter (the constant values are 0x0219, 0x8000, 0x8004):
protected override void WndProc(ref Message m) {
	if (m.Msg==LPWIN_Constants.WM_DEVICECHANGE) { 
		int wParam=(int)m.WParam;
		int lParam=(int)m.LParam;
		if (xpanel!=null) {
			if (wParam==LPWIN_Constants.DBT_DEVICEARRIVAL) xpanel.DeviceAdded();
			else if (wParam==LPWIN_Constants.DBT_DEVICEREMOVECOMPLETE) xpanel.DeviceRemoved();
		}
	}
}


Smile | :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use < PRE > tags for code snippets, it preserves indentation, and improves readability.


QuestionRe: Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Аslam Iqbal2-Jul-10 9:58
professionalАslam Iqbal2-Jul-10 9:58 
AnswerRe: Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Luc Pattyn2-Jul-10 10:38
sitebuilderLuc Pattyn2-Jul-10 10:38 
GeneralRe: Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Аslam Iqbal2-Jul-10 10:43
professionalАslam Iqbal2-Jul-10 10:43 
GeneralRe: Multi threading and garbage collected problem using RegisterShellHook and SetWindowLong API. Pin
Luc Pattyn2-Jul-10 11:32
sitebuilderLuc Pattyn2-Jul-10 11:32 
Questionshare and unshare folder Pin
mehrnoosh30-Jun-10 18:27
mehrnoosh30-Jun-10 18:27 
AnswerRe: share and unshare folder Pin
Dave Kreskowiak30-Jun-10 18:37
mveDave Kreskowiak30-Jun-10 18:37 
GeneralRe: share and unshare folder Pin
mehrnoosh30-Jun-10 21:54
mehrnoosh30-Jun-10 21:54 
GeneralRe: share and unshare folder Pin
Alan N30-Jun-10 22:32
Alan N30-Jun-10 22:32 
GeneralRe: share and unshare folder Pin
Dave Kreskowiak1-Jul-10 2:16
mveDave Kreskowiak1-Jul-10 2:16 
QuestionHow can I detect child form close action in VB.NET 2005 Pin
Andraw Tang30-Jun-10 9:19
Andraw Tang30-Jun-10 9:19 
AnswerRe: How can I detect child form close action in VB.NET 2005 Pin
Dave Kreskowiak30-Jun-10 9:31
mveDave Kreskowiak30-Jun-10 9:31 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Andraw Tang30-Jun-10 9:40
Andraw Tang30-Jun-10 9:40 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Dave Kreskowiak30-Jun-10 12:39
mveDave Kreskowiak30-Jun-10 12:39 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Andraw Tang1-Jul-10 3:32
Andraw Tang1-Jul-10 3:32 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Dave Kreskowiak1-Jul-10 3:42
mveDave Kreskowiak1-Jul-10 3:42 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Andraw Tang1-Jul-10 3:59
Andraw Tang1-Jul-10 3:59 
GeneralRe: How can I detect child form close action in VB.NET 2005 Pin
Andraw Tang1-Jul-10 4:03
Andraw Tang1-Jul-10 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.