根据程序基本框架,可以根据需要建立多窗口程序(其中包括多个窗口共有一个wndpro,以及一个窗口一个wndpro).
方法很简单: 定义不同的窗口类,每个窗口类启用不同的回调函数;同一窗口类,创建不同窗口实例.
这里给出的例子为后者,以下为具体改变的代码行:
// create the first windowif (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "窗口1号", // title WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0,0, // initial x,y 400,400, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parmsreturn(0);// create the second windowif (!(hwnd = CreateWindowEx(NULL, // extended style WINDOW_CLASS_NAME, // class "窗口2号", // title WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100,100, // initial x,y 400,400, // initial width, height NULL, // handle to parent NULL, // handle to menu hinstance,// instance of this application NULL))) // extra creation parmsreturn(0);
这样就得到了两个窗口实例.
大家也许注意到,其hwnd是一样的.这个值也可以由你自己去决定--->你可以选用不同的标识符,如hwnd1,hwnd2等.
把这些输入到你的代码中去,有问题与我联系--->给我留言^_^