如何sdk实现一个窗口类,对应多个窗口过程,对应多个窗口?
请给个实例,非常感谢!
wndclass.lpfnWndProc   = WndProc ;
wndclass.lpszClassName = szAppName
表明一个窗口类对应了一个窗口过程.
hwnd = CreateWindow (szAppName,....)用szAppName把窗口对应到特定窗口类。
但是如何实现一个窗口类,对应多个窗口过程,对应多个窗口?请给个框架出来.

解决方案 »

  1.   

    你再用
    别的HWND的对象来CreateWindow就好了嘛
      

  2.   

    下面是我修改的,不过有问题,是多个窗口对应一个窗口类,且子窗口的打开和关闭会相互影响#include <windows.h>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;static HWND         hwnd1,hwnd2 ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                        PSTR szCmdLine, int iCmdShow)
    {
         static TCHAR szAppName[] = TEXT ("HelloWin") ;
         
         MSG          msg ;
         WNDCLASS     wndclass ;     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
         wndclass.lpfnWndProc   = WndProc ;
         ...
         wndclass.lpszClassName = szAppName ;
         ...
         
         hwnd1 = CreateWindow (szAppName,                  // window class name
                              TEXT ("11111111111111"),  // window caption
                             ...
                              hInstance,                  // program instance handle
                              NULL) ;                     // creation parameters   hwnd2 = CreateWindow (szAppName,                  // window class name
                              TEXT ("2222222222222"), // window caption
                              ...
                              hInstance,                  // program instance handle
                              NULL) ;                     // creation parameters
         
         ShowWindow (hwnd1, iCmdShow) ;
         UpdateWindow (hwnd1) ;
      ShowWindow (hwnd2, iCmdShow) ;
         UpdateWindow (hwnd2) ;
         
         while (GetMessage (&msg, NULL, 0, 0))
         {
              TranslateMessage (&msg) ;
              DispatchMessage (&msg) ;
         }
         return msg.wParam ;
    }LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
         HDC         hdc ;
         PAINTSTRUCT ps ;
         RECT        rect ;
         
         if(hwnd == hwnd1)
         {
          switch (message)
          {          
          case WM_PAINT:
               hdc = BeginPaint (hwnd, &ps) ;        
               GetClientRect (hwnd, &rect) ;   
               DrawText (hdc, TEXT ("1111111111"), -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
               EndPaint (hwnd, &ps) ;
               return 0 ;
               
          case WM_DESTROY:
               PostQuitMessage (0) ;
               return 0 ;
          }
         }
         else
         {
          switch (message)
          {          
          case WM_PAINT:
               hdc = BeginPaint (hwnd, &ps) ;           
               GetClientRect (hwnd, &rect) ;           
               DrawText (hdc, TEXT ("222222222222"), -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;           
               EndPaint (hwnd, &ps) ;
               return 0 ;
               
          case WM_DESTROY:
               PostQuitMessage (0) ;
               return 0 ;
          }
         }
         return DefWindowProc (hwnd, message, wParam, lParam) ;
    }