Ciao a tutti,
vorrei sapere come fare per realizzare piu' finestre ed averne pieno controllo.
Insieme all'aiuto della guida Microsoft ho tirato fuori questo:
[CLASSE EditorCore.h]
codice:
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <tchar.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
class EditorCore
{
public:
WNDCLASSEX WndClass[10];
HWND hWnd[10];
int CreateEditorWindow(int wndcID,HINSTANCE hInstance,int nCmdShow)
{
WndClass[wndcID].cbSize = sizeof(WNDCLASSEX);
WndClass[wndcID].style = CS_HREDRAW | CS_VREDRAW;
WndClass[wndcID].lpfnWndProc = WndProc;
WndClass[wndcID].cbClsExtra = 0;
WndClass[wndcID].cbWndExtra = 0;
WndClass[wndcID].hInstance = hInstance;
WndClass[wndcID].hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
WndClass[wndcID].hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass[wndcID].hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
WndClass[wndcID].lpszMenuName = NULL;
WndClass[wndcID].lpszClassName = _T("win32app");
WndClass[wndcID].hIconSm = LoadIcon( WndClass[wndcID].hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
WindowRegister(wndcID);
hWnd[wndcID] = CreateWindow(_T("Wname"),_T("wTitle"),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT, CW_USEDEFAULT,800,600,NULL,NULL,hInstance,NULL);
if(!hWnd)
{
MessageBox(NULL,_T("Call to CreateWindow failed!"),_T("Win32 Guided Tour"),NULL);
}
ShowEditorWindow(wndcID,nCmdShow);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
void WindowRegister(int wndcID)
{
if (!RegisterClassEx(&WndClass[wndcID]))
{
MessageBox(NULL,_T("Call to RegisterClassEx Failed!"),_T("Win32 Guided Tour"),NULL);
}
}
void ShowEditorWindow(int wndID,int nCmdShow)
{
ShowWindow(hWnd[wndID],nCmdShow);
UpdateWindow(hWnd[wndID]);
}
};
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
[CLASSE Editor.cpp]
codice:
#include "EditorCore.h"
EditorCore test;
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
test.CreateEditorWindow(0,hInstance,nCmdShow);
}
Ma non funziona... non da errori e non parte...