Article View: alt.msdos.programmer
Article #1095Re: Borland C/C++ blues
From: RAVET, STEVEN
Date: Sat, 09 Jan 1993 01:36
Date: Sat, 09 Jan 1993 01:36
43 lines
2346 bytes
2346 bytes
In article <1993Jan8.055812.26546@wariat.org>, erica@wariat.org (Lady of the BitMode) writes...
>Hello, a have a question about borland c++/c 3.1.
>I running win3.1 under dos5.0. I own borland c/c++ 3.1.
>WHen I compile and execute the following code the windows just vanishes
>away before I can cause an event to happen to exit WaitMessage function
>call. Also, the text part of the button on the window is blank.
>
>=============================================================================
>#include <windows.h>
>
>int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
>int nCmdShow )
> {
> HWND hWnd;
>
> hWnd= CreateWindow( "BUTTON", "PRESS ME", BS_PUSHBUTTON,
> 10, 10, 100, 100, NULL, NULL, hInstance, NULL ) ;
> ShowWindow( hWnd, nCmdShow ) ;
> WaitMessage();
> return 0;
> }
I think the problem is that in the process of creating a window, many messages
are sent to the window before it is actually displayed on the screen. my
guess is that you program starts the window creation in motion, waits for one
message (probably WM_CREATE), and then exits. the problem is that the window
has not been displayed yet, and certainly is not ready for user input yet.
i think if you use GetMessage(), you will have better results:
MSG msg;
do {
GetMessage(&msg,hWnd,0,0):
} while (msg.message!=WM_COMMAND);
take out the WaitMessage() call, and use this instead. This code ignores
all messages from windows except for the WM_COMMAND message, which signals
user input. Actuall, DefWindowProc() should be called for any message that
you ignore, but that's probably not important for this example.
Bear in mind that I did not try to compile or run this, and it might be total
crap. But I don't think it is. Good luck.
--Steve
Technical Details
Message-ID:
<8JAN199319363281@zeus.tamu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!tamsun.tamu.edu!zeus.tamu.edu!s0r1282References:
<1993Jan8.055812.26546@wariat.org>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!tamsun.tamu.edu!zeus.tamu.edu!s0r1282 From: s0r1282@zeus.tamu.edu (RAVET, STEVEN) Newsgroups: alt.msdos.programmer Subject: Re: Borland C/C++ blues Date: 8 Jan 1993 19:36 CST Organization: Texas A&M University, Academic Computing Services Lines: 44 Distribution: usa Message-ID: <8JAN199319363281@zeus.tamu.edu> References: <1993Jan8.055812.26546@wariat.org> NNTP-Posting-Host: zeus.tamu.edu News-Software: VAX/VMS VNEWS 1.41