-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstsbar.c
103 lines (71 loc) · 2.45 KB
/
stsbar.c
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "constantes.h"
#include "stsbar.h"
#ifndef __cplusplus
#include <stdbool.h>
#endif
HWND hWndStatusbar;
BOOL CreateSBar(HWND hwndParent,char *initialText,int nrOfParts)
{
RECT rectP;
RECT rect;
int cx;
int cy;
unsigned int flags;
flags= SWP_NOOWNERZORDER;
hWndStatusbar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_BORDER,
initialText,
hwndParent,
IDM_STATUSBAR);
GetWindowRect(hwndParent, &rectP);
GetWindowRect(hWndStatusbar, &rect);
cx=rectP.right-rectP.left;
cy=(rectP.bottom-rectP.top)+(rect.bottom-rect.top);
SetWindowPos(hwndParent,0,0,0,cx,cy,flags);
if(hWndStatusbar)
{
InitializeStatusBar(hwndParent,nrOfParts);
UpdateStatusBar(initialText, 0, 0);
return TRUE;
}
return FALSE;
}
void InitializeStatusBar(HWND hwndParent,int nrOfParts)
{
//const int cSpaceInBetween = 8;
int ptArray[40]; // Array defining the number of parts/sections
HDC hDC;
/* * Fill in the ptArray... */
hDC = GetDC(hwndParent);
//RECT rect;
//GetClientRect(hwndParent, &rect);
ptArray[0] =wid/2;
ptArray[1] = wid;
//---TODO--- Add code to calculate the size of each part of the status
// bar here.
ReleaseDC(hwndParent, hDC);
SendMessage(hWndStatusbar,
SB_SETPARTS,
nrOfParts,
(LPARAM)(LPINT)ptArray);
//---TODO--- Add code to update all fields of the status bar here.
// As an example, look at the calls commented out below.
// UpdateStatusBar("Cursor Pos:", 1, SBT_POPOUT);
// UpdateStatusBar("Time:", 3, SBT_POPOUT);
}
/*------------------------------------------------------------------------
Procedure: UpdateStatusBar ID:1
Purpose: Updates the statusbar control with the appropiate
text
Input: lpszStatusString: Charactar string that will be shown
partNumber: index of the status bar part number.
displayFlags: Decoration flags
Output: none
Errors: none
------------------------------------------------------------------------*/
void UpdateStatusBar(LPSTR lpszStatusString, WORD partNumber, WORD displayFlags)
{
SendMessage(hWndStatusbar,
SB_SETTEXT,
partNumber | displayFlags,
(LPARAM)lpszStatusString);
}