
gregroar
|
#include <windows.h>
#define IDC_Discussion 1100
#define IDC_UserDlg 1200
#define ID_A 1001
#define ID_B 1002
#define ID_C 1003
#define ID_D 1004
#define ID_E 1005
#define ID_F 1006
#define ID_G 1007
#define ID_H 1008
#define ID_I 1009
#define ID_J 1010
#define ID_K 1011
#define ID_L 1012
#define ID_M 1013
#define ID_N 1014
#define ID_O 1015
#define ID_P 1016
#define ID_Q 1017
#define ID_R 1018
#define ID_S 1019
#define ID_T 1020
#define ID_U 1021
#define ID_V 1022
#define ID_W 1023
#define ID_X 1024
#define ID_Y 1025
#define ID_Z 1026
static int cxClient, cyClient ;
int cxScreen, cyScreen ;
LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int Select;
char buf[501];
HANDLE hFile;
DWORD Read;
static HWND hedit1,hedit2,hedit3,hlire,hquitter,ha,hb,hc,hd,he,hf,hg,hh,hi,hj,hk,hl,hm,hn,ho,hp,hq,hr,hs,ht,hu,hv,hw,hx,hy,hz; // Déclaration des variables en static:
switch(message)
{
// case WM_SIZE:
// cxClient = LOWORD (lParam)/2 ;
// cyClient = HIWORD (lParam)/2 ;
// return 0 ;
case WM_CREATE:
{
// Création des contrôles:
hedit1=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL
,5 ,cyClient-100 ,cxClient-30 ,40 ,hwnd,0,0,0);
hedit2=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_MULTILINE | ES_AUTOVSCROLL | WS_VSCROLL |ES_WANTRETURN
,5 ,20 ,cxClient-30 ,cyClient-150 ,hwnd,0,0,0);
// hedit3=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP,20,100,100,20,hwnd,0,0,0);
hlire=CreateWindowEx(0,"button",">>>",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-55,cyClient-55,30,20,hwnd,(HMENU)IDOK,0,0);
hquitter=CreateWindowEx(0,"button","X",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,0,20,20,hwnd,(HMENU)IDCANCEL,0,0);
ha=CreateWindowEx(0,"button","A",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,40,20,20,hwnd,(HMENU)ID_A,0,0);
hb=CreateWindowEx(0,"button","B",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,60,20,20,hwnd,(HMENU)ID_B,0,0);
hc=CreateWindowEx(0,"button","C",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,80,20,20,hwnd,(HMENU)ID_C,0,0);
hd=CreateWindowEx(0,"button","D",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,100,20,20,hwnd,(HMENU)ID_D,0,0);
he=CreateWindowEx(0,"button","E",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,120,20,20,hwnd,(HMENU)ID_E,0,0);
hf=CreateWindowEx(0,"button","F",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,140,20,20,hwnd,(HMENU)ID_F,0,0);
hg=CreateWindowEx(0,"button","G",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,160,20,20,hwnd,(HMENU)ID_G,0,0);
hh=CreateWindowEx(0,"button","H",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,180,20,20,hwnd,(HMENU)ID_H,0,0);
hi=CreateWindowEx(0,"button","I",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,200,20,20,hwnd,(HMENU)ID_I,0,0);
hj=CreateWindowEx(0,"button","J",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,220,20,20,hwnd,(HMENU)ID_J,0,0);
hk=CreateWindowEx(0,"button","K",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,240,20,20,hwnd,(HMENU)ID_K,0,0);
hl=CreateWindowEx(0,"button","L",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,260,20,20,hwnd,(HMENU)ID_L,0,0);
hm=CreateWindowEx(0,"button","M",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,280,20,20,hwnd,(HMENU)ID_M,0,0);
hn=CreateWindowEx(0,"button","N",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,300,20,20,hwnd,(HMENU)ID_N,0,0);
ho=CreateWindowEx(0,"button","O",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,320,20,20,hwnd,(HMENU)ID_O,0,0);
hp=CreateWindowEx(0,"button","P",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,340,20,20,hwnd,(HMENU)ID_P,0,0);
hq=CreateWindowEx(0,"button","Q",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,360,20,20,hwnd,(HMENU)ID_Q,0,0);
hr=CreateWindowEx(0,"button","R",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,380,20,20,hwnd,(HMENU)ID_R,0,0);
hs=CreateWindowEx(0,"button","S",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,400,20,20,hwnd,(HMENU)ID_S,0,0);
ht=CreateWindowEx(0,"button","T",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,420,20,20,hwnd,(HMENU)ID_T,0,0);
hu=CreateWindowEx(0,"button","U",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,440,20,20,hwnd,(HMENU)ID_U,0,0);
hv=CreateWindowEx(0,"button","V",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,460,20,20,hwnd,(HMENU)ID_V,0,0);
hw=CreateWindowEx(0,"button","W",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,480,20,20,hwnd,(HMENU)ID_W,0,0);
hx=CreateWindowEx(0,"button","X",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,500,20,20,hwnd,(HMENU)ID_X,0,0);
hy=CreateWindowEx(0,"button","Y",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,520,20,20,hwnd,(HMENU)ID_Y,0,0);
hz=CreateWindowEx(0,"button","Z",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,cxClient-10,540,20,20,hwnd,(HMENU)ID_Z,0,0);
HFONT font=(HFONT)GetStockObject(DEFAULT_GUI_FONT); // Changement de la police des contrôles:
HWND child=FindWindowEx(hwnd,0,0,0);
do
{
SendMessage(child,WM_SETFONT,(WPARAM)font,0);
child=FindWindowEx(hwnd,child,0,0);
}
while(child);
// Mettre le focus sur le premier EDIT:
SetFocus(hedit1);
return 0;
}
case WM_CLOSE:
// Détruire la fenêtre:
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
// Forcer la sortie de la boucle des messages:
PostQuitMessage(0);
return 0;
case WM_COMMAND:
// Clic sur le bouton Ok ou appui sur la touche ENTREE:
if((HWND)lParam==hlire)
{
///du coup j met des ptits //pour éviter que ca fouare ICI : les 2 lignes qui suivent
GetDlgItemText(hwnd,hedit1,buf,256);
SetDlgItemText(hwnd,hedit2,buf);
}
// Clic sur le bouton Quitter ou appui sur la touche ECHAP:
if((HWND)lParam==hquitter)SendMessage(hwnd,WM_CLOSE,0,0);
return 0;
default:
break;
}
// Appeler la procedure par défaut de la fenêtre:
return DefWindowProc(hwnd,message, wParam, lParam);
}
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmd, int show)
{
cxScreen = GetSystemMetrics (SM_CXSCREEN); cyScreen = GetSystemMetrics (SM_CYSCREEN)-35 ;
cxClient= cxScreen/4; cyClient= cyScreen-200;
// Déclaration et initialisation de la structure WNDCLASSEX:
WNDCLASSEX wc;
ZeroMemory(&wc,sizeof(WNDCLASSEX));
wc.cbSize=sizeof(WNDCLASSEX);
wc.hInstance=hinst;
wc.lpszClassName="fenetre";
wc.lpfnWndProc=WinProc;
wc.hCursor=LoadCursor(0,IDC_ARROW);
wc.hIcon=LoadIcon(0,IDI_APPLICATION);
wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);//////////////////////////LTGRAY
// Enregistrement de notre classe de fenêtre:
RegisterClassEx(&wc);
// Création de notre fenêtre:
HWND hwnd=CreateWindowEx(WS_EX_TOPMOST| WS_EX_WINDOWEDGE ,"fenetre","Dialogue",WS_SYSMENU | WS_VISIBLE ,///////////////////|WS_EX_TOOLWINDOW
0,0,499,cyScreen,
0,0,hinst,0);
HRGN rect_rnd = CreateRoundRectRgn(5, 18, cxClient+14, cyClient-1, 50, 50);
SetWindowRgn(hwnd, rect_rnd, TRUE);
// Boucle des messages:
MSG msg;
while(GetMessage(&msg,0,0,0)){if(!IsDialogMessage(hwnd,&msg)){DispatchMessage(&msg);TranslateMessage(&msg);}}
// Sortie du programme:
return 0;
}
|