home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5338 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.8 KB  |  90 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!mcsun!sun4nl!spider.research.ptt.nl!sun032!janssen
  3. From: janssen@sun032.research.ptt.nl (Richard Janssen)
  4. Subject: Subclassing dialog controls
  5. Message-ID: <1993Jan25.123715.27106@spider.research.ptt.nl>
  6. Sender: usenet@spider.research.ptt.nl (USEnet News)
  7. Nntp-Posting-Host: sun032.research.ptt.nl
  8. Organization: PTT Research, Groningen, the Netherlands
  9. Distribution: comp.os.ms-windows.programmer.misc
  10. Date: Mon, 25 Jan 1993 12:37:15 GMT
  11. Lines: 77
  12.  
  13. Hello, I posted this problem a week ago and got
  14. some answers, but none solved the problem.
  15. That's why I decided to repost and once again
  16. ask if one of you people can help me out.
  17.  
  18. This is a short description of the problem:
  19.  
  20. I try to "subclass" controls in a dialog (created from a .DLG template)
  21. by replacing there Window procedure by my own. I do this by calling 
  22. SetWindowLong(..) in the handling of the WM_INITDIALOG message in the
  23. Dialog Procedure.
  24.  
  25. The old Window procedure of the control (returned by SetWindowLong())
  26. is stored. The new Window procedure of the control is set up to call
  27. the old Window Procedure for all messages that are not processed.
  28.  
  29. Here is what my code looks like:
  30.  
  31. (The variable oldWindowProc is part of a C++ class for the
  32.  control, so appropriate storage space the old Window Procedure is
  33.  arranged.)  
  34.  
  35. /* DIALOG PROCEDURE */  
  36. ... DialogProc (...., WORD wParam, ...)     
  37.  
  38.    switch (wParam)
  39.    {
  40.       case WM_INITDIALOG: 
  41.          oldWindowProc = SetWindowLong(GetDlgItem(hDlg,ID_CONTROL),
  42.                                        MakeProcInstance(hInst,NewWinProc)); 
  43.          break;  
  44.       ...  
  45.    } 
  46.  
  47.  
  48.  
  49. /* NEW WINDOW PROCEDURE */  
  50. ... NewWinProc (HWND hWin, WORD wMsg, WORD  wParam, LONG lParam)   
  51. {
  52.    switch (wMsg)
  53.    {
  54.       ...
  55.  
  56.       default:
  57.          return CallWindowProc(oldWindowProc, wMsg, wParam, lParam);
  58.          break;
  59.  
  60.    }
  61.  
  62. }
  63.  
  64. The actual problem? As soon as the dialog displays the subclassed control
  65. is not displayed!! The Window is created though, which is shown by
  66. Borlands' WinSight (Borland version of Spy).
  67. In fact if the control is a button, it does display if i click my left
  68. mouse button over it. If i release the mouse button outside the button,
  69. the button stays visble! But now comes the strange part: Firt i drag the
  70. dialog box, so that the button is off the screen.  After releasing the
  71. mouse button i again drag the dialog box, moving the button position
  72. back onto the screen. The button is not drawn, it is invisble !!!
  73. Pressing the left mouse button over it displays it again, which
  74. means the window is still there.
  75.  
  76. I have tried lots of things like calling ShowWindow() and EnableWindow()
  77. after calling SetWindowLong(), it just doesn't work!!!
  78.  
  79. Can anybody please help me out !! I'm starting to get desperate !!
  80.  
  81. Mail to me at: R.H.P.Janssen@research.ptt.nl
  82.  
  83.  
  84.  
  85. Thanks ahead, Richard Janssen
  86. PTT Research, The Netherlands
  87.  
  88.  
  89.  
  90.