?
Solved

Threads an Forms ...

Posted on 1999-12-12
5
Medium Priority
?
163 Views
Last Modified: 2012-05-04
I'm writing a c++ builder3 app in which i need to create a form (window) within the context of the thread such that the thread owns the message que.
p.s: i would prefere to use the thread class provided with cbuilder but alternatives are welcome
0
Comment
Question by:BitHawk
  • 3
  • 2
5 Comments
 

Author Comment

by:BitHawk
ID: 2274856
Adjusted points to 150
0
 
LVL 6

Expert Comment

by:WxW
ID: 2274859
Load the form from the thread's code . For example , if your thread starts with function Funcx() , load the form within this function . Then do a standard message loop , like the same you do in the main function of your program , for example

MSG mx;
while (GetMessage(&mx,0,0,0))
  {
  TranslateMessage(&mx);
  DispatchMessage(&mx);
  }



0
 

Author Comment

by:BitHawk
ID: 2274874
WxW, that might not work because class TForm's 3 contructors require
1. a TComponent object
2. a TComponent object and an int
3. the WHND handle of the parent window

but a thread derived from TThread has TObject as its only ancestor.

Could you think of another way ?

thanx, BitHawk
0
 
LVL 6

Accepted Solution

by:
WxW earned 450 total points
ID: 2274931
Why , can't they be standalone windows ? Can't you pass NULL for a Parent Window Handle ?

In that case , your only solution will be creating the form yourself ( registering the class and doing the message box ) . As an alternative , make your form a dialog box , thats easier to process using a message loop .
0
 

Author Comment

by:BitHawk
ID: 2274950
Wxw, I think your NULL sugestion should work, let me try it out, if it works, ill give you the points.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question