-
Notifications
You must be signed in to change notification settings - Fork 0
/
win16.cpp
78 lines (57 loc) · 2.05 KB
/
win16.cpp
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <Windows.H>
#include <Stdio.H>
#include <Stdlib.H>
#include <String.H>
#include <Winsock.H>
#include <DIRENT.H>
#include <ERRNO.H>
#include <IO.H>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool IsDirectory(char *sPath)
{
errno = 0;
DIR *dir = opendir(sPath);
bool bResult = (errno == 0);
if(dir != NULL)
{
closedir(dir);
}
return bResult;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void ListBox_Insert(HWND hWnd, const char *sInBuf)
{
int index = SendMessage(hWnd, LB_GETCOUNT, 0, 0);
SendMessage(hWnd, LB_INSERTSTRING, index, (LPARAM)sInBuf);
while (index > 1000)
{
index = (int)SendMessage(hWnd, LB_GETCOUNT, 0, 0);
SendMessage(hWnd, LB_DELETESTRING, 0, FALSE);
}
SendMessage(hWnd, LB_SETCURSEL, index, 0);
SendMessage(hWnd, LB_SETCARETINDEX, index, FALSE);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Set_Text(HWND hWnd, const char *sInBuf)
{
SendMessage(hWnd, (UINT)WM_SETTEXT, (WPARAM)0, (LPARAM)sInBuf);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Get_TextLength(HWND hWnd)
{
return GetWindowTextLength(hWnd);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int Get_Text(HWND hWnd, char *sOutBuf, int iMaxSize)
{
int iLen = GetWindowTextLength(hWnd);
if (iLen >= iMaxSize)
{
return iLen;
}
iLen = GetWindowText(hWnd, sOutBuf, iMaxSize);
sOutBuf[iLen] = '\0';
return iLen;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////