Advertisement
Guest User

c++

a guest
Jan 28th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.26 KB | None | 0 0
  1. //Main.cpp
  2. #include <windows.h>
  3. #include "Header1.h"
  4. EVENTHANDLER  EventHandler[2];
  5.  
  6.  
  7. long fnWndProc_OnPaint(lpWndEventArgs Wea)
  8. {
  9.  HFONT hFont,hTmp;
  10.  PAINTSTRUCT ps;
  11.  HBRUSH hBrush;
  12.  RECT rc;
  13.  HDC hDC;
  14.  
  15.  hDC=BeginPaint(Wea->hWnd,&ps);
  16.  GetClientRect(Wea->hWnd,&rc);
  17.  hBrush=CreateSolidBrush(RGB(240,240,240));
  18.  FillRect(hDC,&rc,hBrush);
  19.  DeleteObject(hBrush);
  20.  SetTextColor(hDC,RGB(0,0,0));
  21.  hFont=CreateFont(15,0,0,0,FW_NORMAL,0,0,0,0,0,0,2,0,"SYSTEM_FIXED_FONT");
  22.  hTmp=(HFONT)SelectObject(hDC,hFont);
  23.  SetBkMode(hDC,TRANSPARENT);
  24.  DrawText(hDC,"\nDeadBolt is a simple password keeper that uses the Advanced Encryption Standard to secure and store your usernames and passwords. The program stores your information to DeadBolt's information database and secures them. To open them, all you need to do is enter the key you used to encrypt the information.",-1,&rc,DT_CENTER|DT_TOP|DT_WORDBREAK);
  25.   DrawText(hDC,"\n\n\n\n\n\n\n\n Enter encryption key for your database (DO NOT FORGET THIS KEY) :",-1,&rc,DT_LEFT|DT_VCENTER|DT_WORDBREAK);
  26.  DeleteObject(SelectObject(hDC,hTmp));
  27.  EndPaint(Wea->hWnd,&ps);
  28.  
  29.  return 0;
  30. }
  31.  
  32. long fnWndProc_OnClose(lpWndEventArgs Wea)
  33. {
  34.  DestroyWindow(Wea->hWnd);
  35.  PostQuitMessage(0);
  36.  
  37.  return 0;
  38. }
  39.  
  40.  
  41. void AttachEventHandlers(void)      //This procedure maps windows messages to the
  42. {                                   //procedure which handles them.
  43.  EventHandler[0].Code=WM_PAINT,     EventHandler[0].fnPtr=fnWndProc_OnPaint;
  44.  EventHandler[1].Code=WM_CLOSE,     EventHandler[1].fnPtr=fnWndProc_OnClose;
  45. }
  46.  
  47.  
  48. long __stdcall fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam,LPARAM lParam)
  49. {
  50.  WndEventArgs Wea;                  //This procedure loops through the EVENTHANDER array
  51.                                     //of structs to try to make a match with the msg parameter
  52.  for(unsigned int i=0; i<2; i++)    //of the WndProc.  If a match is made the event handling
  53.  {                                  //procedure is called through a function pointer -
  54.      if(EventHandler[i].Code==msg)  //(EventHandler[i].fnPtr).  If no match is found the
  55.      {                              //msg is passed onto DefWindowProc().
  56.         Wea.hWnd=hwnd, Wea.lParam=lParam, Wea.wParam=wParam;
  57.         return (*EventHandler[i].fnPtr)(&Wea);
  58.      }
  59.  }
  60.  
  61.  return (DefWindowProc(hwnd, msg, wParam, lParam));
  62. }
  63.  
  64.  
  65. int __stdcall WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
  66. {
  67.  char szClassName[]="DeadBolt v1.1";
  68.  WNDCLASSEX wc;
  69.  MSG messages;
  70.  HWND hWnd;
  71.  
  72.  AttachEventHandlers();
  73.  wc.lpszClassName=szClassName;                            wc.lpfnWndProc=fnWndProc;
  74.  wc.cbSize=sizeof (WNDCLASSEX);                           wc.style=CS_HREDRAW|CS_VREDRAW;
  75.  wc.hIcon=LoadIcon(NULL,IDI_APPLICATION);                 wc.hInstance=hIns;
  76.  wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION);              wc.hCursor=LoadCursor(NULL,IDC_ARROW);
  77.  wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH),    wc.cbWndExtra=0;
  78.  wc.lpszMenuName=NULL;                                    wc.cbClsExtra=0;
  79.  RegisterClassEx(&wc);
  80.  hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW&(~WS_MINIMIZEBOX&~WS_MAXIMIZEBOX&~WS_THICKFRAME),100,100,400,350,HWND_DESKTOP,0,hIns,0);
  81.  ShowWindow(hWnd,iShow);
  82.  #define SOME_KIND_OF_ID 50
  83.  HWND hEdit =CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",
  84. "",WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_AUTOHSCROLL,
  85. 25,150,350,100,hWnd,(HMENU)SOME_KIND_OF_ID,GetModuleHandle(NULL),
  86. NULL);
  87.  
  88.  
  89.                    
  90. hEdit =CreateWindow(TEXT("button"), TEXT("Save/Open DB"),    
  91.                      WS_VISIBLE | WS_CHILD ,
  92.                      240, 260, 110, 25,        
  93.                      hWnd, (HMENU) 1, NULL, NULL);
  94.                      
  95.                      if ("button"==BN_CLICKED)
  96.                       MessageBox(NULL, "test", NULL, NULL);
  97.                      
  98.  
  99.  
  100.                      
  101.                      //This is what I need to make work right now
  102.                    
  103.                      
  104.                      
  105.                
  106.                
  107.                      // I'll use something like this later
  108.                      /*if (hEdit=="matress") MessageBox(NULL, "x must be 2", NULL, NULL);*/
  109.                      
  110.  
  111.  while(GetMessage(&messages,NULL,0,0))
  112.  {
  113.        TranslateMessage(&messages);
  114.        DispatchMessage(&messages);
  115.  }
  116.  return messages.wParam;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement