Hi all,
I'm seeing cases running my application outside the debugging environment
where WndProc is running in a separate thread context from the form and
mainline. This is causing issues trying to post messages from the middleware
since the windows handle is in a different context and therefore the
PostMessage() call returns an INVALID_WINDOW_ HANDLE error. Has anyone else
experienced this? Is there a way to force WndProc, the form, and mainline to
all run in the same thread context? Thanks for any help.
-Mike 3 3820
Just an update on the problem...when I create the debug version of the code
and run it (outside VS), I'm seeing WndProc and the form running in different
threads. The release version doesn't seem to do this. If I run in the VS
environment, it almost always assigns WndProc, the form, and the mainline
separate threads. Is there any way to override this in the debugger?
"mike2036" wrote: Hi all,
I'm seeing cases running my application outside the debugging environment where WndProc is running in a separate thread context from the form and mainline. This is causing issues trying to post messages from the middleware since the windows handle is in a different context and therefore the PostMessage() call returns an INVALID_WINDOW_ HANDLE error. Has anyone else experienced this? Is there a way to force WndProc, the form, and mainline to all run in the same thread context? Thanks for any help.
-Mike This is causing issues trying to post messages from the middleware since the windows handle is in a different context and therefore the PostMessage( ) call returns an INVALID_WINDOW_ HANDLE error.
Window handles are valid "globally" on the same desktop, and you can
call PostMessage from any thread. The only reason I can see for
PostMessage to return that error is that the handle is indeed invalid
(i.e. the window has been destroyed or the handle contains a bogus
value).
Is there a way to force WndProc, the form, and mainline to all run in the same thread context?
"the form" is an object and as such doesn't run on any specific
thread. The methods of the object run on whatever thread they are
called on.
I'm not sure what you mean by "mainline".
WndProc should definitely ony be called from the thread the window was
created on.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Hi Mattias,
Thanks for the reply. I think my problem may have something to do with the
fact that my application uses a hidden form to get messages sent to it via
WndProc, and that the window wasn't getting registered because it never went
through its 'load' event...I can see this because after I instantiate the
form, I do a Hide(), and my load event handler for the form never gets
called. If I do a Show() and then a Hide() immediately after, the window
gets 'loaded' by the Show() call, and all the thread ID are the same both
inside and outside the debugger. The windows handle is also valid. So it
looks like it was more an issue with the proper loading of the window than
separate thread IDs.
-Mike
"Mattias Sjögren" wrote: This is causing issues trying to post messages from the middleware since the windows handle is in a different context and therefore the PostMessage( ) call returns an INVALID_WINDOW_ HANDLE error.
Window handles are valid "globally" on the same desktop, and you can call PostMessage from any thread. The only reason I can see for PostMessage to return that error is that the handle is indeed invalid (i.e. the window has been destroyed or the handle contains a bogus value).
Is there a way to force WndProc, the form, and mainline to all run in the same thread context?
"the form" is an object and as such doesn't run on any specific thread. The methods of the object run on whatever thread they are called on.
I'm not sure what you mean by "mainline".
WndProc should definitely ony be called from the thread the window was created on.
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Beach Potato |
last post by:
Hi:
I've searched newsgroups and various archives, including MSDN & MFC sources,
but at this point failed to locate an accurate and simple implementation of
WndProc function for MSWindows window objects.
Something like:
class BaseWindow {
virtual LRESULT WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam);
|
by: sshuangw |
last post by:
Hello:
I am encountering a very weird issue with MDI child, Overriden WndProc
function and hidden form.
Basically, the application has two forms, Form1(parent form),
Form2(Child form), Form2's WndProc method is overriden, if the message
is CLOSE message, just hide the form. I first initialize and show the
child form, then close it by clicking the Close(X) button, the
overriden WndProc method gets invoked, and the form is hidden. Then
|
by: Ed Sutton |
last post by:
How can a WndProc be created inside a component?
Currently I have a WndProc in my frmMain. It looks for WM_DEVICECHANGE
messages for connection and removal events for a USB/Serial device. My
frmMain uses a component to communicate with a USB/Serial device. I would
prefer that this component handle the WM_DEVICECHANGE messages internally
and only fires events to my frmMain when my USB device connects or
disconnects.
In case anyone...
|
by: cyrille |
last post by:
Hello
from example from web i did a little code to avoiding columnHeader resize.
this code seems to work well,
but when I put a 'normal' ListView on the same Form than my overrided ListView
it seems to stop working.
if I'm resizing 'normal' ListView ColumnHeaders, then I can resizing ColumnHeaders of my overrided ListView.
If I don't resizing 'normal' ListView ColumnHeaders, then resizing of my overrided ListView ColumnHeaders is...
|
by: MariusI |
last post by:
Are objects implicitly stored in the TLS of the currently running thread?
When creating multithreaded applications i get errors when accessing data
from a different thread than the thread used to create the objects (which is
easely fixed by calling Invoke()). Also, is there a way to acces the thread
which created the thread, or in other words: is there a parent/child
relationship between threads?
| |
by: shengmin.ruan |
last post by:
when i use delegate like this:
-----------------
protected override void WndProc(ref Message m)
{
delegate_ReplyFromDataProcess = new
PrepareDelegate_ReplyFromDataProcess(ReplyFromDataProcess);
|
by: Chris Ashley |
last post by:
Hi,
I'm overriding WndProc to process some custom messages like so:
protected override void WndProc(ref Message m)
{
if (m.Msg == ImageFileMsg.MSG_IF_NEW_DATA)
{
ProcessNewDataMessage(m);
|
by: Rob |
last post by:
I've constructed a user control inherited from ListView so I can handle and
respond to scrolling events (to keep 2 listviews scrolling in sync).
My user control includes an Overrides of WndProc (I've attached the code at
the end of this mail). Is it possible to 'disable' this override until I need
it - it's just when I populate the ListViews this sub is called repeatadly.
What I'd like to do is populate the listviews and then 'enable'...
|
by: makifsar |
last post by:
I am using a comserver to communicate remote equipments. This server gives response via WndProc. First I call READ function to start communication and remote equipment gives response this via WndProc. Mw request is, I want to
sleep READ thead and after taking right message from WndProc, wake up this thead return this value to main thead. I am trying some methods using delagate but I can not achive it.
My Program like this
Public Void...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |