473,396 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

borland c++ event handler crash

I am trying to write a program in Borland c++ 5.5 which has multiple
windows.

I am having trouble registering an event to be called from one class
to another.

I have two classes in my application. One class manages all the
windows in the app (TWinMan) and the other represents a particular
window (TWindow). When TWinMan is created it registers the window
class and assigns the WndProc function to a static member of TWindow.

Whenever this static function receives a WM_CREATE event it uses
SetWindowsLong to put the this pointer into GWL_USERDATA. Then
whenever another event is received it calls the appropriate member
function for the this pointer.

I need to app to close when all windows in TWinMan are closed. I
therefore am trying to set up and event so that whenever a TWindow
gets a WM_CLOSE message it raises an event in TWinMan so it can
deallocate the class instance and check to see if it needs to close
the application.

Whenver I close the window though I get a windows crash.

Thanks for any help
Gareth Williams

Some code:

typedef void __fastcall (__closure *TMyEvent)();

class TWindow {
....
public: TMyEvent OnClose;
....
}

class TWinMan {
....
private:
void __fastcall _windowKilled();
TWindow* _win[255];
....
}

void TWinMan::AddWindow(char* title, int width, int height, int bits)
{
....
_win[_winCount] = new TWindow(...);
_win[_winCount]->OnClose=_windowKilled;
....
}

bool TWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
switch (uMsg)
{
...
case WM_CLOSE:
{
if(OnClose!=NULL)OnClose();
return TRUE;
}
}
return FALSE; // unhandled message (invoke default wndproc)
}
Jul 23 '05 #1
1 2367
Turbo_King wrote:
I am trying to write a program in Borland c++ 5.5 which has multiple
windows.

I am having trouble registering an event to be called from one class
to another.

Events (especially windowing events) and Windowing is not
a part of the _standard_ C++ language and thus is not
discussed here. You'll find better resources in a Borland
newsgroup or a Windows newsgroup. Read the Welcome.txt
and FAQs below for newsgroup ideas.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
17
by: Ziggi | last post by:
Hi. I want to get a C++ IDE, but I dont know whether to go for Bill Gate's solution or Borland's. Could any kind folks detail the relative strength and weaknesses of both, and also tell me which...
5
by: Charles Law | last post by:
I think I asked the wrong question last time, so I am starting a separate post to distinguish them. Take five classes: ClassA and ClassW...Z ClassA raises five events: Event1...5 ClassW...Z...
3
by: DS | last post by:
I seem to have stumbled upon something that I can't explain and was wondering if someone else could maybe help me figure out why this happens. I've tried it in both VS2003 and with VS2005b2 and in...
11
by: anon | last post by:
Borland's BGI graphics library (GRAPHICS.LIB, GRAPHICS.TPU) has a bug which can cause the floodfill routine to crash. It's most likely to occur in C applications when compiled using the small data...
17
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and...
1
by: Sendil kumar | last post by:
Hi All, I have a C++ apllication which in turn loads the jvm. When the JVM is loaded it turns off my crash handler filter and sets its own filter by default, so, when ever a crash happens I was...
1
by: Grant Schenck | last post by:
Hello, I built a client application using C# .NET 2.0. It runs fine at a number of customer sites. One customer is reporting several users getting problems. At start up it crashes with a...
2
by: poko | last post by:
I have 3 textboxes on my form, TB1, TB2 and TB3. TB1 & TB2 are constantly being updated with new data as fast as it is received. TB3 is used to show the difference between TB1 & TB2. I convert...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.