Click here to Skip to main content
15,892,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Cancelling ESC in dialogs Pin
Rickard Andersson2019-Mar-02 1:56
Rickard Andersson2019-Mar-02 1:56 
GeneralRe: Cancelling ESC in dialogs Pin
alex.barylski19-Mar-02 9:57
alex.barylski19-Mar-02 9:57 
QuestionHow create Folder in Class View VS.NET??? Pin
Alexey Kourakolov18-Mar-02 17:28
Alexey Kourakolov18-Mar-02 17:28 
AnswerRe: How create Folder in Class View VS.NET??? Pin
Tomasz Sowinski18-Mar-02 22:51
Tomasz Sowinski18-Mar-02 22:51 
QuestionHow I can add handler for Toolbar button in VS.NET (VC/MFC) Pin
Alexey Kourakolov18-Mar-02 17:25
Alexey Kourakolov18-Mar-02 17:25 
GeneralLPT port Pin
18-Mar-02 16:44
suss18-Mar-02 16:44 
QuestionHow to extend the all edit-like control in my code? Any idea? Pin
Aaron K.B. Huang18-Mar-02 16:37
Aaron K.B. Huang18-Mar-02 16:37 
AnswerRe: How to extend the all edit-like control in my code? Any idea? Pin
Paul M Watt18-Mar-02 19:47
mentorPaul M Watt18-Mar-02 19:47 
You can do that with local superclassing.

Subclassing is where you replace the windowproc of a window or control after it is created.

Local Superclassing is where you register a new class in your process that has the same name as one of the controls that have already been defined. When windows attempts to create a new control that has been superclasses, it will look in the local class definitions before it looks in the global definitions.

Here is an example of the code that you can add to make it so that every time that you hit a key in the edit box, a beep will sound. You can make the changes to do what you need to do.

WNDPROC lpfnEditClassProc = NULL;

LRESULT CALLBACK LocalEdit_WndProc(HWND hwnd, UINT msg, 
                                   WPARAM wParam, LPARAM lParam)
{
   if (msg == WM_CHAR ) {
     MessageBeep(-1);
   }
   return CallWindowProc(lpfnEditClassProc, hwnd, msg, wParam, lParam);
}

BOOL CreateLocalEditClass()
{
   WNDCLASS wc;

   if ( lpfnEditClassProc == NULL ) {
      GetClassInfo(NULL, "Edit", &wc);
      lpfnEditClassProc = (WNDPROC) wc.lpfnWndProc;
      wc.lpfnWndProc = LocalEdit_WndProc;
      wc.lpszClassName   = "Edit";
      wc.hInstance = _hInstance;
      if (!RegisterClass(&wc))
         return FALSE;

      return TRUE;
   }
}

void DeleteLocalEditClass()
{
   if ( lpfnEditClassProc != NULL ) {
      UnregisterClass("Edit", _hInstance);
      lpfnEditClassProc = NULL;
   }
}



If you need to change every edit control in windows to do what you want, you can look into global superclassing, but this is generally not a good idea.
GeneralRe: How to extend the all edit-like control in my code? Any idea? Pin
Aaron K.B. Huang18-Mar-02 21:03
Aaron K.B. Huang18-Mar-02 21:03 
Generalstart a program which start at logon Pin
FutureWizard18-Mar-02 16:23
FutureWizard18-Mar-02 16:23 
GeneralRe: start a program which start at logon Pin
Nish Nishant18-Mar-02 17:38
sitebuilderNish Nishant18-Mar-02 17:38 
QuestionHow to make a window(?) Pin
SilverShalkin18-Mar-02 14:06
SilverShalkin18-Mar-02 14:06 
AnswerRe: How to make a window(?) Pin
Christian Graus18-Mar-02 14:16
protectorChristian Graus18-Mar-02 14:16 
AnswerRe: How to make a window(?) Pin
Nish Nishant18-Mar-02 14:21
sitebuilderNish Nishant18-Mar-02 14:21 
GeneralCWnd::CreateEx Pin
SilverShalkin18-Mar-02 15:26
SilverShalkin18-Mar-02 15:26 
GeneralRe: CWnd::CreateEx Pin
realfly18-Mar-02 15:56
realfly18-Mar-02 15:56 
GeneralRe: CWnd::CreateEx Pin
realfly18-Mar-02 15:59
realfly18-Mar-02 15:59 
GeneralRe: CWnd::CreateEx Pin
Christian Graus18-Mar-02 16:03
protectorChristian Graus18-Mar-02 16:03 
GeneralRe: CWnd::CreateEx Pin
Nish Nishant18-Mar-02 17:05
sitebuilderNish Nishant18-Mar-02 17:05 
AnswerRe: How to make a window(?) Pin
Tomasz Sowinski18-Mar-02 23:43
Tomasz Sowinski18-Mar-02 23:43 
GeneralHopefully easy doc/view question Pin
Coremn18-Mar-02 13:28
Coremn18-Mar-02 13:28 
GeneralRe: Hopefully easy doc/view question Pin
Joaquín M López Muñoz18-Mar-02 13:30
Joaquín M López Muñoz18-Mar-02 13:30 
GeneralRe: Hopefully easy doc/view question Pin
Nish Nishant18-Mar-02 13:40
sitebuilderNish Nishant18-Mar-02 13:40 
GeneralRe: Hopefully easy doc/view question Pin
Derek Waters18-Mar-02 14:19
Derek Waters18-Mar-02 14:19 
GeneralRe: Hopefully easy doc/view question Pin
realfly18-Mar-02 14:17
realfly18-Mar-02 14:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.