PC Review


Reply
Thread Tools Rate Thread

Custom message loop

 
 
Nak
Guest
Posts: n/a
 
      7th Jul 2004
Hi there,

I am attempting to make a custom message loop in VB.NET so that I can
use it for interprocess communication. At current I am successfully
creating a window class that never actually gets drawn to screen so that I
can recieve messages, this seems to work but for only a few messages then
all of a sudden my application seems to start unloading.

I have a class that exposes shared methods, mainly windows API's and
types, after a couple of messages have been sent to the "windowless" I can
no longer use any of the shared methods as I am being told that the object
is not referenced, I never thought it was??!?

I am wondering if there is anything else that I should be processing in
order to keep this object alive, currently my Windows message handler looks
like so...

-----

Private Function MyWndProc(ByVal hWnd As Integer, ByVal msgvalue As Integer,
ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Dim pIntRetVal As Integer

Select Case msgvalue
Case WM_DESTROY
Call PostQuitMessage(0)
Case Else
RaiseEvent messageRecieved(msgvalue, wParam, lParam)
pIntRetVal = DefWindowProc(hWnd, msgvalue, wParam, lParam)
End Select

Return (pIntRetVal)

End Function

-----

I seem to be able to send about 2 or 3 of my own messages to the window
before it suddenly stops working, maybe it has something to do with
DefWindowProc being called at the wrong time?

If anyone has any suggestions I would be most appreciative. Thanks
loads in advance!!!

Nick.



 
Reply With Quote
 
 
 
 
Peter Huang
Guest
Posts: n/a
 
      8th Jul 2004
Hi Nak,

I suggest you create a new thread to do the interprocess communication by
message loop. Because one thread will be associated with one message queue,
if there is something making MyWndProc hang, then all the thread including
the main window's winproc will hang.

Also can you describe your senario more detailed, there may be another
solution.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      11th Jul 2004
Ahh, not to worry, I have utilized the NativeForm class to produce a
solution that actually works.

Nick.

"Nak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi there,
>
> I am attempting to make a custom message loop in VB.NET so that I can
> use it for interprocess communication. At current I am successfully
> creating a window class that never actually gets drawn to screen so that I
> can recieve messages, this seems to work but for only a few messages then
> all of a sudden my application seems to start unloading.
>
> I have a class that exposes shared methods, mainly windows API's and
> types, after a couple of messages have been sent to the "windowless" I can
> no longer use any of the shared methods as I am being told that the object
> is not referenced, I never thought it was??!?
>
> I am wondering if there is anything else that I should be processing

in
> order to keep this object alive, currently my Windows message handler

looks
> like so...
>
> -----
>
> Private Function MyWndProc(ByVal hWnd As Integer, ByVal msgvalue As

Integer,
> ByVal wParam As Integer, ByVal lParam As Integer) As Integer
> Dim pIntRetVal As Integer
>
> Select Case msgvalue
> Case WM_DESTROY
> Call PostQuitMessage(0)
> Case Else
> RaiseEvent messageRecieved(msgvalue, wParam, lParam)
> pIntRetVal = DefWindowProc(hWnd, msgvalue, wParam, lParam)
> End Select
>
> Return (pIntRetVal)
>
> End Function
>
> -----
>
> I seem to be able to send about 2 or 3 of my own messages to the

window
> before it suddenly stops working, maybe it has something to do with
> DefWindowProc being called at the wrong time?
>
> If anyone has any suggestions I would be most appreciative. Thanks
> loads in advance!!!
>
> Nick.
>
>
>



 
Reply With Quote
 
Nak
Guest
Posts: n/a
 
      12th Jul 2004
Hi Peter,

I managed to get a working solution via inheriting from NativeForm. All
is sorted now!

Nick.

""Peter Huang"" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Nak,
>
> I suggest you create a new thread to do the interprocess communication by
> message loop. Because one thread will be associated with one message

queue,
> if there is something making MyWndProc hang, then all the thread including
> the main window's winproc will hang.
>
> Also can you describe your senario more detailed, there may be another
> solution.
>
> Best regards,
>
> Peter Huang
> Microsoft Online Partner Support
>
> Get Secure! - www.microsoft.com/security
> This posting is provided "AS IS" with no warranties, and confers no

rights.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
My custom loop is getting stuck at the end =?Utf-8?B?bWFyem9sZnM=?= Microsoft Powerpoint 3 23rd Mar 2006 06:53 PM
Custom Show - Ending the loop =?Utf-8?B?RGF2ZXlDNFM=?= Microsoft Powerpoint 6 15th Feb 2006 03:53 PM
Continuous Loop of Custom Show =?Utf-8?B?SkNvbg==?= Microsoft Powerpoint 6 10th Feb 2006 04:01 PM
Application_OnError loop with custom object =?Utf-8?B?TWFydHkgVS4=?= Microsoft ASP .NET 1 23rd Sep 2004 06:47 PM
custom message form recieved without custom fields - outlook 2000 motiv8d Microsoft Outlook Form Programming 1 5th Mar 2004 12:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:31 AM.