home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / alt / msdos / programm / 3119 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  2.2 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!tamsun.tamu.edu!zeus.tamu.edu!s0r1282
  2. From: s0r1282@zeus.tamu.edu (RAVET, STEVEN)
  3. Newsgroups: alt.msdos.programmer
  4. Subject: Re: Borland C/C++ blues
  5. Date: 8 Jan 1993 19:36 CST
  6. Organization: Texas A&M University, Academic Computing Services
  7. Lines: 44
  8. Distribution: usa
  9. Message-ID: <8JAN199319363281@zeus.tamu.edu>
  10. References: <1993Jan8.055812.26546@wariat.org>
  11. NNTP-Posting-Host: zeus.tamu.edu
  12. News-Software: VAX/VMS VNEWS 1.41    
  13.  
  14. In article <1993Jan8.055812.26546@wariat.org>, erica@wariat.org (Lady of the BitMode) writes...
  15. >Hello, a have a question about borland c++/c 3.1.
  16. >I running win3.1 under dos5.0. I own borland c/c++ 3.1.
  17.  
  18. >WHen I compile and execute the following code the windows just vanishes
  19. >away before I can cause an event to happen to exit WaitMessage function
  20. >call. Also, the text part of the button on the window is blank.
  21. >=============================================================================
  22. >#include <windows.h>
  23. >int PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine,
  24. >int nCmdShow )
  25. >  {
  26. >  HWND hWnd;
  27. >  hWnd= CreateWindow( "BUTTON", "PRESS ME", BS_PUSHBUTTON,
  28. >  10, 10, 100, 100, NULL, NULL, hInstance, NULL ) ;
  29. >  ShowWindow( hWnd, nCmdShow ) ;
  30. >  WaitMessage();
  31. >  return 0;
  32. >  } 
  33.  
  34. I think the problem is that in the process of creating a window, many messages
  35. are sent to the window before it is actually displayed on the screen.  my
  36. guess is that you program starts the window creation in motion, waits for one
  37. message (probably WM_CREATE), and then exits.  the problem is that the window
  38. has not been displayed yet, and certainly is not ready for user input yet.
  39. i think if you use GetMessage(), you will have better results:
  40.  
  41.     MSG msg;
  42.  
  43.   do {
  44.     GetMessage(&msg,hWnd,0,0):
  45.   }  while (msg.message!=WM_COMMAND);
  46.  
  47. take out the WaitMessage() call, and use this instead.  This code ignores
  48. all messages from windows except for the WM_COMMAND message, which signals
  49. user input.  Actuall, DefWindowProc() should be called for any message that
  50. you ignore, but that's probably not important for this example.
  51. Bear in mind that I did not try to compile or run this, and it might be total
  52. crap.  But I don't think it is.  Good luck.
  53. --Steve
  54.  
  55.