🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.msdos.programmer
2 messages
2 total messages Started by Lady of the BitMode Fri, 08 Jan 1993 05:58
Borland C/C++ blues
#1091
Author: Lady of the BitMode
Date: Fri, 08 Jan 1993 05:58
43 lines
1773 bytes
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.

Basically, the program is terminating before anythings happends and all the the defined window get is a captions and a outline of  aa button.

Why ?, I copied this program out of a book. does anyone know why it won't run.
actual code followins.

*All code is small*

test.c:
=============================================================================
#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;
  } 

test.def
=============================================================================
EXETYPE	WINDOWS
STUB	'WINSTUB.EXE'
CODE	PRELOAD MOVEABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120

test.prj
=============================================================================
test.c
test.def                                                                                 
Re: Borland C/C++ blues
#1095
Author: RAVET, STEVEN
Date: Sat, 09 Jan 1993 01:36
43 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads