Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main.cpp
- #include <windows.h>
- #include "Header1.h"
- EVENTHANDLER EventHandler[2];
- long fnWndProc_OnPaint(lpWndEventArgs Wea)
- {
- HFONT hFont,hTmp;
- PAINTSTRUCT ps;
- HBRUSH hBrush;
- RECT rc;
- HDC hDC;
- hDC=BeginPaint(Wea->hWnd,&ps);
- GetClientRect(Wea->hWnd,&rc);
- hBrush=CreateSolidBrush(RGB(240,240,240));
- FillRect(hDC,&rc,hBrush);
- DeleteObject(hBrush);
- SetTextColor(hDC,RGB(0,0,0));
- hFont=CreateFont(15,0,0,0,FW_NORMAL,0,0,0,0,0,0,2,0,"SYSTEM_FIXED_FONT");
- hTmp=(HFONT)SelectObject(hDC,hFont);
- SetBkMode(hDC,TRANSPARENT);
- 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);
- 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);
- DeleteObject(SelectObject(hDC,hTmp));
- EndPaint(Wea->hWnd,&ps);
- return 0;
- }
- long fnWndProc_OnClose(lpWndEventArgs Wea)
- {
- DestroyWindow(Wea->hWnd);
- PostQuitMessage(0);
- return 0;
- }
- void AttachEventHandlers(void) //This procedure maps windows messages to the
- { //procedure which handles them.
- EventHandler[0].Code=WM_PAINT, EventHandler[0].fnPtr=fnWndProc_OnPaint;
- EventHandler[1].Code=WM_CLOSE, EventHandler[1].fnPtr=fnWndProc_OnClose;
- }
- long __stdcall fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam,LPARAM lParam)
- {
- WndEventArgs Wea; //This procedure loops through the EVENTHANDER array
- //of structs to try to make a match with the msg parameter
- for(unsigned int i=0; i<2; i++) //of the WndProc. If a match is made the event handling
- { //procedure is called through a function pointer -
- if(EventHandler[i].Code==msg) //(EventHandler[i].fnPtr). If no match is found the
- { //msg is passed onto DefWindowProc().
- Wea.hWnd=hwnd, Wea.lParam=lParam, Wea.wParam=wParam;
- return (*EventHandler[i].fnPtr)(&Wea);
- }
- }
- return (DefWindowProc(hwnd, msg, wParam, lParam));
- }
- int __stdcall WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
- {
- char szClassName[]="DeadBolt v1.1";
- WNDCLASSEX wc;
- MSG messages;
- HWND hWnd;
- AttachEventHandlers();
- wc.lpszClassName=szClassName; wc.lpfnWndProc=fnWndProc;
- wc.cbSize=sizeof (WNDCLASSEX); wc.style=CS_HREDRAW|CS_VREDRAW;
- wc.hIcon=LoadIcon(NULL,IDI_APPLICATION); wc.hInstance=hIns;
- wc.hIconSm=LoadIcon(NULL, IDI_APPLICATION); wc.hCursor=LoadCursor(NULL,IDC_ARROW);
- wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH), wc.cbWndExtra=0;
- wc.lpszMenuName=NULL; wc.cbClsExtra=0;
- RegisterClassEx(&wc);
- hWnd=CreateWindowEx(0,szClassName,szClassName,WS_OVERLAPPEDWINDOW&(~WS_MINIMIZEBOX&~WS_MAXIMIZEBOX&~WS_THICKFRAME),100,100,400,350,HWND_DESKTOP,0,hIns,0);
- ShowWindow(hWnd,iShow);
- #define SOME_KIND_OF_ID 50
- HWND hEdit =CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT",
- "",WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_AUTOHSCROLL,
- 25,150,350,100,hWnd,(HMENU)SOME_KIND_OF_ID,GetModuleHandle(NULL),
- NULL);
- hEdit =CreateWindow(TEXT("button"), TEXT("Save/Open DB"),
- WS_VISIBLE | WS_CHILD ,
- 240, 260, 110, 25,
- hWnd, (HMENU) 1, NULL, NULL);
- if ("button"==BN_CLICKED)
- MessageBox(NULL, "test", NULL, NULL);
- //This is what I need to make work right now
- // I'll use something like this later
- /*if (hEdit=="matress") MessageBox(NULL, "x must be 2", NULL, NULL);*/
- while(GetMessage(&messages,NULL,0,0))
- {
- TranslateMessage(&messages);
- DispatchMessage(&messages);
- }
- return messages.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement