Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Hidden window for messaging-only in a TThread, need some more info


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Nov 5, 2017 7:20 AM Last Post By: Marc Van den Br...
Goran Ekstrom

Posts: 149
Registered: 1/10/04
Hidden window for messaging-only in a TThread, need some more info  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 10:31 AM
Hi,
in my TThread Execute() method (before the thread loop) I do the following:

MessageWindow = CreateWindowEx(0, class_name, L"VCLSYNC_HWIN", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, this);

In the TThread Execute method:

while(!Terminated)
{
while(PeekMessage(&Msg, MessageWindow, 0, 0, PM_REMOVE))
{
// What does this do?
TranslateMessage(&Msg);

// Is it in the context of this call that my WndProc (message handler) is called?
DispatchMessage(&Msg);
}

// Other stuff....

}

The underlying reason for my question is that I need to be sure that the thread message handler is called within the context of the thread, i.e. no multithreading issues when handling messages.

Regards
Goran

Goran Ekstrom

Posts: 149
Registered: 1/10/04
Re: Trying to create a hidden window for messaging only in a TThread  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 10:55 AM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Original post rewritten
Goran Ekstrom

Posts: 149
Registered: 1/10/04
Re: Hidden window for messaging only in a TThread, need some more info  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 12:08 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
New issues
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Hidden window for messaging-only in a TThread, need some more info[Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 12:23 PM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran wrote:

The underlying reason for my question is that I need to be sure that
the thread message handler is called within the context of the thread

It will be, since that is where your message loop and dispatching resides.

--
Remy Lebeau (TeamB)
Goran Ekstrom

Posts: 149
Registered: 1/10/04
Re: Hidden window for messaging-only in a TThread, need some more info  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 1, 2017 12:43 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Goran wrote:

The underlying reason for my question is that I need to be sure that
the thread message handler is called within the context of the thread

It will be, since that is where your message loop and dispatching resides.

Thanks Remy.
Marc Van den Br...

Posts: 10
Registered: 6/16/07
Re: Hidden window for messaging-only in a TThread, need some more info  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 5, 2017 7:20 AM   in response to: Goran Ekstrom in response to: Goran Ekstrom
Goran Ekstrom wrote:
Hi,
in my TThread Execute() method (before the thread loop) I do the following:

MessageWindow = CreateWindowEx(0, class_name, L"VCLSYNC_HWIN", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, this);

In the TThread Execute method:

while(!Terminated)
{
while(PeekMessage(&Msg, MessageWindow, 0, 0, PM_REMOVE))
{
// What does this do?
TranslateMessage(&Msg);

// Is it in the context of this call that my WndProc (message handler) is called?
DispatchMessage(&Msg);
}

// Other stuff....

}

The underlying reason for my question is that I need to be sure that the thread message handler is called within the context of the thread, i.e. no multithreading issues when handling messages.

Regards
Goran

pss edn wrote:
Since several years, I am using Indy HTTPServer in all my projects related to serving dynamic web pages.
The HTML pages are all generated in code, using a combination of static HTML code and dynamic database information.
There is also some JavaScript to make the web pages responsive.
The projects are small in size and pages, and also require a low need for bandwidth or concurrency.
For a new project that is mainly for data entry forms, I am thinking about using Intraweb instead of Indy HTTPServer.
As read in other threads, to make the application as web-responsive as possible, I want to duplicate the forms one for desktop/tablets and another for smartphones.
It is not my idea to start any debate, but to know the opinion of experienced users about what is the best option for such a project, choosing between Indy or IntraWeb.
Also, as I can see in the feature matrix of the actual Delphi version, Intraweb does not apear on it, so, what is the meaning or reason of this change.

never do while(!Terminated) and MessageWindow = CreateWindowEx(0, class_name, L"VCLSYNC_HWIN", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, this);
will kill yar application ya should use SendMessage to a eventhandler and there calling a new window , but won't work in code you use "this)" any ideay what this means?
this is the pointer where yar main entrypoint is stored ,

__fastcall BESTEL_THREAD::BESTEL_THREAD(int x)
:TThread(true)
{
FreeOnTerminate=TRUE;
Priority=3;
Resume();
};

void __fastcall BESTEL_THREAD::Execute(void)
{
char *buf=(char *)malloc(10000);
int waiting=0;
WaitForSingleObject(Route_bestel,INFINITE);

do
{
EnterCriticalSection(&Bestel_critical);
if(Form1->ListBox4->Items->Count==0)
{
WaitForSingleObject(Route_bestel,INFINITE);
waiting=1;
}

if(waiting==1)
{
waiting=0;
LeaveCriticalSection(&Bestel_critical);
continue;
};

Form1->ListBox4->ItemIndex=0;
buf=Form1->ListBox4->Items->GetText();
Form1->ListBox4->Items->Delete(0);
if(buf[0]!=0)
{
if(buf[0]=='P' && buf[1]=='T' && buf[2]=='Y')
RouteSecondServer(buf);
else
RouteBestelling(buf);
}
}
while(!Terminated);
free(buf);
};
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02