50cent Posted December 27, 2010 Report Posted December 27, 2010 (edited) Programul de mai jos ilustreaza controale windows de baza,scris in Windows API#include <Windows.h>//#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")#define latime 200#define inaltime 250#define buton 1#define buton2 2#define buton3 3LRESULT CALLBACK WindowProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInsatce,LPSTR lpCmdLine,int nCmdShow){ HWND hWnd; WNDCLASSEX clasa; ZeroMemory(&clasa,sizeof(WNDCLASSEX)); clasa.cbSize=sizeof(WNDCLASSEX); clasa.hbrBackground=(HBRUSH)COLOR_WINDOW; clasa.hCursor=LoadCursor(NULL,IDC_ARROW); clasa.hIcon=LoadIcon(NULL,IDI_APPLICATION); clasa.hInstance=hInstance; clasa.lpfnWndProc=WindowProc; clasa.lpszClassName=L"orton"; clasa.style=CS_VREDRAW|CS_HREDRAW; RegisterClassEx(&clasa); hWnd=CreateWindowEx(NULL,L"orton",L"orton",WS_OVERLAPPED|WS_SYSMENU|WS_MINIMIZEBOX,10,10,latime,inaltime,NULL,NULL,hInstance,NULL); ShowWindow(hWnd,nCmdShow); HFONT hFont = CreateFont(15, 0, 0, 0, FW_NORMAL, false, false, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, L"Lucida Sans Unicode"); HWND label=CreateWindow(L"STATIC",L"butonul 1",WS_VISIBLE|WS_CHILD|SS_EDITCONTROL,5,15,60,25,hWnd,0,hInstance,NULL); HWND label2=CreateWindow(L"STATIC",L"butonul 2",WS_VISIBLE|WS_CHILD|SS_EDITCONTROL,5,45,60,25,hWnd,0,hInstance,NULL); HWND Button=CreateWindow(L"BUTTON",L"apasa",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,60,10,50,25,hWnd,(HMENU)buton,hInstance,NULL); HWND Button2=CreateWindow(L"BUTTON",L"apasa",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,60,40,50,25,hWnd,(HMENU)buton2,hInstance,NULL); HWND Button3=CreateWindow(L"BUTTON",L"fisier",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,110,10,80,55,hWnd,(HMENU)buton3,hInstance,NULL); HWND edit=CreateWindow(L"EDIT",L"edit box",WS_VISIBLE|WS_CHILD|WS_HSCROLL|WS_VSCROLL|ES_LEFT|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL,5,90,180,130,hWnd,0,hInstance,NULL); SendMessage(Button, WM_SETFONT,(WPARAM)hFont, true); SendMessage(Button2, WM_SETFONT,(WPARAM)hFont, true); SendMessage(label, WM_SETFONT,(WPARAM)hFont, true); SendMessage(label2, WM_SETFONT,(WPARAM)hFont, true); SendMessage(edit, WM_SETFONT,(WPARAM)hFont, true); SendMessage(Button3, WM_SETFONT,(WPARAM)hFont, true); MSG mesaj={0}; while(GetMessage(&mesaj,0,0,0)) { TranslateMessage(&mesaj); DispatchMessage(&mesaj); } return mesaj.wParam;}LRESULT CALLBACK WindowProc(HWND hWnd,UINT mesaj,WPARAM wParam,LPARAM lParam){ switch(mesaj) { case WM_DESTROY: PostQuitMessage(0); break; case WM_COMMAND: if (wParam == buton) MessageBox(hWnd,L"ai apasat pe butonul 1",L"Info",MB_OK|MB_ICONINFORMATION); if (wParam == buton2) MessageBox(hWnd,L"ai apasat pe butonul 2",L"Info",MB_OK|MB_ICONINFORMATION); if (wParam == buton3) { OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hWnd; ofn.lpstrFilter = L"Fisiere text (*.txt)\0*.txt\0All Files (*.*)\0*.*\0"; ofn.lpstrFile = (LPWSTR)szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT; ofn.lpstrDefExt = (LPCWSTR)"txt"; if(GetOpenFileName(&ofn)) { MessageBox(hWnd,(LPCWSTR)szFileName,L"Info",MB_OK|MB_ICONINFORMATION); } } break; default : return DefWindowProc(hWnd,mesaj,wParam,lParam); break; } return 0;}decomentati linia cu #pragma comment sa vedeti ce se intampla Edited December 27, 2010 by 50cent update Quote