Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. HWND ListViewCreate(HWND hparent)
  2. {
  3. INITCOMMONCONTROLSEX icex;
  4.  
  5. icex.dwSize = sizeof(icex);
  6. icex.dwICC = ICC_LISTVIEW_CLASSES;
  7. InitCommonControlsEx(&icex);
  8. RECT clientrect;
  9. GetClientRect(hparent, &clientrect);
  10. HWND hwndListView = CreateWindow(WC_LISTVIEW, _T("IDC_LVSTUDENT"), WS_CHILD|WS_VISIBLE|LVS_REPORT | LVS_AUTOARRANGE | WS_BORDER, 10, 10, clientrect.right - clientrect.left -410,
  11. clientrect.bottom - clientrect.top - 20, hparent, (HMENU)IDC_LISTVIEW, hInst, NULL);
  12. return hwndListView;
  13. }
  14.  
  15. bool CreateColumn(HWND hLV)
  16. {
  17. LVCOLUMN lvc;
  18. int iCol;
  19.  
  20. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  21. lvc.cx = 150;
  22.  
  23. for(iCol = 0; iCol < 4; iCol++)
  24. {
  25. lvc.iSubItem = iCol;
  26. switch(iCol)
  27. {
  28. case 0:
  29. lvc.pszText = _T("NoE");
  30. break;
  31. case 1:
  32. lvc.pszText = _T("Nom et Prenom");
  33. break;
  34. case 2:
  35. lvc.pszText = _T("Date de naissance");
  36. break;
  37. case 3:
  38. lvc.pszText = _T("Courrier");
  39. }
  40. if(iCol > 0)
  41. lvc.fmt = LVCFMT_CENTER;
  42. else
  43. lvc.fmt = LVCFMT_LEFT;
  44.  
  45. if(ListView_InsertColumn(hLV, iCol, &lvc) == -1)
  46. return false;
  47. }
  48. return true;
  49. }
  50.  
  51. bool CreateItem(HWND hLV, int iCol, TCHAR Item[])
  52. {
  53. LVITEM lvI;
  54.  
  55. lvI.pszText = Item;
  56. lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
  57. lvI.stateMask = 0;
  58. lvI.iSubItem = iCol;
  59. lvI.state = 0;
  60.  
  61. lvI.iItem = iItem;
  62.  
  63. if (iCol == 0)
  64. {
  65. if (ListView_InsertItem(hLV, &lvI) == -1)
  66. {
  67. return false;
  68. }
  69. return true;
  70. }
  71. else
  72. {
  73. if (ListView_SetItem(hLV, &lvI) == -1)
  74. {
  75. return false;
  76. }
  77. return true;
  78. }
  79. }
  80.  
  81. HWND PushButtonCreate(HWND hParent, int ID, int Position, TCHAR Name[])
  82. {
  83. int X, Y, WIDTH, HEIGHT;
  84.  
  85. X = Position;
  86. Y = 10;
  87. WIDTH = 100;
  88. HEIGHT = 40;
  89.  
  90. HWND hbtn = CreateWindow(_T("BUTTON"), Name, WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, X, Y, WIDTH, HEIGHT, hParent, (HMENU)ID, hInst, NULL);
  91. return hbtn;
  92. }
  93.  
  94. HWND TextBoxCreate(HWND hParent, int ID, int Position, TCHAR Name[], int Type)
  95. {
  96. int X, Y, WIDTH, HEIGHT;
  97.  
  98. X = 650;
  99. Y = Position;
  100. WIDTH = 100;
  101. HEIGHT = 40;
  102.  
  103. HWND hbtn;
  104. if(Type == 1)
  105. hbtn = CreateWindow(_T("EDIT"), Name, WS_CHILD | WS_VISIBLE| ES_LEFT | ES_MULTILINE | WS_BORDER | WS_DISABLED, X, Y, WIDTH, HEIGHT, hParent, (HMENU)ID, hInst, NULL);
  106. if(Type == 0)
  107. {
  108. X = 750;
  109. WIDTH = 240;
  110. hbtn = CreateWindow(_T("EDIT"), Name, WS_CHILD | WS_VISIBLE| ES_LEFT | ES_MULTILINE | WS_BORDER, X, Y, WIDTH, HEIGHT, hParent, (HMENU)ID, hInst, NULL);
  111. }
  112. return hbtn;
  113. }
  114.  
  115. void AddFunction(HWND hLV)
  116. {
  117. LPTSTR Noe, Nom, Dat, Mail;
  118.  
  119. Noe = new TCHAR[50];
  120. Nom = new TCHAR[50];
  121. Dat = new TCHAR[50];
  122. Mail = new TCHAR[50];
  123.  
  124. Edit_GetText(hNoe, Noe, 50);
  125. Edit_GetText(hName, Nom, 50);
  126. Edit_GetText(hDate, Dat, 50);
  127. Edit_GetText(hMail, Mail, 50);
  128.  
  129. if(Noe == _T("") || Nom == _T("") || Dat == _T("") || Mail == _T(""))
  130. MessageBox(hLV, _T("Bạn cần nhập toàn bộ thông tin"), ERROR, MB_OK);
  131. else
  132. {
  133. CreateItem(hLV, 0, Noe);
  134. CreateItem(hLV, 1, Nom);
  135. CreateItem(hLV, 2, Dat);
  136. CreateItem(hLV, 3, Mail);
  137. iItem++;
  138. }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement