TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: RAY GEAR
from: ADAM MAJER
date: 1998-01-28 13:05:00
subject: Borland c++ v 4.52

Here's the explonation of my modifications your code:
RG> I change the following line from:
RG> AM> RG>                GetMainWindow()->AssignMenu("EXITMENU");
RG> to your suggestion of:
RG> AM>                    GetMainWindow()->AssignMenu(EXITMENU)      <- int
RG> which works well.
RG>With the program which crashed when the dialog was called I did the same
RG>thing...remove the quotes.
This is because EXITMENU is defined to by a number therefore the
resource compiler didn't name it EXITMENU but 5 for example. If you
opened your .exe or .res file for your program you'll know first hand
what I'm taking about - all resources are numbers unless you kept them
as strings.
    There are also two declerations for AssignMenu. One is
AssignMenu(LPSTR) and the other is
AssignMenu(int n){AssignMenu(MAKEINTRESOURCE(n));};
The int version calls the string version using the Windows macro
MAKEINTRESOURCE(a). MKEINTRESOURCE produces a string from an int. Check
help file for details (or windows.h)
RG> AM> RG>class TMyWindow : public TWindow
RG> AM> RG>{
RG> AM> RG>public:
RG> AM> RG>        TMyWindow(Twindow* parent = 0);
RG> AM> RG>        ~TMyWindow();
RG> AM> RG>protected:
RG> AM> RG>        virtual void SetupWindow();
RG> AM> RG>        BOOL CanClose();
RG> AM> Isn't CanClose() public for TWindow?
RG>Yes it is. Tried to remove this line but the compiler complained that
RG>        BOOL TMyWindow::CanClose() is not a member of  TMyWindow
RG>so I changed the procedure to:
RG>        TWindow::CanClose()
RG>this ran but every time I closed a dialog box I got the "Do you want to
RG>close" message box I call in CanClose(). By declaring CanClose as part of
RG>TMyWindow I only get the Query box when I try to close the main window.
What I meant is to put CanClose in the public: section of your class but
redeclaring TWindow::CanClose() also works. CanClose is also a virtual
function:
    class BOO
    {
        public:
         virtual BOOL CanClose();   <- decleration should look like this
    };
RG> AM> RG>        void CmExit();
RG> AM> Delete the above function. By default CanClose is called on exit and
RG>I deleted this declaration and the procedure which had
RG> SendMessage(WM_CLOSE)
RG>and as you suggested it worked well.
That's because the CmExit() in calls the CanClose function so you don't
need to redeclare CmExit(); ;-)
RG>Thanks for your help. Using OWL for programming windows is SLOWLY starting
RG>to make some sense but I guess it will take a while longer to actually
RG>understand what all the lines of code actually do.
And OWL programming is easy since the OWL engine handles all the Windows
messages quite nicely. Straight C programming is much more challenging.
If you need more help with OWL just post a message to me.
 * SLMR 2.1a * Hello, I am part number ################
--- FMail 0.92
---------------
* Origin: The Programmer's Oasis on FIDONET! (1:348/203)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.