-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindowsimplified.h
52 lines (52 loc) · 1.12 KB
/
windowsimplified.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef WINDOWSIMPLIFIED_H_INCLUDED
using namespace std;
bool error(string s)
{
if(s=="") s="Something has gone wrong!";
MessageBox(NULL,s.c_str(),"Error!",MB_OK);
}
void ErrorAndExit(string s)
{
if(s=="") s="Sorry for your inconvenience,but something has gone wrong! Unavoidable exit.";
MessageBox(NULL,s.c_str(),"Error!",MB_OK);
exit(0);
}
string lpstrtostring(LPSTR x)
{
string s;
s.clear();
s.insert(0,x);
return s;
}
LPSTR strtolpstr(string x)
{
LPSTR y=const_cast<char*>(x.c_str());
return y;
}
BOOL MouseIsOnWindow(HWND hwnd)
{
RECT rect;
GetWindowRect(hwnd,&rect);
POINT p;
GetCursorPos(&p);
if(PtInRect(&rect,p)) return true;
else return false;
}
bool MouseIsOnRgn(HRGN h)
{
POINT p;
GetCursorPos(&p);
if(PtInRegion(h,p.x,p.y)) return true;
else return false;
}
bool GetText(HWND h, string* s)
{
LPSTR l;
l=(LPSTR)GlobalAlloc(GPTR,GetWindowTextLength(h)+1);
GetWindowText(h,l,GetWindowTextLength(h)+1);
*s=lpstrtostring(l);
GlobalFree(l);
return true;
}
#define WINDOWSIMPLIFIED_H_INCLUDED
#endif // WINDOWSIMPLIFIED_H_INCLUDED