perfetto, devo notare però che la tua versione può essere riscritta anche in questo modo:
main.cpp
codice:
#include <windows.h>
#include "resource.h"
LPTSTR szClassName = "mywindowclass";
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS wndclass;
HMENU hmenu;
hmenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDM_MENU));
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szClassName;
RegisterClass(&wndclass); //registrazione della classe
hwnd = CreateWindow(szClassName, //nome della classe window
TEXT("Programma che usa una finestra di dialogo About"), //titolo della finestra(barra del titolo)
WS_OVERLAPPEDWINDOW, //stile window
GetSystemMetrics(SM_CXSCREEN) / 4, //posizione x iniziale
GetSystemMetrics(SM_CYSCREEN) / 4, //posizione y iniziale
GetSystemMetrics(SM_CXSCREEN) / 3, //dimensione x iniziale(larghezza)
GetSystemMetrics(SM_CXSCREEN) / 3, //dimensione y iniziale(altezza)
NULL, //handle alla finestra genitore
hmenu, //handle al menù della finestra
hInstance, //handle all'istanza del programma
NULL); //parametri di creazione
ShowWindow(hwnd, nCmdShow); //disegna la finestra sullo schermo, con le impostazioni iniziali date dall'utente
UpdateWindow(hwnd); //disegna l'area client della finestra
//ciclo dei messaggi
while (GetMessage(&msg, NULL, 0, 0)) //recupera un messaggio dalla coda (restituisce FALSE (0) solo per WM_QUIT)
{
TranslateMessage(&msg); //opera alcune modifiche al messaggio a seconda della tastiera
DispatchMessage(&msg); //invia il messaggio alla window procedure appropriata
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance;
switch(message)
{
case WM_CREATE:
hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
return 0;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_APP_ABOUT:
DialogBoxParam(hInstance,"ABOUTBOX",hwnd,AboutDlgProc,0);
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
BOOL CALLBACK AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
EndDialog(hDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}
resource.rc
codice:
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"
//Finestra di dialogo
ABOUTBOX DIALOG 32, 32, 180, 100
STYLE DS_MODALFRAME | WS_POPUP
FONT 8, "Ms Sans Serif"
BEGIN
DEFPUSHBUTTON "Ok", IDOK, 66, 80, 50, 14
CTEXT "About", IDC_STATIC, 40, 12, 100, 8
CTEXT "Programma che usa una finestra di dialogo About", IDC_STATIC, 7, 40, 166, 8
CTEXT "(c) THEARTOFWEB Software, 2001-2009", IDC_STATIC, 7, 52, 166, 8
END
//Menu
IDM_MENU MENU
BEGIN
POPUP "&Aiuto"
BEGIN
MENUITEM "&Informazioni su...", IDM_APP_ABOUT
END
END
resource.h
codice:
#define IDM_APP_ABOUT 5000
#define IDC_STATIC -1
#define IDM_MENU 1006
questo solo per essere più precisi!
http://en.wikibooks.org/wiki/Windows...indow_Creation