1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#include <windows.h>
#include <commctrl.h>
LRESULT CALLBACK Procedure(HWND , UINT , WPARAM, LPARAM );
BOOL APIENTRY Dialog1Proc(HWND, UINT, WPARAM, LPARAM);
BOOL APIENTRY Tab1Proc(HWND ,UINT ,WPARAM ,LPARAM );
BOOL APIENTRY Tab2Proc(HWND ,UINT ,WPARAM ,LPARAM );
HINSTANCE hinstance;
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
static MSG msg;
static WNDCLASSEX wc;
static HWND hwnd;
// Structure de la classe de la fenêtre principale
wc.cbSize =sizeof(WNDCLASSEX);
wc.style =0;
wc.lpfnWndProc = Procedure;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = CreateSolidBrush(RGB(255,255,255));
wc.lpszMenuName = NULL;
wc.lpszClassName = "Class";
wc.hIconSm=NULL;
//Enregistrer la classe de fenêtre
if(!RegisterClassEx(&wc)) return FALSE;
//créer la fenêtre
hwnd = CreateWindowEx(WS_EX_COMPOSITED,"Class", ""
,WS_BORDER |WS_CAPTION|WS_MINIMIZEBOX |WS_SYSMENU |WS_CLIPCHILDREN ,
300,100,300,400, NULL,NULL, hinstance, NULL);
if (!hwnd) return FALSE;
ShowWindow (hwnd, nCmdShow);
UpdateWindow( hwnd );
//Boucle de message
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
/******************************************************************************/
//Procédure principale
LRESULT CALLBACK Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hwndBouton=NULL;
switch (uMsg)
{
case WM_CREATE:
hwndBouton = CreateWindow("BUTTON","testeur",
WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON ,
50,30,50,25,hwnd,NULL,NULL,NULL);
return 0;
case WM_COMMAND:
//quand on clique sur le bouton ok de la fenêtre princiaple -->
if (HIWORD (wParam)==(DWORD)hwndBouton)
{
PROPSHEETPAGE psp[2];
PROPSHEETHEADER psh;
ZeroMemory(psp, sizeof(psp));
ZeroMemory(&psh, sizeof(psh));
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE ;
psp[0].hInstance = hinstance;
psp[0]. pszTemplate = "TAB1";
psp[0].pfnDlgProc = Tab1Proc;
psp[0].pszTitle = "Onglet 1";
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = hinstance;
psp[1].pszTemplate = "TAB2";
psp[1].pfnDlgProc = Tab2Proc;
psp[1].pszTitle = "Onglet 2";
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
psh.hwndParent = hwnd;
psh.pszCaption = (LPSTR) "Propriétés";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
PropertySheet(&psh);
InvalidateRect(hwnd,NULL,TRUE);
}
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
/******************************************************************************/
//Procédure de la premiere boîte de dialogue (premier onglet)
INT_PTR CALLBACK Tab1Proc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_NOTIFY:
return FALSE;
default:
return FALSE;
}
}
/******************************************************************************/
//Procédure de la deuxième boîte de dialogue (deuxième onglet)
INT_PTR CALLBACK Tab2Proc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
return TRUE;
case WM_NOTIFY:
return FALSE;
default:
return FALSE;
}
} |
Partager